home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Workbench / Libs / GADUTIL.LHA / GadUtil / include / libraries / gadutil.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-21  |  16.8 KB  |  482 lines

  1. #ifndef LIBRARIES_GADUTIL_H
  2. #define LIBRARIES_GADUTIL_H
  3. /*------------------------------------------------------------------------**
  4. **
  5. **    $VER: gadutil.h 36.56 (11.10.95)
  6. **
  7. **    Filename:    libraries/gadutil.h
  8. **    Version:    36.56
  9. **    Date:        29-Sep-95
  10. **
  11. **    GadUtil definitions, a dynamic gadget layout system.
  12. **
  13. **    © Copyright 1994, 1995 by P-O Yliniemi and Staffan Hämälä.
  14. **
  15. **    All Rights Reserved.
  16. **
  17. **------------------------------------------------------------------------*/
  18.  
  19. #ifndef EXEC_TYPES_H
  20. #include <exec/types.h>
  21. #endif
  22.  
  23. #ifndef EXEC_LIBRARIES_H
  24. #include <exec/libraries.h>
  25. #endif
  26.  
  27. #ifndef UTILITY_TAGITEM_H
  28. #include <utility/tagitem.h>
  29. #endif
  30.  
  31. #ifndef INTUITION_INTUITION_H
  32. #include <intuition/intuition.h>
  33. #endif
  34.  
  35. /*------------------------------------------------------------------------**
  36. **
  37. ** Extended gadget types available in GadUtil.library.
  38. **
  39. */
  40.  
  41. #define IMAGE_KIND    50
  42. #define LABEL_KIND    51            /* Not implemented */
  43. #define DRAWER_KIND    52
  44. #define FILE_KIND    53
  45. #define BEVELBOX_KIND    54
  46. #define PROGRESS_KIND    55
  47.  
  48. /*-------------------------- Bevel box frame types -----------------------*/
  49. #define BFT_BUTTON    0    /* Normal button bevel box border */
  50. #define BFT_RIDGE    1    /* STRING_KIND bevel box border      */
  51. #define BFT_DROPBOX    2    /* Icon dropbox type border      */
  52.  
  53. #define BFT_HORIZBAR    10    /* Horizontal shadowed line       */
  54. #define BFT_VERTBAR    11    /* Vertical shadowed line         */
  55.  
  56. /*------------------------- Text placement flags -------------------------*/
  57. #define BB_TEXT_ABOVE    0    /* Place bevel box text above the
  58.                  * upper border   ___ Example ___ */
  59.  
  60. #define BB_TEXT_IN    1    /* Place bevel box text centered at
  61.                  * the upper border --- Example --- */
  62.  
  63. #define BB_TEXT_BELOW    2    /* Place bevel box text below the
  64.                  * upper border   ___        ___
  65.                  *                    Example      */
  66.  
  67. #define BB_TEXT_CENTER    0    /* Place the text centered at the
  68.                  * upper border (default)         */
  69.  
  70. #define BB_TEXT_LEFT    4    /* Place the text left adjusted   */
  71.  
  72. #define BB_TEXT_RIGHT    8    /* Place the text right adjusted  */
  73.  
  74. /*--------------- Alternatives to text placement flags -------------------*/
  75. #define BB_TEXT_ABOVE_CENTER    BB_TEXT_ABOVE|BB_TEXT_CENTER
  76. #define BB_TEXT_ABOVE_LEFT    BB_TEXT_ABOVE|BB_TEXT_LEFT
  77. #define BB_TEXT_ABOVE_RIGHT    BB_TEXT_ABOVE|BB_TEXT_RIGHT
  78.  
  79. #define BB_TEXT_IN_CENTER    BB_TEXT_IN|BB_TEXT_CENTER
  80. #define BB_TEXT_IN_LEFT        BB_TEXT_IN|BB_TEXT_LEFT
  81. #define BB_TEXT_IN_RIGHT    BB_TEXT_IN|BB_TEXT_RIGHT
  82.  
  83. #define BB_TEXT_BELOW_CENTER    BB_TEXT_BELOW|BB_TEXT_CENTER
  84. #define BB_TEXT_BELOW_LEFT    BB_TEXT_BELOW|BB_TEXT_LEFT
  85. #define BB_TEXT_BELOW_RIGHT    BB_TEXT_BELOW|BB_TEXT_RIGHT
  86.  
  87. /*-----------------------Text Shadow placement ---------------------------*/
  88. #define BB_SHADOW_DR    0    /* Place the shadow at x+1, y+1   */
  89. #define BB_SHADOW_UR    16    /* Place the shadow at x+1, y-1   */
  90. #define BB_SHADOW_DL    32    /* Place the shadow at x-1, y+1   */
  91. #define BB_SHADOW_UL    48    /* Place the shadow at x-1, y-1   */
  92.  
  93. /*------------------ Alternatives for shadow placement -------------------*/
  94. #define BB_SUNAT_UL    0    /* Place the shadow at x+1, y+1   */
  95. #define BB_SUNAT_DL    16    /* Place the shadow at x+1, y-1   */
  96. #define BB_SUNAT_UR    32    /* Place the shadow at x-1, y+1   */
  97. #define BB_SUNAT_DR    48    /* Place the shadow at x-1, y-1   */
  98.  
  99. /*------------------------------------------------------------------------**
  100. **
  101. ** This is the structure that actually holds the definition of a single
  102. ** gadget.  It contains the new layout tags defined below, as well as the
  103. ** normal GadTools tags.  You setup all the gadgets in a window by
  104. ** making an array of this structure and passing it to GU_LayoutGadgetsA().
  105. **
  106. */
  107. struct LayoutGadget
  108. {
  109.     WORD    lg_GadgetID;
  110.     struct    TagItem *lg_LayoutTags;
  111.     struct    TagItem *lg_GadToolsTags;
  112.     struct    Gadget *lg_Gadget;
  113. };
  114.  
  115. /*------------------------------------------------------------------------**
  116. **
  117. ** Structure used to hold the built in strings of a localized program. These
  118. ** strings will be used if we couldn't get a string from the catalog.
  119. **
  120. */
  121. struct AppString
  122. {
  123.     LONG    as_ID;            /* String ID              */
  124.     LONG    as_Str;            /* String pointer          */
  125. };
  126.  
  127. /*------------------------------------------------------------------------**
  128. **
  129. ** GadUtil.library is basically an extension to Gadtools.library.  It adds
  130. ** to GadTools the ability to dynamically layout gadgets according to the
  131. ** positions of other gadgets, font size, locale, etc. The goal in designing
  132. ** this was to create a system so that programmers could easily create a GUI
  133. ** that automatically adjusted to a user's environment.
  134. **
  135. ** Every gadget is now defined as a TagList, there is no more need to make
  136. ** use of the NewGadget structure as this taglist allows you to access all
  137. ** fields used in that structure. An array of the TagLists for all your
  138. ** window's gadgets is then passed to GU_LayoutGadgetsA() and your gadget
  139. ** list is created.
  140. */
  141.  
  142. #define GU_TagBase    TAG_USER + 0x60000
  143.  
  144. /*********** Define which kind of gadget we are going to have. ************/
  145.  
  146. #define GU_GadgetKind    GU_TagBase+1    /* Which kind of gadget to make.  */
  147.  
  148.  
  149. /************************ Gadget width control. ***************************/
  150.  
  151. #define GU_Width    GU_TagBase+20    /* Absolute gadget width.      */
  152.  
  153. #define GU_DupeWidth    GU_TagBase+21    /* Duplicate the width of another
  154.                      * gadget.              */
  155.  
  156. #define GU_AutoWidth    GU_TagBase+22    /* Set width according to length
  157.                      * of text label + ti_Data.       */
  158.  
  159. #define GU_Columns    GU_TagBase+23    /* Set width so that approximately
  160.                      * ti_Data columns will fit.      */
  161.  
  162. #define GU_AddWidth    GU_TagBase+24    /* Add some value to the total
  163.                      * width calculation.          */
  164.                       
  165. #define GU_MinWidth    GU_TagBase+25    /* Make sure width is at least this */
  166.  
  167. #define GU_MaxWidth    GU_TagBase+26    /* Make sure width is at most this */
  168.  
  169. #define GU_AddWidChar    GU_TagBase+27    /* Add the width of ti_Data chars
  170.                      *  to the gadget width          */
  171.  
  172. /************************* Gadget height control. *************************/
  173.  
  174. #define GU_Height    GU_TagBase+40    /* Absolute gadget height.       */
  175.  
  176. #define GU_DupeHeight    GU_TagBase+41    /* Duplicate the height of another
  177.                      * gadget.              */
  178.  
  179. #define GU_AutoHeight    GU_TagBase+42    /* Set height according to height
  180.                      * of text font + ti_Data.      */
  181.  
  182. #define GU_HeightFactor    GU_TagBase+43    /* Make the gadget height a
  183.                      * multiple of the font height.      */
  184.  
  185. #define GU_AddHeight    GU_TagBase+44    /* Add some value to the total
  186.                      * height calculation.          */
  187.  
  188. #define GU_MinHeight    GU_TagBase+45    /* Make sure height is at least this */
  189.  
  190. #define GU_MaxHeight    GU_TagBase+46    /* Make sure height is at most this */
  191.  
  192. #define GU_AddHeiLines    GU_TagBase+47    /* Add the height of ti_Data lines
  193.                      *  to the gadget height      */
  194.  
  195. /************************* Gadget top edge control. ***********************/
  196.  
  197. #define GU_Top        GU_TagBase+60    /* Absolute top edge.          */
  198.  
  199. #define GU_TopRel    GU_TagBase+61    /* Top edge relative to bottom
  200.                      * edge of another gadget.      */
  201.  
  202. #define GU_AddTop    GU_TagBase+62    /* Add some value to the final
  203.                      * top edge calculation.      */
  204.  
  205. #define GU_AlignTop    GU_TagBase+63    /* Align top edge of gadget with
  206.                      * top edge of another gadget.      */
  207.  
  208. #define GU_AdjustTop    GU_TagBase+64    /* Add the height of the text font
  209.                      * + ti_Data to the top edge.      */
  210.  
  211. #define GU_AddTopLines    GU_TagBase+65    /* Add the height of ti_Data lines
  212.                      * to the top edge
  213.  
  214. /*********************** Gadget bottom edge control. **********************/
  215.  
  216. #define GU_Bottom    GU_TagBase+80    /* Absolute bottom edge.      */
  217.  
  218. #define GU_BottomRel    GU_TagBase+81    /* Bottom edge relative to top
  219.                      * edge of another gadget.      */
  220.  
  221. #define GU_AddBottom    GU_TagBase+82    /* Add some value to the final
  222.                      * bottom edge calculation.      */
  223.  
  224. #define GU_AlignBottom    GU_TagBase+83    /* Align bottom edge of gadget with
  225.                      * bottom edge of another gadget. */
  226.  
  227. #define GU_AdjustBottom    GU_TagBase+84    /* Subtract the height of the text
  228.                      * font + ti_Data from the top edge */
  229.  
  230. /********************** Gadget left edge control. *************************/
  231.  
  232. #define GU_Left        GU_TagBase+100    /* Absolute left edge.          */
  233.  
  234. #define GU_LeftRel    GU_TagBase+101    /* Left edge relative to right
  235.                      * edge of another gadget.      */
  236.  
  237. #define GU_AddLeft    GU_TagBase+102    /* Add some value to the final
  238.                      * left edge calculation.      */
  239.  
  240. #define GU_AlignLeft    GU_TagBase+103    /* Align left edge of gadget with
  241.                      * left edge of another gadget.      */
  242.  
  243. #define GU_AdjustLeft    GU_TagBase+104    /* Add the width of the text label
  244.                      * + ti_Data to the left edge.      */
  245.  
  246. #define GU_AddLeftChar    GU_TagBase+105    /* Add length of ti_Data characters
  247.                      * to the left edge.          */
  248.  
  249. /********************** Gadget right edge control. ************************/
  250.  
  251. #define GU_Right    GU_TagBase+120    /* Absolute right edge.          */
  252.  
  253. #define GU_RightRel    GU_TagBase+121    /* Right edge relative to left
  254.                      * edge of another gadget.      */
  255.  
  256. #define GU_AddRight    GU_TagBase+122    /* Add some value to the final
  257.                      * right edge calculation.      */
  258.  
  259. #define GU_AlignRight    GU_TagBase+123    /* Align right edge of gadget with
  260.                      * right edge of another gadget.  */
  261.  
  262. #define GU_AdjustRight    GU_TagBase+124    /* Subtract the width of the text
  263.                      * label + ti_Data from the left edge */
  264.  
  265. /******************************* Other tags *******************************/
  266.  
  267. #define GU_ToggleSelect    GU_TagBase+150    /* Create a toggle-select gadget -
  268.                      * only BUTTON_KIND & IMAGE_KIND
  269.  
  270. #define GU_Selected    GU_TagBase+151    /* Set default state of toggle-
  271.                      * select gadget
  272.  
  273. /********* Access to the other fields of the NewGadget structure **********/
  274.  
  275. #define GU_GadgetText    GU_TagBase+160    /* Gadget label.          */
  276.  
  277. #define GU_TextAttr    GU_TagBase+161    /* Desired font for gadget label. */
  278.  
  279. #define GU_Flags    GU_TagBase+162    /* Gadget flags.          */
  280.  
  281. #define GU_UserData    GU_TagBase+163    /* Gadget UserData.          */
  282.  
  283. #define GU_LocaleText    GU_TagBase+164    /* Gadget label taken from a locale. */
  284.  
  285. /*************** Tags for GadUtil's extended gadget kinds. *****************
  286.  
  287. #define GUIM_Image    GU_TagBase+200    /* Image structure for an image
  288.                      * gadget.              */
  289.  
  290. #define GUIM_ReadOnly    GU_TagBase+201    /* TRUE if read-only.          */
  291.  
  292. #define GUIM_SelectImg    GU_TagBase+202    /* Selected image for IMAGE_KIND
  293.                      * gadgets              */
  294.  
  295. #define GUIM_BOOPSILook    GU_TagBase+203    /* Render selected image background
  296.                      * with the fillpen (default = TRUE) */
  297.                      
  298. #define GUBD_Border    GU_TagBase+200    /* Border structure for an border
  299.                      * gadget.              */
  300.  
  301. #define GUBD_ReadOnly    GU_TagBase+201    /* TRUE if read-only.          */
  302.  
  303. #define GUBB_Recessed    GU_TagBase+220    /* TRUE for a recessed bevel box  */
  304.  
  305. #define GUBB_FrameType    GU_TagBase+221    /* Frame type for bevel box      */
  306.  
  307. #define GUBB_TextColor    GU_TagBase+222    /* Color of the title text      */
  308.  
  309. #define GUBB_TextPen    GU_TagBase+223    /* Pen to print title text with -
  310.                      *  overrides GUBB_TextColor      */
  311.  
  312. #define GUBB_Flags    GU_TagBase+224    /* Text placement flags          */
  313.  
  314. #define GUBB_3DText:    GU_TagBase+225    /* Tag to enable 3D text (shadow)
  315.                      *  Not needed if GU_ShadowColor or
  316.                      *  GU_ShadowPen is used      */
  317.  
  318. #define GUBB_ShadowColor GU_TagBase+226 /* Color of the title text's shadow */
  319.  
  320. #define GUBB_ShadowPen    GU_TagBase+227    /* Pen to print the text's shadow
  321.                      *  with - overrides GUBB_ShadowColor */
  322.  
  323. #define GUPR_FillColor    GU_TagBase+240    /* Color of filled part of indicator */
  324.  
  325. #define GUPR_FillPen    GU_TagBase+241    /* Pen to fill the indicator with
  326.                      *  - overrides GUPR_FillColor      */
  327.  
  328. #define GUPR_BackColor    GU_TagBase+242    /* Color of the background of the
  329.                      *  indicator              */
  330.  
  331. #define GUPR_BackPen    GU_TagBase+243    /* Pen to use for the indocator's
  332.                      *  background - overrides
  333.                      *  GUPR_BackColor          */
  334.  
  335. #define GUPR_Current    GU_TagBase+244    /* Current value of the indicator */
  336.  
  337. #define GUPR_Total    GU_TagBase+245    /* Total value for the indicator  */
  338.  
  339. /************** Tags passed directly to GU_LayoutGadgetsA(). **************/
  340.  
  341. #define GU_RightExtreme    GU_TagBase+500    /* ti_Data is a pointer to a LONG
  342.                      * that is used to store the right-
  343.                      * most point that a gadget
  344.                      * will exist in.          */
  345.  
  346. #define GU_LowerExtreme    GU_TagBase+501    /* ti_Data is a pointer to a LONG
  347.                      * that is used to store the lower-
  348.                      * most point that a gadget will
  349.                      * exist in.              */
  350.  
  351. #define GU_Catalog    GU_TagBase+502    /* Indicates locale for the gadgets. */
  352.  
  353.  
  354. #define GU_DefTextAttr    GU_TagBase+503    /* Specifies a default font for use
  355.                      * with all gadgets, can still be
  356.                      * over-ridden with GU_TextAttr.  */
  357.  
  358. #define GU_AppStrings    GU_TagBase+504    /* Application string table w/IDs. */
  359.  
  360. #define GU_BorderLeft    GU_TagBase+505    /* Size of window left border.      */
  361.  
  362. #define GU_BorderTop    GU_TagBase+506    /* Size of window top border.      */
  363.  
  364. #define GU_NoCreate     GU_TagBase+507    /* Don't actually create the gadgets. */
  365.  
  366. #define GU_MimimumIDCMP GU_TagBase+508    /* Minimum required IDCMP, so that
  367.                      *  all gadgets will work      */
  368.  
  369. /***************************** Hotkey tags ********************************/
  370.  
  371. #define GU_Hotkey    GU_TagBase+300    /* Hotkey for gadget (VANILLAKEY) */
  372.  
  373. /********************* Boolean flags for hotkey code **********************/
  374.  
  375. #define GU_HotkeyCase    GU_TagBase+301    /* TRUE for a case-sensitive hotkey */
  376. #define GU_LabelHotkey    GU_TagBase+302    /* TRUE = get hotkey code from label */
  377. #define GU_RawKet    GU_TagBase+303    /* TRUE if hotkey is a RAWKEY code */
  378.  
  379. /*********************** Constants for hotkey support *********************/
  380.  
  381. #define GADUSERMAGIC    0x1122        /* Identification for structure that
  382.                      * the gadgets UserData points to */
  383.  
  384. /******************* Public bit numbers for gu_Flags **********************/
  385.  
  386. #define GU_HOTKEYCASE    0        /* Hoykey is case-sensitive      */
  387. #define GU_RAWKEY    2        /* gu_Code is a RAWKEY code      */
  388.  
  389. #define GU_HOTKEYCASEMASK 1<<GU_HOTKEYCASE /* Mask for GU_HOTKEYCASE bit  */
  390. #define GU_RAWKEYMASK      1<<GU_RAWKEY       /* Mask for GU_RAWKEY bit      */
  391.  
  392. /************** Structure the gadget's UserData points to ******************
  393. *
  394. * This structure is the public part of the allocated data structure for
  395. * hotkeys and IMAGE_KIND gadgets (including FILE_KIND and DRAWER_KIND).
  396. *
  397. * This structure should be considered READ ONLY. The only fields you may
  398. * change is the gu_Code and gu_Flags fields.
  399. *
  400. * DO NOT WRITE ANYTHING BEYOND THIS STRUCTURE WITHOUT ALLOCATING MEMORY FIRST
  401. *
  402. */
  403.  
  404. struct GU_Public
  405. {
  406.     UWORD    gu_Magic;    /* Identification word for structure      */
  407.     ULONG    gu_GadFlags;    /* Flags for GENERIC kind GadUtil gadgets */
  408.     UBYTE    gu_Flags;    /* Flags for the hotkey type          */
  409.     UBYTE    gu_Code;    /* VANILLA or RAWKEY code to react on      */
  410.     WORD    gu_Active;    /* Active entry for some gadget kinds      */
  411.     WORD    gu_MaxVal;    /* Maximum value for some gadgets      */
  412.     WORD    gu_MinVal;    /* Minimum value for some gadgets      */
  413.     ULONG    gu_GadgetType;    /* Gadget type that was created          */
  414. };
  415.  
  416. /*------------------------------------------------------------------------**
  417. **                  Library base                  **
  418. **------------------------------------------------------------------------*/
  419.  
  420. struct GadUtilBase
  421. {
  422.         struct    Library LibNode;
  423.         UBYTE   gub_Flags;        /* Private!              */
  424.     UBYTE    gub_Pad;        /* Private!              */
  425.  
  426.     struct    Library *GadToolsBase;    /* The following library bases      */
  427.     struct    GfxBase    *GfxBase;    /* may be read and used by your      */
  428.     struct    IntuitionBase *IntuitionBase;    /* program          */
  429.     struct    Library *LocaleBase;    /* LocaleBase may be NULL!      */
  430.     struct    Library *UtilityBase;
  431.     struct    Library *DiskFontBase;    /* DiskFontBase may be NULL!      */
  432.     LONG    gub_SegList;        /* Private!              */
  433. };
  434.  
  435. #define GADUTILNAME     "gadutil.library"
  436.  
  437. /*------------------------------------------------------------------------**
  438. **                  BevelBox structure              **
  439. **------------------------------------------------------------------------*/
  440. struct BBoxData
  441. {
  442.     UWORD    bbd_XPos;         /* X position of box          */
  443.     UWORD    bbd_YPos;         /* Y position of box          */
  444.     UWORD    bbd_Width;        /* Width of box              */
  445.     UWORD    bbd_Height;        /* Height of box          */
  446.  
  447.     UWORD    bbd_LeftEdge;        /* Left edge of text          */
  448.     UWORD    bbd_TopEdge;        /* Top edge of text          */
  449.     UWORD    bbd_TextWidth;        /* Pixel width of text          */
  450.  
  451.     struct    TextAttr *bbd_TextFont; /* Font to print text with      */
  452.     STRPTR    bbd_Text;        /* Text to display          */
  453.         
  454.     UBYTE    bbd_FrontPen;        /* Text color              */
  455.     UBYTE    bbd_Flags;        /* Text placement flags          */
  456.     UBYTE    bbd_Recessed;        /* Recessed frame          */
  457.     UBYTE    bbd_FrameType;        /* Type of box frame          */
  458.     UBYTE    bbd_ShadowPen        /* Shadow color              */
  459.     UBYTE    bbd_Reserved1        /* No use in v36.53 - reserved!      */
  460. };
  461.  
  462. /*------------------------------------------------------------------------**
  463. **              ProgressIndicator structure              **
  464. **------------------------------------------------------------------------*/
  465.  
  466. struct ProgressGad
  467. {
  468.     UWORD    pg_XPos            /* X pos of box around gadget      */
  469.     UWORD    pg_YPos            /* Y pos of box around gadget      */
  470.     UWORD    pg_Width        /* Width of box around gadget      */
  471.     UWORD    pg_Height        /* Height of box around gadget      */
  472.     ULONG    pg_Current        /* Current value of indicator      */
  473.     ULONG    pg_Total        /* Total value of indicator      */
  474.     UBYTE    pg_FillColor        /* Color of upto current value      */
  475.     UBYTE    pg_BackColor        /* Color from current to end      */
  476.     UBYTE    pg_Flags        /* Flags              */
  477.     UBYTE    pg_reserved1
  478.     UWORD    pg_XFilledTo        /* Initialized to pg_XPos + 4      */
  479. };
  480.  
  481. #endif /* LIBRARIES_GADUTIL_H */
  482.