/[MITgcm]/MITgcm/tools/mpack-1.6/macnapp.h
ViewVC logotype

Contents of /MITgcm/tools/mpack-1.6/macnapp.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Aug 26 20:45:25 2003 UTC (20 years, 7 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint58l_post, checkpoint64z, checkpoint51k_post, checkpoint57t_post, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint57o_post, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint52l_pre, checkpoint52e_pre, hrcube4, checkpoint58e_post, mitgcm_mapl_00, checkpoint52n_post, checkpoint52j_post, checkpoint53d_post, checkpoint58u_post, checkpoint58w_post, checkpoint54a_pre, checkpoint51o_pre, checkpoint57m_post, checkpoint55c_post, checkpoint54e_post, checkpoint52e_post, checkpoint57s_post, checkpoint51n_pre, checkpoint54a_post, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint53c_post, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint57k_post, checkpoint55d_pre, checkpoint57d_post, checkpoint51l_post, checkpoint57g_post, checkpoint51q_post, checkpoint64, checkpoint65, checkpoint60, checkpoint61, checkpoint62, checkpoint63, checkpoint57b_post, checkpoint57c_pre, checkpoint51j_post, checkpoint58r_post, checkpoint55j_post, checkpoint56b_post, checkpoint57i_post, checkpoint57y_post, hrcube_1, checkpoint57e_post, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, branch-netcdf, checkpoint52d_pre, checkpoint52l_post, checkpoint55h_post, checkpoint58n_post, checkpoint53b_post, checkpoint58x_post, checkpoint52k_post, checkpoint52b_pre, checkpoint57g_pre, checkpoint54b_post, checkpoint53b_pre, checkpoint55b_post, checkpoint58t_post, checkpoint58h_post, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint54d_post, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint56c_post, checkpoint52m_post, checkpoint57y_pre, checkpoint55, checkpoint53a_post, checkpoint57f_pre, checkpoint57a_post, checkpoint54, checkpoint58q_post, checkpoint54f_post, checkpoint57v_post, checkpoint59q, checkpoint59p, checkpoint55g_post, checkpoint59r, checkpoint51o_post, checkpoint51p_post, checkpoint58j_post, checkpoint52a_pre, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint55f_post, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint59j, checkpoint57r_post, checkpoint59, checkpoint58, checkpoint57a_pre, checkpoint55i_post, checkpoint57, checkpoint56, checkpoint51i_post, checkpoint53, checkpoint52, checkpoint51f_post, checkpoint52d_post, eckpoint57e_pre, checkpoint51r_post, checkpoint52a_post, checkpoint57h_done, checkpoint58f_post, checkpoint52b_post, checkpoint53g_post, checkpoint52f_post, branchpoint-genmake2, checkpoint57x_post, checkpoint57n_post, checkpoint52c_post, checkpoint58d_post, checkpoint58c_post, checkpoint57w_post, checkpoint57p_post, checkpint57u_post, checkpoint57f_post, checkpoint58a_post, checkpoint51h_pre, checkpoint51l_pre, checkpoint58i_post, checkpoint57q_post, checkpoint51g_post, checkpoint58g_post, ecco_c52_e35, hrcube5, checkpoint58o_post, checkpoint57z_post, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint57c_post, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint58y_post, checkpoint55e_post, checkpoint58k_post, checkpoint52i_post, checkpoint52j_pre, checkpoint58v_post, checkpoint53f_post, checkpoint55a_post, checkpoint51t_post, checkpoint53d_pre, checkpoint54c_post, checkpoint58s_post, checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint58p_post, checkpoint61a, checkpoint61n, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint51n_post, checkpoint57j_post, checkpoint61z, checkpoint61x, checkpoint61y, checkpoint58b_post, checkpoint57h_pre, checkpoint51i_pre, checkpoint58m_post, checkpoint57l_post, checkpoint52i_pre, checkpoint51u_post, checkpoint52h_pre, checkpoint52f_pre, checkpoint57h_post, hrcube_2, hrcube_3, checkpoint56a_post, checkpoint51m_post, checkpoint51s_post, checkpoint55d_post, HEAD
Branch point for: branch-nonh, branch-genmake2, tg2-branch, checkpoint51n_branch, netcdf-sm0
File MIME type: text/plain
Initial check-in of the CMU "mpack" utility.  This allows us to (portably)
send MITgcm output as MIME-encoded email messages and will be used by the
"testreport" script.  The CMU license is basically an "AS-IS" statement.

1 /* macnapp.h -- general mac application library header
2 */
3 /* (C) Copyright 1995 by Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify, distribute, and sell this software
7 * and its documentation for any purpose is hereby granted without
8 * fee, provided that the above copyright notice appear in all copies
9 * and that both that copyright notice and this permission notice
10 * appear in supporting documentation, and that the name of Carnegie
11 * Mellon University not be used in advertising or publicity
12 * pertaining to distribution of the software without specific,
13 * written prior permission. Carnegie Mellon University makes no
14 * representations about the suitability of this software for any
15 * purpose. It is provided "as is" without express or implied
16 * warranty.
17 *
18 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
19 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
20 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
21 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
23 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
24 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
25 * SOFTWARE.
26 */
27 /* (C) Copyright 1990-1995 by Christopher J. Newman
28 * All Rights Reserved.
29 *
30 * Permission to use, copy, modify, and distribute this software and its
31 * documentation for any purpose is hereby granted without fee, provided that
32 * the above copyright notice appear in all copies and that both that
33 * copyright notice and this permission notice appear in supporting
34 * documentation, and that the name of Christopher J. Newman not be used in
35 * advertising or publicity pertaining to distribution of the software without
36 * specific, written prior permission. Christopher J. Newman makes no
37 * representations about the suitability of this software for any purpose. It
38 * is provided "as is" without express or implied warranty.
39 *
40 * CHRISTOPHER J. NEWMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
41 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
42 * SHALL CHRISTOPHER J. NEWMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
43 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
44 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
45 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
46 * OF THIS SOFTWARE.
47 *
48 * Author: Chris Newman
49 * Message: This is a nifty program.
50 */
51
52 #ifdef THINK_C
53 #define QD(x) (x)
54 #ifndef NULL
55 #define NULL 0
56 #endif
57 #else
58 #define QD(x) (qd.x)
59 #include <MacTypes.h>
60 #include <Quickdraw.h>
61 #include <Events.h>
62 #include <Controls.h>
63 #include <Windows.h>
64 #include <MemoryMgr.h>
65 #include <Menus.h>
66 #include <OSUtils.h>
67 #include <TextEdit.h>
68 #include <Dialogs.h>
69 #endif
70
71 /* dual pascal/C strings
72 */
73 typedef unsigned char PCstr;
74 #define C(str) ((char*)(str) + 1)
75 #define P(str) ((unsigned char*)(str))
76
77 /* various machine types.
78 */
79 typedef unsigned short WORD;
80 typedef unsigned char BYTE;
81
82 /* useful macros:
83 */
84 #define HIWORD(x) ( (WORD) ( (x) >> 16) )
85 #define LOWORD(x) ( (WORD) (x) )
86
87 /* most window/menu procedures return short integers (see defines below)
88 */
89 typedef short (*na_menup)(struct na_win *, WORD, WORD);
90 typedef short (*na_mousep)(struct na_win *, Point, short, short);
91 typedef short (*na_ctrlp)(struct na_win *, Point, short, short, ControlHandle);
92 typedef short (*na_activep)(struct na_win *, Boolean);
93 typedef short (*na_closep)(struct na_win *);
94 typedef void (*na_afterp)(struct na_win *);
95 typedef short (*na_updatep)(struct na_win *, Boolean);
96 typedef short (*na_keyp)(struct na_win *, long, short);
97 typedef short (*na_cursorp)(struct na_win *, Point);
98 typedef short (*na_miscp)(struct na_win *, EventRecord *);
99 typedef short (*na_idlep)(struct na_win *);
100 typedef short (*na_taskp)(struct na_win *);
101 typedef short (*na_resizep)(struct na_win *, Point, Rect *);
102 typedef short (*na_openp)(short, FSSpec *, FInfo *);
103 typedef short (*na_initp)(struct na_win *, long *);
104 typedef struct na_win {
105 long flags; /* flags indicating various window settings (see below) */
106 short delay; /* delay between main loop cycles (in ticks) */
107 short mousepix; /* number of pixels mouse can move until drag starts */
108 short minw, minh; /* minimum width and height for the window */
109 short maxw, maxh; /* maximum width and height for the window */
110 short type; /* current window type (negatives reserved) */
111 BYTE locks; /* locks on this window structure */
112 short priority; /* priority if there is a taskp (-1 = everytime) */
113 RgnHandle cursorRgn; /* cursor region */
114 RgnHandle uncrsrRgn; /* region cursor isn't in */
115 WindowPtr pwin; /* window pointer */
116 struct na_win **next; /* handle to next window in linked list */
117 struct na_win **task; /* handle to next task in a linked list of active tasks */
118 struct na_win **child; /* handle to child window list (NULL = no child) */
119 struct na_win **parent; /* handle to parent window (NULL = toplevel) */
120 na_menup menup; /* menu proc */
121 na_mousep mousep; /* mouse proc */
122 na_ctrlp ctrlp; /* dialog item/control proc */
123 na_activep activep; /* activate proc */
124 na_closep closep; /* close proc */
125 na_afterp afterp; /* after proc */
126 na_updatep updatep; /* update proc */
127 na_keyp keyp; /* key proc */
128 na_cursorp cursorp; /* cursor setting proc */
129 na_miscp miscp; /* miscellaneous event proc (disk/net/app/driver) */
130 na_idlep idlep; /* idle proc */
131 na_taskp taskp; /* task proc */
132 na_resizep resizep; /* resize proc */
133 long resid; /* storage for window resource id or user data. */
134 char *data; /* data pointer for user */
135 } na_win;
136 typedef struct nate_win {
137 na_win winp;
138 TEHandle hTE; /* textedit handle for auto-textedit routines */
139 ControlHandle hctrl; /* horizontal scroll bar for textedit */
140 ControlHandle vctrl; /* vertical scroll bar for textedit */
141 long docwidth; /* width of the document */
142 short lheight; /* line height of text */
143 short topoff; /* offset from top of window to textedit area */
144 } nate_win;
145 /* procedures types:
146 *
147 * // called for menu events when window is frontmost
148 * // supercedes global menu function unless NA_NOTPROCESSED is returned.
149 * // if menuid is 0, the procedure should enable/disable menus appropriately
150 * // if menuid is 1, the procedure should disable enabled menus appropriately
151 * short menu(winp, menuid, itemno)
152 * WORD menuid; // resource id of the menu
153 * WORD itemno; // item number of the menu item
154 *
155 * // called for mouse down/up/move events in the window
156 * short mouse(winp, p, type, mods)
157 * Point p; // location of mouse action
158 * short type; // type of mouse action (see below)
159 * short mods; // modifier keys
160 *
161 * // called for dialog events in dialog windows
162 * // control events in windows with controls
163 * // In a dialog window with no key procedure, ESC, command-., return, enter are
164 * // mapped to iCancel and iOk.
165 * short control(winp, p, itemHit, mods, ctrlh)
166 * Point p; // point in window local coords
167 * short itemHit; // the item/part code clicked
168 * short mods; // modifier keys
169 * ControlHandle ctrlh; // handle to the control
170 *
171 * // called when window is activated or deactivated
172 * // close return values may be ignored on a deactivate
173 * short activate(winp, on)
174 * Boolean on; // true = activate, false = deactivate
175 *
176 * // called when a window close request has been made (close box/close menu item)
177 * // called when any window function returns NA_REQCLOSE or NA_REQCLOSEALL
178 * // respond with either NA_CLOSED or NA_NOTPROCESSED
179 * short close(winp)
180 *
181 * // called after window closed & removed from lists, but before window object freed
182 * void afterp(winp)
183 *
184 * // called on update events
185 * short update(winp, newsize)
186 * Boolean newsize; // true if r is a new window size
187 *
188 * // called on key/autokey events (menu keys are parsed out first)
189 * short key(winp, c, mods)
190 * long c; // ASCII value of the key (unless NA_RAWKEY option set)
191 * short mods; // modifier keys
192 *
193 * // called when cursor moves into or out of a window
194 * // use winp->flags & NA_CURSORON
195 * // close request return values are ignored.
196 * // return NA_PROCESSED only when the cursorRgn is changed
197 * short cursor(winp, p)
198 * Point p; // point where the cursor is
199 *
200 * // This is called for miscellaneous events (disk/network/driver/app1-3)
201 * short miscp(winp, pevent)
202 * EventRecord *pevent; // the event
203 *
204 * // called every time through the event loop when window active
205 * short idle(winp)
206 *
207 * // called cyclicly with other tasks with each pass through event loop
208 * // only used when task is installed
209 * // the task procedure can only close it's own window.
210 * short task(winp)
211 *
212 * // function called to resize the window
213 * // (parameters similar to GrowWindow function)
214 * short resize(winp, where, rct)
215 * Point where;
216 * Rect *rct;
217 *
218 * // function passed to NAinit:
219 * // should return 0 if OK, and -1 to stop opening files
220 * short open(message, afile, fspec)
221 * short message; // either appOpen or appPrint (in SegLoad.h)
222 * FSSpec *fspec; // file to open/print
223 * Finfo *finfo; // finder info
224 *
225 * // function passed to NAwindow:
226 * // returns standard window status
227 * short init(winp, datap)
228 * na_win *winp; // pointer to new window structure
229 * long *datap; // pointer to data passed through NAwindow
230 */
231
232 /* niftyapp globals */
233 extern na_win **NAhead; /* handle to the head of the window tree */
234 extern na_win **NAtask; /* handle to the head of the window task list */
235 extern na_win **NActask; /* handle to the current task */
236 extern na_win *NAwin; /* pointer to current window (NULL = no current window) */
237 extern na_menup NAmenup; /* pointer to default menu procedure */
238 extern MenuHandle **NAmenus; /* list of menu handles */
239 extern short NAnewitem; /* item number of the new item on the file menu (0 = not avail) */
240 extern short NAcloseitem; /* item number of the close item on the file menu (0 = not avail) */
241 extern short NAappleitems; /* the number of (user) items at the top of the apple menu */
242 extern short NAhelpitems; /* the number of (user) help items */
243 extern short NAhelpcount; /* the number of (system) items at the top of the help menu */
244 extern Boolean NAhasedit; /* true if application has an edit menu */
245 extern long NAdelay; /* the wait next event delay */
246 extern SysEnvRec NAsysenv; /* mac system environment */
247 extern Boolean NAinBack; /* true if application is backgrounded */
248 extern long NAmousetime; /* time of last mouse up event */
249 extern short NAlastmouse; /* kind of last mouse event */
250 extern Cursor NAibeam; /* the ibeam cursor */
251 extern long NAgestaltBits; /* 0 = gestalt not on system */
252
253 /* globals for your convenience */
254 extern RgnHandle NAfullRgn, NAnullRgn;
255
256 /* niftyapp definitions */
257
258 /* default resource id for niftyapp windows */
259 #define NA_CLIPWINDOW 1000
260 #define NA_ABOUTDLOG 1000
261 #define NA_PREFSDLOG 1001
262 #define NA_HELPSTR 1000
263 /* default item numbers for OK & cancel */
264 #define iOk 1
265 #define iCancel 2
266 /* default ids for APPLE, FILE, EDIT, and HELP menus */
267 #define mApple 128
268 #define mFile 129
269 #define mEdit 130
270 #define mHelp ((WORD)-16490)
271 /* default item numbers for about & edit menu */
272 #define iAbout 1
273 #define iUndo 1
274 #define iCut 3
275 #define iCopy 4
276 #define iPaste 5
277 #define iClear 6
278 #define iSelAll 7
279 #define iClipboard 9
280 /* new window positions */
281 #define NA_HFULLSCN 0x0000
282 #define NA_HQUARTERSCN 0x0001
283 #define NA_HHALFSCN 0x0002
284 #define NA_H3QUARTERSCN 0x0003
285 #define NA_VFULLSCN 0x0000
286 #define NA_VQUARTERSCN 0x0004
287 #define NA_VHALFSCN 0x0008
288 #define NA_V3QUARTERSCN 0x000C
289 #define NA_CENTERSCN 0x0000
290 #define NA_TOPSCN 0x0010
291 #define NA_BOTTOMSCN 0x0020
292 #define NA_LEFTSCN 0x0040
293 #define NA_RIGHTSCN 0x0080
294 #define NA_TITLEOFFSET 0x0100
295 /* new window flags */
296 #define NA_PLAINWIN 0x00000000L /* plain window -- no title, simple border */
297 #define NA_COLORWINDOW 0x00000001L /* allow color in the window */
298 #define NA_DIALOGWINDOW 0x00000002L /* open as a dialog */
299 #define NA_TITLEBAR 0x00000004L /* have title bar */
300 #define NA_GROWBOX 0x00000008L /* have a grow box (enables automatic drawing) */
301 #define NA_ZOOMBOX 0x00000010L /* have a zoom box */
302 #define NA_CLOSEBOX 0x00000020L /* have a close box (enables close menu item) */
303 #define NA_SHADOWBORDER 0x00000040L /* have a shadow border (for dialogs) */
304 #define NA_DOUBLEBORDER 0x00000080L /* have a double (dialog) border */
305 #define NA_ROUNDBORDER 0x000000c0L /* have rounded corners and black title bar */
306 #define NA_CHILDWINDOW 0x00000100L /* open as a child window of current window */
307 #define NA_NOTVISIBLE 0x00000200L /* do not make window visible on open */
308 #define NA_BEHIND 0x00000400L /* open window behind current window */
309 #define NA_HASCONTROLS 0x00000800L /* process/draw/kill controls automatically */
310 #define NA_HASTASK 0x00001000L /* install window in background task list */
311 #define NA_USERESOURCE 0x00002000L /* use res parameter as WIND/DLOG/wctb/dctb resource */
312 #define NA_CURSORON 0x00004000L /* true if application has set the cursor */
313 #define NA_MODAL 0x00008000L /* set if window/dialog will be modal */
314 #define NA_DEFBUTTON 0x00010000L /* show default button after init proc */
315 #define NA_COPYDATA 0x00020000L /* data will by copied by NAwindow */
316 #define NA_SMARTSIZE 0x00040000L /* window resizes & placements are saved in WIND res */
317 #define NA_FORCESIZE 0x00080000L /* when a resource is used, re-size the window anyway */
318 #define NA_RAWKEY 0x00100000L /* if set, key event fields aren't stripped */
319 #define NA_HILITECTRLS 0x00200000L /* if set, hilite controls on activate/deactive */
320 #define NATE_FLAGS 0x0f000000L /* flags reserved for NATE */
321 #define NA_USER_FLAG1 0x10000000L /* flags reserved for users */
322 #define NA_USER_FLAG2 0x20000000L
323 #define NA_USER_FLAG3 0x40000000L
324 #define NA_USER_FLAG4 0x80000000L
325 /* niftyapp window/task types */
326 #define NA_CLIPTYPE -1
327 #define NA_DEBUGTYPE -2
328 #define NA_TCPTYPE -3
329 #define NA_SMTPTYPE -4
330 /* mouse click types */
331 #define NA_DOWN1 0
332 #define NA_UP1 1
333 #define NA_DOWN2 2
334 #define NA_UP2 3
335 #define NA_DOWNN 4
336 #define NA_UPN 5
337 #define NA_DRAG 6
338 #define NA_RELEASE 7
339 /* return values for window/menu procedures */
340 #define NA_ALLCLOSED -4 /* all windows are to be destroyed & exit app immediately */
341 #define NA_REQCLOSEALL -3 /* request to close all windows & exit app */
342 #define NA_CLOSED -2 /* current window is ready to close (used by closep/taskp) */
343 #define NA_REQCLOSE -1 /* request to close current window */
344 #define NA_NOTPROCESSED 0 /* use any default handler available */
345 #define NA_PROCESSED 1 /* do nothing more */
346 #define NA_USERINTERACT 2 /* user interaction pending -- don't do tasks */
347 /* Gestalt bits */
348 #define NA_HASAEVENTS 0x00000001L /* Apple events supported */
349 #define NA_HASFSSPEC 0x00000002L /* FSSpec calls supported */
350 #define NA_HASSTDFILE 0x00000004L /* New standard file available */
351
352 /* niftyapp basic macros */
353
354 #define NAunlockWindow(winp) {if (!--(winp)->locks) HUnlock((Handle) GetWRefCon((winp)->pwin));}
355 #define NAunlockWindowh(winh, winp) {if (!--(winp)->locks) HUnlock((Handle) winh);}
356 #define NAisDAWindow(pWnd) (( (WindowPeek) pWnd)->windowKind < 0)
357 #define NAmenuh(menu) ((*NAmenus)[(menu) - mApple])
358 #define NAenableMItem(menu, item) EnableItem(NAmenuh(menu), item)
359 #define NAdisableMItem(menu, item) DisableItem(NAmenuh(menu), item)
360 #define NAcheckItem(menu, item, c) CheckItem(NAmenuh(menu), item, c)
361 #define NAgetDHandle(dlg, it, hn) {short ty; Rect r; GetDItem(dlg, it, &ty, (Handle *) (hn), &r);}
362 #define NAgetDRect(dlg, it, rct) {short ty; Handle hn; GetDItem(dlg, it, &ty, &hn, (rct));}
363 #define NAsetIval(dlg, it, val) {short ty; Rect r; Handle hn; GetDItem(dlg, it, &ty, &hn, &r); SetCtlValue((ControlHandle)hn, (val));}
364 #define NAsetInum(dlg, it, val) NAsetIText(dlg, it, longtoPCstr(val))
365 #define NAalert(resid) Alert(resid, NAfilterProc)
366
367 /* niftyapp basic procedures */
368
369 /* initialize the Macintosh managers and niftyapp internal variables.
370 * optionally set up a menu bar & menu procedure.
371 * Returns 0 if OK, negative if an error occured, 1 if print files requested & app should quit
372 * short minK; // minimum K needed to execute
373 * short masters; // number of times to call MoreMasters()
374 * na_proc *openp; // open file procedure -- called for each application in the startup list
375 * na_proc *menup; // pointer to a menu procedure (NULL = no menu handling)
376 * short nummenu; // number of menus (starting at mApple == 128)
377 * short numapple; // number of apple menu items
378 * short newitem; // item number of new item (mFile)
379 * short closeitem; // item number of close item (mFile)
380 */
381 short NAinit(short, short, na_openp, na_menup, short, short, short, short);
382
383 /* call the main loop procedure
384 */
385 void NAmainloop(void);
386
387 /* create a rectangle based on the screen size
388 * short position; // see above
389 */
390 Rect *NAscreenrect(short);
391
392 /* create a new window structure
393 * returns window status result, up to the caller to pass on NA_ALLCLOSED
394 * Rect *rpos; // placement rectangle
395 * long flags; // flags determining type of window
396 * char *title; // window title (C string may not be NULL unless NA_USERESOURCE)
397 * short res; // resource number of WIND/DLOG/wctb/dctb/DITL
398 * long *initdata; // window data (may be NULL)
399 * long datasize; // bytes of window data
400 * na_proc *initp; // procedure to initialize the window functions, etc.
401 */
402 short NAwindow(Rect *, long, char *, short, long *, long, na_initp);
403
404 /* create & add a new task to the task list, given pointer to task procedure,
405 * and data size
406 */
407 na_win **NAaddtask(na_taskp, long);
408
409 /* standard init procedure for an about box -- stops all background tasks, however */
410 short NAabout(na_win*, long*);
411
412 /* standard button flash procedure used by shell for keypresses */
413 void NAflashButton(DialogPtr, short);
414
415 /* draw the default button */
416 void NAdefaultButton(DialogPtr);
417
418 /* filter proc for modal dialogs which handles ESC and command-. */
419 pascal Boolean NAfilterProc(DialogPtr, EventRecord *, short *);
420
421 /* re-calculate cursor region information (after changing winp->cursorRgn) */
422 void NAcalcCursor(na_win*);
423
424 /* this saves a window's dimensions into a 'WIND' resource with appropriate resid */
425 void NAsaveWin(na_win*);
426
427 /* This is available to access window structures other than the current window
428 * best for looking at parent window or child window(s).
429 */
430 na_win *NAlockWindow(na_win**);
431
432 /* This is available, but the user should only call it is severe cases */
433 short NAcloseWindow(na_win*, short);
434
435 /* this is for closing all windows, the user should only call it from main
436 * usually NAhead is the first parameter.
437 */
438 short NAcloseWindows(na_win**, short);
439
440 /* this is for sending an event directly to the misc procedure of all windows.
441 * usually NAhead is the first parameter.
442 */
443 short NAallWindows(na_win**, EventRecord*);
444
445
446 /* niftyapp clipboard library:
447 * NAclipboard: true = window on, false = window off, 'TEXT' or 'PICT'
448 */
449 void NAclipboard(Boolean, ResType);
450
451
452 /* niftyapp debug library:
453 */
454 void NAdebug(char *, ...);
455 #ifdef DEBUG
456 #define NADEBUG(x) NAdebug x
457 #else
458 #define NADEBUG(x)
459 #endif
460
461
462 /* niftyapp dialog library:
463 */
464 /* select a radio button
465 * returns number from 0 to firstitem - lastitem: the button that's been pressed
466 * DialogPtr dialog; // the dialog window
467 * short firstitem; // the itemno of first radio button
468 * short lastitem; // the itemno of last radio button
469 * short setting; // the radio button to set (itemno to lastitem)
470 */
471 short NAradioSet(DialogPtr, short, short, short);
472
473 /* get the itemno of the active radio button
474 * DialogPtr dialog; // the dialog window
475 * short firstitem; // the itemno of first radio button
476 * short lastitem; // the itemno of last radio button
477 */
478 short NAradioGet(DialogPtr, short, short);
479
480 /* enable/disable,hilite,show/hide an item in a dialog window */
481 void NAenableDItem(DialogPtr, short, Boolean);
482 void NAhiliteDItem(DialogPtr, short, short);
483 void NAvisibleDItem(DialogPtr, short, Boolean);
484
485 /* set/get the item text in a dialog item */
486 void NAsetIText(DialogPtr, short, PCstr*);
487 void NAgetIText(DialogPtr, short, PCstr*);
488
489 /* enable/disable modal menus for a moveable modal dialog box (1 = go modal) */
490 void NAmodalMenus(int);
491
492 /* handle edit menu for dialogs */
493 short NAdialogMenu(na_win *, WORD, WORD);
494
495
496 /* NATE (NiftyApp TextEdit) libraries
497 */
498 #define NATEflags (NA_TITLEBAR | NA_GROWBOX | NA_ZOOMBOX | NA_CLOSEBOX \
499 | NA_HASCONTROLS | NA_HILITECTRLS)
500 #define NATE_DEFAULT 0x00000000L
501 #define NATE_READONLY 0x01000000L
502 #define NATE_NOMOUSE 0x02000000L
503 #define NATE_NOHSCROLL 0x04000000L
504 #define NATE_NOVSCROLL 0x08000000L
505 void NATEinit(na_win*, long, short, Ptr, long); /* winp, flags, horizwidth, data, len */
506 short NATEinitp(na_win*, long*);
507 short NATEmousep(na_win*, Point, short, short);
508 short NATEidlep(na_win*);
509 short NATEactivep(na_win*, Boolean);
510 short NATEkeyp(na_win*, long, short);
511 short NATEmenup(na_win*, WORD, WORD);
512 short NATEupdatep(na_win*, Boolean);
513 short NATEctrlp(na_win*, Point, short, short, ControlHandle);
514 short NATEclosep(na_win*);
515
516 void NATEsetscroll(na_win*, Boolean, Rect*, Rect*);
517 void NATEappend(na_win*, char*, long);
518
519
520 /* Niftyapp file library
521 */
522 /* get a file to open -- similar to StandardGetFile, but works on older systems
523 * extra fields in "StandardFileReply" are only valid if NA_HASSTDFILE is set in
524 * NAgestaltBits
525 */
526 void NAgetFile(FileFilterProcPtr, short, SFTypeList, StandardFileReply *);
527 /* put a file to open -- similar to StandardPutFile, but works on older systems
528 * extra fields in "StandardFileReply" are only valid if NA_HASSTDFILE is set in
529 * NAgestaltBits
530 */
531 void NAputFile(Str255, Str255, StandardFileReply *);
532
533
534 /* Niftyapp TCP library
535 */
536 /* tcp stream descriptor */
537 typedef int na_tcp;
538 /* tcp init function
539 * passed NATCP_connect for success, NATCP_nodriver/NATCP_nomem for failure
540 * passed 1 to 100 for progress waiting for MacTCP to finish cleanly
541 */
542 typedef void na_tcpinitp(short);
543 /* TCP read/status callback for connection, or TCP window
544 * void *user; Context generic pointer (passed to NATCPopen)
545 * na_tcp s; TCP stream id
546 * short status; TCP status (see below)
547 * long size; size of buffer (or Macintosh error)
548 * char *data; data or NULL
549 */
550 typedef void na_tcpreadp(void *, na_tcp, short, long, char *);
551 typedef void na_readp(na_win *, short, long, char *);
552 /* TCP window */
553 typedef struct natcp_win {
554 na_win winp;
555 na_tcp s;
556 na_readp *readp;
557 } natcp_win;
558 /* status values/bits */
559 #define NATCP_closing 0x08 /* other end of connection closed */
560 #define NATCP_urgent 0x04 /* in urgent mode */
561 #define NATCP_more 0x02 /* more data will follow immediately */
562 #define NATCP_data 0x01 /* data to read */
563 #define NATCP_connect 0x00 /* connection ready */
564 #define NATCP_noread -1 /* non-fatal */
565 #define NATCP_nowrite -2 /* fatal... */
566 #define NATCP_nodriver -3
567 #define NATCP_notcpbuf -4
568 #define NATCP_nomem -5
569 #define NATCP_nohost -6
570 #define NATCP_nocon -7
571 #define NATCP_closed -8 /* connection fully closed */
572 /* open flags */
573 #define NATCP_server 0x01 /* be a server */
574 /* functions */
575 void NATCPinit(na_tcpinitp *);
576 /* NATCPsettings: TCP buffer size, type of service, precedence, write buffer size */
577 void NATCPsettings(long, short, short, unsigned short);
578 short NATCPtask(na_win *);
579 /* NATCPopen: callback, context, host, port, flags */
580 na_tcp NATCPopen(na_tcpreadp *, void *, char *, long, short);
581 na_tcp NATCPwinopen(natcp_win *, char *, long, short); /* tcp window, host, port, flags */
582 short NATCPwrite(na_tcp, Ptr, long, short); /* tcp, buffer, length, dispose */
583 short NATCPputchar(na_tcp, char);
584 void NATCPclose(na_tcp);
585 void NATCPdone(long); /* number of 1/60 sec intervals to wait for MacTCP to finish cleanly */
586 /* returns passes NATCP_connect to readp on success with hostname as argument */
587 void NATCPgethost(na_tcpreadp *, void *);
588
589
590 /* niftyapp SMTP library
591 */
592 /* status:
593 * void *context; user context
594 * short code; see below
595 * short err; SMTP error code or NATCP error code (NASMTP_tcpfail) or 0
596 * long num; macintosh TCP error code or address number or 0
597 * char *errstr; SMTP error string or NULL
598 */
599 typedef void (*na_smtpstat)(void *, short, short, long, char *);
600 #define NASMTP_progress 2 /* progress: err = % done */
601 #define NASMTP_badaddr 1 /* address was not valid */
602 #define NASMTP_completed 0 /* success */
603 #define NASMTP_nomem -1 /* not enough memory */
604 #define NASMTP_badargs -2 /* input arguments invalid */
605 #define NASMTP_oserr -3 /* OS failure (e.g. file error) */
606 #define NASMTP_tcpfail -4 /* TCP connection to SMTP server failed */
607 #define NASMTP_conclosed -5 /* connection closed by other side before completion */
608 #define NASMTP_badprot -6 /* other end sent unrecognizable protocol */
609 #define NASMTP_temperr -7 /* SMTP persistant temporary failure */
610 #define NASMTP_permerr -8 /* SMTP permanent failure */
611 /* Submit email: statf, server, fspec, headers, envelope, flags, context */
612 void NASMTPsubmit(na_smtpstat, char *, FSSpec *, Handle, Handle, short, void *);
613 #define NASMTP_crtrans 0x01 /* flag indicating translation of CR -> CRLF desired */
614
615 /* PC, C string libraries:
616 */
617 #define SetClen(pcstr) (*((pcstr) + *(pcstr) + 1) = '\0')
618 #define PCstrlen(pcstr) (*(pcstr))
619 #define Pstrlen(pstr) (* (unsigned char *) (pstr))
620
621 void PtoPCstrcpy(PCstr*, char*);
622 void CtoPCstrcpy(PCstr*, char*);
623 void PCtoPCstrcpy(PCstr*, PCstr*);
624 void PtoPCstrncpy(PCstr*, char*, short);
625 void CtoPCstrncpy(PCstr*, char*, short);
626 void PtoPCstrcat(PCstr*, char*);
627 void CtoPCstrcat(PCstr*, char*);
628 PCstr *PtoPCstr(char*);
629 PCstr *CtoPCstr(char*);
630 void SetPlen(PCstr*);
631 PCstr *longtoPCstr(long);

  ViewVC Help
Powered by ViewVC 1.1.22