home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / util / edit / jade / src / amiga_windowsys.h < prev    next >
C/C++ Source or Header  |  1994-06-26  |  4KB  |  127 lines

  1. /* amiga_windowsys.h -- Amiga window-system data and macros
  2.    Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
  3.  
  4.    This file is part of Jade.
  5.  
  6.    Jade is free software; you can redistribute it and/or modify it
  7.    under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2, or (at your option)
  9.    any later version.
  10.  
  11.    Jade is distributed in the hope that it will be useful, but
  12.    WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with Jade; see the file COPYING.  If not, write to
  18.    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifndef _AMIGA_WINDOWSYS_H
  21. #define _AMIGA_WINDOWSYS_H
  22.  
  23. typedef struct {
  24.     struct Window      *ws_Window;
  25.     struct RastPort    *ws_Rp;
  26.     short        ws_PenX, ws_PenY;
  27.     struct TextFont    *ws_Font;
  28.     UWORD        ws_OldDimensions[4];    /* l,t,w,h */
  29.     short        ws_FontSize;
  30.     short        ws_Pad; /* keep on long word alignment. */
  31.     VALUE        ws_ScreenName;
  32. } VW_WindowSys;
  33.  
  34. #define vw_Window    vw_WindowSys.ws_Window
  35. #define vw_Font     vw_WindowSys.ws_Font
  36. #define WINDOW_NIL    NULL
  37.  
  38. typedef struct {
  39.     struct Gadget      *gad;
  40.     long        top;
  41.     long        total;
  42. } ScrollBar;
  43.  
  44. /* Pen colours. */
  45. #define P_TEXT    0
  46. #define P_BLOCK 1
  47.  
  48. /*
  49.  * Macros for drawing operations. These are mainly used in render.c for
  50.  * system-independant rendering.
  51.  */
  52.  
  53. /* Move to position (X,Y). The next DRAW() will happen at this position. */
  54. #define MOVE(vw,x,y) \
  55.     do { \
  56.     (vw)->vw_WindowSys.ws_PenX = x; \
  57.     (vw)->vw_WindowSys.ws_PenY = y; \
  58.     } while(0)
  59.  
  60. #define PEN_X(vw) ((vw)->vw_WindowSys.ws_PenX)
  61. #define PEN_Y(vw) ((vw)->vw_WindowSys.ws_PenY)
  62.  
  63. /* Draw LEN bytes of the string STR with colour COL (P_TEXT or P_BLOCK)
  64.    at the position set by the MOVE() macro.  */
  65. #define TEXT(vw,col,str,len) \
  66.     do { \
  67.     Move((vw)->vw_WindowSys.ws_Rp, \
  68.          (vw)->vw_WindowSys.ws_PenX, \
  69.          (vw)->vw_WindowSys.ws_PenY); \
  70.     SetAPen((vw)->vw_WindowSys.ws_Rp, 1); \
  71.     SetDrMd((vw)->vw_WindowSys.ws_Rp, JAM2 | (((col) == P_TEXT) ? 0 : INVERSVID)); \
  72.     Text((vw)->vw_WindowSys.ws_Rp, (str), (len)); \
  73.     (vw)->vw_WindowSys.ws_PenX += (len) * (vw)->vw_FontX; \
  74.     } while(0)
  75.  
  76. /* Clear a rectangle from (X,Y) to (X+W,Y+H).  */
  77. #define CLR_AREA(vw,x,y,w,h) \
  78.     do { \
  79.     SetAPen((vw)->vw_WindowSys.ws_Rp, 0); \
  80.     SetDrMd((vw)->vw_WindowSys.ws_Rp, JAM2); \
  81.     RectFill((vw)->vw_WindowSys.ws_Rp, \
  82.          (x), (y), ((x) + (w)) - 1, ((y) + (h)) - 1); \
  83.     } while(0)
  84.  
  85. #define CLR_RECT(vw,x1,y1,x2,y2) \
  86.     do { \
  87.     SetAPen((vw)->vw_WindowSys.ws_Rp, 0); \
  88.     SetDrMd((vw)->vw_WindowSys.ws_Rp, JAM2); \
  89.     RectFill((vw)->vw_WindowSys.ws_Rp, (x1), (y1), (x2) - 1, (y2) - 1); \
  90.     } while(0)
  91.  
  92. /* Fill a rectangle from (X,Y) to (X+W,Y+H).  */
  93. #define SET_AREA(vw,x,y,w,h) \
  94.     do { \
  95.     SetAPen((vw)->vw_WindowSys.ws_Rp, 1); \
  96.     SetDrMd((vw)->vw_WindowSys.ws_Rp, JAM2); \
  97.     RectFill((vw)->vw_WindowSys.ws_Rp, \
  98.          (x), (y), ((x) + (w)) - 1, ((y) + (h)) - 1); \
  99.     } while(0)
  100.  
  101. #define SET_RECT(vw,x1,y1,x2,y2) \
  102.     do { \
  103.     SetAPen((vw)->vw_WindowSys.ws_Rp, 1); \
  104.     SetDrMd((vw)->vw_WindowSys.ws_Rp, JAM2); \
  105.     RectFill((vw)->vw_WindowSys.ws_Rp, (x1), (y1), (x2) - 1, (y2) - 1); \
  106.     } while(0)
  107.  
  108. /* Copy pixels from (X1,Y1),(X1+W,Y1+H) to (X2,Y2)  */
  109. #define COPY_AREA(vw,x1,y1,w,h,x2,y2) \
  110.     ClipBlit((vw)->vw_WindowSys.ws_Rp, (x1), (y1), \
  111.          (vw)->vw_WindowSys.ws_Rp, (x2), (y2), \
  112.          (w), (h), 0xc0)
  113.  
  114. /* Number of pixels from top of font to its baseline.  */
  115. #define FONT_ASCENT(vw) ((vw)->vw_Font->tf_Baseline)
  116.  
  117. /* Draw a line from (x1,y1) to (x2,y2)    */
  118. #define DRAW_LINE(vw,x1,y1,x2,y2) \
  119.     do { \
  120.     SetAPen((vw)->vw_WindowSys.ws_Rp, 1); \
  121.     SetDrMd((vw)->vw_WindowSys.ws_Rp, JAM2); \
  122.     Move((vw)->vw_WindowSys.ws_Rp, x1, y1); \
  123.     Draw((vw)->vw_WindowSys.ws_Rp, x2, y2); \
  124.     } while(0)
  125.  
  126. #endif /* _AMIGA_WINDOWSYS_H */
  127.