home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / frntsdk1.cpt / Frontier SDK 1.0 ƒ / Move These Files / UserLand #includes / applet.h next >
Encoding:
C/C++ Source or Header  |  1991-11-07  |  11.3 KB  |  567 lines

  1.  
  2.  
  3. #define appletinclude /*so other modules can tell if we've been included*/
  4.  
  5.  
  6. #ifndef __IAC__
  7.  
  8.     #include <iac.h>
  9.     
  10. #endif
  11.  
  12.  
  13. #define macintosh
  14.  
  15. #undef windows
  16.  
  17.  
  18. #ifdef macintosh
  19.     
  20.     #ifdef MPWC
  21.         
  22.         #include <types.h>
  23.         #include <resources.h>
  24.         #include <dialogs.h>
  25.         #include <menus.h>
  26.         #include <fonts.h>
  27.         #include <events.h>
  28.         #include <controls.h>
  29.         #include <segload.h>
  30.         #include <memory.h>
  31.         #include <toolutils.h>
  32.         #include <packages.h>
  33.         #include <sound.h>
  34.         #include <files.h>
  35.         #include <desk.h>
  36.     
  37.     #endif
  38.     
  39.     
  40.     #define widthsmallicon 16 /*dimensions of a SICN resource*/
  41.     #define heightsmallicon 16
  42.  
  43.     typedef ControlHandle hdlscrollbar;
  44.     
  45.     #define quickdrawglobal(x) qd.x
  46.     
  47.     #define sizegrowicon 15 /*it's square, this is the length of each side*/
  48.      
  49.     #define dragscreenmargin 4 /*for dragging windows, leave this many pixels on all sides*/
  50.     
  51.     #define doctitlebarheight 18 /*number of pixels in the title bar of each standard window*/
  52.  
  53.     #define lenbigstring 255
  54.        
  55.     #define OsType OSType
  56.     
  57.     #define boolean short
  58.     
  59.     #define bigstring Str255
  60.     
  61.     typedef unsigned char *ptrstring, **hdlstring;
  62.     
  63.     #define sysbeep SysBeep(1) 
  64.     
  65.     #define    stringlength(bs) ((bs)[0])
  66.     
  67.     #define setstringlength(bs,len) (bs[0]=(char)len)
  68.     
  69.     #define setstringwithchar(ch,bs) {bs[0]=1;bs[1]=ch;}
  70.     
  71.     #define setemptystring(bs) (setstringlength(bs,0))
  72.     
  73.     #define isemptystring(bs) (stringlength(bs)==0)
  74.     
  75.     #define isemptyrect(r) EmptyRect (&r)
  76.     
  77.     #include <Printing.h>
  78.     
  79. #endif
  80.  
  81.  
  82.  
  83.  
  84.  
  85. #define true 1
  86. #define false 0
  87.  
  88. #define infinity 32767
  89. #define longinfinity (long)0x7FFFFFFF
  90. #define intinfinity 32767
  91. #define intminusinfinity -32766
  92.  
  93. #define emptystring (ptrstring) "\p"
  94.  
  95. #define chnul            ((char) 0)
  96. #define chbacktab        ((char) 0)
  97. #define chhome             ((char) 1)
  98. #define chenter            ((char) 3)
  99. #define chend             ((char) 4)
  100. #define chhelp             ((char) 5)
  101. #define chbackspace        ((char) 8) 
  102. #define chtab             ((char) 9)
  103. #define chlinefeed        ((char) 10)
  104. #define chpageup         ((char) 11)
  105. #define chpagedown         ((char) 12)
  106. #define chreturn        ((char) 13)
  107. #define chescape        ((char) 27)
  108. #define chrightarrow     ((char) 29)
  109. #define chleftarrow     ((char) 28)
  110. #define chuparrow         ((char) 30)
  111. #define chdownarrow     ((char) 31)
  112. #define chsinglequote     ((char) 39)
  113. #define chdoublequote     ((char) 34)
  114. #define chspace            ((char) 32)
  115. #define chdelete         ((char) 127)
  116.  
  117.  
  118. typedef enum tydirection { /*the possible values for a Toolkit direction parameter*/
  119.     
  120.     nodirection = 0, 
  121.     
  122.     up = 1, 
  123.     
  124.     down = 2, 
  125.     
  126.     left = 3,
  127.     
  128.     right = 4, 
  129.     
  130.     flatup = 5, 
  131.     
  132.     flatdown = 6, 
  133.     
  134.     sorted = 8,
  135.     
  136.     pageup = 9,
  137.     
  138.     pagedown = 10,
  139.     
  140.     pageleft = 11,
  141.     
  142.     pageright = 12
  143.     } tydirection;
  144.  
  145.  
  146. #define ctdirections 12 /*the number of directions, for looping and arrays*/
  147.  
  148.  
  149. typedef void *ptrvoid;
  150.  
  151. typedef char *ptrchar;
  152.  
  153. typedef short *ptrint;
  154.  
  155. typedef boolean (*callback) ();
  156.  
  157. typedef    unsigned char byte, *ptrbyte;    
  158.  
  159. #define mod %
  160.  
  161. #define div /
  162.  
  163. #define abs(x) ((x) < 0? -(x) : (x))
  164.  
  165. #define odd(x) ((x) % 2)
  166.  
  167. #define even(x) (!((x) % 2))
  168.  
  169. #define max(x,y) ((x) > (y)? (x) : (y))
  170.  
  171. #define min(x,y) ((x) < (y)? (x) : (y))
  172.  
  173. #define bitboolean(fl) ((fl)?true:false)
  174.  
  175. #define isnumeric(x) ((x >= '0') && (x <= '9'))
  176.  
  177. #define longsizeof(x) (long)sizeof(x)
  178.  
  179.  
  180. extern FontInfo globalfontinfo;
  181.  
  182.  
  183. typedef struct tykeystrokerecord {
  184.  
  185.     char chkb;
  186.     
  187.     boolean flshiftkey, flcmdkey, floptionkey, flalphalock, flcontrolkey;
  188.         
  189.     short ctmodifiers; /*the number of booleans that are on*/
  190.  
  191.     short keycode; /*see Toolbox Event Manager -- this is the hardware key code*/
  192.     
  193.     boolean flkeypad: 1; /*if true, keystroke comes from numeric keypad*/
  194.     
  195.     boolean flautokey: 1; /*if true, keystroke is an automatic key*/
  196.     
  197.     tydirection keydirection; 
  198.     } tykeystrokerecord, *ptrkeystrokerecord, **hdlkeystrokerecord;
  199.  
  200.  
  201. extern tykeystrokerecord keyboardstatus;
  202.  
  203.  
  204. typedef struct tymouserecord {
  205.     
  206.     boolean fldoubleclick;
  207.     
  208.     Point localpt;
  209.     
  210.     long mouseuptime; 
  211.     
  212.     long mousedowntime; 
  213.     
  214.     Point mouseuppoint;
  215.     
  216.     Point mousedownpoint;
  217.     
  218.     boolean fldoubleclickdisabled;
  219.     } tymouserecord;
  220.     
  221.     
  222. extern tymouserecord mousestatus;
  223.  
  224.  
  225. typedef struct tyappwindow {
  226.     
  227.     bigstring fname;
  228.     
  229.     short vnum;
  230.     
  231.     short fnum;
  232.     
  233.     short windowvertpixels, windowhorizpixels;
  234.     
  235.     short defaultfont, defaultsize, defaultstyle;
  236.     
  237.     short fontheight;
  238.     
  239.     Handle appdata;
  240.     
  241.     Rect windowrect;
  242.     
  243.     Rect contentrect;
  244.     
  245.     Rect statusrect; /*the rectangle covering the status portion of window*/
  246.     
  247.     WindowPtr macwindow;
  248.     
  249.     hdlscrollbar vertbar, horizbar; /*the window's scrollbars*/
  250.     
  251.     boolean flmadechanges;
  252.     
  253.     boolean flresetscrollbars;
  254.     
  255.     Point scrollorigin;
  256.     } tyappwindow, *ptrappwindow, **hdlappwindow;
  257.  
  258.  
  259. #define app1class 'app1'
  260.  
  261.  
  262. typedef boolean (*tyappcallback) (void);
  263.  
  264. typedef boolean (*tyapphandleptrcallback) (Handle *);
  265.  
  266. typedef boolean (*tyapphandlecallback) (Handle);
  267.  
  268. typedef boolean (*tyappbooleancallback) (boolean);
  269.  
  270. typedef boolean (*tyappshortcallback) (short);
  271.  
  272. typedef boolean (*tyappsscrollcallback) (tydirection, boolean, short);
  273.  
  274.  
  275. typedef struct typrintinfo {
  276.     
  277.     Rect paperrect;
  278.     
  279.     short vpagepixels; /*number of pixels on a page, vertically*/
  280.     
  281.     short ctpages; /*the number of pages in the document being printed*/
  282.     
  283.     Handle printhandle; /*a handle to the machine's print record*/
  284.     } typrintinfo;
  285.  
  286.  
  287. typedef struct tyappletrecord {
  288.     
  289.     hdlappwindow appwindow; /*the frontmost applet window, callbacks work on this*/
  290.  
  291.     Handle appdata; /*a handle allocated by the applet to hold its data*/
  292.     
  293.     long filetype, creator; /*file type and creator for file saving*/
  294.     
  295.     typrintinfo printinfo; /*for coordinating printing between applet and the shell*/
  296.     
  297.     boolean resizeable; /*if true the app's windows can be resized*/
  298.     
  299.     boolean easywindowcreate; /*check it out!*/
  300.     
  301.     boolean statswindow; /*if true, we automatically open stats window for IAC Toolkit*/
  302.     
  303.     boolean horizscroll; /*if true, the applet implements horiz scrolling*/
  304.     
  305.     boolean vertscroll; /*if true, the applet implements vert scrolling*/
  306.     
  307.     boolean notsaveable; /*if true, the applet doesn't implement saving/opening files*/
  308.     
  309.     short statuspixels; /*height of status bar at top of window*/
  310.     
  311.     tyappcallback newrecordcallback; /*allocate and initialize a new data handle*/
  312.     
  313.     tyappcallback disposerecordcallback; /*dealloc a data handle*/
  314.     
  315.     tyappcallback adjustcursorcallback; /*set the mouse cursor according to location*/
  316.     
  317.     tyappbooleancallback activatecallback; /*activate or deactivate the window data*/
  318.     
  319.     tyappcallback updatecallback; /*update the display of the window data*/
  320.     
  321.     tyappcallback windowresizecallback; /*recalc display data, adjust to new window size*/
  322.     
  323.     tyappcallback iacmessagecallback; /*process an IAC message*/
  324.     
  325.     tyapphandleptrcallback packcallback; /*pack memory structure into a disk handle*/
  326.     
  327.     tyapphandlecallback unpackcallback; /*unpack disk handle into memory structure*/
  328.     
  329.     tyapphandleptrcallback gettextcallback; /*return a handle of unformatted ASCII text*/
  330.     
  331.     tyapphandleptrcallback getpictcallback; /*return a Macintosh PicHandle of selected items*/
  332.     
  333.     tyappcallback resetscrollbarscallback; /*set all values for both scrollbars*/
  334.     
  335.     tyappsscrollcallback scrollcallback; /*scroll*/
  336.     
  337.     tyappcallback pagesetupcallback;
  338.     
  339.     tyappcallback openprintcallback;
  340.     
  341.     tyappshortcallback printpagecallback;
  342.     
  343.     tyappcallback closeprintcallback;
  344.     
  345.     tyapphandlecallback puttextcallback;
  346.     
  347.     tyapphandlecallback putpictcallback;
  348.     
  349.     tyappcallback haveselectioncallback;
  350.     
  351.     tyappcallback selectallcallback;
  352.     
  353.     tyappcallback keystrokecallback;
  354.     
  355.     tyappcallback mousecallback;
  356.     
  357.     tyappcallback mouseinstatuscallback;
  358.     
  359.     tyappcallback updatestatuscallback;
  360.     } tyappletrecord, *ptrappletrecord, **hdlappletrecord;
  361.     
  362.     
  363. extern tyappletrecord app; /*global applet record, short name for easy access*/
  364.  
  365.  
  366.  
  367.  
  368. boolean apppushwindow (hdlappwindow);
  369.  
  370. boolean apppopwindow (void);
  371.  
  372. boolean apppushorigin (void);
  373.  
  374. boolean apppoporigin (void);
  375.  
  376. boolean appopenbitmap (Rect, hdlappwindow);
  377.  
  378. boolean appclosebitmap (hdlappwindow);
  379.  
  380. boolean pushpen (void);
  381.  
  382. boolean poppen (void);
  383.  
  384. boolean pushmacport (GrafPtr);
  385.  
  386. boolean popmacport (void);
  387.  
  388. boolean pushclip (Rect);
  389.  
  390. boolean popclip (void);
  391.  
  392. boolean pushstyle (short, short, short);
  393.  
  394. boolean popstyle (void);
  395.  
  396. boolean equalstrings (bigstring, bigstring);
  397.  
  398. boolean unicaseequalstrings (bigstring, bigstring);
  399.  
  400. void copystring (void *, void *);
  401.  
  402. void centerstring (Rect, bigstring);
  403.  
  404. boolean pushstring (bigstring, bigstring);
  405.  
  406. boolean pushspace (bigstring);
  407.  
  408. void pushlong (long, bigstring);
  409.  
  410. void pushint (short, bigstring);
  411.  
  412. void allupper (bigstring);
  413.  
  414. void alllower (bigstring);
  415.  
  416. boolean stringlessthan (bigstring, bigstring);
  417.  
  418. void midstring (bigstring, short, short, bigstring);
  419.  
  420. boolean pushchar (byte, bigstring);
  421.  
  422. boolean scanstring (byte, bigstring, short *);
  423.  
  424. boolean deletestring (bigstring, short, short);
  425.  
  426. boolean firstword (bigstring, char, bigstring);
  427.  
  428. boolean lastword (bigstring, char, bigstring);
  429.  
  430. void ellipsize (Str255, short);
  431.  
  432. void setfontsizestyle (short, short, short);
  433.  
  434. boolean newappwindow (bigstring, boolean);
  435.  
  436. void invalappwindow (hdlappwindow, boolean);
  437.  
  438. void updateappwindow (hdlappwindow);
  439.  
  440. boolean findbywindowtitle (bigstring, hdlappwindow *);
  441.  
  442. boolean findnthwindow (short, hdlappwindow *);
  443.  
  444. short countwindows (void);
  445.  
  446. boolean findbyfile (bigstring, short, hdlappwindow *);
  447.  
  448. boolean newclearhandle (long, Handle *);
  449.  
  450. boolean newfilledhandle (ptrvoid, long, Handle *);
  451.  
  452. boolean newheapstring (bigstring, hdlstring *);
  453.  
  454. void copyheapstring (hdlstring, bigstring);
  455.  
  456. boolean enlargehandle (Handle, long, ptrchar);
  457.  
  458. void lockhandle (Handle);
  459.  
  460. void unlockhandle (Handle);
  461.  
  462. void disposehandle (Handle);
  463.  
  464. void moveleft (void *, void *, long);
  465.  
  466. boolean newtexthandle (bigstring, Handle *);
  467.  
  468. boolean pushtexthandle (bigstring, Handle);
  469.  
  470. void texthandletostring (Handle, bigstring);
  471.  
  472. void arrowcursor (void);
  473.  
  474. void initbeachball (void);
  475.  
  476. void rollbeachball (void);
  477.  
  478. boolean settargetglobals (void);
  479.  
  480. boolean copyhandle (Handle, Handle *);
  481.  
  482. void clearbytes (void *, long);
  483.  
  484. boolean equalrects (Rect, Rect);
  485.  
  486. void zerorect (Rect *);
  487.  
  488. void scrollrect (Rect, short, short);
  489.  
  490. void centerrect (Rect *, Rect);
  491.  
  492. short getfontheight (void);    
  493.  
  494. void timestamp (long *);
  495.  
  496. void enablescrollbar (hdlscrollbar);
  497.  
  498. void disablescrollbar (hdlscrollbar);
  499.  
  500. void getscrollbarinfo (hdlscrollbar, short *, short *, short *);
  501.  
  502. void setscrollbarinfo (hdlscrollbar, short, short, short);
  503.  
  504. extern boolean optionkeydown (void);
  505.  
  506. extern boolean cmdkeydown (void);
  507.  
  508. extern boolean shiftkeydown (void);
  509.  
  510. boolean alertdialog (bigstring);
  511.  
  512. boolean msgdialog (bigstring);
  513.  
  514. boolean askdialog (bigstring, bigstring);
  515.  
  516. boolean oserror (OSErr);
  517.  
  518. boolean filedelete (bigstring, short);
  519.  
  520. void fileclose (short);
  521.  
  522. boolean fileseteof (short, long);
  523.  
  524. boolean fileopenorcreate (bigstring, short, OSType, OSType, short *);
  525.  
  526. boolean filenew (bigstring, short, OSType, OSType, short *);
  527.  
  528. boolean fileopen (bigstring, short, short *);
  529.  
  530. boolean filetruncate (short);
  531.  
  532. boolean filewrite (short, long, void *);
  533.  
  534. boolean fileread (short, long, void *);
  535.  
  536. boolean filewritehandle (short, Handle);
  537.  
  538. boolean filereadhandle (short, long, Handle *);
  539.  
  540. boolean filegetchar (short, byte *);
  541.  
  542. boolean filefrompath (bigstring, bigstring);
  543.  
  544. boolean folderfrompath (bigstring, bigstring);
  545.  
  546. boolean pathtofileinfo (bigstring, bigstring, short *);
  547.  
  548. boolean directorytopath (long, short, bigstring);
  549.  
  550. boolean fileinfotopath (bigstring, short, bigstring);
  551.  
  552. boolean getstringlist (short, short, bigstring);
  553.  
  554. boolean plotsmallicon (hdlappwindow, Rect, short, short, boolean);
  555.  
  556. boolean mousetrack (Rect, void (*) (boolean));
  557.  
  558. boolean FrontierDoScript (bigstring, bigstring);
  559.  
  560. void initmacintosh (void);
  561.  
  562. void appletinitmanagers (void);
  563.  
  564. void runapplet (void);
  565.  
  566.  
  567.