home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / stdwin / Ports / mac / macwin.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-28  |  6.5 KB  |  228 lines  |  [TEXT/????]

  1. /* Source for the precompiled header file "macwin.h" in THINK C.
  2.    This file includes other header files and defines symbols and types.
  3.    It is included in the project for convenience; it generates no code.
  4.    
  5.    **********************************************************************
  6.    * When you edit this file, you must generate a new "macwin.h":       *
  7.    * Choose "Precompile..." from the Source menu and save as "macwin.h" *
  8.    * (overwriting the old "macwin.h").                                  *
  9.    **********************************************************************
  10.    
  11.    For Think C version 3.0, define THINK_C and THINK_C_3_0 in "stdwconf.h".
  12.    
  13.    For MPW, move macwin.c to macwin.h and remove the <MacHeaders>
  14.    include below.
  15. */
  16.  
  17. #ifdef THINK_C
  18. #include <MacHeaders>        /* You MUST precompile this file! */
  19. #else
  20. #include <Types.h>
  21. #include <Quickdraw.h>
  22. #include <Controls.h>
  23. #include <Events.h>
  24. #include <Windows.h>
  25. #endif
  26.  
  27. #include "stdwconf.h"        /* Will set MPW or THINK_C */
  28.  
  29.  
  30. #ifdef MPW
  31.  
  32. /* Without NO_STDIO, some THINK specific code gets compiled */
  33. #define NO_STDIO
  34.  
  35. /* MPW names for Mac include files */
  36. #include <Types.h>
  37. #include <Quickdraw.h>
  38. #include <Windows.h>
  39. #include <Controls.h>
  40.  
  41. /* Quickdraw globals aren't really global in MPW */
  42. #define QD(var) qd.var
  43.  
  44. /* MPW allows 'static' in forward declarations */
  45. #define STATIC static
  46.  
  47. /* MPW passes all Points by value */
  48. #define PASSPOINT &
  49.  
  50. /* MPW glue converts most string on the fly.
  51.    (XXX I believe you can turn this off now?) */
  52. #define CLEVERGLUE
  53.  
  54. #endif
  55.  
  56.  
  57. #ifdef THINK_C
  58.  
  59. /* You may also define NO_STDIO under THINK C, to avoid pulling in stdio */
  60. /* ...and for 4.0, it doesn't work anymore (sigh) */
  61. #ifndef THINK_C_3_0
  62. #define NO_STDIO
  63. #endif
  64.  
  65. /* THINK's <WindowMgr.h> omits two essential constants of the Mac+ ROM */
  66. #define zoomDocProc 8
  67. #define zoomNoGrow 12
  68.  
  69. /* Pascal-to-C and back string conversion routines have different names */
  70. #include <pascal.h>
  71. #ifndef p2cstr
  72. #define p2cstr PtoCstr
  73. #endif
  74. #ifndef p2cstr
  75. #define c2pstr CtoPstr    /* XXX actually, used nowhere */
  76. #endif
  77.  
  78. /* Quickdraw globals are real globals in THINK C */
  79. /* But don't use them, the console library breaks this!!! */
  80. #define QD(var) (var)
  81.  
  82. /* THINK C can't declare forward functions as static */
  83. #define STATIC /**/
  84.  
  85. /* THINK C passes Points by value to some toolbox routines */
  86. #define PASSPOINT /**/
  87.  
  88. #endif
  89.  
  90.  
  91. /* Private include files: */
  92.  
  93. #include "tools.h"
  94. #include "stdwin.h"
  95. #include "menu.h"
  96.  
  97.  
  98. #ifdef CLEVERGLUE
  99. /* MPW converts C to Pascal strings in the glue */
  100. #define PSTRING(str) (str)
  101. #else
  102. /* THINK C needs a real function to do this (see "pstring.c").
  103.    This is different from CtoPstr since it does not do it inline */
  104. extern char *PSTRING _ARGS((char *));
  105. #endif
  106.  
  107.  
  108. /* Window struct. */
  109.  
  110. struct _window {
  111.     short tag;        /* Window tag, usable as document id */
  112.     void (*drawproc)();    /* Draw procedure */
  113.     WindowPtr w;        /* Mac Window */
  114.     int hcaret, vcaret;    /* Caret position, document coordinates */
  115.     bool caret_on;        /* Set if caret currently visible */
  116.     TEXTATTR attr;        /* Text attributes */
  117.     ControlHandle hbar, vbar;    /* Scroll bars */
  118.     int docwidth, docheight;    /* Document size */
  119.     int orgh, orgv;        /* Window origin, document coordinates */
  120.     struct menubar mbar;    /* List of attached local menus */
  121.     unsigned long timer;    /* Tick count for timer event */
  122.     CURSOR *cursor;        /* Cursor if not default */
  123.     COLOR fgcolor, bgcolor;    /* Default colors for this window */
  124. };
  125.  
  126. extern TEXTATTR wattr;        /* Current text attributes */
  127.  
  128. #define TX_INVERSE    0x80    /* Or-ed into style bits */
  129.  
  130. /* Peculiarities of the Macintosh: */
  131.  
  132. #define TICKSPERSECOND    60    /* Clock ticks at 60 Hz (everywhere) */
  133.  
  134. #define MENUBARHEIGHT    20    /* Height of menu bar */
  135. #define TITLEBARHEIGHT    18    /* Height of window title bar */
  136. #define BAR        15    /* Scroll bar width, minus one pixel */
  137.  
  138. /* ASCII codes generated by special keys: */
  139. #define ENTER_KEY    0x03
  140.  
  141. #define LEFT_ARROW    0x1c
  142. #define RIGHT_ARROW    0x1d
  143. #define UP_ARROW    0x1e
  144. #define DOWN_ARROW    0x1f
  145.  
  146.  
  147. /* Miscellaneous definitions. */
  148.  
  149. #define CLICK_DIST    5    /* Max mouse move within a click */
  150.  
  151. /* Text drawn in the very left or right margin doesn't look nice.
  152.    Therefore, we have a little margin on each side.
  153.    Its width is determined here: */
  154. #define LSLOP    4    /* Pixels in left margin */
  155. #define RSLOP    4    /* Pixels in right margin */
  156.  
  157. /* Global data: */
  158. extern GrafPtr screen;        /* Window Manager's GrafPort */
  159. extern WINDOW *active;        /* Active window, if any */
  160. extern bool _wmenuhilite;    /* Set if menu item highlighted */
  161. extern bool _wm_down;        /* Set if mouse down (in appl. area) */
  162. extern COLOR _w_fgcolor;    /* Current foreground color */
  163. extern COLOR _w_bgcolor;    /* Current background color */
  164.  
  165. /* Function prototypes: */
  166.  
  167. void dprintf _ARGS((char *fmt, ...));
  168.  
  169. void wsetstyle _ARGS((Style face));
  170.  
  171. WINDOW *whichwin _ARGS((WindowPtr w));
  172.  
  173. void makerect _ARGS((WINDOW *win, Rect *pr,
  174.     int left, int top, int right, int bottom));
  175. void getwinrect _ARGS((WINDOW *win, Rect *pr));
  176.  
  177. void set_arrow _ARGS((void));
  178. void set_applcursor _ARGS((void));
  179. void set_watch _ARGS((void));
  180. void set_ibeam _ARGS((void));
  181. void set_hand _ARGS((void));
  182.  
  183. void makescrollbars _ARGS((WINDOW *win, /*bool*/int hor, /*bool*/int ver));
  184. void movescrollbars _ARGS((WINDOW *win));
  185. void hidescrollbars _ARGS((WINDOW *win));
  186. void showscrollbars _ARGS((WINDOW *win));
  187. void _wgrowicon _ARGS((WINDOW *win));
  188. void _wfixorigin _ARGS((WINDOW *));
  189.  
  190. void scrollby _ARGS((WINDOW *win, Rect *pr, int dh, int dv));
  191. void do_scroll _ARGS((Point *pwhere,
  192.     WINDOW *win, ControlHandle bar, int pcode));
  193. void dragscroll _ARGS((WINDOW *win, int h, int v, int constrained));
  194.  
  195. void initwattr _ARGS((void));
  196.  
  197. void inval_border _ARGS((WindowPtr w));
  198. void valid_border _ARGS((WindowPtr w));
  199.  
  200. void rmlocalmenus _ARGS((WINDOW *win));
  201. void addlocalmenus _ARGS((WINDOW *win));
  202. void initmbar _ARGS((struct menubar *mp));
  203. void killmbar _ARGS((struct menubar *mp));
  204. void setup_menus _ARGS((void));
  205.  
  206. void do_about _ARGS((void));
  207. void getargcargv _ARGS((int *pargc, char ***pargv));
  208. void fullpath _ARGS((char *buf, int wdrefnum, char *file));
  209. char *getdirname _ARGS((int wdrefnum));
  210.  
  211.  
  212. void rmcaret _ARGS((WINDOW *win));
  213. void showcaret _ARGS((WINDOW *win));
  214. void blinkcaret _ARGS((WINDOW *win));
  215. void _wresetmouse _ARGS((void));
  216.  
  217. void _wfreeclip _ARGS((void));
  218. bool checktimer _ARGS((EVENT *ep));
  219. void autoscroll _ARGS((WINDOW *active, int h, int v));
  220. void _wdo_menu _ARGS((EVENT *ep, long menu_item));
  221.  
  222. void _w_usefgcolor _ARGS((COLOR color));
  223. void _w_usebgcolor _ARGS((COLOR color));
  224.  
  225. /* SetRect is much faster this way... */
  226. #define SetRect(pr, l, t, r, b) ((pr)->left = (l), (pr)->top = (t), \
  227.                 (pr)->right = (r), (pr)->bottom = (b))
  228.