home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1997: The Complete Utilities Toolkit / macworld-complete-utilities-1997.iso / Programming / Little Smalltalk v3.1.5 / C Source / Headers / glue.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-21  |  8.1 KB  |  233 lines  |  [TEXT/KAHL]

  1. /*
  2.     Little Smalltalk, version 2
  3.     Written by Tim Budd, Oregon State University, July 1987
  4.  
  5.     Symantec Think Class Library interface code ©Julian Barkway, April 1994 
  6.     
  7.     glue.h 
  8.     ------
  9.     Structures, #defines and prototypes relating to the Little Smalltalk-TCL 
  10.     interface. Currently, this header is largely identifier-compatible with 
  11.     StdWin. However, this may change in future.
  12. */
  13. #ifndef __GLUE_H__
  14. #define __GLUE_H__
  15.  
  16. #define CURSOR Cursor
  17. #define WINDOW    _window    // These will be used as a pointer to the memory containing
  18. #define TEXTEDIT char    // the real data and should be casted.
  19. #define MENU    MenuInfo
  20.  
  21. typedef struct _window {
  22.     char    *window;
  23.     char    *document;
  24.     int        stObject;        // The Smalltalk window object - added for v3.2
  25. } _window;
  26.  
  27. //
  28. //====== The following definitions and prototypes have been taken from
  29. //====== Guido van Rossum's StdWin system for reasons of compatibility.
  30. //
  31. /* EVENT struct */
  32.  
  33. struct _event {
  34.     int type;
  35.     WINDOW *window;
  36.     union {
  37.         int character;                                        /* case WE_CHAR: */
  38.         int command;                                        /* case WE_COMMAND: */
  39.         struct { int id; int item; } m;                        /* case WE_MENU: */
  40.         struct { int left, top, right, bottom; } area;        /* case WE_DRAW: */
  41.         struct {                    /* case WE_MOUSE_DOWN, WE_MOUSE_MOVE, WE_MOUSE_UP: */
  42.             int h;
  43.             int v;
  44.             int clicks;
  45.             int button;
  46.             int mask;
  47.         } where;
  48.         int sel;                                            /* case WE_LOST_SEL: */
  49.         struct { int code; int mask; } key;                    /* case WE_KEY: */
  50.     } u;
  51. };
  52.  
  53. #define EVENT struct _event
  54.  
  55.  
  56. /* Event types */
  57. /* XXX Should be reordered */
  58.  
  59. #define WE_NULL        0        /* (Used internally) */
  60. #define WE_ACTIVATE    1        /* Window became active */
  61. #define WE_CHAR        2        /* Character typed at keyboard */
  62. #define WE_COMMAND    3        /* Special command, function key etc. */
  63. #define WE_MOUSE_DOWN    4    /* Mouse button pressed */
  64. #define WE_MOUSE_MOVE    5    /* Mouse moved with button down */
  65. #define WE_MOUSE_UP    6        /* Mouse button released */
  66. #define WE_MENU        7        /* Menu item selected */
  67. #define WE_SIZE        8        /* Window size changed */
  68. #define WE_MOVE        9        /* Window moved (reserved) */
  69. #define WE_DRAW        10        /* Request to redraw part of window */
  70. #define WE_TIMER    11        /* Window's timer went off */
  71. #define WE_QUIT        11            // -- Since the use of the timer is not supported
  72.                                 //    by Little Smalltalk, I am using this event to
  73.                                 //    pass the command-Q (quit) notification from 
  74.                                 //    TCL to Little Smalltalk. JRB, 5/94
  75. #define WE_DEACTIVATE    12    /* Window became inactive */
  76. #define WE_EXTERN    13        /* Externally generated event (Amoeba) */
  77. #define WE_KEY        14        /* Non-ASCII key event */
  78. #define WE_LOST_SEL    15        /* Lost selection */
  79. #define WE_CLOSE    16        /* User wants to close window */
  80.  
  81.  
  82. /* Special keys reported by WE_COMMAND */
  83. /* XXX Should become key events */
  84.  
  85. #define WC_CLOSE    1        /* Obsolete */
  86. /* The following four are arrow keys */
  87. #define WC_LEFT        2
  88. #define WC_RIGHT    3
  89. #define WC_UP        4
  90. #define WC_DOWN        5
  91. /* ASCII keys */
  92. #define WC_CANCEL    6
  93. #define WC_BACKSPACE    7
  94. #define WC_TAB        8
  95. #define WC_RETURN    9
  96. /* IBM-PC keys -- not in all implementations */
  97. /* XXX Should be done differently */
  98. #define WC_HOME        10
  99. #define WC_END        11
  100. #define WC_CLEAR    12
  101. #define WC_INS        13
  102. #define WC_DEL        14
  103. #define WC_PAGE_UP    15
  104. #define WC_PAGE_DOWN    16
  105. #define WC_META_LEFT    17
  106. #define WC_META_RIGHT    18
  107. #define WC_META_HOME    19
  108. #define WC_META_END    20
  109. #define WC_META_PAGE_UP    21
  110. #define WC_META_PAGE_DOWN    22
  111. /* XXX Should have entries for Alt-letter and F1-F10 etc. ? */
  112.  
  113.  
  114. /* Codes for selections (e.u.sel for WE_LOST_SEL) */
  115.  
  116. #define WS_CLIPBOARD    0
  117. #define WS_PRIMARY    1
  118. #define WS_SECONDARY    2
  119.  
  120.  
  121. /* Masks for EVENT->u.where.mask and EVENT->u.key.mask.
  122.    Some of these happen to be the same as the X11 masks (which are cast
  123.    in stone for eternity); the implementation relies on that.
  124.    (It is merely a convention that Meta is bit 3, and Option/Num aren't
  125.    normally used in X11.) */
  126.  
  127. #define WM_SHIFT    (1 << 0)
  128. #define WM_LOCK        (1 << 1)
  129. #define WM_CONTROL    (1 << 2)
  130. #define WM_META        (1 << 3)
  131. #define WM_OPTION    (1 << 4)
  132. #define WM_NUM        (1 << 5)
  133.  
  134. #define WM_BUTTON1    (1 << 8)
  135. #define WM_BUTTON2    (1 << 9)
  136. #define WM_BUTTON3    (1 << 10)
  137. #define WM_BUTTON4    (1 << 11)
  138. #define WM_BUTTON5    (1 << 12)
  139.  
  140.  
  141. //====================== Function Prototypes =========================
  142.  
  143. void     winit                 (void);
  144. void     getVersionNumber     (char *str);
  145. void     wdone                 (void);
  146. void     setFont                (TEXTEDIT *tp, char *fontName);
  147. void     setFontSize            (TEXTEDIT *tp, short fontSize);
  148. void     setTypeFace            (TEXTEDIT *tp, short typeFace);
  149. void     tereplace             (TEXTEDIT *tp, char *str);
  150. void    replaceAllText        (TEXTEDIT *tp, char *str);
  151. void     deleteAllText         (TEXTEDIT *tp);
  152. void    getPaneSize            (TEXTEDIT *tp, short *width, short *height);
  153. TEXTEDIT *addScrollPane     (WINDOW *win, short left, short top, short right, short bottom,
  154.                                 short horizOption, short vertOption);
  155. TEXTEDIT *addSelPane        (WINDOW *win, short left, short top, short right, short bottom,
  156.                                short horizElastic, short vertElastic, short lineLength);
  157. TEXTEDIT *addTextPane         (WINDOW *win, short left, short top, short right, short bottom,
  158.                                short horizElastic, short vertElastic, short lineLength);
  159. TEXTEDIT *tecreate            (WINDOW *win, int left, int top, int right, int bottom);
  160. TEXTEDIT *addGraphicsPane     (WINDOW *win, short left, short top, short right, short bottom,
  161.                                short horizElastic, short vertElastic);
  162. Boolean teevent                (TEXTEDIT *tp, EVENT *e);
  163. void    scrollToSelection    (TEXTEDIT *tp);
  164. void    setTextSelection    (TEXTEDIT *tp, long startPos, long endPos);
  165. void    getTextSelection    (TEXTEDIT *tp, long *startPos, long *endPos);
  166. char    *teGetSelectedText    (TEXTEDIT *tp);
  167. char     *tegettext            (TEXTEDIT *tp);
  168. void     tedraw                (register TEXTEDIT *tp);
  169.  
  170. void     wmessage            (char *prompt);
  171. void     wperror                (char *name);
  172. Boolean waskstr                (char *prompt, char *buf, int len);
  173. int     waskync                (char *prompt, int def);
  174. Boolean waskfile             (char *prompt, char *buf, int len, Boolean newFile, short ftype);
  175. void     saveTE                (TEXTEDIT *tp, short fileNum);
  176. void     loadTE                (TEXTEDIT *tp, short fileNum);
  177.  
  178. void     wmenuenable         (MENU *mp, int item, int flag);
  179. MENU     *wmenucreate        (int id, char *title);
  180. MENU     *popUpMenuCreate    (short menuID);
  181. void     wmenuattach         (WINDOW *win, MENU *mp);
  182. void     wmenudetach         (WINDOW *win, MENU *mp);
  183. void     wmenucheck            (MENU *mp, int item, int flag);
  184. void     wmenusetdeflocal    (Boolean local);
  185. int     wmenuadditem        (MENU *mp, char *text, int shortcut);
  186. void     selectFromPopUpMenu (MENU *mp, short top, short left, short *menu, short *item);
  187. void     wmenudelete         (MENU *mp);
  188. void     removeMenuItem        (MENU *mp, short menuItem);
  189.  
  190. void     getMaxScreenArea     (short *left, short *top, short *right, short *bottom);
  191. CURSOR    *wfetchcursor        (char *name);
  192. void    wsetwincursor        (WINDOW *win, CURSOR *cursor);
  193. void    setArrowCursor        (void);
  194.  
  195. Boolean    docDirty            (WINDOW *win);
  196. void     wsetdocsize            (WINDOW *win, int docwidth, int docheight);
  197. void     wsetactive            (WINDOW *win);
  198. WINDOW     *wopen                (char *title, 
  199.                              void (*drawproc)(WINDOW *win, int top, int left,
  200.                                            int bottom, int right) );
  201. WINDOW *wopentosize            (char *title, int left, int top, int width, int height, Boolean noClose);
  202. void     wfleep                (void);
  203. void     wclose                (WINDOW *win);
  204. void     wgetwinsize            (WINDOW *win, int *pwidth, int *pheight);
  205. void     wgetwinpos            (WINDOW *win, int *h, int *v);
  206. void     windowToFront         (WINDOW *win);
  207. void     wsettitle            (WINDOW *win, Str255 title);
  208. void     wsetorigin             (WINDOW *win, int orgh, int orgv);
  209.  
  210. void    wbegindrawing        (TEXTEDIT *pane);
  211. void     wenddrawing            (TEXTEDIT *pane);
  212. void     wshade                (int left, int top, int right, int bottom, int perc);
  213. void     werase                 (int left, int top, int right, int bottom);
  214. void     wdrawcircle            (int h, int v, int radius);
  215. void     drawLineTo            (int h, int v);
  216. void     moveTo                (short h, short v);
  217. void     drawPixel            (short h, short v);
  218. void     wdrawbox            (int left, int top, int right, int bottom);
  219. void     winvert                (int left, int top, int right, int bottom);
  220. void     wpaint                (int left, int top, int right, int bottom);
  221. void     wdrawtext            (int h, int v, char *str, int len);
  222. void     wdrawchar            (int h, int v, int c);
  223.  
  224. OSErr     sendOpenDocEvent    (long theAppSig, SFReply *theSFReply);
  225. Boolean getFileInfo            (char *fullPath, long *fType);
  226.  
  227. Boolean processStartUpEvent (char *buf);
  228.  
  229. void     wgetevent            (EVENT *ep);
  230. void     processMouseDown    (EventRecord *macEvent, EVENT *ep);
  231. void     wsettimer            (WINDOW *win, int deciseconds);
  232. #endif
  233.