Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:44:53 UTC

view on githubraw file Latest commit ec6cf3b0 on 2003-08-26 20:45:25 UTC
ec6cf3b09d Ed H*0001 /* macnapp.h -- general mac application library header
                0002  */
                0003 /* (C) Copyright 1995 by Carnegie Mellon University
                0004  * All Rights Reserved.
                0005  *
                0006  * Permission to use, copy, modify, distribute, and sell this software
                0007  * and its documentation for any purpose is hereby granted without
                0008  * fee, provided that the above copyright notice appear in all copies
                0009  * and that both that copyright notice and this permission notice
                0010  * appear in supporting documentation, and that the name of Carnegie
                0011  * Mellon University not be used in advertising or publicity
                0012  * pertaining to distribution of the software without specific,
                0013  * written prior permission.  Carnegie Mellon University makes no
                0014  * representations about the suitability of this software for any
                0015  * purpose.  It is provided "as is" without express or implied
                0016  * warranty.
                0017  *
                0018  * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
                0019  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
                0020  * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
                0021  * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                0022  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
                0023  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
                0024  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
                0025  * SOFTWARE.
                0026  */
                0027 /* (C) Copyright 1990-1995 by Christopher J. Newman
                0028  * All Rights Reserved.
                0029  *
                0030  * Permission to use, copy, modify, and distribute this software and its
                0031  * documentation for any purpose is hereby granted without fee, provided that
                0032  * the above copyright notice appear in all copies and that both that
                0033  * copyright notice and this permission notice appear in supporting
                0034  * documentation, and that the name of Christopher J. Newman not be used in
                0035  * advertising or publicity pertaining to distribution of the software without
                0036  * specific, written prior permission.  Christopher J. Newman makes no
                0037  * representations about the suitability of this software for any purpose.  It
                0038  * is provided "as is" without express or implied warranty.
                0039  *
                0040  * CHRISTOPHER J. NEWMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
                0041  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
                0042  * SHALL CHRISTOPHER J. NEWMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
                0043  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
                0044  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
                0045  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
                0046  * OF THIS SOFTWARE.
                0047  *
                0048  * Author:      Chris Newman
                0049  * Message:     This is a nifty program.
                0050  */
                0051 
                0052 #ifdef THINK_C
                0053 #define QD(x)   (x)
                0054 #ifndef NULL
                0055 #define NULL    0
                0056 #endif
                0057 #else
                0058 #define QD(x)   (qd.x)
                0059 #include <MacTypes.h>
                0060 #include <Quickdraw.h>
                0061 #include <Events.h>
                0062 #include <Controls.h>
                0063 #include <Windows.h>
                0064 #include <MemoryMgr.h>
                0065 #include <Menus.h>
                0066 #include <OSUtils.h>
                0067 #include <TextEdit.h>
                0068 #include <Dialogs.h>
                0069 #endif
                0070 
                0071 /* dual pascal/C strings
                0072  */
                0073 typedef unsigned char PCstr;
                0074 #define C(str)  ((char*)(str) + 1)
                0075 #define P(str)  ((unsigned char*)(str))
                0076 
                0077 /* various machine types.
                0078  */
                0079 typedef unsigned short WORD;
                0080 typedef unsigned char BYTE;
                0081 
                0082 /* useful macros:
                0083  */
                0084 #define HIWORD(x)       ( (WORD) ( (x) >> 16) )
                0085 #define LOWORD(x)       ( (WORD) (x) )
                0086 
                0087 /* most window/menu procedures return short integers (see defines below)
                0088  */
                0089 typedef short (*na_menup)(struct na_win *, WORD, WORD);
                0090 typedef short (*na_mousep)(struct na_win *, Point, short, short);
                0091 typedef short (*na_ctrlp)(struct na_win *, Point, short, short, ControlHandle);
                0092 typedef short (*na_activep)(struct na_win *, Boolean);
                0093 typedef short (*na_closep)(struct na_win *);
                0094 typedef void (*na_afterp)(struct na_win *);
                0095 typedef short (*na_updatep)(struct na_win *, Boolean);
                0096 typedef short (*na_keyp)(struct na_win *, long, short);
                0097 typedef short (*na_cursorp)(struct na_win *, Point);
                0098 typedef short (*na_miscp)(struct na_win *, EventRecord *);
                0099 typedef short (*na_idlep)(struct na_win *);
                0100 typedef short (*na_taskp)(struct na_win *);
                0101 typedef short (*na_resizep)(struct na_win *, Point, Rect *);
                0102 typedef short (*na_openp)(short, FSSpec *, FInfo *);
                0103 typedef short (*na_initp)(struct na_win *, long *);
                0104 typedef struct na_win {
                0105         long                    flags;          /* flags indicating various window settings (see below) */
                0106         short                   delay;          /* delay between main loop cycles (in ticks) */
                0107         short                   mousepix;       /* number of pixels mouse can move until drag starts */
                0108         short                   minw, minh;     /* minimum width and height for the window */
                0109         short                   maxw, maxh;     /* maximum width and height for the window */
                0110         short                   type;           /* current window type (negatives reserved) */
                0111         BYTE                    locks;          /* locks on this window structure */
                0112         short                   priority;       /* priority if there is a taskp (-1 = everytime) */
                0113         RgnHandle               cursorRgn;      /* cursor region */
                0114         RgnHandle               uncrsrRgn;      /* region cursor isn't in */
                0115         WindowPtr               pwin;           /* window pointer */
                0116         struct na_win   **next;         /* handle to next window in linked list */
                0117         struct na_win   **task;         /* handle to next task in a linked list of active tasks */
                0118         struct na_win   **child;        /* handle to child window list (NULL = no child) */
                0119         struct na_win   **parent;       /* handle to parent window (NULL = toplevel) */
                0120         na_menup                menup;          /* menu proc */
                0121         na_mousep               mousep;         /* mouse proc */
                0122         na_ctrlp                ctrlp;          /* dialog item/control proc */
                0123         na_activep              activep;        /* activate proc */
                0124         na_closep               closep;         /* close proc */
                0125         na_afterp               afterp;         /* after proc */
                0126         na_updatep              updatep;        /* update proc */
                0127         na_keyp                 keyp;           /* key proc */
                0128         na_cursorp              cursorp;        /* cursor setting proc */
                0129         na_miscp                miscp;          /* miscellaneous event proc (disk/net/app/driver) */
                0130         na_idlep                idlep;          /* idle proc */
                0131         na_taskp                taskp;          /* task proc */
                0132         na_resizep              resizep;        /* resize proc */
                0133         long                    resid;          /* storage for window resource id or user data. */
                0134         char                    *data;          /* data pointer for user */
                0135 } na_win;
                0136 typedef struct nate_win {
                0137         na_win                  winp;
                0138         TEHandle                hTE;            /* textedit handle for auto-textedit routines */
                0139         ControlHandle   hctrl;          /* horizontal scroll bar for textedit */
                0140         ControlHandle   vctrl;          /* vertical scroll bar for textedit */
                0141         long                    docwidth;       /* width of the document */
                0142         short                   lheight;        /* line height of text */
                0143         short                   topoff;         /* offset from top of window to textedit area */
                0144 } nate_win;
                0145 /* procedures types:
                0146  *
                0147  * // called for menu events when window is frontmost
                0148  * // supercedes global menu function unless NA_NOTPROCESSED is returned.
                0149  * // if menuid is 0, the procedure should enable/disable menus appropriately
                0150  * // if menuid is 1, the procedure should disable enabled menus appropriately
                0151  * short menu(winp, menuid, itemno)
                0152  *      WORD menuid;                    // resource id of the menu
                0153  *      WORD itemno;                    // item number of the menu item
                0154  *
                0155  * // called for mouse down/up/move events in the window
                0156  * short mouse(winp, p, type, mods)
                0157  *      Point p;                                // location of mouse action
                0158  *      short type;                             // type of mouse action (see below)
                0159  *      short mods;                             // modifier keys
                0160  *
                0161  * // called for dialog events in dialog windows
                0162  * // control events in windows with controls
                0163  * // In a dialog window with no key procedure, ESC, command-., return, enter are
                0164  * // mapped to iCancel and iOk.
                0165  * short control(winp, p, itemHit, mods, ctrlh)
                0166  *      Point p;                                // point in window local coords
                0167  *      short itemHit;                  // the item/part code clicked
                0168  *      short mods;                             // modifier keys
                0169  *      ControlHandle ctrlh;    // handle to the control
                0170  *
                0171  * // called when window is activated or deactivated
                0172  * // close return values may be ignored on a deactivate
                0173  * short activate(winp, on)
                0174  *      Boolean on;                             // true = activate, false = deactivate
                0175  *
                0176  * // called when a window close request has been made (close box/close menu item)
                0177  * // called when any window function returns NA_REQCLOSE or NA_REQCLOSEALL
                0178  * // respond with either NA_CLOSED or NA_NOTPROCESSED
                0179  * short close(winp)
                0180  *
                0181  * // called after window closed & removed from lists, but before window object freed
                0182  * void afterp(winp)
                0183  *
                0184  * // called on update events
                0185  * short update(winp, newsize)
                0186  *      Boolean newsize;                // true if r is a new window size
                0187  *
                0188  * // called on key/autokey events (menu keys are parsed out first)
                0189  * short key(winp, c, mods)
                0190  *      long c;                                 // ASCII value of the key (unless NA_RAWKEY option set)
                0191  *      short mods;                             // modifier keys
                0192  *
                0193  * // called when cursor moves into or out of a window
                0194  * // use winp->flags & NA_CURSORON
                0195  * // close request return values are ignored.
                0196  * // return NA_PROCESSED only when the cursorRgn is changed
                0197  * short cursor(winp, p)
                0198  *      Point p;                                // point where the cursor is
                0199  *
                0200  * // This is called for miscellaneous events (disk/network/driver/app1-3)
                0201  * short miscp(winp, pevent)
                0202  *      EventRecord *pevent;    // the event
                0203  *
                0204  * // called every time through the event loop when window active
                0205  * short idle(winp)
                0206  *
                0207  * // called cyclicly with other tasks with each pass through event loop
                0208  * // only used when task is installed
                0209  * // the task procedure can only close it's own window.
                0210  * short task(winp)
                0211  *
                0212  * // function called to resize the window 
                0213  * // (parameters similar to GrowWindow function)
                0214  * short resize(winp, where, rct)
                0215  *  Point where;
                0216  *  Rect *rct;
                0217  *
                0218  * // function passed to NAinit:
                0219  * // should return 0 if OK, and -1 to stop opening files
                0220  * short open(message, afile, fspec)
                0221  *      short message;                  // either appOpen or appPrint (in SegLoad.h)
                0222  *  FSSpec *fspec;                      // file to open/print
                0223  *  Finfo *finfo;                       // finder info
                0224  *
                0225  * // function passed to NAwindow:
                0226  * // returns standard window status
                0227  * short init(winp, datap)
                0228  *      na_win  *winp;                  // pointer to new window structure
                0229  *      long    *datap;                 // pointer to data passed through NAwindow
                0230  */
                0231 
                0232 /* niftyapp globals */
                0233 extern na_win **NAhead;                 /* handle to the head of the window tree */
                0234 extern na_win **NAtask;                 /* handle to the head of the window task list */
                0235 extern na_win **NActask;                /* handle to the current task */
                0236 extern na_win *NAwin;                   /* pointer to current window (NULL = no current window) */
                0237 extern na_menup NAmenup;                /* pointer to default menu procedure */
                0238 extern MenuHandle **NAmenus;    /* list of menu handles */
                0239 extern short NAnewitem;                 /* item number of the new item on the file menu (0 = not avail) */
                0240 extern short NAcloseitem;               /* item number of the close item on the file menu (0 = not avail) */
                0241 extern short NAappleitems;              /* the number of (user) items at the top of the apple menu */
                0242 extern short NAhelpitems;               /* the number of (user) help items */
                0243 extern short NAhelpcount;       /* the number of (system) items at the top of the help menu */
                0244 extern Boolean NAhasedit;               /* true if application has an edit menu */
                0245 extern long NAdelay;                    /* the wait next event delay */
                0246 extern SysEnvRec NAsysenv;              /* mac system environment */
                0247 extern Boolean NAinBack;                /* true if application is backgrounded */
                0248 extern long NAmousetime;                /* time of last mouse up event */
                0249 extern short NAlastmouse;               /* kind of last mouse event */
                0250 extern Cursor NAibeam;                  /* the ibeam cursor */
                0251 extern long NAgestaltBits;      /* 0 = gestalt not on system */
                0252 
                0253 /* globals for your convenience */
                0254 extern RgnHandle NAfullRgn, NAnullRgn;
                0255 
                0256 /* niftyapp definitions */
                0257 
                0258 /* default resource id for niftyapp windows */
                0259 #define NA_CLIPWINDOW   1000
                0260 #define NA_ABOUTDLOG    1000
                0261 #define NA_PREFSDLOG    1001
                0262 #define NA_HELPSTR              1000
                0263 /* default item numbers for OK & cancel */
                0264 #define iOk                             1
                0265 #define iCancel                 2
                0266 /* default ids for APPLE, FILE, EDIT, and HELP menus */
                0267 #define mApple                  128
                0268 #define mFile                   129
                0269 #define mEdit                   130
                0270 #define mHelp                   ((WORD)-16490)
                0271 /* default item numbers for about & edit menu */
                0272 #define iAbout                  1
                0273 #define iUndo                   1
                0274 #define iCut                    3
                0275 #define iCopy                   4
                0276 #define iPaste                  5
                0277 #define iClear                  6
                0278 #define iSelAll                 7
                0279 #define iClipboard              9
                0280 /* new window positions */
                0281 #define NA_HFULLSCN             0x0000
                0282 #define NA_HQUARTERSCN  0x0001
                0283 #define NA_HHALFSCN             0x0002
                0284 #define NA_H3QUARTERSCN 0x0003
                0285 #define NA_VFULLSCN             0x0000
                0286 #define NA_VQUARTERSCN  0x0004
                0287 #define NA_VHALFSCN             0x0008
                0288 #define NA_V3QUARTERSCN 0x000C
                0289 #define NA_CENTERSCN    0x0000
                0290 #define NA_TOPSCN               0x0010
                0291 #define NA_BOTTOMSCN    0x0020
                0292 #define NA_LEFTSCN              0x0040
                0293 #define NA_RIGHTSCN             0x0080
                0294 #define NA_TITLEOFFSET  0x0100
                0295 /* new window flags */
                0296 #define NA_PLAINWIN             0x00000000L     /* plain window -- no title, simple border */
                0297 #define NA_COLORWINDOW  0x00000001L     /* allow color in the window */
                0298 #define NA_DIALOGWINDOW 0x00000002L     /* open as a dialog */
                0299 #define NA_TITLEBAR             0x00000004L     /* have title bar */
                0300 #define NA_GROWBOX              0x00000008L     /* have a grow box (enables automatic drawing) */
                0301 #define NA_ZOOMBOX              0x00000010L     /* have a zoom box */
                0302 #define NA_CLOSEBOX             0x00000020L     /* have a close box (enables close menu item) */
                0303 #define NA_SHADOWBORDER 0x00000040L     /* have a shadow border (for dialogs) */
                0304 #define NA_DOUBLEBORDER 0x00000080L     /* have a double (dialog) border */
                0305 #define NA_ROUNDBORDER  0x000000c0L     /* have rounded corners and black title bar */
                0306 #define NA_CHILDWINDOW  0x00000100L     /* open as a child window of current window */
                0307 #define NA_NOTVISIBLE   0x00000200L     /* do not make window visible on open */
                0308 #define NA_BEHIND               0x00000400L     /* open window behind current window */
                0309 #define NA_HASCONTROLS  0x00000800L     /* process/draw/kill controls automatically */
                0310 #define NA_HASTASK              0x00001000L     /* install window in background task list */
                0311 #define NA_USERESOURCE  0x00002000L     /* use res parameter as WIND/DLOG/wctb/dctb resource */
                0312 #define NA_CURSORON             0x00004000L     /* true if application has set the cursor */
                0313 #define NA_MODAL                0x00008000L     /* set if window/dialog will be modal */
                0314 #define NA_DEFBUTTON    0x00010000L     /* show default button after init proc */
                0315 #define NA_COPYDATA             0x00020000L     /* data will by copied by NAwindow */
                0316 #define NA_SMARTSIZE    0x00040000L     /* window resizes & placements are saved in WIND res */
                0317 #define NA_FORCESIZE    0x00080000L     /* when a resource is used, re-size the window anyway */
                0318 #define NA_RAWKEY               0x00100000L     /* if set, key event fields aren't stripped */
                0319 #define NA_HILITECTRLS  0x00200000L     /* if set, hilite controls on activate/deactive */
                0320 #define NATE_FLAGS              0x0f000000L     /* flags reserved for NATE */
                0321 #define NA_USER_FLAG1   0x10000000L     /* flags reserved for users */
                0322 #define NA_USER_FLAG2   0x20000000L
                0323 #define NA_USER_FLAG3   0x40000000L
                0324 #define NA_USER_FLAG4   0x80000000L
                0325 /* niftyapp window/task types */
                0326 #define NA_CLIPTYPE             -1
                0327 #define NA_DEBUGTYPE    -2
                0328 #define NA_TCPTYPE              -3
                0329 #define NA_SMTPTYPE             -4
                0330 /* mouse click types */
                0331 #define NA_DOWN1                0
                0332 #define NA_UP1                  1
                0333 #define NA_DOWN2                2
                0334 #define NA_UP2                  3
                0335 #define NA_DOWNN                4
                0336 #define NA_UPN                  5
                0337 #define NA_DRAG                 6
                0338 #define NA_RELEASE              7
                0339 /* return values for window/menu procedures */
                0340 #define NA_ALLCLOSED    -4              /* all windows are to be destroyed & exit app immediately */
                0341 #define NA_REQCLOSEALL  -3              /* request to close all windows & exit app */
                0342 #define NA_CLOSED               -2              /* current window is ready to close (used by closep/taskp) */
                0343 #define NA_REQCLOSE             -1              /* request to close current window */
                0344 #define NA_NOTPROCESSED 0               /* use any default handler available */
                0345 #define NA_PROCESSED    1               /* do nothing more */
                0346 #define NA_USERINTERACT 2               /* user interaction pending -- don't do tasks */
                0347 /* Gestalt bits */
                0348 #define NA_HASAEVENTS   0x00000001L     /* Apple events supported */
                0349 #define NA_HASFSSPEC    0x00000002L /* FSSpec calls supported */
                0350 #define NA_HASSTDFILE   0x00000004L /* New standard file available */
                0351 
                0352 /* niftyapp basic macros */
                0353 
                0354 #define NAunlockWindow(winp)            {if (!--(winp)->locks) HUnlock((Handle) GetWRefCon((winp)->pwin));}
                0355 #define NAunlockWindowh(winh, winp)     {if (!--(winp)->locks) HUnlock((Handle) winh);}
                0356 #define NAisDAWindow(pWnd)                      (( (WindowPeek) pWnd)->windowKind < 0)
                0357 #define NAmenuh(menu)                           ((*NAmenus)[(menu) - mApple])
                0358 #define NAenableMItem(menu, item)       EnableItem(NAmenuh(menu), item)
                0359 #define NAdisableMItem(menu, item)      DisableItem(NAmenuh(menu), item)
                0360 #define NAcheckItem(menu, item, c)      CheckItem(NAmenuh(menu), item, c)
                0361 #define NAgetDHandle(dlg, it, hn)       {short ty; Rect r; GetDItem(dlg, it, &ty, (Handle *) (hn), &r);}
                0362 #define NAgetDRect(dlg, it, rct)        {short ty; Handle hn; GetDItem(dlg, it, &ty, &hn, (rct));}
                0363 #define NAsetIval(dlg, it, val)         {short ty; Rect r; Handle hn; GetDItem(dlg, it, &ty, &hn, &r); SetCtlValue((ControlHandle)hn, (val));}
                0364 #define NAsetInum(dlg, it, val)         NAsetIText(dlg, it, longtoPCstr(val))
                0365 #define NAalert(resid)                          Alert(resid, NAfilterProc)
                0366 
                0367 /* niftyapp basic procedures */
                0368 
                0369 /* initialize the Macintosh managers and niftyapp internal variables.
                0370  * optionally set up a menu bar & menu procedure.
                0371  * Returns 0 if OK, negative if an error occured, 1 if print files requested & app should quit
                0372  * short minK;                  // minimum K needed to execute
                0373  * short masters;               // number of times to call MoreMasters()
                0374  * na_proc *openp;              // open file procedure -- called for each application in the startup list
                0375  * na_proc *menup;              // pointer to a menu procedure (NULL = no menu handling)
                0376  * short nummenu;               // number of menus (starting at mApple == 128)
                0377  * short numapple;              // number of apple menu items
                0378  * short newitem;               // item number of new item (mFile)
                0379  * short closeitem;             // item number of close item (mFile)
                0380  */
                0381 short NAinit(short, short, na_openp, na_menup, short, short, short, short);
                0382 
                0383 /* call the main loop procedure
                0384  */
                0385 void NAmainloop(void);
                0386 
                0387 /* create a rectangle based on the screen size
                0388  *      short position;         // see above
                0389  */
                0390 Rect *NAscreenrect(short);
                0391 
                0392 /* create a new window structure
                0393  * returns window status result, up to the caller to pass on NA_ALLCLOSED
                0394  *      Rect *rpos;                     // placement rectangle
                0395  *      long flags;                     // flags determining type of window
                0396  *      char *title;            // window title (C string may not be NULL unless NA_USERESOURCE)
                0397  *      short res;                      // resource number of WIND/DLOG/wctb/dctb/DITL
                0398  *      long *initdata;         // window data (may be NULL)
                0399  *      long datasize;          // bytes of window data
                0400  *      na_proc *initp;         // procedure to initialize the window functions, etc.
                0401  */
                0402 short NAwindow(Rect *, long, char *, short, long *, long, na_initp);
                0403 
                0404 /* create & add a new task to the task list, given pointer to task procedure,
                0405  * and data size
                0406  */
                0407 na_win **NAaddtask(na_taskp, long);
                0408 
                0409 /* standard init procedure for an about box -- stops all background tasks, however */
                0410 short NAabout(na_win*, long*);
                0411 
                0412 /* standard button flash procedure used by shell for keypresses */
                0413 void NAflashButton(DialogPtr, short);
                0414 
                0415 /* draw the default button */
                0416 void NAdefaultButton(DialogPtr);
                0417 
                0418 /* filter proc for modal dialogs which handles ESC and command-. */
                0419 pascal Boolean NAfilterProc(DialogPtr, EventRecord *, short *);
                0420 
                0421 /* re-calculate cursor region information (after changing winp->cursorRgn) */
                0422 void NAcalcCursor(na_win*);
                0423 
                0424 /* this saves a window's dimensions into a 'WIND' resource with appropriate resid */
                0425 void NAsaveWin(na_win*);
                0426 
                0427 /* This is available to access window structures other than the current window
                0428  * best for looking at parent window or child window(s).
                0429  */
                0430 na_win *NAlockWindow(na_win**);
                0431 
                0432 /* This is available, but the user should only call it is severe cases */
                0433 short NAcloseWindow(na_win*, short);
                0434 
                0435 /* this is for closing all windows, the user should only call it from main
                0436  * usually NAhead is the first parameter.
                0437  */
                0438 short NAcloseWindows(na_win**, short);
                0439 
                0440 /* this is for sending an event directly to the misc procedure of all windows.
                0441  * usually NAhead is the first parameter.
                0442  */
                0443 short NAallWindows(na_win**, EventRecord*);
                0444 
                0445 
                0446 /* niftyapp clipboard library:
                0447  * NAclipboard: true = window on, false = window off, 'TEXT' or 'PICT'
                0448  */
                0449 void NAclipboard(Boolean, ResType);
                0450 
                0451 
                0452 /* niftyapp debug library:
                0453  */
                0454 void NAdebug(char *, ...);
                0455 #ifdef DEBUG
                0456 #define NADEBUG(x) NAdebug x
                0457 #else
                0458 #define NADEBUG(x)
                0459 #endif
                0460 
                0461 
                0462 /* niftyapp dialog library:
                0463  */
                0464 /* select a radio button
                0465  * returns number from 0 to firstitem - lastitem: the button that's been pressed
                0466  *      DialogPtr dialog;       // the dialog window
                0467  *      short firstitem;        // the itemno of first radio button
                0468  *      short lastitem;         // the itemno of last radio button
                0469  *      short setting;          // the radio button to set (itemno to lastitem)
                0470  */
                0471 short NAradioSet(DialogPtr, short, short, short);
                0472 
                0473 /* get the itemno of the active radio button
                0474  *      DialogPtr dialog;       // the dialog window
                0475  *      short firstitem;        // the itemno of first radio button
                0476  *      short lastitem;         // the itemno of last radio button
                0477  */
                0478 short NAradioGet(DialogPtr, short, short);
                0479 
                0480 /* enable/disable,hilite,show/hide an item in a dialog window */
                0481 void NAenableDItem(DialogPtr, short, Boolean);
                0482 void NAhiliteDItem(DialogPtr, short, short);
                0483 void NAvisibleDItem(DialogPtr, short, Boolean);
                0484 
                0485 /* set/get the item text in a dialog item */
                0486 void NAsetIText(DialogPtr, short, PCstr*);
                0487 void NAgetIText(DialogPtr, short, PCstr*);
                0488 
                0489 /* enable/disable modal menus for a moveable modal dialog box (1 = go modal) */
                0490 void NAmodalMenus(int);
                0491 
                0492 /* handle edit menu for dialogs */
                0493 short NAdialogMenu(na_win *, WORD, WORD);
                0494 
                0495 
                0496 /* NATE (NiftyApp TextEdit) libraries
                0497  */
                0498 #define NATEflags (NA_TITLEBAR | NA_GROWBOX | NA_ZOOMBOX | NA_CLOSEBOX \
                0499         | NA_HASCONTROLS | NA_HILITECTRLS)
                0500 #define NATE_DEFAULT    0x00000000L
                0501 #define NATE_READONLY   0x01000000L
                0502 #define NATE_NOMOUSE    0x02000000L
                0503 #define NATE_NOHSCROLL  0x04000000L
                0504 #define NATE_NOVSCROLL  0x08000000L
                0505 void NATEinit(na_win*, long, short, Ptr, long); /* winp, flags, horizwidth, data, len */
                0506 short NATEinitp(na_win*, long*);
                0507 short NATEmousep(na_win*, Point, short, short);
                0508 short NATEidlep(na_win*);
                0509 short NATEactivep(na_win*, Boolean);
                0510 short NATEkeyp(na_win*, long, short);
                0511 short NATEmenup(na_win*, WORD, WORD);
                0512 short NATEupdatep(na_win*, Boolean);
                0513 short NATEctrlp(na_win*, Point, short, short, ControlHandle);
                0514 short NATEclosep(na_win*);
                0515 
                0516 void NATEsetscroll(na_win*, Boolean, Rect*, Rect*);
                0517 void NATEappend(na_win*, char*, long);
                0518 
                0519 
                0520 /* Niftyapp file library
                0521  */
                0522 /* get a file to open -- similar to StandardGetFile, but works on older systems
                0523  * extra fields in "StandardFileReply" are only valid if NA_HASSTDFILE is set in
                0524  * NAgestaltBits
                0525  */
                0526 void NAgetFile(FileFilterProcPtr, short, SFTypeList, StandardFileReply *);
                0527 /* put a file to open -- similar to StandardPutFile, but works on older systems
                0528  * extra fields in "StandardFileReply" are only valid if NA_HASSTDFILE is set in
                0529  * NAgestaltBits
                0530  */
                0531 void NAputFile(Str255, Str255, StandardFileReply *);
                0532 
                0533 
                0534 /* Niftyapp TCP library
                0535  */
                0536 /* tcp stream descriptor */
                0537 typedef int na_tcp;
                0538 /* tcp init function 
                0539  *  passed NATCP_connect for success, NATCP_nodriver/NATCP_nomem for failure
                0540  *  passed 1 to 100 for progress waiting for MacTCP to finish cleanly
                0541  */
                0542 typedef void na_tcpinitp(short);
                0543 /* TCP read/status callback for connection, or TCP window
                0544  * void *user;   Context generic pointer (passed to NATCPopen)
                0545  * na_tcp s;     TCP stream id
                0546  * short status; TCP status (see below)
                0547  * long size;    size of buffer (or Macintosh error)
                0548  * char *data;   data or NULL
                0549  */
                0550 typedef void na_tcpreadp(void *, na_tcp, short, long, char *);
                0551 typedef void na_readp(na_win *, short, long, char *);
                0552 /* TCP window */
                0553 typedef struct natcp_win {
                0554         na_win          winp;
                0555         na_tcp          s;
                0556         na_readp    *readp;
                0557 } natcp_win;
                0558 /* status values/bits */
                0559 #define NATCP_closing  0x08             /* other end of connection closed */
                0560 #define NATCP_urgent   0x04             /* in urgent mode */
                0561 #define NATCP_more     0x02             /* more data will follow immediately */
                0562 #define NATCP_data     0x01             /* data to read */
                0563 #define NATCP_connect  0x00             /* connection ready */
                0564 #define NATCP_noread   -1               /* non-fatal */
                0565 #define NATCP_nowrite  -2               /* fatal... */
                0566 #define NATCP_nodriver -3
                0567 #define NATCP_notcpbuf -4
                0568 #define NATCP_nomem    -5
                0569 #define NATCP_nohost   -6
                0570 #define NATCP_nocon    -7
                0571 #define NATCP_closed   -8               /* connection fully closed */
                0572 /* open flags */
                0573 #define NATCP_server    0x01    /* be a server */
                0574 /* functions */
                0575 void NATCPinit(na_tcpinitp *);
                0576 /* NATCPsettings: TCP buffer size, type of service, precedence, write buffer size */
                0577 void NATCPsettings(long, short, short, unsigned short);
                0578 short NATCPtask(na_win *);
                0579 /* NATCPopen: callback, context, host, port, flags */
                0580 na_tcp NATCPopen(na_tcpreadp *, void *, char *, long, short);
                0581 na_tcp NATCPwinopen(natcp_win *, char *, long, short); /* tcp window, host, port, flags */
                0582 short NATCPwrite(na_tcp, Ptr, long, short); /* tcp, buffer, length, dispose */
                0583 short NATCPputchar(na_tcp, char);
                0584 void NATCPclose(na_tcp);
                0585 void NATCPdone(long); /* number of 1/60 sec intervals to wait for MacTCP to finish cleanly */
                0586 /* returns passes NATCP_connect to readp on success with hostname as argument */
                0587 void NATCPgethost(na_tcpreadp *, void *);
                0588 
                0589 
                0590 /* niftyapp SMTP library
                0591  */
                0592 /* status:
                0593  * void *context;       user context
                0594  * short code;          see below
                0595  * short err;           SMTP error code or NATCP error code (NASMTP_tcpfail) or 0
                0596  * long num;            macintosh TCP error code or address number or 0
                0597  * char *errstr;        SMTP error string or NULL
                0598  */
                0599 typedef void (*na_smtpstat)(void *, short, short, long, char *);
                0600 #define NASMTP_progress   2 /* progress: err = % done */
                0601 #define NASMTP_badaddr    1 /* address was not valid */
                0602 #define NASMTP_completed  0 /* success */
                0603 #define NASMTP_nomem     -1 /* not enough memory */
                0604 #define NASMTP_badargs   -2 /* input arguments invalid */
                0605 #define NASMTP_oserr     -3 /* OS failure (e.g. file error) */
                0606 #define NASMTP_tcpfail   -4 /* TCP connection to SMTP server failed */
                0607 #define NASMTP_conclosed -5 /* connection closed by other side before completion */
                0608 #define NASMTP_badprot   -6 /* other end sent unrecognizable protocol */
                0609 #define NASMTP_temperr   -7 /* SMTP persistant temporary failure */
                0610 #define NASMTP_permerr   -8 /* SMTP permanent failure */
                0611 /* Submit email: statf, server, fspec, headers, envelope, flags, context */
                0612 void NASMTPsubmit(na_smtpstat, char *, FSSpec *, Handle, Handle, short, void *);
                0613 #define NASMTP_crtrans  0x01 /* flag indicating translation of CR -> CRLF desired */
                0614 
                0615 /* PC, C string libraries:
                0616  */
                0617 #define SetClen(pcstr)  (*((pcstr) + *(pcstr) + 1) = '\0')
                0618 #define PCstrlen(pcstr) (*(pcstr))
                0619 #define Pstrlen(pstr)   (* (unsigned char *) (pstr))
                0620 
                0621 void PtoPCstrcpy(PCstr*, char*);
                0622 void CtoPCstrcpy(PCstr*, char*);
                0623 void PCtoPCstrcpy(PCstr*, PCstr*);
                0624 void PtoPCstrncpy(PCstr*, char*, short);
                0625 void CtoPCstrncpy(PCstr*, char*, short);
                0626 void PtoPCstrcat(PCstr*, char*);
                0627 void CtoPCstrcat(PCstr*, char*);
                0628 PCstr *PtoPCstr(char*);
                0629 PCstr *CtoPCstr(char*);
                0630 void SetPlen(PCstr*);
                0631 PCstr *longtoPCstr(long);