home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / INCLUDE / WINPROTO.H < prev    next >
Text File  |  1990-10-30  |  14KB  |  333 lines

  1. /*
  2.     winproto.h
  3.  
  4.     % definitions for windows
  5.     % macros and functions for windows
  6.  
  7.     1/20/88    by Ted
  8.  
  9.     OWL 1.2
  10.     Copyright (c) 1988, 1989 by Oakland Group, Inc.
  11.     ALL RIGHTS RESERVED.
  12.  
  13.     Revision History:
  14.     -----------------
  15.      8/13/88 jmd    Changed win_GetAttr and win_SetAttr
  16.      8/15/88 jmd    added winopen_struct (later removed)
  17.      2/12/88 ted    Fixed up mouse support for new current window cases
  18.  
  19.      3/20/89 ted    Made everything refer to static curr_dmgr / curr_wmgr
  20.      3/24/89 ted    Made windows pure objects; shook everything up.
  21.      3/24/89 ted    Changed order of args to win_Open and win_PixOpen.
  22.      3/29/89 ted    Extracted winpriv.h.
  23.      3/31/89 ted    Added wmgr_PointWin.
  24.      4/21/89 ted    Renamed xd elements box and border to wbox and bord for Unix.
  25.      5/28/89 jmd    added Shadow support
  26.      6/26/89 ted    Added macros for fromwin, nextwin, mousecode.
  27.      7/08/89 gam    Changed NULL to FNULL where necessary
  28.      7/10/89 ted    Moved nextwin to window structure from wmgr.
  29.      7/25/89 ted    Added explode function.
  30.      8/08/89 jmd    Added win_Really funcs.
  31.      8/16/89 ted    Added mev_IsFake macro.
  32.      8/23/89 ted    Added disp_Get/Set[Shadow]Attr macros.
  33.  
  34.      9/26/89 ted    Fixed 'win_SetResize' macro.
  35.     11/10/89 jmd    added win_Grab macro
  36.     11/27/89 ted    Moved IsTrappedMouse macro here, created GetMouseTrap() macro.
  37.     12/10/89 jmd    added win gofunc, made win_GetBorder macro, added Shadow color macros
  38.      1/17/90 ted    Added shademsg args to _Expose functions.
  39.      3/28/90 jmd    ansi-fied
  40.      5/12/90 jmd    converted scancodes to ints
  41.      6/06/90 ted    Added disp_GetTopWin() macro.
  42.      7/25/90 jmd    added winmou_Track
  43.      8/08/90 ted    Added kb_Stuff, obsoleted disp_SetMouseCode.
  44.      8/27/90 ted    added nextchild stuff for offer/request mouse msgs to use.
  45.      9/01/90 ted    added Claim/Release calls to win_Employ macro.
  46.      9/05/90 jmd    removed Claim/Release calls from win_Employ macro.
  47.      9/24/90 jmd    added userpaint flaq, removed gofunc
  48.     10/31/90 ted    added cast in win_GetBorderFunc of FNULL to (class_fptr).
  49. */
  50.  
  51. /* -------------------------------------------------------------------------- */
  52. /* Macros */
  53. #define    win_Close(win)                obj_Close(win)
  54. #define win_MouseInit()                 bord_MouseInit()
  55.  
  56. #define win_getxd(win)                ((win_xd *) obj_getxd(win))
  57.  
  58. #define win_GetParent(win)            bob_GetParent(win)
  59. #define win_IsParentClip(win)        bob_IsDepend(win)
  60.  
  61. #define win_SetParent(win, parnt)    bob_SetParent(win, parnt)
  62. #define win_SetParentClip(win, c)      bob_SetDepend(win, c)
  63.  
  64. #define win_IsEmployed(win)            ((boolean) win_getxd(win)->employed)
  65. #define win_GetAbove(win)            (win_getxd(win)->above)
  66. #define win_GetBelow(win)            (win_getxd(win)->below)
  67.  
  68. #define win_pixboxp(win)            (&win_getxd(win)->wbox)
  69. #define win_inboxp(win)                (&win_getxd(win)->inbox)
  70. #define win_GetBorder(win)            (win_getxd(win)->bord)
  71.  
  72. #define win_GetFont(win)            (win_getxd(win)->font)
  73. #define win_GetAttr(win)            (win_getxd(win)->attribute)
  74. #define win_GetCursx(win)            (win_getxd(win)->cursx)
  75. #define win_GetCursy(win)            (win_getxd(win)->cursy)
  76. #define win_GetCursorType(win)        (win_getxd(win)->curstype)
  77. #define win_GetNullfont(win)        ((boolean) win_getxd(win)->nullfont)
  78.  
  79. #define win_GetShadowAttr(win)        (win_getxd(win)->shadowattr)
  80. #define win_SetShadowAttr(win, a)     (win_getxd(win)->shadowattr = (a))
  81.  
  82. #define win_GetShadowX(win)            (win_getxd(win)->shadowx)
  83. #define win_SetShadowX(win,x)        (win_getxd(win)->shadowx = (x))
  84. #define win_GetShadowY(win)            (win_getxd(win)->shadowy)
  85. #define win_SetShadowY(win,y)        (win_getxd(win)->shadowy = (y))
  86. #define win_SetPixShadow(win, x ,y)    (win_SetShadowX(win, x), win_SetShadowY(win, y))
  87.  
  88. #define win_SetMouse(win, mh)        (win_getxd(win)->mouhandler = (mh))
  89. #define win_GetMouhandler(win)        (win_getxd(win)->mouhandler)
  90. #define win_MouseOk(win)            (win_getxd(win)->mouhandler != FNULL)
  91. #define win_GetDebounced(win)        ((boolean) win_getxd(win)->debounced)
  92. #define win_SetDebounced(win, db)    (win_getxd(win)->debounced = (unsigned)(db))
  93. #define win_SetNextWin(win, nwin)    (win_getxd(win)->nextwin = (nwin))
  94. #define win_SetNextChild(win, nch)    (win_getxd(win)->nextchild = (nch))
  95.  
  96. #define win_SetExplode(win, ex)        (win_getxd(win)->explode = (ex))
  97. #define win_GetExplodeFptr(win)        (win_getxd(win)->explode)
  98.  
  99. #define win_SetUserPaint(win, f)      (win_getxd(win)->userpaint = (f))
  100. #define win_IsUserPaint(win)         (win_getxd(win)->userpaint)
  101.  
  102. #define win_IsCharSize(win)            ((boolean) win_getxd(win)->charsize)
  103. #define win_SetCharSize(win, cs)    (win_getxd(win)->charsize = (unsigned)(cs))
  104. #define win_GetResize(win)            ((boolean) win_getxd(win)->resize)
  105. #define win_SetResize(win, rs)        (win_getxd(win)->resize = (unsigned)(rs))
  106.  
  107. #define win_GetData(win)             ((win_getxd(win))->data)
  108. #define win_SetData(win, d)          ((win_getxd(win))->data = (d))
  109.  
  110. /* -------------------------------------------------------------------------- */
  111. #define win_Ok(win)                                    \
  112.     (((win) == NULL) ? FALSE : (win_getxd(win)->idmgr == curr_dmgr->id))
  113.  
  114. #define win_GetBorderFunc(win)                        \
  115.     ((win_GetBorder(win) == NULL) ? ((class_fptr) FNULL) : win_GetBorder(win)->dispatch)
  116.  
  117. #define win_GetXmin(win)            (win_pixboxp(win)->xmin + win_inboxp(win)->xmin)
  118. #define win_GetYmin(win)            (win_pixboxp(win)->ymin + win_inboxp(win)->ymin)
  119. #define win_GetXmax(win)            (win_pixboxp(win)->xmin + win_inboxp(win)->xmax)
  120. #define win_GetYmax(win)            (win_pixboxp(win)->ymin + win_inboxp(win)->ymax)
  121.  
  122. #define win_GetBgColor(win)            disp_GetAttrBgColor(win_GetAttr(win))
  123. #define win_GetFgColor(win)            disp_GetAttrFgColor(win_GetAttr(win))
  124. #define win_GetShadowBgColor(win)    disp_GetAttrBgColor(win_GetShadowAttr(win))
  125. #define win_GetShadowFgColor(win)    disp_GetAttrFgColor(win_GetShadowAttr(win))
  126.  
  127. #define win_GetPixCursorPos(win, cxp, cyp)            \
  128.     (*(cxp) = win_GetCursx(win), *(cyp) = win_GetCursy(win))
  129.  
  130. #define win_SetFont(win, font)        ((boolean) win_Do(win, WINM_SETFONT, font, NULL))
  131. #define win_GetFontWidth(win)        ofont_GetWidth(win_GetFont(win))
  132. #define win_GetFontHeight(win)        ofont_GetHeight(win_GetFont(win))
  133.  
  134. #define win_CheckEventWait(win, wt)    hard_CheckEvent(wt)
  135. #define win_CheckEvent(win)            hard_CheckEvent(0)
  136.  
  137. #define win_MouseHoldDown(win, mev)                    \
  138.     win_MouseHoldDownTime(win, mev,    disp_MouseTimeout())
  139.  
  140. #define win_MouseReleaseWait(win, mev)                    \
  141.     win_MouseHoldDownTime(win, mev, (unsigned)-1)
  142.  
  143. /* -------------------------------------------------------------------------- */
  144. #define win_GetPixWidth(win)        ((opcoord)opbox_GetWidth(win_inboxp(win)))
  145. #define win_GetPixHeight(win)        ((opcoord)opbox_GetHeight(win_inboxp(win)))
  146.  
  147. #define win_GetPixBox(win, boxp)                    \
  148.     ((boxp)->xmin = 0, (boxp)->ymin = 0,            \
  149.      (boxp)->xmax = win_GetPixWidth(win), (boxp)->ymax = win_GetPixHeight(win))
  150.  
  151. /*    Paints all unobscured parts of win in relbox. */
  152. #define win_PaintPixBox(win, relboxp)                \
  153.     win_ExposePixBox(win, relboxp, WINM_PAINT, NULL, WINM_SHADOW, NULL)
  154.  
  155. /*    Paints all unobscured parts of win. */
  156. #define    win_Paint(win)                win_Expose(win, WINM_PAINT, NULL, WINM_SHADOW, NULL)
  157.  
  158. /*    Saves all unobscured parts of win in relbox. */
  159. #define win_SavePixBox(win, relboxp)  win_ExposePixBox(win, relboxp, WINM_SAVE, NULL, WINM_SHADOWSAVE, NULL)
  160.  
  161. /*    Saves all unobscured parts of win. */
  162. #define    win_Save(win)                win_Expose(win, WINM_SAVE, NULL, WINM_SHADOWSAVE, NULL)
  163. #define    win_Grab(win)                win_Expose(win, WINM_GRAB, NULL, WINM_SHADOWSAVE, NULL)
  164.  
  165. #define win_Employ(win)                win_PutUnder(win, curr_wmgr->bot_sys_win)
  166.  
  167. #define win_UnEmploy(win)            win_Do(win, WINM_UNEMPLOY, NULL, NULL)
  168.  
  169. #define win_Top(win)                win_Do(win, WINM_PUTUNDER, NULL, NULL)
  170. #define win_PutUnder(win, dest)        win_Do(win, WINM_PUTUNDER, dest, NULL)
  171.  
  172. /* Character-grid coordinate window macros */
  173. #define win_GetLeftCol(win)                            \
  174.     opcoord_GetXCol(win_GetXmin(win), win_GetFont(win))
  175.  
  176. #define win_GetTopRow(win)                            \
  177.     opcoord_GetYRow(win_GetYmin(win), win_GetFont(win))
  178.  
  179. #define win_GetRightCol(win)                        \
  180.     (opcoord_GetXCol(win_GetXmax(win), win_GetFont(win)) - 1)
  181.  
  182. #define win_GetBotRow(win)                            \
  183.     (opcoord_GetYRow(win_GetYmax(win), win_GetFont(win)) - 1)
  184.  
  185. #define win_GetWidth(win)                            \
  186.     ((int)(win_GetPixWidth(win) / win_GetFontWidth(win)))
  187.  
  188. #define win_GetHeight(win)                            \
  189.     ((int)(win_GetPixHeight(win) / win_GetFontHeight(win)))
  190.  
  191. #define win_Scroll(win, nrows, ncols)                \
  192.     win_ScrollPix(win, (ncols)*win_GetFontWidth(win), \
  193.                         (nrows)*win_GetFontHeight(win))
  194.  
  195. #define win_SetPosition(win, row, col)                \
  196.     win_SetPixPosition(win, (col)*win_GetFontWidth(win), \
  197.                             (row)*win_GetFontHeight(win))
  198.  
  199. #define win_GetBox(win, cboxp)                        \
  200.     ((cboxp)->toprow = 0, (cboxp)->leftcol = 0,        \
  201.      (cboxp)->botrow = win_GetHeight(win) - 1,        \
  202.      (cboxp)->rightcol = win_GetWidth(win) - 1)
  203.  
  204. #define win_GetCursorPos(win, rowp, colp)            \
  205.     (*(colp) = opcoord_GetXCol(win_GetCursx(win), win_GetFont(win)), \
  206.      *(rowp) = opcoord_GetYRow(win_GetCursy(win), win_GetFont(win)) - 1)
  207.  
  208. #define win_SetCursorPos(win, row, col)                \
  209.     win_SetPixCursorPos(win, (col) * win_GetFontWidth(win), \
  210.                             ((row+1)) * win_GetFontHeight(win))
  211.  
  212. #define win_SetSize(win, rows, cols)                \
  213.     win_SetPixSize(win, (cols) * win_GetFontWidth(win), \
  214.                         (rows) * win_GetFontHeight(win))
  215.  
  216. #define win_PaintChar(win, row, col)    win_PaintRow(win, row, col, 1)
  217.  
  218. /* -------------------------------------------------------------------------- */
  219. /* *** wmgr_ funcs renamed to win_ for public consumption *** */
  220.  
  221. #define win_IsObscured(win)                            \
  222.     (wmgr_IsObscuredPixBox(curr_wmgr->bot_sys_win, win, win_pixboxp(win), TRUE) != NULL)
  223. /* -------------------------------------------------------------------------- */
  224. /* *** wmgr_ funcs renamed to disp_ for public consumption *** */
  225.  
  226. #define disp_GetBackWin()            (curr_wmgr->backwin)
  227. #define disp_GetTopWin()            win_GetBelow((curr_wmgr->bot_sys_win))
  228. #define disp_GetBotWin()            (curr_wmgr->bot_employed_win)
  229. #define disp_GetCurrentWin()        (curr_wmgr->currwin)
  230. #define disp_GetDispWin()            (curr_wmgr->dispwin)
  231. #define disp_GetAttr()                win_GetAttr(disp_GetDispWin())
  232. #define disp_SetAttr(at)            win_SetAttr(disp_GetDispWin(), at)
  233. #define disp_GetShadowAttr()        win_GetShadowAttr(disp_GetDispWin())
  234. #define disp_SetShadowAttr(at)        win_SetShadowAttr(disp_GetDispWin(), at)
  235. #define disp_TrapMouse(win)            (curr_wmgr->trapmousewin = (win))
  236. #define disp_TrapMouseOff()            (curr_wmgr->trapmousewin = NULL)
  237. #define disp_GetMouseTrap()            (curr_wmgr->trapmousewin)
  238. #define disp_IsTrappedMouse()        (disp_GetMouseTrap() != NULL)
  239. #define disp_GetFromWin()            (curr_wmgr->fromwin)
  240.  
  241. #define cls()                        disp_Clear(win_GetBgColor(disp_GetDispWin()))
  242.  
  243. /* Note: disp_SetMouseCode is now obsolete. */
  244. #define disp_SetMouseCode(mcode)    kb_Stuff(mcode)
  245. /* -------------------------------------------------------------------------- */
  246. /* *** wmgr_ funcs renamed to kb_ for public consumption *** */
  247.  
  248. #define kb_Stuff(code)                (curr_wmgr->stuffcode = (code))
  249. #define kb_WasMouse()                ((boolean) curr_wmgr->wasmouse)
  250. #define mev_IsFake()                ((boolean) curr_wmgr->fakemouse)
  251. /* -------------------------------------------------------------------------- */
  252. /* Function prototypes */
  253.  
  254. /* WINCLEAR.C */
  255. extern void        win_Clear(win_type win, opixval color);
  256. extern void        win_ClearPixBox(win_type win, opbox *boxp, opixval color);
  257. extern void        win_ClearBox(win_type win, ocbox *cboxp, opixval color);
  258.  
  259. /* WINCLIP.C */
  260. extern unsigned win_clipbox(win_type win, opbox *boxp);
  261. extern unsigned win_clippoint(win_type win, opcoord *xp, opcoord *yp);
  262.  
  263. /* WINCURSO.C */
  264. extern void        win_SetPixCursorPos(win_type win, opcoord cursx, opcoord cursy);
  265. extern void        win_SetCursorType(win_type win, cursortype ctype);
  266. extern void        win_GetCursorPixBox(win_type win, opbox *cursboxp);
  267. extern boolean    win_ShowCursor(win_type win);
  268. extern boolean    win_HideCursor(win_type win);
  269. extern void        win_SetCursorColor(win_type win, opixval color);
  270.  
  271. /* WINDUMP.C (debugging aid) */
  272. extern void        win_Dump(char *msg);
  273.  
  274. /* WINEXPOS.C */
  275. extern void        win_Expose(win_type win, int emsg, VOID *emsgdata, int shademsg, VOID *shademsgdata);
  276. extern void        win_ExposePixBox(win_type win, opbox *relboxp, int emsg, VOID *emsgdata, int shademsg, VOID *shademsgdata);
  277.  
  278. /* WINGETP.C */
  279. extern void        win_GetPixPosition(win_type win, opbox *opboxp);
  280. extern void        win_GetPosition(win_type win, ocbox *ocboxp);
  281.  
  282. /* WINGO.C */
  283. extern int        win_Go(win_type win);
  284.  
  285. /* WINMEV.C */
  286. extern void        winmev_grantrequest(win_type win, mev_struct *mev);
  287.  
  288. /* WINMOUSE.C */
  289. extern int        win_ReadEvent(win_type win, mev_struct *mev);
  290. extern boolean    win_MouseCurrEvent(mev_struct *mev);
  291. extern int        win_MouseHoldDownTime(win_type win, mev_struct *mev, unsigned duration);
  292. extern int        win_MouseDblClick(win_type win, mev_struct *mev);
  293.  
  294. /* WINMOUTK.C */
  295. extern mouhandler_func    (winmou_Track);
  296.  
  297. /* WINOBSC.C */
  298. extern win_type wmgr_IsObscuredPixBox(win_type topwin, win_type win, opbox *boxp, boolean doshad);
  299. extern win_type wmgr_PointWin(opcoord x, opcoord y);
  300. extern win_type wmgr_FindBelow(win_type win);
  301.  
  302. /* WINOPEN.C */
  303. extern win_type win_Open(class_fptr winclass, ocbox *cboxp);
  304. extern win_type win_PixOpen(class_fptr winclass, opbox *boxp, ofont_type font);
  305. extern void        win_SetAttr(win_type win, byte attr);
  306. extern void        win_SetShadow(win_type win, int csize);
  307.  
  308. /* WINPAINT.C */
  309. extern void        win_PaintRow(win_type win, int row, int col, int length);
  310. extern void        win_PaintCol(win_type win, int row, int col, int length);
  311. extern void        win_PaintBox(win_type win, ocbox *cboxp);
  312.  
  313. /* WINSCROL.C */
  314. extern void        win_ScrollPix(win_type win, opcoord nx, opcoord ny);
  315. extern void        win_ScrollPixBox(win_type win, opbox *boxp, opcoord nx, opcoord ny);
  316. extern void        win_ScrollBox(win_type win, ocbox *cboxp, int nrows, int ncols);
  317.  
  318. /* WINSETP.C */
  319. extern void        win_SetPixPosition(win_type win, opcoord xpos, opcoord ypos);
  320. extern void        win_ReallySetPixPosition(win_type win, opcoord xpos, opcoord ypos);
  321.  
  322. /* WINSIZE.C */
  323. extern void        win_SetPixSize(win_type win, odim width, odim height);
  324. extern void        win_ReallySetPixSize(win_type win, odim width, odim height);
  325.  
  326. /* WINTOP.C */
  327. extern boolean    win_ReallyPutUnder(win_type win, win_type destwin);
  328. extern boolean    win_ReallyUnEmploy(win_type win);
  329. extern boolean    win_IsAbove(win_type winabove, win_type win);
  330.  
  331. /* -------------------------------------------------------------------------- */
  332.  
  333.