home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / utility / gemfut15.lzh / GEMXTEND.DOC < prev   
Text File  |  1990-08-06  |  23KB  |  484 lines

  1.  
  2. **************************************************************************
  3. *
  4. * GEMXTEND.DOC - Descriptions of extensions made to GEM bindings since
  5. *                the original TOS 1.0 release.
  6. *
  7. *  06/29/90    - v1.5
  8. *                Added function v_gchar() to output a single text char.
  9. *
  10. *  05/26/90    - v1.4
  11. *                Included documentation on the new calling standard,
  12. *                and the bindings that currently support it:
  13. *                   evnx_multi()
  14. *                   frmx_center()
  15. *                   winx_get()
  16. *                   winx_calc()
  17. *
  18. *  09/06/89    - v1.3
  19. *                This document is new with this release, and contains
  20. *                revisions through TOS 1.4.
  21. **************************************************************************
  22.  
  23. This document is divided into two sections.  Section 1 documents the 
  24. changes and additions Atari has made to the GEM routines in TOS.  Section 2 
  25. documents alternate calling standards to the existing functions.  These
  26. alternate bindings provide more efficient ways to call AES functions.
  27.  
  28.  
  29. **************************************************************************
  30. *
  31. * Section 1 - Changes Atari has made to GEM/TOS.
  32. *
  33. **************************************************************************
  34.  
  35. This section describes extensions Atari has made to TOS/GEM since the
  36. original TOS 1.0 operating system.  When Atari adds new VDI/AES functions,
  37. appropriate bindings will be created and documented here.  Note that some
  38. of the functions listed here have been available since TOS 1.0, but Atari
  39. neglected to document them.  The title bar for each function lists the
  40. first TOS version that supported the function.  Other functions have 
  41. backwards compatibility built into the GEMFAST binding so that they will 
  42. work correctly on all TOS versions (these are noted in the title bars too).
  43.  
  44. *--------------------------------------------------------------------------
  45. * About TOS 1.4...
  46. *--------------------------------------------------------------------------
  47.  
  48.  The TOS 1.4 pre-release notes contain documentation for the following:
  49.  
  50.    form_error    form_alert    shel_write    shel_get    shel_put  
  51.    fsel_exinput  wind_new
  52.  
  53.  Of these, the form_error/alert and shel_???? docs seem to be just a 
  54.  clarification of the docs without any functional changes.
  55.  
  56.  The wind_new and fsel_exinput functions are new with TOS 1.4.
  57.  
  58. ;-------------------------------------------------------------------------
  59. ; wind_new                    TOS 1.4
  60. ;-------------------------------------------------------------------------
  61.  
  62.   void wind_new();
  63.  
  64.   The 'wind_new' function is for doing a major cleanup after a GEM 
  65.   application.  It closes & deletes all windows, flushes all the windows'
  66.   buffers (of redraw msgs, I presume), clears the wind_update flag, and
  67.   restores ownership of the mouse to the system (END_MCTRL I presume). The
  68.   documentation is not clear on whether this function should be used by
  69.   an application that wants to shut down everything quickly, or whether it
  70.   is intended for a shell's use in cleaning up after an application exits.
  71.   I tend to suspect the latter, and I think this function was developed 
  72.   because shell writers all begged Atari to provide something that could
  73.   clean up after an application the way the desktop does.
  74.  
  75. ;-------------------------------------------------------------------------
  76. ; fsel_exinput                TOS 1.4 (binding compatible with 1.0 and up)
  77. ;-------------------------------------------------------------------------
  78.  
  79.   Full 1.4 emulation...
  80.  
  81.   status = fsel_exinput(in_path, in_sel, &exitbtn, prompt_text);
  82.   
  83.    (status and exitbtn are 16-bit ints, others are char *).
  84.    
  85.  This routine is functionally equivelent to fsel_input, except that it
  86.  also allows you to specify a prompt string of up to 30 characters to be
  87.  displayed along with the file selector.  While the function is new with
  88.  TOS 1.4, the AESFAST bindings support it in all versions via a routine
  89.  which checks the AES version number and simulates the actions of
  90.  fsel_exinput by using fsel_input and objc_draw.  If running under
  91.  TOS 1.4, the system will display your prompt text in place of the words
  92.  'FILE SELECTOR' inside the fsel box.  If running under pre-TOS 1.4, the
  93.  simulation routines place the prompt text in a box which appears 
  94.  between the menu bar and the fsel box.
  95.  
  96.  Other TOS 1.4 changes to the fsel routines that this routine supports 
  97.  via simulation when running on pre-TOS 1.4 systems...
  98.  
  99.   - The file selector now allows you to edit the pathname and hit RETURN
  100.     without exiting the dialog.  If you edit the filename and hit <CR>,
  101.     you will exit as if you clicked on OK.
  102.   - If the initial pathname has a leading '\', it will be appended to the
  103.     end of the current default drive and path, and the entire resulting
  104.     string will be returned if the user exits via OK or <CR>.
  105.   - The current default drive and path are preserved, and the contents
  106.     of the current DTA are preserved.  Only the default path on the 
  107.     default drive is saved with the simulation software. If the user
  108.     changes devices during file selection, the default path on all devices
  109.     may  be changed except for the device that was the default when 
  110.     fsel_exinput was called.
  111.  
  112.   The executable code for the fsel_exinput binding is big -- about 800
  113.   bytes.  Also, it uses about 350 bytes of stack space during the call.
  114.   Still, having a prompted file selector that works correctly on all
  115.   machines will lend a touch of class to your application (IMHO).
  116.  
  117.   Note that all of the above fsel ehancements which are supported by the
  118.   simulation on pre-TOS 1.4 systems are supported ONLY if you call
  119.   fsel_exinput; if you call fsel_input on a pre-1.4 system the default
  120.   path et. al. will behave as they always have. (Hint: USE exinput).
  121.  
  122. ;-------------------------------------------------------------------------
  123. ; fsel_smallexinput           TOS 1.4 (binding compatible with 1.0 and up)
  124. ;-------------------------------------------------------------------------
  125.  
  126.   Prompting emulation only...
  127.  
  128.   This function has calling parameters identical to fsel_exinput() (see
  129.   above), but it's behavior (return values, etc) is identical to that of
  130.   fsel_input() (the original).  This function will call the real 'exinput'
  131.   routine if on TOS 1.4, but if on an earlier version it emulates only the
  132.   prompting of 'exinput', it does not save the path or DTA, or handle <CR>
  133.   correctly, or any of the other nice TOS 1.4 features.  On the other hand,
  134.   it's only half as big as the full emulator for fsel_exinput(), so it's
  135.   handy for accessories and other small-memory applications.  (It will add
  136.   about 450 bytes to your program, as opposed to 800).        
  137.   
  138.   I'd like to recommend that you do not code calls to fsel_smallexinput()
  139.   directly in your program.  Instead, just code fsel_exinput(), and at the
  140.   top of your C source, code:
  141.   
  142.     #define fsel_exinput fsel_smallexinput
  143.  
  144.   and let the C compiler handle the rest for you.  This ought to keep your
  145.   code compatible many years into the future...
  146.  
  147. ;-------------------------------------------------------------------------
  148. ; fsel_14input              TOS 1.4 (binding compatible with 1.0 and up)
  149. ;-------------------------------------------------------------------------
  150.  
  151.   No emulation.
  152.  
  153.   This function has calling parameters identical to fsel_exinput() (see
  154.   above).  However, it makes no attempt to emulate any of the 1.4 exinput
  155.   features.  Basically, if running on TOS 1.4, fsel_exinput is called.  If
  156.   running on a pre-1.4 system, the prompt string is thrown away, and the
  157.   normal file selector is called.  This binding is very small compared to
  158.   other (emulation mode) exinput bindings.
  159.   
  160.   Again, it is best to access this function through a #define statement:
  161.   
  162.     #define fsel_exinput fsel_14input
  163.  
  164. | This function was added with v1.4.
  165.  
  166. ;-------------------------------------------------------------------------
  167. ; shel_get / shel_put         TOS 1.0
  168. ;-------------------------------------------------------------------------
  169.  
  170.   status = shel_get(char *bufadr, int buflen)
  171.   status = shel_put(char *bufadr, int buflen)
  172.   
  173.           These functions read and write the desktop's internal buffer
  174.           which holds a copy of the DESKTOP.INF file.  The buffer holds
  175.           an exact image of the file, in plain ASCII text.  If 'status'
  176.           is returned as zero, an error occurred.  The Atari docs say that
  177.           the buffer should never exceed 1024 bytes, but I've been told
  178.           that it *can* in fact exceed this length.
  179.  
  180. ;-------------------------------------------------------------------------
  181. ; form_keybd                  TOS 1.0
  182. ;-------------------------------------------------------------------------
  183.  
  184.   keyret = form_keybd(tree, object, nxtobject, thechar, &nxtobject, &thechar);
  185.   
  186.      (All values are 16-bit words, except 'tree', which is OBJECT *).
  187.      
  188.      The form_keybd routine acts as a filter on character input.
  189.      When it  recognizes a control  character,  it processes
  190.      it and zeroes the keyboard word.  Other chararacters can be
  191.      passed on to objc_edit to be inserted in the editable object.  
  192.      If the routine returns a zero, a default object is selected (<CR>).
  193.      (Hints:  If 'nxtobject' is not equal to 'object' after this call,
  194.      form_keybd() has detected a TAB or ARROW key to move to the next
  195.      edit field, so call objc_edit(..., EDEND) for the current field,
  196.      as long as nxtobject is non-zero.  If 'thechar' comes back non-zero,
  197.      pass it to objc_edit(..., EDCHAR).  If this doesn't make sense, get
  198.      the Tim Oren articles and make your own interpretations.)
  199.  
  200. ;-------------------------------------------------------------------------
  201. ; form_button                 TOS 1.0
  202. ;-------------------------------------------------------------------------
  203.  
  204.   btnret = form_button(tree, object, clicks, &nxtobject);
  205.   
  206.      (All values are 16-bit words, except 'tree', which is OBJECT *).
  207.           
  208.      I can't tell you as much about this one.  This routine handles an
  209.      already-occurred mouse button event.  It handles changing the 
  210.      selected object into reverse video.  It (presumably) handles radio
  211.      buttons. 'object' is the index of the object the mouse is over, so
  212.      I presume have have to call objc_find() first to get this. 'nxtobject'
  213.      is the new selected object index.  If the routine returns a zero,
  214.      a default or exit object was selected.
  215.  
  216.  
  217. **************************************************************************
  218. *
  219. * Section 2 - An alternate calling standard, and supporting bindings...
  220. *
  221. **************************************************************************
  222.  
  223. BACKGROUND
  224.  
  225. The calling standard for AES functions defined and documented by DRI was
  226. defined for ease of use in C programming, but it does not lend itself to
  227. particularly efficient code generation.  For example, the wind_get() call
  228. can be used to return many different types of values, so DRI defined the
  229. function as taking pointers to 4 separate output fields.  However, one of 
  230. most common functions for wind_get() is to return information about window
  231. rectangles; the values are returned in typical GRECT order. 
  232.  
  233. In the old days, a call of this type was often coded as:
  234.  
  235.     wind_get(wi_handle, WF_CURRXYWH, &x, &y, &w, &h);
  236.     
  237. As GEM coding techniques have become more sophisticated, people have found
  238. that it makes more sense to keep xywh values in GRECT structures instead of
  239. in discrete variables.  This leads to the rather cumbersome construct:
  240.  
  241.     wind_get(wi_handle, WF_CURRXYWH, 
  242.                 &windrect.g_x, &windrect.g_y,
  243.                 &windrect.g_w, &windrect.g_h);
  244.                 
  245. When ideally, one would prefer to code:
  246.  
  247.     wind_get(wi_handle, WF_CURRXYWH, &windrect);
  248.     
  249. This makes a huge difference in runtime performance.  When the binding for
  250. the original wind_get() routine is called, it has no idea whether discrete
  251. (possibly discontiguous) addresses are passed, so it must build a temporary
  252. output array on the stack in which the AES can pass return values.  Upon 
  253. return from the AES, the binding must copy each of the four return values
  254. back to the caller's memory, using the 4 individual pointers specified.
  255. Using the alternate calling standard, the binding can simply pass the AES
  256. the GRECT pointer specified in the call, and the AES can place the returned
  257. values directly into the caller's memory, avoiding intermediate arrays.
  258. Also, the C compiler only has to stack one address when setting up the call.
  259.  
  260. STANDARDS
  261.  
  262. Because it is not possible to have one function name to handle both types
  263. of calling standards, I have choosen to implement the alternate bindings
  264. using similar names, with an 'x' to indicate it is one of the extended
  265. bindings.  Thus, wind_get() would be called when discrete addresses are
  266. passed, and winx_get() would be called when a single pointer is passed.
  267.  
  268. There will be a certain amount of schizophrenia in the alternate binding
  269. standards.  Some functions (such as evnx_multi) will take all input and
  270. output values in a single consolidated structure.  Others will pass 
  271. discrete input values, but take the return values in a structure, or
  272. vice versa.  I will try to use common sense when making such decisions;
  273. what I want to avoid is the VDI mess.  With VDI calls, you have to load
  274. *everything* into an array, even when it doesn't seem to make sense to 
  275. do so.  I think VDI coding is very tedious for this reason, and I'm going
  276. to try to avoid that with the alternate AES bindings.
  277.  
  278. As an aside:  I've heard rumours that Tim Oren defined an entire alternate
  279. calling structure for the AES under the name GEMX.  Unfortunately, I can't
  280. find out anything about it except that it 'may exist'.  Therefore, nothing
  281. in my alternate calling standards are going to correspond to his, except
  282. by accident.  If anybody has more info on GEMX, I'd love to learn about it.
  283.  
  284. IMPLEMENTATION
  285.  
  286. I had planned to write the entire set of alternate bindings and release
  287. them as GemFast v2.0.  I've been planning that for months, and it isn't
  288. working out.  Therefore, beginning with v1.4, I'm releasing things as I 
  289. go.  As of 1.4, there are only a couple of these extended bindings 
  290. available.
  291.  
  292. The C-source version of the AESFAST utilities (GEMFUTxx.ARC) contains 
  293. versions of the extended AES routines (evnx_multi, et. al.), to provide
  294. code compatibility.  The C versions of these functions do not provide the
  295. speed of the assemblerized versions in AESFAST.A, but they also do not add
  296. more than a few bytes to the size of your program.
  297.  
  298. X-STRUCTURES
  299.  
  300. Where custom data structures are needed by an alternate binding, the
  301. structures will be documented with the binding(s) that use them.  All such
  302. structures are defined in the GEMFAST.H header file.
  303.  
  304. ;-------------------------------------------------------------------------
  305. ; evnx_multi    - Alternate for evnt_multi.
  306. ;-------------------------------------------------------------------------
  307.  
  308.     int evnx_multi(XMULTI *xm);
  309.     
  310.     This binding takes a single parm, a pointer to an XMULTI structure.  It 
  311.     returns an integer, which is a bit mask of events which occurred (the
  312.     same value returned by evnt_multi).  This mask is also returned in 
  313.     the mwhich element of the XMULTI structure.
  314.     
  315.     All of the values normally passed to evnt_multi are included in the
  316.     XMULTI structure.  All of the output values are returned in the XMULTI
  317.     structure, including messages in the message buffer, which is the 1st
  318.     eight words of the XMULTI structure.
  319.     
  320.     The XMULTI structure is defined as follows:
  321.     
  322.         typedef struct xmulti {         
  323.             int     msgbuf[8];          /* Message buffer               */
  324.             int     mflags;             /* Mask of events to wait for   */
  325.             int     mbclicks,           /* Button clicks to wait for    */
  326.                     mbmask,             /* Which buttons to wait for    */
  327.                     mbstate;            /* Button state to wait for     */
  328.             int     mm1flags;           /* M1 rect: wait for in/out flag*/
  329.             GRECT   mm1rect;            /* M1 rect: xywh coordinates    */
  330.             int     mm2flags;           /* M2 rect: wait for in/out flag*/
  331.             GRECT   mm2rect;            /* M2 rect: xywh coordinates    */
  332.             int     mtlocount,          /* Timer count low value        */
  333.                     mthicount;          /* Timer count high value       */
  334.             int     mwhich,             /* Mask of events that occurred */
  335.                     mmox,               /* Mouse x at time of event     */
  336.                     mmoy,               /* Mouse y at time of event     */
  337.                     mmobutton,          /* Mouse buttons at event       */
  338.                     mmokstate,          /* Keystate at event            */
  339.                     mkreturn,           /* Key pressed at event         */
  340.                     mbreturn;           /* Times buttons was clicked    */
  341.         } XMULTI;                       
  342.  
  343.     It is most efficient to code the XMULTI structure as a local variable
  344.     of the function that uses it, although it can be defined as a global
  345.     or static variable.  A simple, typical multi-handler might look like:
  346.     
  347.     multi()
  348.     {
  349.         XMULTI  xm;
  350.         int     events
  351.         
  352.         /* 
  353.          * set up static portions of xm structure...
  354.          */
  355.  
  356.         xm.mflags = MU_TIMER | MU_MESAG | MU_BUTTON;
  357.         
  358.         xm.tlocount = 1000;         /* 1 second     */
  359.         xm.thicount = 0;            /* timer value  */
  360.  
  361.         xm.mbclicks = 1;            /* wait for single  */
  362.         xm.mbmask   = 1;            /* click of left    */
  363.         xm.mbstate  = 1;            /* button           */
  364.  
  365.         while (1) {
  366.  
  367.             events = evnx_multi(&xm);
  368.             
  369.             if (events & MU_BUTTON) {
  370.                 handle_button(xm.mox, xm.moy);
  371.             }
  372.  
  373.             if (events & MU_TIMER) {
  374.                 handle_timeout();
  375.             }
  376.  
  377.             if (events & MU_MESAG) {
  378.                 switch(xm.msgbuf[0]) {
  379.                   case WM_REDRAW:
  380.                     do_redraw(xm.msgbuf[3], &xm.msgbuf[4]);
  381.                     break;
  382.                   case MN_SELECTED:
  383.                     do_menuitem(xm.msgbuf[3], xm.msgbuf[4]);
  384.                     break;
  385.                 /* etc */
  386.                 }               /* end switch           */
  387.             }                   /* end if (MU_MESAG)    */
  388.         }                       /* end while(1)         */
  389.     }                           /* end multi() function */
  390.     
  391.     As can be seen in the example, this can be much more efficient than
  392.     the usual call to evnt_multi, because it is not necessary to stack
  393.     50-some bytes of info on each loop iteration.  Also, the binding for
  394.     envx_multi is *much* smaller and faster than the one for evnt_multi.
  395.     
  396. ;-------------------------------------------------------------------------
  397. ; winx_get          - Alternate for wind_get
  398. ;-------------------------------------------------------------------------
  399.  
  400.     int winx_get(int whandle, int wfield, GRECT *outrect);
  401.     
  402.     This binding takes the same 2 input parms as wind_get; the window 
  403.     handle, and a value indicating the window info to be returned.  For 
  404.     output, it takes a pointer to a GRECT structure.  The return value is
  405.     the same as for wind_get() (0 indicates error).
  406.     
  407.     Note that the pointer to the output doesn't *have* to be a GRECT 
  408.     pointer, it is more specifically a pointer to 4 contiguous words of 
  409.     storage which will hold the return values.  The only wind_get() 
  410.     functions which return more than a single value all return GRECT type
  411.     output, however.  
  412.     
  413.     If winx_get() is called with a wfield value that implies just one 
  414.     return value (WF_TOP, for example), you must be aware that EIGHT BYTES
  415.     OF MEMORY WILL BE MODIFIED at the location pointed to by the output
  416.     pointer.  (All but the first 2 bytes will be garbage, of course).
  417.     
  418.     Usage example:
  419.     
  420.         GRECT currect;
  421.         
  422.             winx_get(wi_handle, WF_CURRXYWH, &currect);
  423.  
  424. ;-------------------------------------------------------------------------
  425. ; winx_calc         - Alternate for wind_calc
  426. ;-------------------------------------------------------------------------
  427.  
  428.     int winx_calc(int type, kind, in_x, in_y, in_w, in_h, GRECT *outrect);
  429.  
  430.     This binding takes all the same input values as wind_calc, but returns
  431.     the output in a GRECT structure.  Note that although the input xywh
  432.     values are listed as discrete in the definition above, your compiler
  433.     will accept the name of a GRECT as the third parameter, and will 
  434.     stack the four values from the rectangle as discrete parms.
  435.     
  436.     The following example might be used to create a window around an
  437.     object tree...
  438.     
  439.         int   wi_kind  = MOVER | FULLER | CLOSER;
  440.         GRECT workrect;
  441.         GRECT fullrect;
  442.  
  443.         frmx_center(tree, &workrect); 
  444.         winx_calc(WC_BORDER, wi_kind, workrect, &fullrect);
  445.         wi_handle = wind_create(wi_kind, fullrect);
  446.         if (wi_handle >= 0)
  447.             wind_open(wi_handle, fullrect);
  448.  
  449. ;-------------------------------------------------------------------------
  450. ; frmx_center        - Alternate for form_center
  451. ;-------------------------------------------------------------------------
  452.  
  453.     int frmx_center(OBJECT *ptree, GRECT *outrect);
  454.  
  455.     This binding takes a pointer to an object tree (as form_center does),
  456.     and a pointer to a GRECT where the output xywh values will be returned.
  457.     The return value from the function is always 1, as for form_center.
  458.     
  459.     Example:
  460.     
  461.         GRECT treerect;
  462.         
  463.         frmx_center(ptree, &treerect);
  464.         objc_draw(ptree, R_TREE, MAX_DEPTH, treerect);
  465.  
  466. ;-------------------------------------------------------------------------
  467. ; v_gchar - Output a single character via a fast call to v_gtext
  468. ;-------------------------------------------------------------------------
  469.  
  470.     void v_gchar(int vdi_handle, int x, int y, char outchar);
  471.  
  472.     This function generates a fast call to v_gtext to output a single
  473.     character.  It is about half the size of the regular v_gtext binding,
  474.     and will execute **much** faster.  It is useful for things like 
  475.     telecomm programs that must do character-at-a-time output to a window.
  476.     
  477. |   This function is new with v1.5.
  478.  
  479.  
  480. **************************************************************************
  481. * END OF GEMXTEND DOC
  482. **************************************************************************
  483.  
  484.