home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / suntar1.cpt / windows.h < prev   
Encoding:
C/C++ Source or Header  |  1992-06-13  |  7.5 KB  |  244 lines

  1. /*********************************************************************
  2.  
  3.     miniedit.h
  4.     
  5.     header file for Miniedit
  6.     
  7.     Copyright (c) 1989 Symantec Corporation.  All rights reserved.
  8.     
  9. *********************************************************************/
  10.  
  11. #define ErrorAlert        256
  12.  
  13. /* resource IDs of menus */
  14. #define appleID            128
  15. #define fileID            129
  16. #define editID            130
  17.  
  18.  
  19. /* Edit menu command indices */
  20. #define undoCommand     1
  21. #define cutCommand        3
  22. #define copyCommand        4
  23. #define pasteCommand    5
  24. #define clearCommand    6
  25.  
  26. /* Menu indices */
  27. #define appleM            0
  28. #define fileM            1
  29. #define editM            2
  30.  
  31. #define SBarWidth    15
  32.  
  33. #ifndef NULL
  34. #define NULL 0L
  35. #endif
  36.  
  37.  
  38. /*------------------------------------------------------------------------------
  39. #
  40. #    Apple Macintosh Developer Technical Support
  41. #
  42. #    MultiFinder-Aware TextEdit Sample Application
  43. #
  44. #    TESample
  45. #
  46. #    TESample.h    -    Rez and C Include Source
  47. #
  48. #    Copyright ⌐ 1989 Apple Computer, Inc.
  49. #    All rights reserved.
  50. #
  51. ------------------------------------------------------------------------------*/
  52.  
  53. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  54.    by MultiFinder. Once we determine that an event is an OSEvent, we look at the
  55.    high byte of the message sent to determine which kind it is. To differentiate
  56.    suspend and resume events we check the resumeMask bit. */
  57. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  58. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  59. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  60. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  61. #define    kNoEvents                0        /* no events mask */
  62.  
  63.  
  64. /*******************************************************************************\
  65.  
  66. include file
  67.  
  68. suntar, ⌐1991 Sauro & Gabriele Speranza
  69.  
  70. This program is public domain, feel free to use it or part of it for anything
  71.  
  72. \*******************************************************************************/
  73.  
  74. #ifndef LF
  75. #define LF     '\012'    /*    '\n' in Think C, '\r' in MPW    */
  76. #define CR     '\015'    /*    '\r' in Think C, '\n' in MPW     */
  77. #endif
  78. #define enter_key    3
  79.  
  80. #define opClose        1
  81. #define opQuit        2
  82.  
  83. typedef struct windowdef{
  84.     WindowRecord    wRecord; /* Å importante sia al primo posto, secondo il solito
  85.                                 criterio di costruzioni di sottoclassi
  86.                                 -- it must be the first field, according to the usual 
  87.                                 object-oriented concept of inheriting a struct and 
  88.                                 adding new fields */
  89.     TEHandle        TEH;
  90.     ControlHandle     vScroll,hScroll;
  91.     short                linesInWindow;    /* il numero di linee nella finestra */
  92.     short                char_width;        /*larghezza in pixel dei caratteri: non Å essenziale sia il
  93.                                     vero valore, determina l'ampiezza dello scroll orizzontale 
  94.                                     -- need not be the true width in pixels, it's used to choose
  95.                                     the width of horizontal scroll*/
  96.     char            dirty;
  97.     char            used;
  98.     short                flags;
  99.     short                lastPrompt;        /* serve in modalitê console (per semplicitê,
  100.                                     readonly Å una console con lastPrompt=maxint)
  101.                                     -- for "readonly" windows: a readonly window is readonly 
  102.                                     till this point, read/write after that. You should set this
  103.                                     to a value different from 32767 only in console windows */
  104.     ProcPtr            itsClickLoop;
  105.     } window_def;
  106.  
  107. #define n_max_windows 2    /* per suntar, ne uso una sola .....
  108.                         -- suntar uses only one window, but the module was 
  109.                         debugged as a text editor having 5 windows, and for some
  110.                         debugging we've used suntar with two */
  111. #define n_max_foreign 8
  112. #define maxTElength 32760
  113. #define DelChar 8
  114. #define prefM    3
  115. #define prefID    131
  116. #define fontID    142
  117. #define sizeID    143
  118. #define styleID 144
  119.  
  120. #define pmAutowrap 1
  121. #define pmFont 2
  122. #define pmSize 3
  123. #define pmStyle 4
  124.  
  125.  
  126. #define vecchiaROM (ROM85==-1)        /* 64K ROMs... prehistoric things */
  127. /*#define vecchiaROM 1 /*debugging*/
  128.  
  129. extern window_def    my_windows[n_max_windows];
  130. extern int            n_currently_open;
  131. extern window_def    *curr_window;
  132. #define myWindow ((WindowPtr)curr_window)
  133. extern TEHandle        TEH;
  134.  
  135. #define hiword(x)        (((short *) &(x))[0])
  136. #define loword(x)        (((short *) &(x))[1])
  137. #define min(x,y)        ((x)<(y)?(x):(y))
  138. #define max(x,y)        ((x)>(y)?(x):(y))
  139.  
  140. #ifdef may_run_on_64K_ROM
  141. #define    MBARHEIGHT    (vecchiaROM ? 20:MBarHeight)
  142. #define SCR_BAR_AND_TEXT_IN_SYNC    \
  143.     if(!vecchiaROM)                            \
  144.         MaintainScrollBars(curr_window);    \
  145.     else                                    \
  146.         ShowSelect();
  147. #else
  148. #define    MBARHEIGHT MBarHeight
  149. #define SCR_BAR_AND_TEXT_IN_SYNC MaintainScrollBars(curr_window);
  150. #endif
  151.  
  152. #define screenHeight    (screenBits.bounds.bottom)
  153. #define screenWidth     (screenBits.bounds.right)
  154.  
  155. /* masks for flag bits: */
  156. #define HSCROLL 1    /* autowrap or horizontal scroll */
  157. #define    READONLY 2
  158. #define CONSOLE 4
  159.     /* the two bits READONLY and CONSOLE and the lastprompt field are used to 
  160.     identify the three states of a window: read-only (e.g. a console without a prompt),
  161.     fully read/write, console with a prompt currently on screen */
  162. #define NOCLOSEBOX 16
  163.  
  164. #define isDAwindow(window) ((window)!=NULL && ((WindowPeek)(window))->windowKind < 0)
  165. #define our(window) ((window)!=NULL && ((WindowPeek)(window))->windowKind >= userKind )
  166. #define ourTE(window) ((window)!=NULL && ((WindowPeek)(window))->windowKind == userKind && ((WindowPeek)(window))->refCon>=0)
  167. /* l'applicazione che si appoggia a questo modulo puÿ definirsi delle finestre,
  168. ma o le distrugge prima di richiamare MainEvent (tipico per dialoghi modali) o
  169. deve mettere windowkind > userKind o refCon < 0 
  170. -- the application which uses the routines in MainEvent.c and windows.c may 
  171. have its own windows, but in order to tell to MainEvent that it must not
  172. touch them they must have either windowKind!=userkind or refCon<0 */
  173. #define myIndex(window) ((int)(((window_def*)(window))->refCon))
  174.  
  175. #define AUTOSELECT /* usato solo per #ifdef */
  176.  
  177. typedef void (*upd_proc)();
  178.  
  179. extern void (*my_add_menus)();
  180. extern void (*my_handle_menus)(long);
  181. extern void (*my_event_filter)();
  182. extern int (*my_at_exit)();
  183. extern Boolean    gInBackground;
  184. extern Boolean sto_lavorando;
  185. extern Cursor editCursor,waitCursor;
  186. extern unsigned char window_title[];
  187. extern short default_flags;
  188.  
  189. extern unsigned char PNS[];    /* Pascal Null String: */
  190.     /* it's silly to have tenths of null strings, rather refer to the same string */
  191.  
  192.  
  193. #define SUNTAR
  194.  
  195. /* prototypes for MainEvent.c */
  196. void InitConsole(void);
  197. void install_handlers(WindowPtr,upd_proc,upd_proc);
  198. void remove_handlers(WindowPtr);
  199. void UpdateFilter (EventRecord *);
  200. void MainEvent(void);
  201. Boolean get_event(EventRecord*);
  202. void handle_event(EventRecord*);
  203. void DoKeyDown(unsigned char,short);
  204. void DoActivate(window_def*,short);
  205. void DoCommand(long);
  206. void DoFont(long);
  207. void MaintainCursor(Point);
  208. void MaintainMenus(void);
  209. void en_dis_edit(short,Boolean);
  210. int SilentSuppression(int);
  211. long pstrtoi(Str255);
  212.  
  213. /* prototypes for windows.c */
  214. void new_window(void);
  215. int get_window_index(void);
  216. void apply_preferences(window_def *);
  217. void MaintainScrollBars(window_def *);
  218. void UpdateWindow(WindowPtr);
  219. void DoContent(WindowPtr,EventRecord*);
  220. void MyGrowWindow(WindowPtr,Point);
  221. void myZoomWindow(WindowPtr,Point,int);
  222. void CloseMyWindow(void);
  223. void PositionDialog(Rect *);
  224. /* debug only: */
  225. void print_string(char*);
  226. void print_int(int);
  227. void print_number(char*,int);
  228.  
  229. /* prototypes for suntar's functions */
  230. int going_to_background(void);
  231. void unexpected_disk_insertion(long);
  232. void MaintainApplSpecificMenus(void);
  233.  
  234. /* prototypes for printf.c */
  235. void disable_autoflush(void);
  236. void enable_autoflush(void);
  237. void start_of_line(void);
  238. void one_empty_line(void);
  239. void prompt(char*,int);
  240. void printf(char*,...);
  241. void print_chars(char*,int);
  242. void put_char(char);
  243. void update_console(void);
  244.