home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / WINSAVE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-25  |  3.9 KB  |  147 lines

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