home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 432b.lha / EzLib / doc / makeboolgadget.doc < prev    next >
Encoding:
Text File  |  1990-11-11  |  2.6 KB  |  64 lines

  1. FUNCTION    makeboolgadget()   -  create an autosizing boolean gadget
  2.  
  3.      struct Gadget *makeboolgadget(win, l_edge, t_edge, text, id)
  4.               struct Window *win;
  5.               SHORT l_edge, t_edge;
  6.               UBYTE *text;
  7.               USHORT id;
  8.  
  9.     This function will create a boolean gadget in your window.    The gadget
  10. will have your specified text, and id.    The size is calculated
  11. automatically to nicely fit the given text (although there is a minimum
  12. size of 30 pixels).  The return value is a pointer to the created gadget.
  13. You should keep this pointer so that you can later remove the gadget with a
  14. call to killgadget().
  15.  
  16.     The gadget returned is dynamically allocated, so take care to call
  17. killgadget() when you are done with the gadget.  Note that you should call
  18. killgadget() before you call killwindow().
  19.  
  20.     The created gadget will have the id you specify so that you will be
  21. able to determine from your Intuition messages which gadget was pressed.
  22. You should take care to make sure that you will receive the GADGETUP
  23. messages in your window.  Windows created with makewindow() do not receive
  24. these types of messages, however, you can use the Intuition function
  25. ModifyIDCMP() to change this behavior.
  26.  
  27.     The gadgets created by this call are simple box affairs with the
  28. highlight mode set to COMPLEMENT.  The text is centered and should be
  29. offset nicely.    The gadgets are not crowded or otherwise unsightly, except
  30. for being rather plain.
  31.  
  32.     To create a boolean gadget with the text "Click Me", you would do the
  33. following (assuming an already opened window) :
  34.  
  35.     struct Window *win;        /* opened beforehand */
  36.     struct Gadget *click_me;
  37.  
  38.     click_me = makeboolgadget(win, 100, 25, "Click Me", 43);
  39.  
  40.     /* do whatever we want (i.e. main loop, etc...)  */
  41.  
  42.     /* free up gadget resources (i.e. memory) */
  43.     killgadget(win, click_me);
  44.  
  45.     The previous code will create and cause to be displayed an autosized
  46. boolean gadget at 100, 25 which contains the text "Click Me", and has a
  47. gadget ID of 43.  makeboolgadget()  WILL  take care of making sure the
  48. gadget is displayed, so you need not do anything after the return from the
  49. function.  You should however keep track of the allocated gadgets so that
  50. you can properly free their allocated memory.
  51.  
  52.     For the curious, this function calls the lower level function
  53. create_boolgadget() with appropriate values.  It then calls AddGList() and
  54. RefreshGList() to cause the gadget to display.
  55.  
  56. TODO : Really need to make the gadgets more 3d'ish.  They look kinda plain
  57.        now.
  58.  
  59. BUGS : could be, but none that I've seen (fingers crossed)
  60.  
  61. SEE ALSO : create_boolgadget(), killgadget(), makewindow(), getyn(),
  62.        getstring()
  63.  
  64.