home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / oberon-a-1.4ß.lha / Oberon-A / source / amiga / GadTools.mod < prev    next >
Text File  |  1994-08-08  |  25KB  |  736 lines

  1. (***************************************************************************
  2.  
  3.      $RCSfile: GadTools.mod $
  4.   Description: Interface to gadtools.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.2 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 01:11:04 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1989-1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A interface Copyright © 1994, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. ***************************************************************************)
  21.  
  22. MODULE GadTools;
  23.  
  24. (*
  25. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  26. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  27. ** $V- OvflChk       $Z- ZeroVars
  28. *)
  29.  
  30. IMPORT
  31.   E := Exec, U := Utility, G := Graphics, I := Intuition, SYS := SYSTEM;
  32.  
  33.  
  34. (*
  35. **      $VER: gadtools.h 39.9 (19.8.92)
  36. **
  37. **      gadtools.library definitions
  38. *)
  39.  
  40. (* -----------------------------------------------------------------------*)
  41.  
  42. (*  The kinds (almost classes) of gadgets in the toolkit.  Use these
  43.     identifiers when calling CreateGadgetA() *)
  44.  
  45. CONST
  46.  
  47.   genericKind *    = 0;
  48.   buttonKind *     = 1;
  49.   checkBoxKind *   = 2;
  50.   integerKind *    = 3;
  51.   listViewKind *   = 4;
  52.   mxKind *         = 5;
  53.   numberKind *     = 6;
  54.   cycleKind *      = 7;
  55.   paletteKind *    = 8;
  56.   scrollerKind *   = 9;
  57. (* Kind number 10 is reserved *)
  58.   sliderKind *     = 11;
  59.   stringKind *     = 12;
  60.   textKind *       = 13;
  61.  
  62.   numKinds *       = 14;
  63.  
  64. (* -----------------------------------------------------------------------*)
  65.  
  66. CONST
  67.  
  68. (*  'Or' the appropriate set together for your Window IDCMPFlags: *)
  69.  
  70.   arrowIdcmp *      =
  71.     { I.idcmpGadgetUp, I.idcmpGadgetDown, I.idcmpIntuiTicks, I.idcmpMouseButtons };
  72.  
  73.   buttonIdcmp *     = { I.idcmpGadgetUp };
  74.   checkBoxIdcmp *   = { I.idcmpGadgetUp };
  75.   integerIdcmp *    = { I.idcmpGadgetUp };
  76.   listViewIdcmp *   =
  77.     { I.idcmpGadgetUp, I.idcmpGadgetDown, I.idcmpMouseMove } + arrowIdcmp;
  78.  
  79.   mxIdcmp *         = { I.idcmpGadgetDown };
  80.   numberIdcmp *     = {};
  81.   cycleIdcmp *      = { I.idcmpGadgetUp };
  82.   paletteIdcmp *    = { I.idcmpGadgetUp };
  83.  
  84. (*  Use ArrowIdcmp + ScrollerIdcmp if your scrollers have arrows: *)
  85.   scrollerIdcmp *   =
  86.     { I.idcmpGadgetUp, I.idcmpGadgetDown, I.idcmpMouseMove };
  87.   sliderIdcmp *     =
  88.     { I.idcmpGadgetUp, I.idcmpGadgetDown, I.idcmpMouseMove };
  89.   stringIdcmp *     = { I.idcmpGadgetUp };
  90.  
  91.   textIdcmp *       = {};
  92.  
  93. (* -----------------------------------------------------------------------*)
  94.  
  95. TYPE
  96.  
  97.   VisualInfo * = CPOINTER TO RECORD END;
  98.  
  99. (*  Generic NewGadget used by several of the gadget classes: *)
  100.  
  101.   NewGadgetPtr * = CPOINTER TO NewGadget;
  102.   NewGadget * = RECORD
  103.     leftEdge *,
  104.     topEdge *    : INTEGER;       (*  gadget position *)
  105.     width *,
  106.     height *     : INTEGER;       (*  gadget size *)
  107.     gadgetText * : E.STRPTR;      (*  gadget label *)
  108.     textAttr *   : G.TextAttrPtr; (*  desired font for gadget label *)
  109.     gadgetID *   : E.UWORD;       (*  gadget ID *)
  110.     flags *      : SET;           (*  see below *)
  111.     visualInfo * : VisualInfo;    (*  Set to retval of GetVisualInfo() *)
  112.     userData *   : E.APTR;        (*  gadget UserData *)
  113.   END; (* NewGadget *)
  114.  
  115.  
  116. CONST
  117.  
  118. (* flags control certain aspects of the gadget.  The first five control
  119.  * the placement of the descriptive text.  Each gadget kind has its default,
  120.  * which is usually placeTextLeft.  Consult the autodocs for details.
  121.  *)
  122.  
  123.   placeTextLeft *  = 0;  (* Right-align text on left side *)
  124.   placeTextRight * = 1;  (* Left-align text on right side *)
  125.   placeTextAbove * = 2;  (* Center text above *)
  126.   placeTextBelow * = 3;  (* Center text below *)
  127.   placeTextIn *    = 4;  (* Center text on *)
  128.  
  129.   ngHighLabel *    = 5;  (* Highlight the label *)
  130.  
  131. (* -----------------------------------------------------------------------*)
  132.  
  133. TYPE
  134.  
  135. (* Fill out an array of these and pass that to CreateMenus(): *)
  136.  
  137.   NewMenuPtr * = CPOINTER TO NewMenu;
  138.   NewMenu * = RECORD
  139.     type *          : SHORTINT; (*  See below *)
  140.     (* Compiler inserts a PAD byte here *)
  141.     label *         : E.STRPTR; (*  Menu's label *)
  142.     commKey *       : E.STRPTR; (*  MenuItem Command Key Equiv *)
  143.     flags *         : E.WSET;   (*  Menu or MenuItem flags (see note) *)
  144.     mutualExclude * : SET;      (*  MenuItem MutualExclude word *)
  145.     userData *      : E.APTR;   (*  For your own use, see note *)
  146.   END; (* NewMenu *)
  147.  
  148. CONST
  149.  
  150. (* Needed only by inside im* definitions below *)
  151.   menuImage * = -128;
  152.  
  153. (* type determines what each NewMenu structure corresponds to.
  154.  * for the nmTitle, nmItem, and nmSub values, label should
  155.  * be a text string to use for that menu title, item, or sub-item.
  156.  * For imItem or imSub, set label to point at the Image structure
  157.  * you wish to use for this item or sub-item.
  158.  * NOTE: At present, you may only use conventional images.
  159.  * Custom images created from Intuition image-classes do not work.
  160.  *)
  161.   nmTitle *        = 1;
  162.   nmItem *         = 2;
  163.   nmSub *          = 3;
  164.  
  165.   imItem *         = nmItem + menuImage;
  166.   imSub *          = nmSub  + menuImage;
  167.  
  168. (* The NewMenu array should be terminated with a NewMenu whose
  169.  * type equals nmEnd.
  170.  *)
  171.   nmEnd * = 0;                  (* End of NewMenu array *)
  172.  
  173. (* Starting with V39, GadTools will skip any NewMenu entries whose
  174.  * ype field has the nmIgnore bit set.
  175.  *)
  176.   nmIgnore * = 64;
  177.  
  178.  
  179. (* nm_Label should be a text string for textual items, a pointer
  180.  * to an Image structure for graphical menu items, or the special
  181.  * constant nmBarlabel, to get a separator bar.
  182.  *)
  183.   nmBarLabel *     = SYS.VAL(E.STRPTR, -1);
  184.  
  185.  
  186. (*  The nmFlags field is used to fill out either the Menu.flags or
  187.     MenuItem.flags field.  Note that the sense of the menuEnabled or
  188.     itemEnabled bit is inverted between this use and Intuition's use,
  189.     in other words, NewMenus are enabled by default.  The following
  190.     labels are provided to disable them: *)
  191.   nmMenuDisabled * = I.menuEnabled;
  192.   nmItemDisabled * = I.itemEnabled;
  193.  
  194. (* New for V39:  nmCommandString.  For a textual MenuItem or SubItem,
  195.  * point commKey at an arbitrary string, and set the nmCommandString
  196.  * flag.
  197.  *)
  198.   nmCommandString * = I.commSeq;
  199.  
  200. (* The following are pre-cleared (commSeq, itemText, and highxxx are set
  201.  * later as appropriate):
  202.  * Under V39, the commSeq flag bit is not cleared, since it now has
  203.  * meaning.
  204.  *)
  205.   nmFlagMask *     = -({ I.commSeq, I.itemText } + I.highFlags);
  206.   nmFlagMaskV39 *  = -({I.itemText} + I.highFlags);
  207.  
  208.  
  209. (*  You may choose among checkIt, menuToggle, and checked.
  210.     Toggle-select menuitems are of type checkIt | menuToggle, along
  211.     with checked if currently selected.  Mutually exclusive ones
  212.     are of type checkIt, and possibly checked too.  The nmMutualExclude
  213.     is a bit-wise representation of the items excluded by this one,
  214.     so in the simplest case (choose 1 among n), these flags would be
  215.     ~1, ~2, ~4, ~8, ~16, etc.  See the Intuition Menus chapter. *)
  216.  
  217. (* A UserData pointer can be associated with each Menu and MenuItem structure.
  218.  * The CreateMenus() call allocates space for a UserData after each
  219.  * Menu or MenuItem (header, item or sub-item).  You should use the
  220.  * GTMENU_USERDATA() or GTMENUITEM_USERDATA() macro to extract it.
  221.  *)
  222.  
  223. (*
  224. #define GTMENU_USERDATA(menu) ( * ( (APTR * )(((struct Menu * )menu)+1) ) )
  225. #define GTMENUITEM_USERDATA(menuitem) ( * ( (APTR * )(((struct MenuItem * )menuitem)+1) ) )
  226.  
  227. (* Here is an old one for compatibility.  Do not use in new code! *)
  228. #define MENU_USERDATA(menuitem) ( * ( (APTR * )(menuitem+1) ) )
  229. *)
  230.  
  231. (*  These return codes can be obtained through the gtmnSecondaryError tag *)
  232.   menuTrimmed *  = 00000001H;      (* Too many menus, items, or subitems,
  233.                                            menu has been trimmed down *)
  234.   menuInvalid *  = 00000002H;      (* Invalid NewMenu array *)
  235.   menuNoMem *    = 00000003H;      (* Out of memory *)
  236.  
  237. (*------------------------------------------------------------------------*)
  238.  
  239. (* Starting with V39, checkboxes and mx gadgets can be scaled to your
  240.  * specified gadget width/height.  Use the new cbScaled or mxScaled
  241.  * tags, respectively.  Under V37, and by def