home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / BCWIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-28  |  2.8 KB  |  118 lines

  1. /*
  2.     bcwin.c    4/22/89
  3.  
  4.     % Blank char window object
  5.     used for unsaved default window etc.
  6.     By Ted.
  7.  
  8.     OWL 1.2
  9.     Copyright (c) 1989 by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14.     11/06/89 jmd    removed DoRaw macros
  15.      3/28/90 jmd    ansi-fied
  16. */
  17.  
  18. #include "oakhead.h"
  19. #include "disppriv.h"
  20. #include "cmwinod.h"
  21. #include "cmwinobj.h"
  22.  
  23. OSTATIC void OWLPRIV bcwin_PlotBox(ptd_struct *ptd, bcwin_od *bcwd);
  24.  
  25. /* -------------------------------------------------------------------------- */
  26.  
  27. int bcwin_Class(VOID *objdata, int msg, VOID *indata, VOID *outdata)
  28. /* 
  29.     Blank char window object dispatch function
  30. */
  31. {
  32.     bcwin_od    *bcwd;
  33.     win_type    win;
  34.     ptd_struct    *ptd;
  35.     ptd_struct  inptd;        /* for use in inner-coordinate computations */
  36.     opbox         inbox;        /* ditto; gets hooked in by ptd_SetInner */
  37.     int            rval;
  38.  
  39.     bcwd = (bcwin_od *) objdata;
  40.  
  41.     switch(msg) {
  42.     case OBJM_GETDATASIZE:
  43.         ((ogds_struct *) outdata)->odsize = sizeof(bcwin_od);
  44.         ((ogds_struct *) outdata)->xdsize = sizeof(bcwin_xd);
  45.         ((ogds_struct *) outdata)->id = ID_BCWIN;
  46.         break;
  47.  
  48.     case OBJM_OPEN:
  49.         win = bcwinod_GetSelf(bcwd);
  50.  
  51.         /* Initialize the char to be repeatedly painted in this window. */
  52.         bcwin_SetChar(win, ' ');
  53.  
  54.         /* Send OPEN msg to win superclass */
  55.         rval = win_Class(&(bcwd->wd), msg, indata, outdata);
  56.  
  57.         /* Override default: allow any pix size for pmwin's */
  58.         win_SetCharSize(win, FALSE);
  59.  
  60.         return(rval);
  61.  
  62.     case OBJM_WHO:
  63.         /* Identify ourselves */
  64.         if (*((int *) indata) == ID_BCWIN) {
  65.             return(TRUE);
  66.         }
  67.         return(win_Class(&(bcwd->wd), msg, indata, outdata));
  68.  
  69.     case WINM_SCROLL:
  70.         break;                /* don't bother scrolling- it's blank anyway */
  71.  
  72.     case WINM_PAINT:
  73.         ptd = (ptd_struct *)indata;
  74.         if (ptd_SetInner(ptd, &inptd, &inbox)) {
  75.             bcwin_PlotBox(&inptd, bcwd);
  76.         }
  77.         /* No break; send msg to win superclass */
  78.     default:
  79.         return(win_Class(&(bcwd->wd), msg, indata, outdata));
  80.     }
  81.     return(TRUE);
  82. }
  83. /* -------------------------------------------------------------------------- */
  84.  
  85. static void OWLPRIV bcwin_PlotBox(ptd_struct *ptd, bcwin_od *bcwd)
  86. /*
  87.     Plots a region of a cmap window to the display.
  88. */
  89. {
  90.     win_type win;
  91.     char bchar;
  92.     byte attr;
  93.     ocbox relcbox;
  94.     opcoord xpix, ypix;
  95.     int row, cwidth;
  96.     ofont_type font;
  97.     odim fheight;
  98.  
  99.     win = bcwinod_GetSelf(bcwd);
  100.     bchar = bcwin_GetChar(win);
  101.     attr = win_GetAttr(win);
  102.  
  103.     font = win_GetFont(ptd->win);
  104.  
  105.     opbox_charcoords(ptd->relboxp, font, &relcbox);
  106.  
  107.     xpix = (relcbox.leftcol) * ofont_GetWidth(font);
  108.     fheight = ofont_GetHeight(font);
  109.     ypix = (relcbox.toprow + 1) * fheight;
  110.     cwidth = ocbox_GetWidth(&relcbox);
  111.  
  112.     for (row = ocbox_GetHeight(&relcbox); row > 0; row--, ypix += fheight) {
  113.         ptd_PlotChar(ptd, xpix, ypix, bchar, attr, cwidth);
  114.     }
  115. }
  116. /* -------------------------------------------------------------------------- */
  117.  
  118.