home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d911 / gadoutline.lha / GadOutline / Examples / example3.c < prev    next >
C/C++ Source or Header  |  1993-10-03  |  66KB  |  1,828 lines

  1.  
  2. #include <graphics/gfxmacros.h>
  3. #include <proto/graphics.h>
  4. #include <proto/gadtools.h>
  5. #include <proto/exec.h>
  6. #include <proto/dos.h>
  7. #include <proto/intuition.h>
  8. #include <proto/utility.h>
  9. #include <proto/asl.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12.  
  13. #ifndef LINKLIB
  14.     #include "proto/gadoutline.h"
  15. #else
  16.     #include "libraries/gadoutline.h"
  17.     #include "interface.h"
  18. #endif
  19.  
  20. #ifdef DEBUGMODULE
  21.     
  22.     #include "support/debug.h"
  23.  
  24. #else
  25.  
  26.     void __stdargs kprintf(UBYTE *fmt,...);  // Serial debugging...
  27.     void __stdargs dprintf(UBYTE *fmt,...);  // Parallel debugging...
  28.  
  29.     #ifndef bug
  30.     #define bug Printf
  31.     #endif
  32.  
  33.     #ifndef DEBTIME
  34.     #define DEBTIME 0
  35.     #endif
  36.  
  37.     #ifdef DEBUG
  38.     #define D(x) (x); if(DEBTIME>0) Delay(DEBTIME);
  39.     #else
  40.     #define D(x) ;
  41.     #endif
  42.  
  43. #endif
  44.  
  45. /*********************************************
  46.  **
  47.  ** Main window outline support data
  48.  **
  49.  *********************************************/
  50.  
  51. // This is a list of IDs to assign to each command (gadget) in the outline.
  52. // Because almost all references to the outline are made through IDs rather
  53. // than pointers, you will need to assign IDs to most commands, including
  54. // any command that has a hotkey attached.  (Hotkeys are stored internally
  55. // as just the ID number of the command that a hotkey is attached to, so
  56. // if it doesn't have a number the library is unable to find the command
  57. // to send an CHM_HOTKEY message to it.)
  58.  
  59. // These "standard" ID codes can range from 1 to 4095; the value of 0 means
  60. // "no ID code," and the upper 20 bits of the ID are used for storing
  61. // "group" ID codes.  Every command which is given a non-zero standard ID
  62. // must be the only command in the outline with that ID; the library will
  63. // report an error if it finds more than one command with the same ID.
  64.  
  65. enum {
  66.  
  67.     // Top-left list with attached string gadget.
  68.     INFOLIST_ID = 1,
  69.     INFOEDIT_ID,
  70.  
  71.     // Top-right area demoing the operation of group IDs.
  72.     WHICHGROUP_ID,
  73.     GRPBUT1_ID,
  74.     GRPBUT2_ID,
  75.     GRPBUT3_ID,
  76.     GRPBUT4_ID,
  77.     GRPBUT5_ID,
  78.     GRPBUT6_ID,
  79.     GRPBUT7_ID,
  80.  
  81.     // Palette ID codes.
  82.     SCRNPALKEY_ID,
  83.     SCRNPAL_ID,
  84.     PALREDKEY_ID,
  85.     PALRED_ID,
  86.     PALGREENKEY_ID,
  87.     PALGREEN_ID,
  88.     PALBLUEKEY_ID,
  89.     PALBLUE_ID,
  90.     PALDEPTH_ID,
  91.  
  92.     // Font control gadgets.
  93.     SETFONT_ID,
  94.     FONTNAME_ID,
  95.     FONTSIZE_ID,
  96.     MINSIZE_ID,
  97.     
  98.     SCALEFONT_ID,
  99.     SYSFONT_ID,
  100.     ROMFONT_ID,
  101.     DISKFONT_ID,
  102.  
  103.     CURFNAME_ID,
  104.     CURFSIZE_ID,
  105.  
  106.     // String gadget to select screen for window.
  107.     PUBSCREEN_ID,
  108.  
  109.     // Gadget to select the library call to use when resizing.
  110.     REMAKE_ID,
  111.  
  112.     // Gadgets to demo enabling and disabling the creation of
  113.     // gadgets and whether they are ignored during layout.
  114.     ONOFFALLC_ID,
  115.     ONOFFALLD_ID,
  116.     BOOGRP_ID,
  117.  
  118.     ONOFF1_ID,
  119.     BOO1_ID,
  120.     HERE1_ID,
  121.  
  122.     ONOFF2A_ID,
  123.     ONOFF2B_ID,
  124.     BOO2A_ID,
  125.     BOO2B_ID,
  126.     HERE2_ID,
  127.  
  128.     ONOFF3A_ID,
  129.     ONOFF3B_ID,
  130.     BOO3A_ID,
  131.     BOO3B_ID,
  132.     HERE3_ID
  133.             
  134. };
  135.  
  136. // These are the group IDs for the group demo gadgets.  A group ID is
  137. // the upper 20 bits of a standard ID, divided itself into two parts.
  138. // The lower 8 bits are a code to assign to the command; unlike the
  139. // standard ID, multiple commands may have the same group code.  The
  140. // other 12 bits are organized as a mask - by setting individual bits
  141. // in the mask, you tell whether the command belongs to the group with
  142. // that bit set.  When refering to a group, a zero in either the mask
  143. // or code means to "match all."  So a group ID of "1" would match
  144. // every command with the group ID code of 1, no matter what its mask
  145. // value is.  An ID of "GO_GRPID_A" would match every commad with its
  146. // GO_GRPID_A bit set, no matter what its code is, and an ID of
  147. // "GO_GRPID_A | 1" would match only those commands with both a mask
  148. // of GO_GRPID_A and a code of 1.
  149.  
  150. #define DEMOGRP_GID GO_GRPID_A      // The demo group mask.
  151. #define DEMOGRP1_GID 1              // Code 1 for this group mask.
  152. #define DEMOGRP2_GID 2              // Code 2 for this group mask.
  153. #define DEMOGRP3_GID 3              // Code 3 for this group mask.
  154.  
  155. // Space to allocate for strings.
  156. #define STRING_LEN 100
  157.  
  158. // These are the string arrays for the cycle and mx gadgets.
  159.  
  160. UBYTE *PalDepths[] = {
  161.     "2 pen",
  162.     "4 pen",
  163.     "8 pen",
  164.     "16 pen",
  165.     "32 pen",
  166.     "64 pen",
  167.     NULL
  168. };
  169.  
  170. UBYTE *GroupLabels[] = {
  171.     "All Enabled",
  172.     "Grp1 Enabled",
  173.     "Grp2 Enabled",
  174.     "Grp3 Enabled",
  175.     NULL
  176. };
  177.  
  178. UBYTE *ResizeTypes[] = {
  179.     "Dimen",
  180.     "Rebuild",
  181.     "Resize",
  182.     NULL
  183. };
  184.  
  185. // This tag list is located outside of the outline because
  186. // it is fairly long and used by multiple commands.  However,
  187. // when the GadOutline structure is created, space is reserved
  188. // to track these tags just like the tags directly included
  189. // in the outline.
  190.  
  191. struct TagItem pal_slider_obj_tags[] =
  192. {
  193.     { GA_RelVerify, TRUE },
  194.     { GA_Immediate, TRUE },
  195.     { PGA_FREEDOM, LORIENT_HORIZ },
  196.     { GTSL_Min, 0 },
  197.     { GTSL_Max, 15 },
  198.     { GTSL_Level, 0 },
  199.     { GTSL_LevelFormat, (ULONG)&"%02ld" },
  200.     { GTSL_LevelPlace, PLACETEXT_LEFT },
  201.     { GTSL_MaxLevelLen, 2 },
  202.     { TAG_END, 0 }
  203. };
  204.  
  205. // This is the data used to make the folder icon.  We first define some
  206. // of the important locations within the icon (which makes it easier to
  207. // design and to later modify), and then create a list of tags which
  208. // describe the drawing operations needed to create it.
  209.  
  210. #define FL_LEFT 12
  211. #define FL_MIDLEFT 30
  212. #define FL_TOP 12
  213. #define FL_MIDTOP 22
  214. #define FL_BOTTOM 51
  215. #define FL_RIGHT 51
  216. #define FL_BOLDEN 5
  217.  
  218. #define FL_TABLEFT FL_MIDLEFT+5
  219. #define FL_TABRIGHT FL_RIGHT-5
  220. #define FL_TABBOTTOM FL_MIDTOP+FL_BOLDEN+6
  221.  
  222. static ULONG FolderDrawing[] = {
  223.     GODT_FillRect, GO_SCLPNT(BACKGROUNDPEN,0,0,63,63),
  224.     GODT_DrawStdFrame, GO_SCLPNT(SHINEPEN,0,0,63,63),
  225.     GODT_FillRect,
  226.         GO_SCLPNT(TEXTPEN,FL_LEFT,FL_MIDTOP,FL_LEFT+FL_BOLDEN,FL_BOTTOM),
  227.     GODT_FillRect,
  228.         GO_SCLPNT(TEXTPEN,FL_LEFT,FL_MIDTOP,FL_MIDLEFT,FL_MIDTOP+FL_BOLDEN),
  229.     GODT_MoveTo,
  230.         GO_SCLPNT(0,FL_MIDLEFT,FL_MIDTOP,0,0),
  231.     GODT_DrawTo2,
  232.         GO_SCLPNT(TEXTPEN,FL_TABLEFT,FL_TOP,FL_TABRIGHT,FL_TOP),
  233.     GODT_DrawTo2,
  234.         GO_SCLPNT(TEXTPEN,FL_RIGHT,FL_MIDTOP,FL_RIGHT,FL_BOTTOM),
  235.     GODT_DrawTo,
  236.         GO_SCLPNT(TEXTPEN,FL_LEFT,FL_BOTTOM,0,0),
  237.     GODT_MoveTo,
  238.         GO_SCLPNT(0,FL_MIDLEFT,FL_MIDTOP+FL_BOLDEN,0,0),
  239.     GODT_DrawTo2,
  240.         GO_SCLPNT(TEXTPEN,FL_TABLEFT,FL_TABBOTTOM,FL_RIGHT,FL_TABBOTTOM),
  241.     TAG_END, 0
  242. };
  243.  
  244. /*********************************************
  245.  **
  246.  ** Main window gadget outline
  247.  **
  248.  *********************************************/
  249.  
  250. // This is the main outline structure.  It is simply an array of ULONGs,
  251. // organized as a series of commands.  Each command may have up to 8
  252. // parameters and 3 tag lists, although currently the library only
  253. // does anything with the first two tag lists.  The first tag list
  254. // is always a list of outline commands (GOCT_*) used to control the
  255. // command - see the header file for information on these.  The
  256. // interpretation of the second tag list depends on the command type --
  257. // It may be a list of GadTools tags, Window tags, Screen tags, GOCT_
  258. // tags to add to the command tag list of following commands, etc.
  259.  
  260. // When the outline is created, all of the supplied parameters and tag
  261. // lists are copied and used to track the state of the gadgets.  Because
  262. // only the state of tags directly supplied to the outline are tracked,
  263. // you will need to make sure you include GTST_String, GTCY_Active,
  264. // GTCY_Labels, etc., even if you do not set them until the gadgets have
  265. // been created.  If these are not included, during a resize and other
  266. // times that the gadgets need to be rebuilt, they will revert to their
  267. // default values.
  268.  
  269. // NOTE!!!!!  _ALL_ tag lists in the outline MUST end with a TAG_END.
  270. // The library does not consider a TAG_MORE, or anything else, a list
  271. // terminator.  So when you use TAG_MORE, it will look like this:
  272. //
  273. // ..., TAG_MORE, (ULONG)&more_tags, TAG_END, NEW_COMMAND(), ...
  274.  
  275. static ULONG outline[] = {
  276.  
  277. // Default GadOutline GOA_ type tags.  These tags are immediately parsed
  278. // when this command is encountered just as if they were passed to
  279. // AllocGadOutline().
  280.  
  281. GO_OUTLINETAGS(0,0),
  282.  
  283.     TAG_END,                        // 1st tag list -- no command tags.
  284.     GOA_AutoNewSize,    FALSE,      // 2nd tag list -- new outline tags.
  285.     GOA_FontMinSize,    4,
  286.     GOA_ClearFullWin,   TRUE,       // Because our outside group has a border.
  287.     GOA_BaseName,       (ULONG)&"GadOutline Example3",
  288.     TAG_END,
  289.  
  290. // Default window tags.  These are supplied as defaults when GO_OpenWindow()
  291. // is called; they will be overridden by any tags passed directly to the
  292. // function call.  Only include this command once.
  293.  
  294. GO_WINDOWTAGS(0,0),
  295.  
  296.     TAG_END,                        // 1st tag list -- no command tags.
  297.     WA_IDCMP,           IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW | IDCMP_NEWSIZE,
  298.     WA_Activate,        TRUE,
  299.     WA_CloseGadget,     TRUE,
  300.     WA_DepthGadget,     TRUE,
  301.     WA_DragBar,         TRUE,
  302.     WA_SizeGadget,      TRUE,
  303.     WA_SizeBBottom,     TRUE,
  304.     WA_ReportMouse,     TRUE,
  305.     WA_SimpleRefresh,   TRUE,
  306.     TAG_END,
  307.  
  308. // Global command tags -- Added to the first tag list (command list)
  309. // of every command which follows this.  Space will be allocated to track
  310. // their state just as if they were directly supplied to the command.
  311.  
  312. GO_COMMANDTAGS(0,0),
  313.  
  314.     TAG_END,
  315.     GOCT_SetHotKey, 0,      // Automatically set hot key code
  316.     GOCT_SetUserHook, 1,    // Set user hook to translation 1
  317.                             // (Computed in translation hook below.)
  318.     TAG_END,
  319.  
  320. // Start the layout.  A layout is organized as a recursive collection
  321. // of "groups."  A group can be either horizontal or vertical, and may
  322. // contain both actual boxes or other groups.
  323.  
  324. // Initial group.  No GrpID, no StdID, give it all the weight.
  325. // A 'VDraw' group is simply a vertical group with a second tag list
  326. // of standard drawing commands.  We can use them to create a frame
  327. // around the group.
  328. GO_VDRAWGRP(0,0,1),
  329.  
  330. // Command tags to set the space around the group.  GOM_PadSet means
  331. // to directly set the amount of padding [padding is space that the
  332. // library is allowed to remove to make a layout fit within its bounds.]
  333. // GOT_PercCharH and GOT_PercCharW are the "type" units - in this case,
  334. // we are asking for 100 Percent of a character height and width.
  335.  
  336. GOCT_SizeSpaceAbove, GO_TSIZE(GOM_PadSet,100,GOT_PercCharH),
  337. GOCT_SizeSpaceBelow, GO_TSIZE(GOM_PadSet,100,GOT_PercCharH),
  338. GOCT_SizeSpaceLeft, GO_TSIZE(GOM_PadSet,100,GOT_PercCharW),
  339. GOCT_SizeSpaceRight, GO_TSIZE(GOM_PadSet,100,GOT_PercCharW),
  340. TAG_END,
  341.  
  342. // Now the second tag list of drawing commands.  DrawGroups are always
  343. // initialized with their drawing boundaries set to the space frame
  344. // around the group, since this is normally where you will be drawing.
  345. // GO_SCLPNT is a macro that creates the standard data format for
  346. // drawing commands.  Its arguments are a standard pen [0 to 15]
  347. // and two pairs of coordinates, whose values each range from 0 to 63
  348. // and are interpreted as 'x/63 of the current drawing boundaries.'
  349. // Frame boundaries, the default for groups, split this 0 to 63 value
  350. // further into left/top and right/bottom sides; 0 to 31 will place you
  351. // in the left/top part of the frame and 32 to 63 in the right/bottom.
  352. // This command essentially says, "draw a raised frame halfway between
  353. // the beginning and ending of the space area."  Note that to get a
  354. // recessed border, you just specify the SHADOWPEN, which causes the
  355. // placement of the light/dark colors to be inverted.
  356. GODT_DrawStdFrame, GO_SCLPNT(SHINEPEN,16,16,48,48),
  357. TAG_END,
  358.  
  359.     // Top vertical slice of initial group -- divide into horizontal slices.
  360.     GO_HORIZGRP(0,0,1), TAG_END,
  361.  
  362.         // Left horizontal slide -- divide into vertical slices.
  363.         GO_VERTGRP(0,0,1),
  364.         GOCT_SizeSpaceRight, GO_TSIZE(GOM_PadSet,50,GOT_PercCharW),
  365.         TAG_END,
  366.         
  367.             // Create a GadTools box.  The parameters are, in order,
  368.             // GadTools Kind, GrpID, StdID, Weight, Label, Flags.
  369.             GO_GTBOX(LISTVIEW_KIND, 0, INFOLIST_ID, 1, (ULONG)&"_Information",
  370.                 PLACETEXT_ABOVE|NG_HIGHLABEL),
  371.  
  372.                 // Set the minimum size that the listview's body can be.
  373.                 // GOM_StdMax means to set the standard size [the bare
  374.                 // minimum size of the box] to the maximum of its current
  375.                 // value and the new value being supplied.
  376.                 GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdMax,700,GOT_PercCharW),
  377.                 GOCT_SizeBodyHeight, GO_TSIZE(GOM_StdMax,300,GOT_PercCharH),
  378.                 
  379.                 // Link this object to another.  This tag tells the library
  380.                 // to point the GTLV_ShowSelected tag in this command's
  381.                 // second/object/GadTools taglist to the object created
  382.                 // by the INFOEDIT_ID command.  This object's creation will
  383.                 // be deferred until the object it is linked to has been
  384.                 // created; if that object is never created, this one won't
  385.                 // be either.
  386.                 
  387.                 GOCT_AddTagLink, GO_MAKELINK(GTLV_ShowSelected,INFOEDIT_ID),
  388.                 
  389.                 // Point hotkey events to the INFOEDIT_ID command.  The
  390.                 // standard GadTools hook automatically sets the command's
  391.                 // hotkey by examining its label text; this allows us to
  392.                 // keep that automatic hotkey while making the hotkey
  393.                 // actually refer to a different command.
  394.                 GOCT_SetHotKeyCmd, INFOEDIT_ID,
  395.                 TAG_END,
  396.                 
  397.                 // Start of the second - GadTools - taglist.  These are the
  398.                 // tags which will be tracked by the library.
  399.                 GTLV_Selected, ~0,
  400.                 GTLV_Labels, NULL,
  401.                 GTLV_ShowSelected, NULL,
  402.                 GT_Underscore, '_',
  403.                 TAG_END,
  404.  
  405.             // Create a string gadget.  This is the gadget that the
  406.             // previous ListView has a TagLink to.
  407.             GO_GTBOX(STRING_KIND, 0, INFOEDIT_ID, 0, NULL, 0),
  408.  
  409.                 // Tell the library to ignore this box's dimensions
  410.                 // when computing both the minimum size of the layout
  411.                 // and the final position of all the boxes.
  412.                 GOCT_IgnoreMinDimens, TRUE, GOCT_IgnoreFinDimens, TRUE,
  413.                 TAG_END,
  414.                 
  415.                 // Set GadTools tags.  The standard hook looks for
  416.                 // GTST_MaxChars and allocates a buffer of that size to track
  417.                 // the string gadget's value.  It currently does _NOT_ change
  418.                 // the size of this buffer to match a change in this tag,
  419.                 // so make sure you leave plenty of room here.
  420.                 GTST_MaxChars, STRING_LEN,
  421.                 GTST_String, (ULONG)&"",
  422.                 TAG_END,
  423.  
  424.         // End the last vertical group.
  425.         GO_ENDGRP(),
  426.  
  427.         // Start a new vertical group -- directly to left of last group.
  428.         GO_VERTGRP(0,0,0),
  429.         
  430.         // This tag tells the library to exactly align all of the box's
  431.         // label areas, space areas and bodies.
  432.         GOCT_FitToGroup, TRUE,
  433.         TAG_END,
  434.         
  435.             GO_GTBOX(CYCLE_KIND, 0, WHICHGROUP_ID, 0, (ULONG)&"Gr_oup Demo",
  436.                 PLACETEXT_ABOVE|NG_HIGHLABEL),
  437.  
  438.                 /** The CYCLE_KIND minimum dimension hook is now implemented. :)
  439.  
  440.                 // Set up information about the array of strings supplied
  441.                 // in the tag "GTCY_Labels" in the second tag list.
  442.                 GOCT_TextArrayTag, GTCY_Labels,
  443.                 
  444.                 // Set user variable 1 to the maximum width of all of these
  445.                 // strings.
  446.                 GOCT_SizeUser1, GO_TSIZE(GOM_StdSet,100,GOT_PercTextMaxW),
  447.                 
  448.                 // Add 4 pixels to the value in User1.
  449.                 GOCT_SizeUser1, GO_TSIZE(GOM_StdAdd,4,GOT_Pixels),
  450.                 
  451.                 // Set the body width to the maximum of its current value
  452.                 // and the Std value in User1.
  453.                 GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdMax,100,GOT_PercMdUser1),
  454.                 
  455.                 // Add 20 pixels for the cycle imagery.  We have now supplied
  456.                 // all of the information needed to determine the minimum
  457.                 // size of this gadget.  We had to go to all of this work
  458.                 // because the library's standard gadtools hook for cycle
  459.                 // gadget isn't finished yet...  But this makes a nice
  460.                 // example, anyway... ;)
  461.                 GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdAdd,20,GOT_Pixels),
  462.  
  463.                 **/
  464.  
  465.                 TAG_END,
  466.                 GTCY_Labels, (ULONG)&GroupLabels[0],
  467.                 GTCY_Active, 0,
  468.                 GT_Underscore, '_',
  469.                 TAG_END,
  470.  
  471.             // Create the group demo buttons.
  472.             GO_GTBOX(BUTTON_KIND, DEMOGRP_GID | DEMOGRP1_GID, GRPBUT1_ID, 0,
  473.                 (ULONG)&"G1-A", PLACETEXT_LEFT),
  474.  
  475.                 TAG_END,
  476.                 
  477.                 // We need to track these gadget's disabled state.
  478.                 GA_Disabled, FALSE,
  479.                 TAG_END,
  480.  
  481.             GO_GTBOX(BUTTON_KIND, DEMOGRP_GID | DEMOGRP2_GID, GRPBUT2_ID, 0,
  482.                 (ULONG)&"G2-A", PLACETEXT_RIGHT),
  483.  
  484.                 TAG_END,
  485.                 GA_Disabled, FALSE,
  486.                 TAG_END,
  487.  
  488.             GO_HORIZGRP(0,0,0), TAG_END,
  489.         
  490.                 GO_GTBOX(BUTTON_KIND, DEMOGRP_GID | DEMOGRP1_GID, GRPBUT3_ID, 0,
  491.                     (ULONG)&"G1-B", PLACETEXT_ABOVE),
  492.  
  493.                     TAG_END,
  494.                     GA_Disabled, FALSE,
  495.                     TAG_END,
  496.  
  497.                 GO_GTBOX(BUTTON_KIND, DEMOGRP_GID | DEMOGRP3_GID, GRPBUT4_ID, 0,
  498.                     (ULONG)&"G3-A", PLACETEXT_BELOW),
  499.  
  500.                     TAG_END,
  501.                     GA_Disabled, FALSE,
  502.                     TAG_END,
  503.  
  504.             GO_ENDGRP(),
  505.             
  506.             GO_HORIZGRP(0,0,0), TAG_END,
  507.         
  508.                 GO_GTBOX(BUTTON_KIND, DEMOGRP_GID | DEMOGRP3_GID, GRPBUT5_ID, 0,
  509.                     (ULONG)&"G3-B", PLACETEXT_LEFT),
  510.  
  511.                     TAG_END,
  512.                     GA_Disabled, FALSE,
  513.                     TAG_END,
  514.  
  515.                 GO_GTBOX(BUTTON_KIND, DEMOGRP_GID | DEMOGRP2_GID, GRPBUT6_ID, 0,
  516.                     (ULONG)&"G2-B BIG", PLACETEXT_RIGHT),
  517.  
  518.                     TAG_END,
  519.                     GA_Disabled, FALSE,
  520.                     TAG_END,
  521.  
  522.             GO_ENDGRP(),
  523.  
  524.             GO_GTBOX(BUTTON_KIND, DEMOGRP_GID, GRPBUT7_ID, 0,
  525.                 (ULONG)&"La Zero", PLACETEXT_IN),
  526.  
  527.                 TAG_END,
  528.                 GA_Disabled, FALSE,
  529.                 TAG_END,
  530.  
  531.         GO_ENDGRP(),
  532.  
  533.     GO_ENDGRP(),
  534.  
  535.     // Second line of root group.
  536.     GO_HORIZGRP(0,0,1), TAG_END,
  537.  
  538.         GO_VERTGRP(0,0,1), TAG_END,
  539.         
  540.             GO_GTBOX(TEXT_KIND, 0, SCRNPALKEY_ID, 0,
  541.                 (ULONG)&"Flexi-_Palette (TM)",PLACETEXT_IN|NG_HIGHLABEL),
  542.  
  543.                 GOCT_SetHotKeyCmd, SCRNPAL_ID,
  544.                 TAG_END,
  545.                 GT_Underscore, '_',
  546.                 TAG_END,
  547.  
  548.             GO_HORIZGRP(0,0,1), TAG_END,
  549.  
  550.                 GO_VERTGRP(0,0,1), TAG_END,
  551.                 
  552.                     GO_GTBOX(PALETTE_KIND, 0, SCRNPAL_ID, 1, NULL, 0),
  553.  
  554.                         // Set up an initial value for the indicator.
  555.                         GOCT_CopyFromTSize, GO_TSIZE(GOM_Set,15,GOT_Pixels),
  556.                         GOCT_CopyTSizeToTag, GTPA_IndicatorHeight,
  557.                     
  558.                         // Compute a nice size for the palette's indicator.
  559.                         GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdMax,500,GOT_PercCharW),
  560.                         GOCT_SizeUser1, GO_TSIZE(GOM_VarSet,20,GOT_PercBodyH),
  561.                         GOCT_SizeUser1, GO_TSIZE(GOM_VarMin,250,GOT_PercCharH),
  562.                         GOCT_SizeUser1, GO_TSIZE(GOM_VarMax,6,GOT_Pixels),
  563.                         
  564.                         // Copy value in User1 to GTPA_IndicatorHeight tag.
  565.                         GOCT_CopyUser1ToTag, GTPA_IndicatorHeight,
  566.                         TAG_END,
  567.  
  568.                         GTPA_IndicatorHeight, 15,
  569.                         GTPA_Color, 0,
  570.                         GTPA_Depth, 2,
  571.                         TAG_END,
  572.  
  573.                     GO_HORIZGRP(0,0,0), TAG_END,
  574.  
  575.                         GO_GTBOX(SLIDER_KIND, 0, PALRED_ID, 1, NULL, 0),
  576.  
  577.                             GOCT_SizeSpaceRight, GO_TSIZE(GOM_AllSet,0,GOT_Pixels),
  578.                             TAG_END,
  579.                             TAG_MORE, (ULONG)&pal_slider_obj_tags,
  580.                             TAG_END,
  581.  
  582.                         GO_GTBOX(TEXT_KIND, 0, PALREDKEY_ID, 0, (ULONG)&"_R",
  583.                             PLACETEXT_IN|NG_HIGHLABEL),
  584.  
  585.                             // No space between this box and one to left.
  586.                             GOCT_SizeSpaceLeft, GO_TSIZE(GOM_AllSet,0,GOT_Pixels),
  587.  
  588.                             GOCT_SetHotKeyCmd, PALRED_ID,
  589.                             TAG_END,
  590.                             GTTX_Border, TRUE,
  591.                             GT_Underscore, '_',
  592.                             TAG_END,
  593.  
  594.                     GO_ENDGRP(),
  595.  
  596.                     GO_HORIZGRP(0,0,0), TAG_END,
  597.             
  598.                         GO_GTBOX(SLIDER_KIND, 0, PALGREEN_ID, 1, NULL, 0),
  599.  
  600.                             GOCT_SizeSpaceRight, GO_TSIZE(GOM_AllSet,0,GOT_Pixels),
  601.                             TAG_END,
  602.                             TAG_MORE, (ULONG)&pal_slider_obj_tags,
  603.                             TAG_END,
  604.  
  605.                         GO_GTBOX(TEXT_KIND, 0, PALGREENKEY_ID, 0, (ULONG)&"_G",
  606.                             PLACETEXT_IN|NG_HIGHLABEL),
  607.  
  608.                             GOCT_SizeSpaceLeft, GO_TSIZE(GOM_AllSet,0,GOT_Pixels),
  609.                             GOCT_SetHotKeyCmd, PALGREEN_ID,
  610.                             TAG_END,
  611.                             GTTX_Border, TRUE,
  612.                             GT_Underscore, '_',
  613.                             TAG_END,
  614.  
  615.                     GO_ENDGRP(),
  616.                     
  617.                     GO_HORIZGRP(0,0,0), TAG_END,
  618.             
  619.                         GO_GTBOX(SLIDER_KIND, 0, PALBLUE_ID, 1, NULL,
  620.                             0),
  621.  
  622.                             GOCT_SizeSpaceRight, GO_TSIZE(GOM_AllSet,0,GOT_Pixels),
  623.                             TAG_END,
  624.                             TAG_MORE, (ULONG)&pal_slider_obj_tags,
  625.                             TAG_END,
  626.  
  627.                         GO_GTBOX(TEXT_KIND, 0, PALBLUEKEY_ID, 0, (ULONG)&"_B",
  628.                             PLACETEXT_IN|NG_HIGHLABEL),
  629.  
  630.                             GOCT_SizeSpaceLeft, GO_TSIZE(GOM_AllSet,0,GOT_Pixels),
  631.                             GOCT_SetHotKeyCmd, PALBLUE_ID,
  632.                             TAG_END,
  633.                             GTTX_Border, TRUE,
  634.                             GT_Underscore, '_',
  635.                             TAG_END,
  636.  
  637.                     GO_ENDGRP(),
  638.  
  639.                 GO_ENDGRP(),
  640.  
  641.                 GO_GTBOX(MX_KIND, 0, PALDEPTH_ID, 0, NULL,
  642.                     PLACETEXT_RIGHT),
  643.  
  644.                     // Note that the library hook expects an Mx's body to be
  645.                     // the width of both the gadget's labels AND buttons.  It
  646.                     // then figures out the correct values to give GadTools.
  647.  
  648.                     // Set up an initial value for the spacing.
  649.                     GOCT_CopyFromTSize, GO_TSIZE(GOM_Set,0,GOT_Pixels),
  650.                     GOCT_CopyTSizeToTag, GTMX_Spacing,
  651.                     
  652.                     // This ugly thing puts spacing between the labels
  653.                     // so that the Mx gad's size is close to its actual
  654.                     // body size.  This is probably about as complicated
  655.                     // as you want to get before writing a user hook...
  656.                     // And this will probably be implemented in the hook
  657.                     // at some point... ;)
  658.                     
  659.                     GOCT_TextArrayTag, GTMX_Labels,
  660.                     GOCT_SizeUser1, GO_TSIZE(GOM_VarSet,100,GOT_PercBodyH),
  661.                     GOCT_SizeUser1, GO_TSIZE(GOM_VarAdd,-100,GOT_PercTextAddH),
  662.                     GOCT_SizeUser2, GO_TSIZE(GOM_VarSet,100,GOT_PercTextAddL),
  663.                     GOCT_SizeUser2, GO_TSIZE(GOM_VarAdd,-1,GOT_Pixels),
  664.                     GOCT_SizeUser1, GO_TSIZE(GOM_VarDiv,100,GOT_PercMdUser2),
  665.                     GOCT_SizeUser1, GO_TSIZE(GOM_VarMax,0,GOT_Pixels),
  666.                     GOCT_CopyUser1ToTag, GTMX_Spacing,
  667.                     
  668.                     // Directly set the hotkey.
  669.                     GOCT_SetHotKey, '`',
  670.                     TAG_END,
  671.  
  672.                     GA_Immediate, TRUE,
  673.                     GTMX_Spacing, 1,
  674.                     GTMX_Labels, (ULONG)&PalDepths[0],
  675.                     GTMX_Active, 1,
  676.                     TAG_END,
  677.  
  678.             GO_ENDGRP(),
  679.         
  680.         GO_ENDGRP(),
  681.         
  682.         GO_VERTGRP(0,0,1), TAG_END,
  683.         
  684.             // This box has a special weight distribution.  Normally,
  685.             // the library assigns all extra space in a box to its
  686.             // body.  "GO_WEIGHT(0,GO_WDIST(1,0,0,0,0,0),1)" says to
  687.             // use this default for the horizontal spacing, but assign
  688.             // all of the extra vertical space to the box's space above
  689.             // area -- GO_WDIST(spcabv,txtabv,body,txtblw,spcblw,leftover).
  690.             GO_GTBOX(STRING_KIND, 0, FONTNAME_ID,
  691.                 GO_WEIGHT(0,GO_WDIST(1,0,0,0,0,0),1),
  692.                 (ULONG)&"Selected _Font",PLACETEXT_ABOVE|NG_HIGHLABEL),
  693.  
  694.                 GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdMax,500,GOT_PercCharW),
  695.                 TAG_END,
  696.                 GTST_MaxChars, 100, GTST_String, (ULONG)&"",
  697.                 GT_Underscore, '_',
  698.                 TAG_END,
  699.  
  700.             // We turn GOCT_FitToGroup on here so that the drawing box
  701.             // will have the exact same vertical dimensions as the
  702.             // string gadget.
  703.             GO_HORIZGRP(0,0,0), GOCT_FitToGroup, TRUE, TAG_END,
  704.             
  705.                 GO_GTBOX(INTEGER_KIND, 0, FONTSIZE_ID, 1, (ULONG)&"_Size",
  706.                     PLACETEXT_LEFT|NG_HIGHLABEL),
  707.  
  708.                     GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdAdd,300,GOT_PercCharW),
  709.                     TAG_END,
  710.                     GTIN_MaxChars, 3, GTIN_Number, 0,
  711.                     GT_Underscore, '_',
  712.                     TAG_END,
  713.  
  714.                 // Create a folder drawing.  The drawing box has no
  715.                 // default dimensions (except the the standard space area
  716.                 // around it), so we must explicately tell it
  717.                 // how big we want it to be.
  718.                 GO_DRAWBOX(GOSD_BoopsiGad,0,SETFONT_ID,0),
  719.  
  720.                     GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdSet,4,GOT_Pixels),
  721.                     GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdAdd,200,GOT_PercCharW),
  722.                     GOCT_SizeBodyWidth, GO_TSIZE(GOM_PadSet,4,GOT_Pixels),
  723.                     GOCT_SetHotKey, 'e',
  724.                     
  725.                     // Define the drawing.  Here we just set our boundaries
  726.                     // to be the box's body size, and then "execute" the
  727.                     // previously defined folder drawing.  GODT_ExecDrawing
  728.                     // is something like TAG_MORE, except that the tags it
  729.                     // points to are not included in the command's local
  730.                     // tag list to have their state tracks - just the pointer
  731.                     // to our previously defined static tag list is stored.
  732.                     // This removes a lot of possible memory overhead in
  733.                     // allocating all of the tags to track their state.  In
  734.                     // addition, GODT_ExecDrawing does not stop the tag list;
  735.                     // this command may be followed by other commands, even
  736.                     // other GODT_ExecDrawings.
  737.                     TAG_END,
  738.                     GODT_ExecDrawing, (ULONG)&FolderDrawing[0],
  739.                     TAG_END,
  740.             
  741.             GO_ENDGRP(),
  742.  
  743.             GO_HORIZGRP(0,0,0), TAG_END,
  744.             
  745.                 GO_GTBOX(INTEGER_KIND, 0, MINSIZE_ID, 1, (ULONG)&"_Min Size",
  746.                     PLACETEXT_LEFT|NG_HIGHLABEL),
  747.  
  748.                     GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdAdd,300,GOT_PercCharW),
  749.                     TAG_END,
  750.                     GTIN_MaxChars, 3, GTIN_Number, 4,
  751.                     GT_Underscore, '_',
  752.                     TAG_END,
  753.  
  754.             GO_ENDGRP(),
  755.     
  756.             GO_HORIZGRP(0,0,0), TAG_END,
  757.             
  758.                 GO_GTBOX(TEXT_KIND, 0, 0, 0, (ULONG)&"Font",
  759.                     PLACETEXT_IN|NG_HIGHLABEL),
  760.  
  761.                     TAG_END,
  762.                     GTTX_Border, FALSE,
  763.                     TAG_END,
  764.                     
  765.                 GO_VERTGRP(0,0,0), TAG_END,
  766.                 
  767.                     GO_GTBOX(CHECKBOX_KIND, 0, SCALEFONT_ID, 0, (ULONG)&"S_cl",
  768.                         PLACETEXT_RIGHT),
  769.  
  770.                         TAG_END,
  771.                         GT_Underscore, '_',
  772.                         GTCB_Checked, TRUE,
  773.                         TAG_END,
  774.     
  775.                     GO_GTBOX(CHECKBOX_KIND, 0, SYSFONT_ID, 0, (ULONG)&"S_ys",
  776.                         PLACETEXT_RIGHT),
  777.  
  778.                         TAG_END,
  779.                         GT_Underscore, '_',
  780.                         GTCB_Checked, FALSE,
  781.                         TAG_END,
  782.     
  783.                 GO_ENDGRP(),
  784.  
  785.                 GO_VERTGRP(0,0,0), TAG_END,
  786.                 
  787.                     GO_GTBOX(CHECKBOX_KIND, 0, DISKFONT_ID, 0, (ULONG)&"_Dsk",
  788.                         PLACETEXT_RIGHT),
  789.  
  790.                         TAG_END,
  791.                         GT_Underscore, '_',
  792.                         GTCB_Checked, TRUE,
  793.                         TAG_END,
  794.     
  795.                     GO_GTBOX(CHECKBOX_KIND, 0, ROMFONT_ID, 0, (ULONG)&"ROM",
  796.                         PLACETEXT_RIGHT),
  797.  
  798.                         TAG_END,
  799.                         GT_Underscore, '_',
  800.                         GTCB_Checked, FALSE,
  801.                         TAG_END,
  802.                         
  803.                 GO_ENDGRP(),
  804.     
  805.             GO_ENDGRP(),
  806.  
  807.             GO_GTBOX(STRING_KIND, 0, PUBSCREEN_ID,
  808.                 GO_WEIGHT(0,GO_WDIST(0,0,0,0,1,0),1),
  809.                 (ULONG)&"P_ubScreen", PLACETEXT_ABOVE|NG_HIGHLABEL),
  810.  
  811.                 GOCT_SizeSpaceAbove, GO_TSIZE(GOM_PadSet,50,GOT_PercCharH),
  812.                 GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdMax,500,GOT_PercCharW),
  813.                 TAG_END,
  814.                 GT_Underscore, '_',
  815.                 GTST_MaxChars, 100, GTST_String, (ULONG)&"",
  816.                 TAG_END,
  817.  
  818.         GO_ENDGRP(),
  819.  
  820.         GO_VERTGRP(0,0,0), TAG_END,
  821.     
  822.             // Another way to get the same effect as the previously
  823.             // discussed weight distribution - put an empty box above
  824.             // that is assigned all of the group's weight.
  825.             GO_EMPTYBOX(0,0,1),
  826.  
  827.                 GOCT_SizeSpaceAbove, GO_TSIZE(GOM_BaseSet,0,GOT_Pixels),
  828.                 GOCT_SizeSpaceBelow, GO_TSIZE(GOM_BaseSet,0,GOT_Pixels),
  829.                 TAG_END,
  830.  
  831.             GO_GTBOX(CYCLE_KIND, 0, REMAKE_ID,
  832.                 GO_WEIGHT(GO_WDIST(1,0,0,0,1,0),0,0),
  833.                 (ULONG)&"Si_ze Mode", PLACETEXT_LEFT|NG_HIGHLABEL),
  834.  
  835.                 GOCT_TextArrayTag, GTCY_Labels,
  836.                 GOCT_SizeUser1, GO_TSIZE(GOM_StdSet,100,GOT_PercTextMaxW),
  837.                 GOCT_SizeUser1, GO_TSIZE(GOM_StdAdd,4,GOT_Pixels),
  838.                 GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdMax,100,GOT_PercMdUser1),
  839.                 GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdAdd,20,GOT_Pixels),
  840.                 TAG_END,
  841.                 GT_Underscore, '_',
  842.                 GTCY_Labels, (ULONG)&ResizeTypes[0],
  843.                 GTCY_Active, 0,
  844.                 TAG_END,
  845.  
  846.             GO_GTBOX(TEXT_KIND, 0, CURFNAME_ID, 0, (ULONG)&"Font",
  847.                 PLACETEXT_LEFT),
  848.  
  849.                 GOCT_SizeSpaceAbove, GO_TSIZE(GOM_PadSet,50,GOT_PercCharH),
  850.                 GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdMax,500,GOT_PercCharW),
  851.                 TAG_END,
  852.                 GTTX_Border, TRUE, GTTX_Text, (ULONG)&"",
  853.                 TAG_END,
  854.  
  855.             GO_GTBOX(NUMBER_KIND, 0, CURFSIZE_ID, 0, (ULONG)&"Curr Size",
  856.                 PLACETEXT_LEFT),
  857.  
  858.                 GOCT_SizeBodyWidth, GO_TSIZE(GOM_StdAdd,300,GOT_PercCharW),
  859.                 TAG_END,
  860.                 GTNM_Border, TRUE, GTNM_Number, 0,
  861.                 TAG_END,
  862.  
  863.             GO_EMPTYBOX(0,0,1),
  864.  
  865.                 GOCT_SizeSpaceAbove, GO_TSIZE(GOM_BaseSet,0,GOT_Pixels),
  866.                 GOCT_SizeSpaceBelow, GO_TSIZE(GOM_BaseSet,0,GOT_Pixels),
  867.                 TAG_END,
  868.  
  869.             GO_HORIZGRP(0,0,0), TAG_END,
  870.         
  871.                 GO_GTBOX(CHECKBOX_KIND, 0, ONOFFALLC_ID,
  872.                     GO_WEIGHT(GO_WDIST(0,0,0,0,1,0),0,1),
  873.                     (ULONG)&"Crea_te", PLACETEXT_RIGHT),
  874.             
  875.                     TAG_END,
  876.                     GT_Underscore, '_',
  877.                     GTCB_Checked, TRUE,
  878.                     TAG_END,
  879.  
  880.                 GO_GTBOX(CHECKBOX_KIND, 0, ONOFFALLD_ID,
  881.                     GO_WEIGHT(GO_WDIST(0,0,0,0,1,0),0,1),
  882.                     (ULONG)&"Dime_n", PLACETEXT_RIGHT),
  883.             
  884.                     TAG_END,
  885.                     GT_Underscore, '_',
  886.                     GTCB_Checked, TRUE,
  887.                     TAG_END,
  888.  
  889.             GO_ENDGRP(),
  890.  
  891.             GO_VERTGRP(0,BOOGRP_ID,0),
  892.         
  893.                 GOCT_IgnoreFinDimens, FALSE, GOCT_IgnoreCreation, FALSE,
  894.                 TAG_END,
  895.  
  896.                 GO_HORIZGRP(0,0,0), TAG_END,
  897.             
  898.                     GO_GTBOX(CHECKBOX_KIND, 0, ONOFF1_ID, 0, NULL, 0),
  899.             
  900.                         GOCT_SetHotKey, '1',
  901.                         TAG_END,
  902.                         GTCB_Checked, TRUE,
  903.                         TAG_END,
  904.  
  905.                     GO_GTBOX(BUTTON_KIND, 0, BOO1_ID, 1,
  906.                         (ULONG)&"B", PLACETEXT_IN),
  907.  
  908.                         GOCT_IgnoreCreation, FALSE,
  909.                         TAG_END,
  910.                         TAG_END,
  911.  
  912.                     GO_GTBOX(BUTTON_KIND, 0, HERE1_ID, 0,
  913.                         (ULONG)&"<", PLACETEXT_IN),
  914.  
  915.                         TAG_END,
  916.                         TAG_END,
  917.  
  918.                 GO_ENDGRP(),
  919.  
  920.                 GO_HORIZGRP(0,0,0), TAG_END,
  921.             
  922.                     GO_GTBOX(CHECKBOX_KIND, 0, ONOFF2A_ID, 0, NULL, 0),
  923.             
  924.                         GOCT_SetHotKey, '2',
  925.                         TAG_END,
  926.                         GTCB_Checked, TRUE,
  927.                         TAG_END,
  928.  
  929.                     GO_GTBOX(CHECKBOX_KIND, 0, ONOFF2B_ID, 0, NULL, 0),
  930.             
  931.                         GOCT_SetHotKey, '3',
  932.                         TAG_END,
  933.                         GTCB_Checked, TRUE,
  934.                         TAG_END,
  935.  
  936.                     GO_GTBOX(BUTTON_KIND, 0, BOO2A_ID, 0,
  937.                         (ULONG)&"B", PLACETEXT_IN),
  938.  
  939.                         GOCT_IgnoreFinDimens, FALSE, GOCT_IgnoreCreation, FALSE,
  940.                         TAG_END,
  941.                         TAG_END,
  942.  
  943.                     GO_GTBOX(BUTTON_KIND, 0, BOO2B_ID, 0,
  944.                         (ULONG)&"B", PLACETEXT_IN),
  945.  
  946.                         GOCT_IgnoreFinDimens, FALSE, GOCT_IgnoreCreation, FALSE,
  947.                         TAG_END,
  948.                         TAG_END,
  949.  
  950.                     GO_EMPTYBOX(0,0,1),
  951.  
  952.                         GOCT_SizeSpaceLeft, GO_TSIZE(GOM_BaseSet,0,GOT_Pixels),
  953.                         GOCT_SizeSpaceRight, GO_TSIZE(GOM_BaseSet,0,GOT_Pixels),
  954.                         TAG_END,
  955.     
  956.                     GO_GTBOX(BUTTON_KIND, 0, HERE2_ID, 0,
  957.                         (ULONG)&"<", PLACETEXT_IN),
  958.  
  959.                         TAG_END,
  960.                         TAG_END,
  961.  
  962.                 GO_ENDGRP(),
  963.  
  964.                 GO_HORIZGRP(0,0,0), TAG_END,
  965.             
  966.                     GO_GTBOX(CHECKBOX_KIND, 0, ONOFF3A_ID, 0, NULL, 0),
  967.             
  968.                         GOCT_SetHotKey, '4',
  969.                         TAG_END,
  970.                         GTCB_Checked, TRUE,
  971.                         TAG_END,
  972.  
  973.                     GO_GTBOX(CHECKBOX_KIND, 0, ONOFF3B_ID, 0, NULL, 0),
  974.                 
  975.                         GOCT_SetHotKey, '5',
  976.                         TAG_END,
  977.                         GTCB_Checked, TRUE,
  978.                         TAG_END,
  979.  
  980.                     GO_GTBOX(BUTTON_KIND, 0, BOO3A_ID, 1,
  981.                         (ULONG)&"B", PLACETEXT_IN),
  982.  
  983.                         GOCT_IgnoreFinDimens, FALSE, GOCT_IgnoreCreation, FALSE,
  984.                         TAG_END,
  985.                         TAG_END,
  986.  
  987.                     GO_GTBOX(BUTTON_KIND, 0, BOO3B_ID, 1,
  988.                         (ULONG)&"B", PLACETEXT_IN),
  989.  
  990.                         GOCT_IgnoreFinDimens, FALSE, GOCT_IgnoreCreation, FALSE,
  991.                         TAG_END,
  992.                         TAG_END,
  993.  
  994.                     GO_GTBOX(BUTTON_KIND, 0, HERE3_ID, 1,
  995.                         (ULONG)&"<", PLACETEXT_IN),
  996.  
  997.                         TAG_END,
  998.                         TAG_END,
  999.  
  1000.                 GO_ENDGRP(),
  1001.  
  1002.             GO_ENDGRP(),
  1003.  
  1004.             GO_EMPTYBOX(0,0,1),
  1005.  
  1006.                 GOCT_SizeSpaceAbove, GO_TSIZE(GOM_BaseSet,0,GOT_Pixels),
  1007.                 GOCT_SizeSpaceBelow, GO_TSIZE(GOM_BaseSet,0,GOT_Pixels),
  1008.                 TAG_END,
  1009.  
  1010.         GO_ENDGRP(),
  1011.         
  1012.     GO_ENDGRP(),
  1013.     
  1014. GO_ENDGRP(),
  1015.  
  1016. // Every outline must end with this command.
  1017. GO_ENDOUTLINE()
  1018.  
  1019. };
  1020.  
  1021. /*********************************************
  1022.  **
  1023.  ** Example hooks used in outline
  1024.  **
  1025.  *********************************************/
  1026.  
  1027. // This is an example command hook.  It implements the code for finding
  1028. // the minimum dimensions of a checkbox and the code for responding to hotkey
  1029. // events.
  1030. // Note that this hook is not directly referenced in the outline - instead,
  1031. // a code is supplied for it in GOCT_SetUserHook and the translation hook
  1032. // converts this code to the actual address.
  1033.  
  1034. ULONG __asm __saveds __interrupt
  1035. checkbox_code(register __a0 struct Hook *hook,
  1036.               register __a2 struct CmdInfo *ci,
  1037.               register __a1 struct CmdHookMsg *msg)
  1038. {
  1039.     struct GadOutline *go;      // Global outline information.
  1040.     struct BoxAttr *ba;         // Box which called this hook.
  1041.     struct Gadget *gad;         // Gadget of hook, if created.
  1042.     ULONG ret;                  // Return code.
  1043.     UWORD kind;                 // GadTools kind of this box.
  1044.  
  1045.     // ---------------------------------------------------
  1046.     // Find some Universally Interesting variables.
  1047.     // ---------------------------------------------------
  1048.  
  1049.     if(ci) {
  1050.         go = ci->ci_GadOutline;             // Extract GadOutline
  1051.         kind = GETCMDSUBC(ci->ci_Command);  // GadTools kind
  1052.         gad = ci->ci_Object;                // Currently created gadget
  1053.         ba = ci->ci_BoxAttr;                // And BoxAttr of caller.
  1054.     } else go = NULL;
  1055.  
  1056.     // ---------------------------------------------------
  1057.     // Sanity checking...
  1058.     // ---------------------------------------------------
  1059.  
  1060.     if(!hook || !msg || !ci || !go) return 0;
  1061.  
  1062.     // ---------------------------------------------------
  1063.     // Check if this is correct type of command.
  1064.     // ---------------------------------------------------
  1065.  
  1066.     if( (ci->ci_Command&GO_OUTCMD(0,0,0xFFFF,0xFFFF,0))
  1067.         != GO_OUTCMD(0,0,GOK_Box,GOKB_GadTools,0) ) {
  1068.         
  1069.         // Continue processing this message.  Note that you must ALWAYS
  1070.         // pass along the return value from lower-level hooks if you are
  1071.         // not going to set it yourself.
  1072.         return GO_ContCmdHookA(ci,msg);
  1073.     }
  1074.  
  1075.     switch(msg->chm_Message) {
  1076.  
  1077.         case CHM_GETMINDIMENS: {
  1078.  
  1079.             struct GODimensInfo *gdi;
  1080.             WORD height,width;
  1081.             
  1082.             // The structure to fill in with out dimension information.
  1083.             gdi = msg->chm_MinDim;
  1084.  
  1085.             // Some example calls, just for the heck of it... :)
  1086.             height = GO_InterpretTypedSize(go,0,
  1087.                         GO_TSIZE(GOM_Set,100,GOT_PercCharH));
  1088.             width = GO_ParseTypedSizeList(go,0,
  1089.                         GOCT_TextPtr,ci->ci_BoxText,
  1090.                         GOCT_SizeParse,GO_TSIZE(GOM_Set,100,GOT_PercTextMaxW),
  1091.                         TAG_END);
  1092.  
  1093.             // If this is a checkbox...
  1094.             if(kind == CHECKBOX_KIND) {
  1095.             
  1096.                 // Let default hook do what it can.  The library currently
  1097.                 // knows how to take care of any GadTools labels.  Note that
  1098.                 // we save the return value, because we have nothing else
  1099.                 // to say.
  1100.                 ret = GO_ContCmdHookA(ci,msg);
  1101.  
  1102.                 // Make sure the checkbox's body is big enough.
  1103.                 if(gdi->gdi_StdBodyWidth < 26) {
  1104.                     if( (gdi->gdi_StdBodyWidth+gdi->gdi_PadBodyWidth) < 26 ) {
  1105.                         gdi->gdi_PadBodyWidth = 0;
  1106.                     }
  1107.                     gdi->gdi_StdBodyWidth = 26;
  1108.                 }
  1109.                 if(gdi->gdi_StdBodyHeight < 11) {
  1110.                     if( (gdi->gdi_StdBodyHeight+gdi->gdi_PadBodyHeight) < 11 ) {
  1111.                         gdi->gdi_PadBodyHeight = 0;
  1112.                     }
  1113.                     gdi->gdi_StdBodyHeight = 11;
  1114.                 }
  1115.  
  1116.             } else {
  1117.             
  1118.                 // If not a checkbox, just let the system handle it.
  1119.                 ret = GO_ContCmdHookA(ci,msg);
  1120.  
  1121.             }
  1122.  
  1123.         } break;
  1124.         
  1125.         case CHM_HOTKEY: {
  1126.  
  1127.             struct TagItem *tg;
  1128.  
  1129.             // Only respond to IDCMP_VANILLAKEY events and IDCMP_RAWKEY
  1130.             // down events.
  1131.  
  1132.             if( (msg->chm_KeyGOIMsg->StdIMsg.Class != IDCMP_VANILLAKEY
  1133.                 && msg->chm_KeyGOIMsg->StdIMsg.Class != IDCMP_RAWKEY)
  1134.                 || (msg->chm_KeyGOIMsg->StdIMsg.Class == IDCMP_RAWKEY
  1135.                     && (msg->chm_KeyGOIMsg->StdIMsg.Code&0x80) != 0) ) {
  1136.  
  1137.                 return GO_ContCmdHookA(ci,msg);
  1138.             }
  1139.             
  1140.             // If this is a checkbox and we are tracking its state...
  1141.     
  1142.             if( kind == CHECKBOX_KIND
  1143.                 && (tg=FindTagItem(GTCB_Checked,ci->ci_GadToolsTags)) != NULL ) {
  1144.  
  1145.                 struct TagItem update[] = {
  1146.                     { 0, 0 }, { TAG_END, 0 }
  1147.                 };
  1148.  
  1149.                 // A REALLY stupid way to do a checkbox hotkey, but it's
  1150.                 // the basic code for most other types...
  1151.  
  1152.                 // If shift is pressed, decrement.
  1153.  
  1154.                 if( (msg->chm_KeyGOIMsg->StdIMsg.Qualifier
  1155.                     &( IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT
  1156.                         | IEQUALIFIER_CAPSLOCK ) ) != 0 ) {
  1157.                         
  1158.                     if(tg->ti_Data <= 0)
  1159.                         tg->ti_Data = 1;
  1160.                     else
  1161.                         tg->ti_Data--;
  1162.                         
  1163.                 // Else, increment.
  1164.  
  1165.                 } else {
  1166.  
  1167.                     if(tg->ti_Data >= 1)
  1168.                         tg->ti_Data = 0;
  1169.                     else
  1170.                         tg->ti_Data++;
  1171.                 }
  1172.                         
  1173.                 // Send a message to command to update its state.
  1174.  
  1175.                 update[0].ti_Tag = GTCB_Checked;
  1176.                 update[0].ti_Data = tg->ti_Data;
  1177.  
  1178.                 GO_CallCmdHook( ci, CHM_SETOBJATTR, 0, &update[0] );
  1179.                 
  1180.                 // If an error occured, exit stage left.
  1181.                 if(go->go_LastReqReturn) return 0;
  1182.                 
  1183.                 // If the gadget has been created, turn the GOIMsg
  1184.                 // into the correct kind of event.  Yes, we are allowed
  1185.                 // to do this. :)
  1186.     
  1187.                 if(gad) {
  1188.                     msg->chm_KeyGOIMsg->StdIMsg.Class = IDCMP_GADGETUP;
  1189.                     msg->chm_KeyGOIMsg->StdIMsg.Code = tg->ti_Data;
  1190.                     msg->chm_KeyGOIMsg->StdIMsg.IAddress = (APTR)gad;
  1191.                 }
  1192.                 
  1193.                 // We don't continue this message because we basically
  1194.                 // just ate it.  Chomp chomp...  yummy...
  1195.                 ret = 0;
  1196.             }
  1197.         }
  1198.         
  1199.         default: {
  1200.  
  1201.             ret = GO_ContCmdHookA(ci,msg);
  1202.  
  1203.         } break;
  1204.     }
  1205.  
  1206.     return ret;
  1207. }
  1208.  
  1209. struct Hook checkbox_hook = {
  1210.     { 0 },
  1211.     (ULONG (*)())checkbox_code,
  1212.     NULL,
  1213.     NULL
  1214. };
  1215.  
  1216. // This is an example transalation hook.  This hook is global to the outline
  1217. // and allows you to not only localize the outline array, but theoretically
  1218. // make it completely independant of any direct references to absolute
  1219. // program addresses.
  1220.  
  1221. // The actual library only sends the CHM_TRANSCMDHOOK to translate user
  1222. // hooks supplied in the outline; all other translation takes place within
  1223. // the library's default hook and can be modified using a user hook.
  1224. // The standard hook asks for translation of GadTools text pointers and the
  1225. // standard GadTools tags which supply strings or arrays of strings.
  1226.  
  1227. ULONG __asm __saveds __interrupt
  1228. translation_code(register __a0 struct Hook *hook,
  1229.                  register __a2 struct GadOutline *go,
  1230.                  register __a1 struct CmdHookMsg *msg)
  1231. {
  1232.     // ---------------------------------------------------
  1233.     // Sanity checking...
  1234.     // ---------------------------------------------------
  1235.  
  1236.     if(!hook || !msg || !go) return 0;
  1237.  
  1238.     switch(msg->chm_Message) {
  1239.  
  1240.         case CHM_TRANSTEXTPTR: {
  1241.  
  1242.             // If I had the developer info, I'd put some code here
  1243.             // to call locale.library... :)
  1244.  
  1245.             if(msg->chm_TransCode)
  1246.                 D(bug("String Trans: %ls\n",msg->chm_TransCode));
  1247.  
  1248.             return msg->chm_TransCode;
  1249.             
  1250.         } break;
  1251.  
  1252.         case CHM_TRANSCMDHOOK: {
  1253.  
  1254.             if(msg->chm_TransCode == 1)
  1255.                 return (ULONG)&checkbox_hook;
  1256.             else return msg->chm_TransCode;
  1257.             
  1258.         } break;
  1259.  
  1260.         default: {
  1261.  
  1262.         } break;
  1263.     }
  1264.  
  1265.     return GO_ContTransHookA(go,msg);
  1266. }
  1267.  
  1268. struct Hook translation_hook = {
  1269.     { 0 },
  1270.     (ULONG (*)())translation_code,
  1271.     NULL,
  1272.     NULL
  1273. };
  1274.  
  1275. /*********************************************
  1276.  **
  1277.  ** Program environment
  1278.  **
  1279.  *********************************************/
  1280.  
  1281. static struct Process *me = NULL;
  1282. static struct Window *oldwin = NULL;    // what me->pr_WindowPtr previously was
  1283.  
  1284. /*********************************************
  1285.  **
  1286.  ** Current program state
  1287.  **
  1288.  *********************************************/
  1289.  
  1290. static struct GadOutline *gad_outline = NULL;
  1291. static struct FontRequester *fr = NULL;
  1292. static UBYTE *go_error;                 // Where error results are returned
  1293. static struct List info_list;
  1294. static UBYTE pub_screen[100] = { 0 };
  1295.  
  1296. /*********************************************
  1297.  **
  1298.  ** All library bases
  1299.  **
  1300.  *********************************************/
  1301.  
  1302. #define MIN_VERSION     37L             // minimum version number for our libs
  1303.  
  1304. long __oslibversion = MIN_VERSION;
  1305.  
  1306. #ifndef LINKLIB
  1307. struct Library *GadOutlineBase = NULL;
  1308. #endif
  1309.  
  1310. static void quit(UBYTE *err);
  1311. static void closedown(void);
  1312. static void opendisplay(struct GadOutline *go);
  1313. static void handledisplay(struct GadOutline *go);
  1314. static void free_list(struct List *list);
  1315.  
  1316. /*********************************************
  1317.  **
  1318.  ** Routines for a clean exit, with optional error display
  1319.  **
  1320.  *********************************************/
  1321.  
  1322. static struct EasyStruct error_es = {
  1323.     sizeof(struct EasyStruct), 0,
  1324.     "GadOutline Example3 Requester",
  1325.     "Problem during startup:\n%ls",
  1326.     "Quit"
  1327. };
  1328.  
  1329. static void quit(UBYTE *err)
  1330. {
  1331.     closedown();
  1332.  
  1333.     if(err == NULL) err = go_error;
  1334.     if(err != NULL) (void)EasyRequest(NULL,&error_es, NULL, err);
  1335.  
  1336.     _exit(0);
  1337. }
  1338.  
  1339. static void closedown(void)
  1340. {
  1341.     if(gad_outline) FreeGadOutline(gad_outline);
  1342.     free_list(&info_list);
  1343.     if(fr) FreeAslRequest(fr);
  1344.     if(me) me->pr_WindowPtr = (APTR)oldwin;
  1345.     #ifndef LINKLIB
  1346.     if(GadOutlineBase) CloseLibrary(GadOutlineBase);
  1347.     #endif
  1348. }
  1349.  
  1350. /*********************************************
  1351.  **
  1352.  ** Routines for opening the screen, window and gadgets
  1353.  **
  1354.  *********************************************/
  1355.  
  1356. static void create_node(struct List *list,UBYTE *name)
  1357. {
  1358.     struct Node *nd;
  1359.     
  1360.     if( nd=AllocVec(sizeof(struct Node)+strlen(name)+5,MEMF_CLEAR) ) {
  1361.         nd->ln_Name = (char *)(nd+1);
  1362.         strcpy((UBYTE *)(nd+1),name);
  1363.         AddTail(list,nd);
  1364.     }
  1365. }
  1366.  
  1367. static void free_list(struct List *list)
  1368. {
  1369.     struct Node *nd;
  1370.     
  1371.     while( nd=RemTail(list) ) {
  1372.         FreeVec(nd);
  1373.     }
  1374. }
  1375.  
  1376. static void opendisplay(struct GadOutline *go)
  1377. {
  1378.     //GO_SetObjGrpAttrs(go,0,0,GA_Disabled,FALSE,TAG_END);
  1379.  
  1380.     GO_OpenWindow(go,   WA_PubScreenName,   pub_screen,
  1381.                         TAG_END );
  1382.  
  1383.     if(go->go_LastReqReturn || !go->go_Window) return;
  1384.  
  1385.     create_node(&info_list,"I'm");
  1386.     create_node(&info_list,"Too");
  1387.     create_node(&info_list,"Lazy");
  1388.     create_node(&info_list,"To");
  1389.     create_node(&info_list,"Put");
  1390.     create_node(&info_list,"Anything");
  1391.     create_node(&info_list,"Interesting");
  1392.     create_node(&info_list,"Here.");
  1393.     create_node(&info_list,"");
  1394.     create_node(&info_list,":p");
  1395.  
  1396.     GO_SetObjAttrs(go,INFOLIST_ID,0,GTLV_Labels,&info_list,TAG_END);
  1397.  
  1398.     me->pr_WindowPtr = (APTR)go->go_Window;
  1399. }
  1400.  
  1401. void update_fontinfo(struct GadOutline *go)
  1402. {
  1403.     GO_SetObjAttrs(go,FONTNAME_ID,0,
  1404.         GTST_String,go->go_TargetTA.tta_Name,TAG_END);
  1405.     GO_SetObjAttrs(go,FONTSIZE_ID,0,
  1406.         GTIN_Number,go->go_TargetTA.tta_YSize,TAG_END);
  1407.     GO_SetObjAttrs(go,CURFNAME_ID,0,
  1408.         GTTX_Text,go->go_TextAttr.tta_Name,TAG_END);
  1409.     GO_SetObjAttrs(go,CURFSIZE_ID,0,
  1410.         GTNM_Number,go->go_TextAttr.tta_YSize,TAG_END);
  1411. }
  1412.  
  1413. static void print_keys(UBYTE *keys)
  1414. {
  1415.     UBYTE *pos;
  1416.     UBYTE conv_keys[100];
  1417.     
  1418.     pos = &conv_keys[0];
  1419.     while( *keys && (pos < &conv_keys[95]) ) {
  1420.         if( (*keys >= ' ' && *keys <= 126) || *keys >= 160 ) {
  1421.             *pos = *keys;
  1422.             pos++;
  1423.             keys++;
  1424.         } else {
  1425.             *pos = '\\';
  1426.             pos++;
  1427.             *pos = ( ((*keys)/16) >= 10 ) ? ((*keys)/16)+'A'-10 : ((*keys)/16)+'0';
  1428.             pos++;
  1429.             *pos = ( ((*keys)&15) >= 10 ) ? ((*keys)&15)+'A'-10 : ((*keys)&15)+'0';
  1430.             pos++;
  1431.             *pos = 'x';
  1432.             pos++;
  1433.             keys++;
  1434.         }
  1435.     }
  1436.     *pos = 0;
  1437.     D(bug("%ls",&conv_keys[0]));
  1438. }
  1439.  
  1440. static void handledisplay(struct GadOutline *go)
  1441. {
  1442.     struct GOIMsg *msg;
  1443.     struct Gadget *gadget;
  1444.     ULONG class;
  1445.     UWORD code;
  1446.     UWORD qual;
  1447.  
  1448.     if(go == NULL || go->go_Window == NULL) return;
  1449.  
  1450.     update_fontinfo(go);
  1451.  
  1452.     while (1) {
  1453.  
  1454.         if(GO_GetObjAttr(go,REMAKE_ID,0,GTCY_Active,0)==0) {
  1455.         
  1456.             // Doing a full DimenGadOutline for a resize is extremely
  1457.             // abnormal; force the window to be able to go smaller than the
  1458.             // outline's minimum size.
  1459.             WindowLimits(go->go_Window,30,20,
  1460.                          go->go_Window->MaxWidth,go->go_Window->MaxHeight);
  1461.         }
  1462.  
  1463.         Wait( (1L<<go->go_Window->UserPort->mp_SigBit) );
  1464.  
  1465.         while (msg = GO_GetGOIMsg(go)) {
  1466.  
  1467.             struct GOIMsg *dupmsg;
  1468.             class = msg->StdIMsg.Class;
  1469.             code = msg->StdIMsg.Code;
  1470.             qual = msg->StdIMsg.Qualifier;
  1471.             gadget=msg->StdIMsg.IAddress;
  1472.  
  1473.             gadget = (struct Gadget *)msg->StdIMsg.IAddress;
  1474.             dupmsg = GO_DupGOIMsg(go,msg);
  1475.  
  1476.             GO_ReplyGOIMsg(msg);
  1477.  
  1478.             switch (class) {
  1479.  
  1480.                 case IDCMP_CLOSEWINDOW:
  1481.                     return;
  1482.  
  1483.                 case IDCMP_NEWSIZE:
  1484.                     if(GO_GetObjAttr(go,REMAKE_ID,0,GTCY_Active,0)==0) {
  1485.                         DimenGadOutline(go,TAG_END);
  1486.                     } else if(GO_GetObjAttr(go,REMAKE_ID,0,GTCY_Active,0)==1) {
  1487.                         RebuildGadOutline(go,TAG_END);
  1488.                     } else {
  1489.                         ResizeGadOutline(go,TAG_END);
  1490.                     }
  1491.                     update_fontinfo(go);
  1492.                     break;
  1493.  
  1494.                 case IDCMP_REFRESHWINDOW:
  1495.                     GO_BeginRefresh(go);
  1496.                     GO_EndRefresh(go, TRUE);
  1497.                     break;
  1498.  
  1499.                 case IDCMP_GADGETDOWN: {
  1500.                     D(bug("A gadget down type: %ld\n",gadget->GadgetID));
  1501.                     switch(gadget->GadgetID) {
  1502.                     
  1503.                         case PALDEPTH_ID: {
  1504.  
  1505.                             // Change the depth of the palette gadget.
  1506.                             // This requires a rebuild of the layout
  1507.                             // to recreate the palette gadget.
  1508.                             GO_SetObjAttrs(go,SCRNPAL_ID,0,
  1509.                                 GTPA_Depth,code+1,TAG_END);
  1510.                             RebuildGadOutline(go,TAG_END);
  1511.                             update_fontinfo(go);
  1512.                         
  1513.                         } break;
  1514.                     }
  1515.                 } break;
  1516.  
  1517.                 case IDCMP_VANILLAKEY: {
  1518.                     D(bug("Van key (Code %lx) (Len %ld): '",code,strlen(&dupmsg->KeyPress[0])));
  1519.                     print_keys(&dupmsg->KeyPress[0]);
  1520.                     D(bug("'\n"));
  1521.                 } break;
  1522.                 
  1523.                 case IDCMP_RAWKEY: {
  1524.                     D(bug("Raw key (Code %lx) (Len %ld): '",code,strlen(&dupmsg->KeyPress[0])));
  1525.                     print_keys(&dupmsg->KeyPress[0]);
  1526.                     D(bug("'\n"));
  1527.                     if(code == 0x5F) {
  1528.                         struct CmdInfo *ci = NULL;
  1529.                         UWORD reqret = GOREQ_CONT;
  1530.                         
  1531.                         GO_SetError(go,0,NULL,NULL);
  1532.                         while( reqret == GOREQ_CONT
  1533.                                && (ci = GO_CmdAtPoint(go,dupmsg,ci,TAG_END)) ) {
  1534.                             reqret = GO_ShowError(go,GO_MAKEERR(GOTYPE_NOTE,0),ci,
  1535.                                 "Command covering this point:\n\nStdID: ~ci; GrpID: ~cg\nKind: ~ck; Code: ~cc; Sub: ~cs\nLabel: ~cl");
  1536.                         }
  1537.                     }
  1538.                 } break;
  1539.                 
  1540.                 case IDCMP_GADGETUP: {
  1541.                     D(bug("A gadget up type: %ld\n",gadget->GadgetID));
  1542.                     switch(gadget->GadgetID) {
  1543.  
  1544.                         case WHICHGROUP_ID: {
  1545.                         
  1546.                             // Turn off every gadget with our demo group mask.
  1547.                             GO_SetObjGrpAttrs(go,GO_CMDID(DEMOGRP_GID,0),0,
  1548.                                 GA_Disabled,TRUE,TAG_END);
  1549.                                 
  1550.                             // Turn on every gadget with out demo group mask
  1551.                             // AND the same group code as the cycle gadget's
  1552.                             // current value.
  1553.                             GO_SetObjGrpAttrs(go,GO_CMDID(DEMOGRP_GID|code,0),0,
  1554.                                 GA_Disabled,FALSE,TAG_END);
  1555.  
  1556.                         } break;
  1557.                         
  1558.                         case FONTNAME_ID: {
  1559.                         
  1560.                             DimenGadOutline(go,
  1561.                                 GOA_FontName,
  1562.                                     GO_GetObjAttr(go,FONTNAME_ID,0,
  1563.                                         GTST_String,NULL),
  1564.                                 TAG_END);
  1565.                             update_fontinfo(go);
  1566.     
  1567.                         } break;
  1568.                         
  1569.                         case FONTSIZE_ID: {
  1570.                         
  1571.                             DimenGadOutline(go,
  1572.                                 GOA_FontSize,
  1573.                                     GO_GetObjAttr(go,FONTSIZE_ID,0,
  1574.                                         GTIN_Number,0),
  1575.                                 TAG_END);
  1576.                             update_fontinfo(go);
  1577.     
  1578.                         } break;
  1579.                         
  1580.                         case MINSIZE_ID: {
  1581.                         
  1582.                             DimenGadOutline(go,
  1583.                                 GOA_FontMinSize,
  1584.                                     GO_GetObjAttr(go,MINSIZE_ID,0,
  1585.                                         GTIN_Number,0),
  1586.                                 TAG_END);
  1587.                             update_fontinfo(go);
  1588.     
  1589.                         } break;
  1590.                         
  1591.                         case SCALEFONT_ID: {
  1592.                         
  1593.                             DimenGadOutline(go,
  1594.                                 GOA_FontDesigned,
  1595.                                     !GO_GetObjAttr(go,SCALEFONT_ID,0,
  1596.                                         GTCB_Checked,TRUE),
  1597.                                 TAG_END);
  1598.                             update_fontinfo(go);
  1599.     
  1600.                         } break;
  1601.                         
  1602.                         case SYSFONT_ID: {
  1603.                         
  1604.                             DimenGadOutline(go,
  1605.                                 GOA_FontSystemOnly,
  1606.                                     GO_GetObjAttr(go,SYSFONT_ID,0,
  1607.                                         GTCB_Checked,TRUE),
  1608.                                 TAG_END);
  1609.                             update_fontinfo(go);
  1610.     
  1611.                         } break;
  1612.                         
  1613.                         case ROMFONT_ID: {
  1614.                         
  1615.                             DimenGadOutline(go,
  1616.                                 GOA_FontROMFont,
  1617.                                     GO_GetObjAttr(go,ROMFONT_ID,0,
  1618.                                         GTCB_Checked,TRUE),
  1619.                                 TAG_END);
  1620.                             update_fontinfo(go);
  1621.     
  1622.                         } break;
  1623.                         
  1624.                         case DISKFONT_ID: {
  1625.                         
  1626.                             DimenGadOutline(go,
  1627.                                 GOA_FontDiskFont,
  1628.                                     GO_GetObjAttr(go,DISKFONT_ID,0,
  1629.                                         GTCB_Checked,TRUE),
  1630.                                 TAG_END);
  1631.                             update_fontinfo(go);
  1632.     
  1633.                         } break;
  1634.                         
  1635.                         case PUBSCREEN_ID: {
  1636.                         
  1637.                             UBYTE *name;
  1638.                             
  1639.                             name = (UBYTE *)GO_GetObjAttr(go,PUBSCREEN_ID,0,
  1640.                                                 GTST_String,NULL);
  1641.                             if(name) {
  1642.                                 strncpy(pub_screen,name,99);
  1643.                             } else {
  1644.                                 pub_screen[0] = 0;
  1645.                             }
  1646.                             
  1647.                             // This routine automagically closes the previous
  1648.                             // window and opens a new window with the gadgets
  1649.                             // in the same state.
  1650.                             
  1651.                             GO_OpenWindow(go,   WA_PubScreenName,   pub_screen,
  1652.                                                 TAG_END );
  1653.                             if(!go->go_Window || go->go_LastReqReturn)
  1654.                                 quit("Couldn't open window.");
  1655.                             update_fontinfo(go);
  1656.  
  1657.                         } break;
  1658.                         
  1659.                         case ONOFFALLC_ID:
  1660.                         case ONOFFALLD_ID: {
  1661.  
  1662.                             ULONG statec,stated;
  1663.  
  1664.                             statec = GO_GetObjAttr(go,ONOFFALLC_ID,0,
  1665.                                                     GTCB_Checked,TRUE);
  1666.                             stated = GO_GetObjAttr(go,ONOFFALLD_ID,0,
  1667.                                                     GTCB_Checked,TRUE);
  1668.  
  1669.                             if(gadget->GadgetID == ONOFFALLC_ID) {
  1670.                                 if(statec && !stated) stated = TRUE;
  1671.                                 GO_SetObjAttrs(go,ONOFFALLD_ID,0,
  1672.                                                 GTCB_Checked,TRUE);
  1673.                             } else {
  1674.                                 if(statec && !stated) statec = FALSE;
  1675.                                 GO_SetObjAttrs(go,ONOFFALLC_ID,0,
  1676.                                                 GTCB_Checked,FALSE);
  1677.                             }
  1678.  
  1679.                             // Turn creation and dimensions of group on/off.
  1680.                             
  1681.                             GO_SetCmdAttrs(go,BOOGRP_ID,0,
  1682.                                 GOCT_IgnoreCreation, !statec,
  1683.                                 GOCT_IgnoreFinDimens, !stated,
  1684.                                 TAG_END);
  1685.                             RebuildGadOutline(go,TAG_END);
  1686.     
  1687.                         } break;
  1688.                         
  1689.                         case ONOFF1_ID: {
  1690.                         
  1691.                             GO_SetCmdAttrs(go,BOO1_ID,0,
  1692.                                 GOCT_IgnoreCreation,
  1693.                                 !GO_GetObjAttr(go,ONOFF1_ID,0,GTCB_Checked,TRUE),
  1694.                                 TAG_END);
  1695.                             RebuildGadOutline(go,TAG_END);
  1696.     
  1697.                         } break;
  1698.                         
  1699.                         case ONOFF2A_ID: {
  1700.                         
  1701.                             ULONG state;
  1702.                             
  1703.                             state = GO_GetObjAttr(go,ONOFF2A_ID,0,
  1704.                                                 GTCB_Checked,TRUE);
  1705.  
  1706.                             GO_SetCmdAttrs(go,BOO2A_ID,0,
  1707.                                 GOCT_IgnoreCreation, !state,
  1708.                                 GOCT_IgnoreFinDimens, !state,
  1709.                                 TAG_END);
  1710.                             RebuildGadOutline(go,TAG_END);
  1711.     
  1712.                         } break;
  1713.                         
  1714.                         case ONOFF2B_ID: {
  1715.                         
  1716.                             ULONG state;
  1717.                             
  1718.                             state = GO_GetObjAttr(go,ONOFF2B_ID,0,
  1719.                                                 GTCB_Checked,TRUE);
  1720.  
  1721.                             GO_SetCmdAttrs(go,BOO2B_ID,0,
  1722.                                 GOCT_IgnoreCreation, !state,
  1723.                                 GOCT_IgnoreFinDimens, !state,
  1724.                                 TAG_END);
  1725.                             RebuildGadOutline(go,TAG_END);
  1726.     
  1727.                         } break;
  1728.                         
  1729.                         case ONOFF3A_ID: {
  1730.                         
  1731.                             ULONG state;
  1732.                             
  1733.                             state = GO_GetObjAttr(go,ONOFF3A_ID,0,
  1734.                                                 GTCB_Checked,TRUE);
  1735.  
  1736.                             GO_SetCmdAttrs(go,BOO3A_ID,0,
  1737.                                 GOCT_IgnoreCreation, !state,
  1738.                                 GOCT_IgnoreFinDimens, !state,
  1739.                                 TAG_END);
  1740.                             RebuildGadOutline(go,TAG_END);
  1741.     
  1742.                         } break;
  1743.                         
  1744.                         case ONOFF3B_ID: {
  1745.                         
  1746.                             ULONG state;
  1747.                             
  1748.                             state = GO_GetObjAttr(go,ONOFF3B_ID,0,
  1749.                                                 GTCB_Checked,TRUE);
  1750.  
  1751.                             GO_SetCmdAttrs(go,BOO3B_ID,0,
  1752.                                 GOCT_IgnoreCreation, !state,
  1753.                                 GOCT_IgnoreFinDimens, !state,
  1754.                                 TAG_END);
  1755.                             RebuildGadOutline(go,TAG_END);
  1756.     
  1757.                         } break;
  1758.                         
  1759.                         case SETFONT_ID: {
  1760.  
  1761.                             // Pop up the font requester
  1762.                             if (AslRequestTags(fr,
  1763.  
  1764.                                 // Supply initial values for requester
  1765.                                 ASL_FontName, (ULONG)go->go_TargetTA.tta_Name,
  1766.                                 ASL_FontHeight, go->go_TargetTA.tta_YSize,
  1767.                                 ASL_FontStyles, go->go_TargetTA.tta_Style,
  1768.                                 ASL_FuncFlags, FONF_STYLES,
  1769.                                 ASL_Window, go->go_Window,
  1770.                                 TAG_END)) {
  1771.  
  1772.                                 DimenGadOutline(go,
  1773.                                                  GOA_TextAttr,&fr->fo_Attr,
  1774.                                                  TAG_END);
  1775.                             }
  1776.                             update_fontinfo(go);
  1777.  
  1778.                         } break;
  1779.                     }
  1780.                 } break;
  1781.  
  1782.             }
  1783.             if(dupmsg) GO_UndupGOIMsg(dupmsg);
  1784.         }
  1785.     }
  1786. }
  1787.  
  1788. /*********************************************
  1789.  **
  1790.  ** Program's main entry point
  1791.  **
  1792.  *********************************************/
  1793.  
  1794. void __regargs main(int argc,char **argv)
  1795. {
  1796.     NewList(&info_list);
  1797.  
  1798.     if( !(me = (struct Process *)FindTask(NULL)) ) quit("Can't find    myself!");
  1799.     oldwin = (struct Window *)me->pr_WindowPtr;
  1800.  
  1801.     if( (fr = (struct FontRequester *)
  1802.         AllocAslRequestTags(ASL_FontRequest,TAG_END)) == NULL) {
  1803.         quit("Can't allocate font requester!");
  1804.     }
  1805.             
  1806. #ifndef LINKLIB
  1807.     GadOutlineBase = OpenLibrary("gadoutline.library", 0);
  1808.     if (!GadOutlineBase)
  1809.        quit("Can't open gadoutline.library.");
  1810.     D(bug("Opened the library.  Creating outline...\n",NULL));
  1811. #endif
  1812.     
  1813.     gad_outline = AllocGadOutline(outline,
  1814.            GOA_ErrorText,       &go_error,
  1815.            GOA_ScreenName,      pub_screen,
  1816.            GOA_OutlineSize,     sizeof(outline),
  1817.            GOA_SetTransHook,    &translation_hook,
  1818.            TAG_END);
  1819.     if(gad_outline == NULL) {
  1820.         quit(go_error);
  1821.     }
  1822.  
  1823.     opendisplay(gad_outline);
  1824.     handledisplay(gad_outline);
  1825.  
  1826.     quit(NULL);
  1827. }
  1828.