home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / WINSAVE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  3.3 KB  |  137 lines

  1. /*
  2.     winsave.c
  3.  
  4.     % sf_reqsave, sfile_SaveComment, strnewlclip
  5.  
  6.     OWL 1.1
  7.     Copyright (c) 1988, 1989 by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.     09/01/89 jdc    added win_IsCharSize
  13. */
  14.  
  15. #include "oakhead.h"
  16. #include "disppriv.h"
  17. #include "jadecl.h"
  18. #include "symldecl.h"
  19.  
  20. #include "winod.h"
  21. #include "bordobj.h"
  22. #include "winsfile.h"
  23. #include "winspriv.h"
  24.  
  25. OSTATIC objreq_func (winreq_save);
  26.  
  27. void win_SaveInit()
  28. {
  29.     winreq_savefptr = winreq_save;
  30. }
  31.  
  32. int winreq_save(objdata, msg, indata, outdata)
  33.     VOID *objdata;
  34.     int msg;                /* message */
  35.     VOID *indata;            /* message input data */
  36.     VOID *outdata;            /* message output data */
  37. {
  38.     char *title = NULL;
  39.     char *s[4];
  40.     unsigned feature;
  41.     sfile_type sfile;
  42.     win_type win;
  43.     opbox box;
  44.     int shadx, shady;
  45.  
  46.     oak_notused(msg);
  47.     oak_notused(outdata);
  48.  
  49.     sfile = (sfile_type)indata;
  50.     win = winod_GetSelf((win_od *)objdata);
  51.  
  52. /* win info:
  53.         ymin, xmin, ymax, xmax, clip,
  54.         shadow x, shadow y, shadow attr, border attr, border features,
  55.         font, border, border title, mouse, explode
  56. */
  57.     bord_Do(win, BDM_GETTITLE, NULL, &title);
  58.     if (title != NULL) {
  59.         strnewlclip(title);
  60.     }
  61.     bord_Do(win, BDM_GETFEATURE, NULL, &feature);
  62.         
  63.     box.xmin = win_GetXmin(win);
  64.     box.xmax = win_GetXmax(win);
  65.     box.ymin = win_GetYmin(win);
  66.     box.ymax = win_GetYmax(win);
  67.     shadx = win_GetShadowX(win);
  68.     shady = win_GetShadowY(win);
  69.  
  70.     if (win_IsCharSize(win)) {
  71.         box.xmin = win_GetLeftCol(win);
  72.         box.ymin = win_GetTopRow(win);
  73.         box.xmax = win_GetRightCol(win);
  74.         box.ymax = win_GetBotRow(win);
  75.         shadx /= win_GetFontWidth(win);
  76.         shady /= win_GetFontHeight(win);
  77.     }
  78.  
  79.     sprintf(sfile->buf, "%d %d %d %d %d %d %d %d %d %d\n",
  80.         box.ymin, box.xmin, box.ymax, box.xmax,
  81.         win_IsParentClip(win), shadx, shady,
  82.         (int)win_GetShadowAttr(win), (int)bord_GetAttr(win), feature);
  83.  
  84.     if (!bfile_Write(sfile->bfile, sfile->buf, strlen(sfile->buf))) {
  85.         return(FALSE);
  86.     }
  87.  
  88.     s[0] = (win_GetFontHandle(win) == -1) ?
  89.           ((win_GetFont(win) == NULL) ? "" : sfile_FindFontName(sfile, win_GetFont(win)))
  90.         : win_GetFontName(win, sfile);
  91.  
  92.     s[1] = (win_GetBorderHandle(win) == -1) ?
  93.           ((win_border(win) == NULL) ? "" : sfile_FindBorderName(sfile, win_GetBorderFunc(win)))
  94.         : win_GetBorderName(win, sfile);
  95.  
  96.     s[2] = (win_GetMouseHandle(win) == -1) ?
  97.           ((win_GetMouhandler(win) == FNULL) ? "" : sfile_FindMouseName(sfile, win_GetMouhandler(win)))
  98.         : win_GetMouseName(win, sfile);
  99.  
  100.     s[3] = (win_GetExplodeHandle(win) == -1) ?
  101.           ((win_GetExplodeFptr(win) == FNULL) ? "" : sfile_FindExplodeName(sfile, win_GetExplodeFptr(win)))
  102.         : win_GetExplodeName(win, sfile);
  103.  
  104.     sprintf(sfile->buf, "%s\n%s\n%s\n%s\n%s\n", 
  105.         fsym_NullCheck(s[0]), fsym_NullCheck(s[1]), fsym_NullCheck(title), 
  106.         fsym_NullCheck(s[2]), fsym_NullCheck(s[3]));
  107.  
  108.     return(bfile_Write(sfile->bfile, sfile->buf, strlen(sfile->buf)));
  109. }
  110.  
  111. boolean sfile_SaveComment(sfile, comment)
  112.     sfile_type sfile;
  113.     char *comment;
  114. {
  115.     sprintf(sfile->buf, "%s\n", comment);    
  116.  
  117.     return(bfile_Write(sfile->bfile, sfile->buf, strlen(sfile->buf)));
  118. }
  119.  
  120. char *strnewlclip(s)
  121.     char *s;
  122. {
  123.     char *p;
  124.  
  125.     for (p = s; ; p++) {
  126.         if (*p != '\n' && *p != '\r' && *p != '\t') {
  127.             *s++ = *p;
  128.         }
  129.         if (*p == '\0') {
  130.             break;
  131.         }
  132.     }
  133.  
  134.     return(s);
  135. }
  136.  
  137.