home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / c / fldlib93 / fldlib.doc next >
Encoding:
Text File  |  1994-05-21  |  16.1 KB  |  494 lines

  1.                                FLDLIB
  2.                Floating dialogue library for Lattice C
  3.                          v0.93 beta (18/5/94)
  4.  
  5.                          (C) 1994 M.J.Maisey
  6.  
  7.  
  8.                              Introduction
  9.                              ------------
  10.  
  11. FLDLIB was designed to be a very easy to use windowed dialog library
  12. which would  integrate  into existing programs  with the minimum  of
  13. hassle, and which would make writing  simple applications which only
  14. use dialogs very quick.
  15.  
  16. It will  manage as  many floating (windowed) dialogs  as the  AES or
  17. memory allows,  and take care of all event  handling for these wind-
  18. ows.
  19.  
  20. The library has been  written for use  with Lattice C 5. Any port to
  21. another implementation of C  will involve the writing of replacement
  22. wind_redraw and  wind_title functions. Anyone  wishing to distribute
  23. such a port should contact me first.
  24.  
  25.  
  26.                                 General
  27.                                 -------
  28.  
  29. Unless you are using the fld_do() call, you will be dealing with the
  30. floating dialogs via a unique  handle which each will have. You will
  31. also have  to change the  structure of your  program a little to re-
  32. flect the non-modality of the dialog system.
  33.  
  34. All structures, function prototypes and defines are in fldlib.h.
  35.  
  36. fldlib.o (the actual library)  must be linked in to any programs us-
  37. ing it. In Lattice C 5.5 and above this is  done by adding it to the
  38. 'input files' list in the project manager.
  39.  
  40. I apologise  for the use  of the American 'dialog'  throughout these
  41. docs  and this library, but  all GEM documentation I have  seen uses
  42. this spelling!
  43.  
  44.  
  45.                              FLDLIB calls
  46.                              ------------
  47.  
  48. short fld_do(form, title)
  49. OBJECT *form;
  50. char *title;
  51.  
  52. Manages a single form in a window.  No other floating dialogs may be
  53. open.
  54.  
  55. Returns:    Index of clicked object
  56.          OR FLDC_NONE if other dialogs already open or the close box
  57.             on the dialog was clicked.
  58.  
  59. 'tree' is a pointer to the resource tree to be managed.
  60. 'title' is the title of the window to be opened.
  61.  
  62. Notes:
  63.  
  64. This function is ideal for  use by those who wish to manage a single
  65. floating  dialog at a time, in a  modal manner, as  your application
  66. cannot respond to other GEM events while the dialog is open.
  67.  
  68. No setup is  required for the call (e.g. form_dial,  form_center) as
  69. all  setup is done  for you, with  the dialog  being centred  on the
  70. screen.
  71.  
  72. The dialog  is automatically  closed before  the call returns  (e.g.
  73. when an object with  EXIT or TOUCHEXIT  flags set has been selected,
  74. or the close box has been clicked).
  75.  
  76. To initialise close boxes, an fld_ability(FLDA_CLOSE) should be iss-
  77. ued before the fld_do().
  78.  
  79. ----------------------------------------------
  80.  
  81. short fld_open(form, centred, title, type)
  82. OBJECT *form;
  83. short centred, type;
  84. char *title;
  85.  
  86. Opens a floating dialog.
  87.  
  88. Returns:    Handle of floating dialog
  89.          OR -1 if problem
  90.  
  91. 'form' is a pointer to the object tree to be managed.
  92. 'centred' indicates the of centreing to be done before opening
  93.           FLDC_NONE     Do not centre
  94.           FLDC_SCREEN   Centre on screen
  95.           FLDC_MOUSE    Centre on mouse pointer
  96. 'title' is the title of the window to be opened
  97. 'type' can be  any short  int. It is  not used internally by FLDLIB,
  98.        and  is purely for the programmer's benefit.  It will be ret-
  99.        urned by  the floating  dialog management  routines which may
  100.        deal  with more  than one dialog.  If assigned a unique value
  101.        (typically the index of the  resource tree), it can provide a
  102.        clearer  method than  the handle for  differentiating between
  103.        different floating  dialogs (see the examples  for a demonst-
  104.        ration of its use).
  105.  
  106. Notes:
  107.  
  108. This call opens a floating dialog  for use with fld_domulti() or the
  109. fld_key()/fld_mouse()/fld_event combination.  form_dial() et al  are
  110. not required beforehand.
  111.  
  112. If fld_open is called with a form parameter which points to the same
  113. OBJECT as an already open flying dialog, the existing dialog will be
  114. topped and its handle returned.
  115.  
  116. ----------------------------------------------
  117.  
  118. void fld_close(fldhandle)
  119. short fldhandle;
  120.  
  121. Close a floating dialog.
  122.  
  123. 'fldhandle' is the handle of the floating dialog to be closed.
  124.  
  125. Notes:
  126.  
  127. This call closes a floating dialog. It is used with fld_domulti() or
  128. the fld_key/fld_mouse()/fld  event combination. Note that dialogs do
  129. not have to be  explicitly closed before program  exit if fld_exit()
  130. is used.
  131.  
  132. ----------------------------------------------
  133.  
  134. void fld_exit(void)
  135.  
  136. Clean up before program exit.
  137.  
  138. Notes:
  139.  
  140. This call should be used directly before  appl_exit(). It closes all
  141. open floating dialogs and frees the memory malloc'd by the library.
  142.  
  143. ----------------------------------------------
  144.  
  145. short fld_domulti(type, fldhandle)
  146. short *type, *fldhandle;
  147.  
  148. Manage multiple floating dialogs.
  149.  
  150. Returns:    Index of selected object
  151.          OR The negative fldhandle of a closed fldhandle
  152.  
  153. 'type' is filled  in with the type  of the floating  dialog with the
  154.        selected object
  155. 'fldhandle' is filled in with the handle of the floating dialog.
  156.  
  157. Notes:
  158.  
  159. This call manages multiple floating dialogs, which must be previous-
  160. ly opened with fld_open().  It is suitable for use in programs which
  161. only use  floating  dialog windows  and do  not do their  own window
  162. management routines.
  163.  
  164. Floating dialogs are *not* closed when an exit object is clicked on, 
  165. although when fld_ability(FLDA_CLOSE) has been called to enable clo-
  166. ser gadgets, they may  be closed  by the  library  when a closer has
  167. been clicked on.  In this case, a negative  return code will be rec-
  168. ieved by  the application.  This code  will be  the negative of  the
  169. fldhandle of the closed dialogue.
  170.  
  171. ----------------------------------------------
  172.  
  173. short fld_key(kc, type, fldhandle)
  174. short kc, *type, *fldhandle;
  175.  
  176. Respond to keypress from evnt_multi().
  177.  
  178. Returns:    Index of selected object
  179.          OR -1 if none selected.
  180.  
  181. 'kc' is the keypress returned by evnt_multi()
  182. 'type' is filled  in with the type of  the floating dialog  with the
  183.        selected object
  184. 'fldhandle' is filled in with the handle of the floating dialog.
  185.  
  186. Notes:
  187.  
  188. This call  is for use in programs  which wish to  utilise non-dialog
  189. windows as well  as using floating dialogs. It should be used  every
  190. time  a MU_KEYBD event  is received, and will check  if any floating
  191. dialogs are  topped and process  the keypress. It will return -1 and
  192. fill in 'type' and 'fldhandle' if an object has been selected. Curr-
  193. ently, the only way this will arise is if  a default exit button ex-
  194. ists on the dialog and <return> has been pressed.
  195.  
  196. ----------------------------------------------
  197.  
  198. short fld_mouse(x, y, numclicks, type, fldhandle)
  199. short x, y, numclicks, *type, *fldhandle;
  200.  
  201. Respond to button click event from evnt_multi().
  202.  
  203. Returns:    Index of selected object
  204.          OR -1 if none selected.
  205.  
  206. 'x', 'y' and 'numclicks' are returned by evnt_multi()
  207. 'type' is filled  in with the type of  the floating dialog  with the
  208.        selected object
  209. 'fldhandle' is filled in with the handle of the floating dialog.
  210.  
  211. Notes:
  212.  
  213. This call  is for use in programs  which wish to  utilise non-dialog
  214. windows as well  as using floating dialogs. It should be used  every
  215. time a  MU_BUTTON event is received, and will check  if any floating
  216. dialogs are topped and process the click. It will return -1 and fill
  217. in 'type' and 'fldhandle' if an object has been selected.
  218.  
  219. ----------------------------------------------
  220.  
  221. short fld_mesag(msgbuf)
  222. short *msgbuf;
  223.  
  224. Respond to message from evnt_multi().
  225.  
  226. Returns:    FLDR_NONE
  227.          or fldhandle of closed dialog
  228.  
  229. 'msgbuf' is the message buffer filled in by evnt_multi().
  230.  
  231. Notes:
  232.  
  233. This call  is for use in programs  which wish to  utilise non-dialog
  234. windows as well  as using floating dialogs. It should be used  every
  235. time a MU_MESAG event is received.
  236.  
  237. Applications which have called fld_ability(FLDA_CLOSE) should monit-
  238. or the return value  to check whether dialog closer boxes  have been
  239. clicked, as applications are responsible for taking their own action
  240. with  closed dialogue  boxes (typically this will  just  be to  call
  241. fld_close()). It is recommended that closer clicks should be treated
  242. as a 'Cancel' rather than an 'OK'.
  243.  
  244. ----------------------------------------------
  245.  
  246. void fld_draw(fldhandle, startobj, depth)
  247. short fldhandle;
  248. int startobj, int depth;
  249.  
  250. Redraw floating dialog.
  251.  
  252. 'fldhandle' is the handle of the dialog
  253. 'startobj' is the object to start drawing from
  254. 'depth' is the depth to draw to
  255.  
  256. Notes:
  257.  
  258. This call should be used as a  replacement for an objc_draw after an
  259. object's attributes have been changed by the program. Object redraw-
  260. ing is handled by the library at all other times.
  261.  
  262. objc_draw() should *never* be used to redraw floating dialogs.
  263.  
  264. ----------------------------------------------
  265.  
  266. int fld_getwin(fldhandle)
  267. short fldhandle;
  268.  
  269. Find window handle for a given floating dialog.
  270.  
  271. Returns:    AES window handle
  272.          OR NULL if invalid handle
  273.  
  274. 'fldhandle' is the handle for the dialog.
  275.  
  276. Notes:
  277.  
  278. This call provides an easier way  to find the windowhandle of a dia-
  279. log  than poking  around  in the  FLD structures  used internally by
  280. FLDLIB.
  281.  
  282. ----------------------------------------------
  283.  
  284. OBJECT *fld_getform(fldhandle)
  285. short fldhandle;
  286.  
  287. Find object tree for a given floating dialog.
  288.  
  289. Returns:    Pointer to object tree
  290.          OR NULL if invalid handle
  291.  
  292. 'fldhandle' is the handle for the dialog.
  293.  
  294. Notes:
  295.  
  296. This call  provides an easier way to find the tree  used by a float-
  297. ing dialog than poking around  in the FLD structures used internally
  298. by FLDLIB.
  299.  
  300. ----------------------------------------------
  301.  
  302. FLD *fld_getfld(fldhandle)
  303. short fldhandle;
  304.  
  305. Find FLD structure for given handle
  306.  
  307. Returns:    Pointer to FLD structure
  308.          OR NULL if invalid handle
  309.  
  310. 'fldhandle' is the handle for the dialog.
  311.  
  312. Notes:
  313.  
  314. This call might be used to  implement functions not included as part
  315. of the  library - for example, changing the object  tree for a given
  316. dialog, and is also used for patching  in an addition redraw routine
  317. (see below).
  318.  
  319. Changes to the contents of  the FLD structure (particularly the next
  320. and fldhandle members) should be made with EXTREME CAUTION, as it is
  321. possible  to crash the library by  doing this. The FLD  structure is
  322. defined in FLDLIB.H.
  323.  
  324. ----------------------------------------------
  325.  
  326. FLD *fld_findtype(type)
  327. short type;
  328.  
  329. Find FLD structure for given floating dialog type.
  330.  
  331. Returns:    Pointer to FLD structure
  332.          OR NULL if type not found
  333.  
  334. 'type' is the type of the dialog.
  335.  
  336. Notes:
  337.  
  338. This call will help you is you wish to check whether a dialog is op-
  339. en or not without tracking via fldhandles thoughout your program.
  340.  
  341. If there are two  or more open dialogs  with the same type, the  FLD 
  342. structure for the first opened will be returned.
  343.  
  344. ----------------------------------------------
  345.  
  346. FLD *fld_findform(form)
  347. short form;
  348.  
  349. Find FLD structure for given object tree.
  350.  
  351. Returns:    Pointer to FLD structure
  352.          OR NULL if object tree not found
  353.  
  354. 'form' is the pointer to the object tree.
  355.  
  356. Notes:
  357.  
  358. This call will help you is you wish to check whether a dialog is op-
  359. en or not without tracking via fldhandles thoughout your program.
  360.  
  361. ----------------------------------------------
  362.  
  363. void fld_ability(progability)
  364. int progability;
  365.  
  366. Set ability of application to handle more advanced FLDLIB features.
  367.  
  368. 'progability' a bitmask of the ability of the application. Currently
  369.               the only defined values are
  370.               
  371.               FLDA_CLOSE indicating that closer boxes should be ena-
  372.                          bled.
  373.               
  374.               FLDA_ICON  indicating that iconify boxes should be en-
  375.                          abled.
  376.               
  377.           and FLDA_NONE  indicating no extra  abilities.  This value
  378.                          is a placeholder value. It is not currently
  379.                          necessary  to  explicitly call  fld_ability
  380.                          as it is the default.
  381.                         
  382. Notes:
  383.  
  384. FLDA_CLOSE   alters  the  behaviour  of  the  functions  fld_open(),
  385. fld_do, fld_domulti() and  fld_event(). The documentation for  these
  386. functions should be consulted, as  close box handling may need to be
  387. added to your source.
  388.  
  389. FLDA_ICON does not require  any additional handling  in your source.
  390. Iconification is completely handled by the library
  391.  
  392. This function is likely to be used in the future to enable other ad-
  393. ditions to FLDLIB.
  394.  
  395. ----------------------------------------------
  396.  
  397.  
  398.                Adding a customised dialog redraw routine
  399.                -----------------------------------------
  400.                             (Advanced users)
  401.  
  402. A technique that has been fairly widely used with modal dialog boxes
  403. is to just draw graphics  other than those  available as GEM objects
  404. straight over the  dialog. This will not work with windowed dialogs,
  405. which may be pushed to the back and later require redrawing.
  406.  
  407. It should  be noted that to be totally solid, programs should imple-
  408. ment  this  type of  graphic  via  G_USERDEF objects.  However,  the
  409. G_USERDEF system  can be quite  difficult  to use, and hence  FLDLIB
  410. provides an alternative method.
  411.  
  412. Each object  has an FLD structure associated,  which may be obtained
  413. with fld_getfld(). The 'xredraw' member is a pointer to an addition-
  414. al redraw routine for the windowed  dialog. Normally this is NULL (=
  415. no additional  redraw),  but can  be set to a  function to be called
  416. every time a redraw is required. This  is done in the following man-
  417. ner.
  418.  
  419.   fld_getfld(fldhandle)->xredraw = custom_redraw;
  420.  
  421. Where custom_redraw is a function of type:
  422.  
  423.   int custom_redraw(int windowhandle, GRECT *rect)  {
  424.     /* redraw code goes here */
  425.  
  426.     return 1;
  427.   }
  428.  
  429. 'windowhandle' will be irrelevent to custom redraw routines
  430. 'rect' is the clipping rectangle for the redraw
  431.  
  432. The redraw routine should always return 1, unless it wishes to abort
  433. the redraw.  It will  be called once for every  rectangle that needs
  434. redrawing.
  435.  
  436. Three external variables are set during redraws, and are:
  437.  
  438.   OBJECT *fld_tempform;   /* Pointer to the object tree being
  439.                              drawn over */
  440.   int fld_tempstart;      /* Start object for the redraw */
  441.   int fld_tempdepth;      /* Depth of the redraw */
  442.  
  443. These are defined in fldlib.h.
  444.  
  445.  
  446. ------------------------------------------------------
  447.  
  448. I can be contacted by email at
  449.  
  450. Martin_Maisey@standard.embassy.com    (Internet)
  451. Martin Maisey @ 2:2501/101            (Fidonet)
  452. Martin Maisey @ 90:104/0.0            (NeST)
  453. Martin Maisey @ 100:107/6.0           (TurboNet)
  454. Martin Maisey @ 51:504/0.0            (AtariNet)
  455.  
  456. Or by snail-mail at
  457.  
  458. 384 Unthank Rd.
  459. Norwich
  460. Norfolk
  461. NR4 7QE
  462. ENGLAND
  463.  
  464. Updates  to the library  will be made available via  the normal file
  465. echos.
  466.  
  467. Please report any bugs or suggestions to me ASAP.
  468.  
  469. ----------------------------------------------
  470.  
  471. FLDLIB is freeware. It may be distributed under the following condi-
  472. tions:
  473.  
  474. 1)  No  profit  may  be made  from the  distribution of  FLDLIB. Any
  475.     charge made must be no more than the cost of distribution.
  476.  
  477. 2)  The files  FLDLIB.C, FLDLIB.O, FLDLIB.H  and FLDLIB.DOC must all
  478.     be present in the distribution.
  479.  
  480. 3)  The software is copyright, and modified versions may not be dis-
  481.     tributed without the prior permission of the author.
  482.  
  483. 4)  The author may not be held  responsible for any damage resulting
  484.     directly or indirectly from the use of this software.
  485.  
  486. 5)  The  freeware status of  FLDLIB does not  mean that any programs 
  487.     using FLDLIB (which distributed without FLDLIB documentation and
  488.     with FLDLIB  in binary form only)  need necessarily be freeware.
  489.     However, if such programs  are to be distributed, FLDLIB must be
  490.     credited either in  the documentation or in the main program. If
  491.     such programs are to be distributed  to the profit of the author 
  492.     or any other  party, a copy of  the program must  be sent to the 
  493.     author.
  494.