home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / 3_1EXAM1.DMS / in.adf / asl / asltester / asltester.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-17  |  46.1 KB  |  1,061 lines

  1.  
  2. /*
  3. COPYRIGHT: Unless otherwise noted, all files are Copyright (c) 1992-1993
  4. Commodore-Amiga, Inc.  All rights reserved.
  5.  
  6. DISCLAIMER: This software is provided "as is".  No representations or
  7. warranties are made with respect to the accuracy, reliability, performance,
  8. currentness, or operation of this software, and all use is at your own risk.
  9. Neither commodore nor the authors assume any responsibility or liability
  10. whatsoever with respect to your use of this software.
  11. */
  12.  
  13.  
  14. /****************************************************************************/
  15.  
  16.  
  17. #include <exec/types.h>
  18. #include <exec/memory.h>
  19. #include <intuition/intuition.h>
  20. #include <intuition/gadgetclass.h>
  21. #include <graphics/displayinfo.h>
  22. #include <dos/dos.h>
  23. #include <dos/rdargs.h>
  24. #include <utility/hooks.h>
  25. #include <libraries/asl.h>
  26. #include <libraries/gadtools.h>
  27. #include <libraries/locale.h>
  28. #include <graphics/gfxmacros.h>
  29. #include <string.h>
  30. #include <stdio.h>
  31.  
  32. #include <clib/dos_protos.h>
  33. #include <clib/exec_protos.h>
  34. #include <clib/intuition_protos.h>
  35. #include <clib/asl_protos.h>
  36. #include <clib/alib_protos.h>
  37. #include <clib/gadtools_protos.h>
  38. #include <clib/graphics_protos.h>
  39. #include <clib/locale_protos.h>
  40.  
  41. #include <pragmas/dos_pragmas.h>
  42. #include <pragmas/exec_pragmas.h>
  43. #include <pragmas/intuition_pragmas.h>
  44. #include <pragmas/asl_pragmas.h>
  45. #include <pragmas/gadtools_pragmas.h>
  46. #include <pragmas/graphics_pragmas.h>
  47. #include <pragmas/locale_pragmas.h>
  48.  
  49. #include "asltester_rev.h"
  50. #include "edithook.h"
  51. #include "gadgets.h"
  52. #include "reqtest.h"
  53.  
  54.  
  55. /****************************************************************************/
  56.  
  57.  
  58. static struct TextAttr topazAttr =
  59. {
  60.     "topaz.font",
  61.      8,
  62.      FS_NORMAL,
  63.      FPF_ROMFONT
  64. };
  65.  
  66. static const struct NewGadget NG[]=
  67. {
  68.     {12,21,148,14,"Reference Object",  NULL,ID_REFOBJECT,  PLACETEXT_ABOVE,NULL,NULL},
  69.  
  70.     {12,45,148,14, "InitialLeftEdge",  NULL,ID_INITIALLEFTEDGE,PLACETEXT_RIGHT,NULL,NULL},
  71.     {12,61,148,14, "InitialTopEdge",   NULL,ID_INITIALTOPEDGE,PLACETEXT_RIGHT,NULL,NULL},
  72.     {12,77,148,14, "InitialWidth",     NULL,ID_INITIALWIDTH,PLACETEXT_RIGHT,NULL,NULL},
  73.     {12,93,148,14, "InitialHeight",    NULL,ID_INITIALHEIGHT,PLACETEXT_RIGHT,NULL,NULL},
  74.     {12,113,148,14,"TitleText",        NULL,ID_TITLETEXT,PLACETEXT_RIGHT,NULL,NULL},
  75.     {12,129,148,14,"PositiveText",     NULL,ID_POSITIVETEXT,PLACETEXT_RIGHT,NULL,NULL},
  76.     {12,145,148,14,"NegativeText",     NULL,ID_NEGATIVETEXT,PLACETEXT_RIGHT,NULL,NULL},
  77.     {12,165,148,14,"TextAttr.ta_Name", NULL,ID_FONTNAME,PLACETEXT_RIGHT,NULL,NULL},
  78.     {12,181,148,14,"TextAttr.ta_YSize",NULL,ID_FONTSIZE,PLACETEXT_RIGHT,NULL,NULL},
  79.     {12,201,148,14,"Locale",           NULL,ID_LOCALE,PLACETEXT_RIGHT,NULL,NULL},
  80.     {12,221,26,11, "PrivateIDCMP",     NULL,ID_PRIVATEIDCMP,PLACETEXT_RIGHT,NULL,NULL},
  81.     {12,233,26,11, "SleepWindow",      NULL,ID_SLEEPWINDOW,PLACETEXT_RIGHT,NULL,NULL},
  82.     {12,245,26,11, "IntuiMsgFunc",     NULL,ID_INTUIMSGFUNC,PLACETEXT_RIGHT,NULL,NULL},
  83.     {12,257,26,11, "FilterFunc",       NULL,ID_FILTERFUNC,PLACETEXT_RIGHT,NULL,NULL},
  84.     {408,21,148,14,"Requester Type",   NULL,ID_REQTYPE,PLACETEXT_ABOVE,NULL,NULL},
  85.     {111,341,87,20,"Test",             NULL,ID_TEST,0,NULL,NULL},
  86.  
  87.     {472,57,148,14, "InitialFile",     NULL,ID_INITIALFILE,0,NULL,NULL},
  88.     {472,73,148,14, "InitialDrawer",   NULL,ID_INITIALDRAWER,0,NULL,NULL},
  89.     {472,89,148,14, "InitialPattern",  NULL,ID_INITIALPATTERN,0,NULL,NULL},
  90.     {472,109,148,14,"AcceptPattern",   NULL,ID_ACCEPTPATTERN,0,NULL,NULL},
  91.     {472,125,148,14,"RejectPattern",   NULL,ID_REJECTPATTERN,0,NULL,NULL},
  92.     {594,145,26,11, "DoSaveMode",      NULL,ID_DOSAVEMODE,0,NULL,NULL},
  93.     {594,157,26,11, "DoMultiSelect",   NULL,ID_DOMULTISELECT,0,NULL,NULL},
  94.     {594,169,26,11, "DoPatterns",      NULL,ID_DOPATTERNS,0,NULL,NULL},
  95.     {594,181,26,11, "DrawersOnly",     NULL,ID_DRAWERSONLY,0,NULL,NULL},
  96.     {594,193,26,11, "RejectIcons",     NULL,ID_REJECTICONS,0,NULL,NULL},
  97.     {594,205,26,11, "FilterDrawers",   NULL,ID_FILTERDRAWERS,0,NULL,NULL},
  98.  
  99.     {504,57,116,14, "InitialName    ",     NULL,ID_INITIALNAME,0,NULL,NULL},
  100.     {504,73,116,11, "InitialSize    ",     NULL,ID_INITIALSIZE,0,NULL,NULL},
  101.     {504,86,116,11, "InitialFrontPen    ", NULL,ID_INITIALFRONTPEN,0,NULL,NULL},
  102.     {504,99,116,11, "InitialBackPen    ",  NULL,ID_INITIALBACKPEN,0,NULL,NULL},
  103.     {504,112,116,14,"InitialDrawMode    ", NULL,ID_INITIALDRAWMODE,0,NULL,NULL},
  104.     {472,148,116,11,"InitialStyle",        NULL,ID_INITIALSTYLE,0,NULL,NULL},
  105.     {594,131,26,11, "Plain",               NULL,ID_INITIALSTYLE_PLAIN,0,NULL,NULL},
  106.     {594,143,26,11, "Bold",                NULL,ID_INITIALSTYLE_BOLD,0,NULL,NULL},
  107.     {594,155,26,11, "Italic",              NULL,ID_INITIALSTYLE_ITALIC,0,NULL,NULL},
  108.     {594,167,26,11, "Underline",           NULL,ID_INITIALSTYLE_UNDERLINE,0,NULL,NULL},
  109.     {594,183,26,11, "DoFrontPen",          NULL,ID_DOFRONTPEN,0,NULL,NULL},
  110.     {594,195,26,11, "DoBackPen",           NULL,ID_DOBACKPEN,0,NULL,NULL},
  111.     {594,207,26,11, "DoStyle",             NULL,ID_DOSTYLE,0,NULL,NULL},
  112.     {594,219,26,11, "DoDrawMode",          NULL,ID_DODRAWMODE,0,NULL,NULL},
  113.     {594,231,26,11, "FixedWidthOnly",      NULL,ID_FIXEDWIDTHONLY,0,NULL,NULL},
  114.     {504,246,116,11,"MinHeight    ",       NULL,ID_MINHEIGHT,0,NULL,NULL},
  115.     {504,259,116,11,"MaxHeight    ",       NULL,ID_MAXHEIGHT,0,NULL,NULL},
  116.     {504,272,116,11,"MaxFrontPen    ",     NULL,ID_MAXFRONTPEN,0,NULL,NULL},
  117.     {504,285,116,11,"MaxBackPen    ",      NULL,ID_MAXBACKPEN,0,NULL,NULL},
  118.     {594,300,26,11, "FrontPens",           NULL,ID_FRONTPENS,0,NULL,NULL},
  119.     {594,312,26,11, "BackPens",            NULL,ID_BACKPENS,0,NULL,NULL},
  120.     {594,324,26,11, "ModeList",            NULL,ID_MODELIST,0,NULL,NULL},
  121.  
  122.     {504,57,116,14, "InitialDispID   ",       NULL,ID_INITIALDISPLAYID,0,NULL,NULL},
  123.     {504,72,116,14, "InitialDispWidth   ",    NULL,ID_INITIALDISPLAYWIDTH,0,NULL,NULL},
  124.     {504,87,116,14, "InitialDispHeight   ",   NULL,ID_INITIALDISPLAYHEIGHT,0,NULL,NULL},
  125.     {504,102,116,11,"InitialDispDepth   ",    NULL,ID_INITIALDISPLAYDEPTH,0,NULL,NULL},
  126.     {504,114,116,14,"InitialOScanType   ",    NULL,ID_INITIALOVERSCANTYPE,0,NULL,NULL},
  127.     {504,129,116,14,"InitialInfoLeftEdge   ", NULL,ID_INITIALINFOLEFTEDGE,0,NULL,NULL},
  128.     {504,144,116,14,"InitialInfoTopEdge   ",  NULL,ID_INITIALINFOTOPEDGE,0,NULL,NULL},
  129.     {594,159,26,11, "InitialInfoOpened",      NULL,ID_INITIALINFOOPENED,0,NULL,NULL},
  130.     {594,171,26,11, "InitialAutoScroll",      NULL,ID_INITIALAUTOSCROLL,0,NULL,NULL},
  131.     {594,183,26,11, "DoWidth",                NULL,ID_DOWIDTH,0,NULL,NULL},
  132.     {594,195,26,11, "DoHeight",               NULL,ID_DOHEIGHT,0,NULL,NULL},
  133.     {594,207,26,11, "DoDepth",                NULL,ID_DODEPTH,0,NULL,NULL},
  134.     {594,219,26,11, "DoOverscanType",         NULL,ID_DOOVERSCANTYPE,0,NULL,NULL},
  135.     {594,231,26,11, "DoAutoScroll",           NULL,ID_DOAUTOSCROLL,0,NULL,NULL},
  136.     {594,243,26,11, "CustomSMList",           NULL,ID_CUSTOMSMLIST,0,NULL,NULL},
  137.     {504,255,116,14,"PropertyFlags   ",       NULL,ID_PROPERTYFLAGS,0,NULL,NULL},
  138.     {504,270,116,14,"PropertyMask   ",        NULL,ID_PROPERTYMASK,0,NULL,NULL},
  139.     {504,285,116,14,"MinWidth   ",            NULL,ID_MINWIDTH_SM,0,NULL,NULL},
  140.     {504,300,116,14,"MaxWidth   ",            NULL,ID_MAXWIDTH_SM,0,NULL,NULL},
  141.     {504,315,116,14,"MinHeight   ",           NULL,ID_MINHEIGHT_SM,0,NULL,NULL},
  142.     {504,330,116,14,"MaxHeight   ",           NULL,ID_MAXHEIGHT_SM,0,NULL,NULL},
  143.     {504,345,116,11,"MinDepth   ",            NULL,ID_MINDEPTH,0,NULL,NULL},
  144.     {504,357,116,11,"MaxDepth   ",            NULL,ID_MAXDEPTH,0,NULL,NULL},
  145. };
  146.  
  147. static const STRPTR ReferenceLabels[] =
  148. {
  149.     "None",
  150.     "Window",
  151.     "Screen",
  152.     "PubScreenName",
  153.     NULL
  154. };
  155.  
  156. static const STRPTR ReqTypeLabels[] =
  157. {
  158.     "File",
  159.     "Font",
  160.     "ScreenMode",
  161.     NULL
  162. };
  163.  
  164. static const STRPTR DrawModeLabels[] =
  165. {
  166.     "Jam1",
  167.     "Jam2",
  168.     "Complement",
  169.     NULL
  170. };
  171.  
  172. static const STRPTR OverscanTypeLabels[] =
  173. {
  174.     "Text",
  175.     "Graphics",
  176.     "Extreme",
  177.     "Maximum",
  178.     NULL
  179. };
  180.  
  181. struct CommonData cd =
  182. {
  183.     0,     // RefObject
  184.     30,    // InitialLeftEdge
  185.     20,    // InitialTopEdge
  186.     320,   // InitialWidth
  187.     200,   // InitialHeight
  188.     "",    // TitleText
  189.     "",    // PositiveText
  190.     "",    // NegativeText
  191.     "",    // FontName
  192.     8,     // FontSize
  193.     "",    // Locale
  194.     TRUE,  // PrivateIDCMP
  195.     TRUE,  // SleepWindow
  196.     FALSE, // IntuiMsgFunc
  197.     FALSE  // FilterFunc
  198. };
  199.  
  200. struct FileReqData frd =
  201. {
  202.     "",    // InitialFile
  203.     "",    // InitialDrawer
  204.     "",    // InitialPattern
  205.     "",    // AcceptPattern
  206.     "",    // RejectPattern
  207.     FALSE, // DoSaveMode
  208.     FALSE, // DoMultiSelect
  209.     FALSE, // DoPatterns
  210.     FALSE, // DrawersOnly
  211.     TRUE,  // RejectIcons
  212.     FALSE  // FilterDrawers
  213. };
  214.  
  215. struct FontReqData fod =
  216. {
  217.     "",    // InitialName
  218.     8,     // InitialSize
  219.     1,     // InitialFrontPen
  220.     0,     // InitialBackPen
  221.     JAM1,  // InitialDrawMode
  222.     0,     // InitialStyle
  223.     TRUE,  // DoFrontPen
  224.     TRUE,  // DoBackPen
  225.     TRUE,  // DoDrawMode
  226.     TRUE,  // DoStyle
  227.     FALSE, // FixedWidthOnly
  228.     4,     // MinHeight
  229.     32,    // MaxHeight
  230.     255,   // MaxFrontPen
  231.     255,   // MaxBackPen
  232.     FALSE, // FrontPens
  233.     FALSE, // BackPens
  234.     FALSE  // ModeList
  235. };
  236.  
  237. struct ScreenModeReqData smrd =
  238. {
  239.     0,          // InitialDisplayID
  240.     640,        // InitialDisplayWidth
  241.     200,        // InitialDisplayHeight
  242.     2,          // InitialDisplayDepth
  243.     OSCAN_TEXT, // InitialOverscanType
  244.     30,         // InitialInfoLeftEdge
  245.     20,         // InitialInfoTopEdge
  246.     FALSE,      // InitialInfoOpened
  247.     TRUE,       // InitialAutoScroll
  248.     TRUE,       // DoWidth
  249.     TRUE,       // DoHeight
  250.     TRUE,       // DoDepth
  251.     TRUE,       // DoOverscanType
  252.     TRUE,       // DoAutoScroll
  253.     FALSE,      // CustomSMList
  254.     DIPF_IS_WB, // PropertyFlags
  255.     DIPF_IS_WB, // PropertyMask
  256.     320,        // MinWidth
  257.     10000,      // MaxWidth
  258.     200,        // MinHeight
  259.     10000,      // MaxHeight
  260.     1,          // MinDepth
  261.     8,          // MaxDepth
  262. };
  263.  
  264.  
  265. /*****************************************************************************/
  266.  
  267.  
  268. extern struct Library *SysBase;
  269. extern struct Library *DOSBase;
  270. struct Library        *GfxBase;
  271. struct Library        *IntuitionBase;
  272. struct Library        *GadToolsBase;
  273. struct Library        *UtilityBase;
  274. struct Library        *AslBase;
  275. struct Library        *LocaleBase;
  276.  
  277. struct Screen         *screen;
  278. struct Window         *window;
  279. struct DrawInfo       *drawInfo;
  280. APTR                   visualInfo;
  281. struct TextFont       *textFont;
  282. struct Gadget         *gadgetList;
  283. struct Gadget         *gadgets[ID_MAX];
  284. struct Gadget         *lastAdded;
  285. struct Hook            hexHook;
  286.  
  287. ULONG                  requesterType;
  288.  
  289.  
  290. /*****************************************************************************/
  291.  
  292.  
  293. /* This function render a few borders and lines within the main window.
  294.  * This gets called whenever the window is initially opened, and whenever
  295.  * there is damage.
  296.  */
  297. static VOID RenderWindow(VOID)
  298. {
  299. static UWORD pattern[] = {0xaaaa, 0x5555};
  300.  
  301.     SetAPen(window->RPort,drawInfo->dri_Pens[SHADOWPEN]);
  302.     RectFill(window->RPort,window->BorderLeft + 316,window->BorderTop,
  303.                            window->BorderLeft + 316,window->Height - window->BorderBottom - 1);
  304.  
  305.     RectFill(window->RPort,window->BorderLeft,window->BorderTop + 325,
  306.                            window->BorderLeft + 315,window->BorderTop + 325);
  307.  
  308.     SetAPen(window->RPort,drawInfo->dri_Pens[SHINEPEN]);
  309.     RectFill(window->RPort,window->BorderLeft + 317,window->BorderTop,
  310.                            window->BorderLeft + 317,window->Height - window->BorderBottom - 1);
  311.  
  312.     RectFill(window->RPort,window->BorderLeft,window->BorderTop + 326,
  313.                            window->BorderLeft + 315,window->BorderTop + 326);
  314.  
  315.     SetAPen(window->RPort,drawInfo->dri_Pens[TEXTPEN]);
  316.     SetAfPt(window->RPort,pattern,1);
  317.     RectFill(window->RPort,window->BorderLeft + 328,window->BorderTop + 47,
  318.                            window->Width - window->BorderRight - 11,window->BorderTop + 47);
  319.     SetAfPt(window->RPort,NULL,0);
  320.  
  321.     if (requesterType == REQ_FONT)
  322.     {
  323.         Move(window->RPort,window->BorderLeft + 504,window->BorderTop + 134);
  324.         Draw(window->RPort,window->BorderLeft + 498,window->BorderTop + 134);
  325.         Draw(window->RPort,window->BorderLeft + 468,window->BorderTop + 153);
  326.         Draw(window->RPort,window->BorderLeft + 498,window->BorderTop + 172);
  327.         Draw(window->RPort,window->BorderLeft + 504,window->BorderTop + 172);
  328.     }
  329. }
  330.  
  331.  
  332. /*****************************************************************************/
  333.  
  334.  
  335. /* Short stub to create a gadget. Copies one of the static definitions,
  336.  * sets its visual info, and text attr pointer, offsets its position by the
  337.  * window's left/top border, then creates the gadget. The resulting pointer
  338.  * is stashes in the gadget pointer array that's maintained
  339.  */
  340. static VOID CreateGad(ULONG kind, ULONG id, ULONG tag1, ...)
  341. {
  342. struct NewGadget ng;
  343.  
  344.     ng = NG[id];
  345.     ng.ng_TextAttr    = &topazAttr;
  346.     ng.ng_VisualInfo  = visualInfo;
  347.     ng.ng_LeftEdge   += window->BorderLeft;
  348.     ng.ng_TopEdge    += window->BorderTop;
  349.  
  350.     lastAdded = gadgets[id] = CreateGadgetA(kind,lastAdded,&ng,(struct TagItem *)&tag1);
  351. }
  352.  
  353.  
  354. /*****************************************************************************/
  355.  
  356.  
  357. /* Special version of CreateGad() that creates a hex-edit gadget, as
  358.  * used to enter a display mode id in the screen mode requester section
  359.  * of the program.
  360.  */
  361. static VOID CreateHexGad(ULONG id, ULONG value)
  362. {
  363. char buffer[12];
  364.  
  365.     sprintf(buffer,"0x%08lX",value);
  366.     CreateGad(STRING_KIND,id,GTST_MaxChars, 10,
  367.                              GTST_String,   buffer,
  368.                              GTST_EditHook, &hexHook,
  369.                              TAG_DONE);
  370.  
  371.     if (gadgets[id])
  372.         gadgets[id]->UserData = (APTR)value;
  373. }
  374.  
  375.  
  376. /*****************************************************************************/
  377.  
  378.  
  379. /* Get a single attribute from one of the gadgets in the gadget array */
  380. static ULONG GetGadAttr(ULONG id, ULONG tag)
  381. {
  382. ULONG result;
  383.  
  384.     GT_GetGadgetAttrs(gadgets[id],window,NULL,tag,&result,TAG_DONE);
  385.  
  386.     return(result);
  387. }
  388.  
  389.  
  390. /*****************************************************************************/
  391.  
  392.  
  393. /* set attributes of one of the gadgets in the gadget array */
  394. static VOID SetGadAttrs(ULONG id, ULONG tag1, ...)
  395. {
  396.     GT_SetGadgetAttrsA(gadgets[id],window,NULL,(struct TagItem *)&tag1);
  397. }
  398.  
  399.  
  400. /*****************************************************************************/
  401.  
  402.  
  403. /* Range check an integer gadget. If the value falls outside of its allowed
  404.  * range, fence it.
  405.  */
  406. static VOID RangeCheckGad(ULONG id, LONG min, LONG max)
  407. {
  408. LONG num;
  409.  
  410.     if (gadgets[id])
  411.     {
  412.         num = GetGadAttr(id,GTIN_Number);
  413.  
  414.         if (num < min)
  415.             SetGadAttrs(id,GTIN_Number,min,TAG_DONE);
  416.  
  417.         if (num > max)
  418.             SetGadAttrs(id,GTIN_Number,max,TAG_DONE);
  419.     }
  420. }
  421.  
  422.  
  423. /*****************************************************************************/
  424.  
  425.  
  426. /* Creates all the gadgets needed for the 3 possible displays presented
  427.  * by the program... The values to set the gadgets to are taken from the
  428.  * global requester data variables (cd, frd, fod, and smrd)
  429.  */
  430. static BOOL InstallGadgets(VOID)
  431. {
  432.     gadgetList = NULL;
  433.     lastAdded  = CreateContext(&gadgetList);
  434.     memset(gadgets,0,sizeof(gadgets));
  435.  
  436.     CreateGad(CYCLE_KIND,ID_REFOBJECT,GTCY_Labels, &ReferenceLabels,
  437.                                       GTCY_Active, cd.RefObject,
  438.                                       TAG_DONE);
  439.  
  440.     CreateGad(INTEGER_KIND,ID_INITIALLEFTEDGE,GTIN_MaxChars, 4,
  441.                                               GTIN_Number,   cd.InitialLeftEdge,
  442.                                               TAG_DONE);
  443.  
  444.     CreateGad(INTEGER_KIND,ID_INITIALTOPEDGE,GTIN_MaxChars, 4,
  445.                                              GTIN_Number,   cd.InitialTopEdge,
  446.                                              TAG_DONE);
  447.  
  448.     CreateGad(INTEGER_KIND,ID_INITIALWIDTH,GTIN_MaxChars, 4,
  449.                                            GTIN_Number,   cd.InitialWidth,
  450.                                            TAG_DONE);
  451.  
  452.     CreateGad(INTEGER_KIND,ID_INITIALHEIGHT,GTIN_MaxChars, 4,
  453.                                             GTIN_Number,   cd.InitialHeight,
  454.                                             TAG_DONE);
  455.  
  456.     CreateGad(STRING_KIND,ID_TITLETEXT,GTST_MaxChars, sizeof(cd.TitleText) - 1,
  457.                                        GTST_String,   cd.TitleText,
  458.                                        TAG_DONE);
  459.  
  460.     CreateGad(STRING_KIND,ID_POSITIVETEXT,GTST_MaxChars, sizeof(cd.PositiveText) - 1,
  461.                                           GTST_String,   cd.PositiveText,
  462.                                           TAG_DONE);
  463.  
  464.     CreateGad(STRING_KIND,ID_NEGATIVETEXT,GTST_MaxChars, sizeof(cd.NegativeText) - 1,
  465.                                           GTST_String,   cd.NegativeText,
  466.                                           TAG_DONE);
  467.  
  468.     CreateGad(STRING_KIND,ID_FONTNAME,GTST_MaxChars, sizeof(cd.FontName) - 1,
  469.                                       GTST_String,   cd.FontName,
  470.                                       TAG_DONE);
  471.  
  472.     CreateGad(‰INTEGER_KIND,ID_FONTSIZE,GTIN_MaxChars, 4,
  473.                                         GTIN_Number,   cd.FontSize,
  474.                                         TAG_DONE);
  475.  
  476.     CreateGad(STRING_KIND,ID_LOCALE,GTST_MaxChars, sizeof(cd.Locale) - 1,
  477.                                     GTST_String,   cd.Locale,
  478.                                     TAG_DONE);
  479.  
  480.     CreateGad(CHECKBOX_KIND,ID_PRIVATEIDCMP,GTCB_Checked, cd.PrivateIDCMP,
  481.                                             TAG_DONE);
  482.  
  483.     CreateGad(CHECKBOX_KIND,ID_SLEEPWINDOW,GTCB_Checked, cd.SleepWindow,
  484.                                            TAG_DONE);
  485.  
  486.     CreateGad(CHECKBOX_KIND,ID_INTUIMSGFUNC,GTCB_Checked, cd.IntuiMsgFunc,
  487.                                             TAG_DONE);
  488.  
  489.     CreateGad(CHECKBOX_KIND,ID_FILTERFUNC,GTCB_Checked, cd.FilterFunc,
  490.                                           TAG_DONE);
  491.  
  492.     CreateGad(CYCLE_KIND,ID_REQTYPE,GTCY_Labels, &ReqTypeLabels,
  493.                                     GTCY_Active, requesterType,
  494.                                     TAG_DONE);
  495.  
  496.     CreateGad(BUTTON_KIND,ID_TEST,TAG_DONE);
  497.  
  498.     if (requesterType == REQ_FILE)
  499.     {
  500.         CreateGad(STRING_KIND,ID_INITIALFILE,GTST_MaxChars, sizeof(frd.InitialFile) - 1,
  501.                                              GTST_String,   frd.InitialFile,
  502.                                              TAG_DONE);
  503.  
  504.         CreateGad(STRING_KIND,ID_INITIALDRAWER,GTST_MaxChars, sizeof(frd.InitialDrawer) - 1,
  505.                                                GTST_String,   frd.InitialDrawer,
  506.                                                TAG_DONE);
  507.  
  508.         CreateGad(STRING_KIND,ID_INITIALPATTERN,GTST_MaxChars, sizeof(frd.InitialPattern) - 1,
  509.                                                 GTST_String,   frd.InitialPattern,
  510.                                                 TAG_DONE);
  511.  
  512.         CreateGad(STRING_KIND,ID_ACCEPTPATTERN,GTST_MaxChars, sizeof(frd.AcceptPattern) - 1,
  513.                                                GTST_String,   frd.AcceptPattern,
  514.                                                TAG_DONE);
  515.  
  516.         CreateGad(STRING_KIND,ID_REJECTPATTERN,GTST_MaxChars, sizeof(frd.RejectPattern) - 1,
  517.                                                GTST_String,   frd.RejectPattern,
  518.                                                TAG_DONE);
  519.  
  520.         CreateGad(CHECKBOX_KIND,ID_DOSAVEMODE,GTCB_Checked, frd.DoSaveMode,
  521.                                               TAG_DONE);
  522.  
  523.         CreateGad(CHECKBOX_KIND,ID_DOMULTISELECT,GTCB_Checked, frd.DoMultiSelect,
  524.                                                  TAG_DONE);
  525.  
  526.         CreateGad(CHECKBOX_KIND,ID_DOPATTERNS,GTCB_Checked, frd.DoPatterns,
  527.                                               TAG_DONE);
  528.  
  529.         CreateGad(CHECKBOX_KIND,ID_DRAWERSONLY,GTCB_Checked, frd.DrawersOnly,
  530.                                                TAG_DONE);
  531.  
  532.         CreateGad(CHECKBOX_KIND,ID_REJECTICONS,GTCB_Checked, frd.RejectIcons,
  533.                                                TAG_DONE);
  534.  
  535.         CreateGad(CHECKBOX_KIND,ID_FILTERDRAWERS,GTCB_Checked, frd.FilterDrawers,
  536.                                                  TAG_DONE);
  537.     }
  538.     else if (requesterType == REQ_FONT)
  539.     {
  540.         CreateGad(STRING_KIND,ID_INITIALNAME,GTST_MaxChars, sizeof(fod.InitialName) - 1,
  541.                                              GTST_String,   fod.InitialName,
  542.                                              TAG_DONE);
  543.  
  544.         CreateGad(SLIDER_KIND,ID_INITIALSIZE,GTSL_MaxLevelLen, 3,
  545.                                              GTSL_LevelFormat, "%3ld",
  546.                                              GTSL_Level,       fod.InitialSize,
  547.                                              GTSL_Min,         4,
  548.                                              GTSL_Max,         127,
  549.                                              TAG_DONE);
  550.  
  551.         CreateGad(SLIDER_KIND,ID_INITIALFRONTPEN,GTSL_MaxLevelLen, 3,
  552.                                                  GTSL_LevelFormat, "%3ld",
  553.                                                  GTSL_Level,       fod.InitialFrontPen,
  554.                                                  GTSL_Min,         0,
  555.                                                  GTSL_Max,         255,
  556.                                                  TAG_DONE);
  557.  
  558.         CreateGad(SLIDER_KIND,ID_INITIALBACKPEN,GTSL_MaxLevelLen, 3,
  559.                                                 GTSL_LevelFormat, "%3ld",
  560.                                                 GTSL_Level,       fod.InitialBackPen,
  561.                                                 GTSL_Min,         0,
  562.                                                 GTSL_Max,         255,
  563.                                                 TAG_DONE);
  564.  
  565.         CreateGad(CYCLE_KIND,ID_INITIALDRAWMODE,GTCY_Labels, &DrawModeLabels,
  566.                                                 GTCY_Active, fod.InitialDrawMode,
  567.                                                 TAG_DONE);
  568.  
  569.         CreateGad(TEXT_KIND,ID_INITIALSTYLE,TAG_DONE);
  570.  
  571.         CreateGad(CHECKBOX_KIND,ID_INITIALSTYLE_PLAIN,GTCB_Checked, fod.InitialStyle == 0,
  572.                                                       TAG_DONE);
  573.  
  574.         CreateGad(CHECKBOX_KIND,ID_INITIALSTYLE_BOLD,GTCB_Checked, fod.InitialStyle & FSF_BOLD,
  575.                                                      TAG_DONE);
  576.  
  577.         CreateGad(CHECKBOX_KIND,ID_INITIALSTYLE_ITALIC,GTCB_Checked, fod.InitialStyle & FSF_ITALIC,
  578.                                                        TAG_DONE);
  579.  
  580.         CreateGad(CHECKBOX_KIND,ID_INITIALSTYLE_UNDERLINE,GTCB_Checked, fod.InitialStyle & FSF_UNDERLINED,
  581.                                                           TAG_DONE);
  582.  
  583.         CreateGad(CHECKBOX_KIND,ID_DOFRONTPEN,GTCB_Checked, fod.DoFrontPen,
  584.                                               TAG_DONE);
  585.  
  586.         CreateGad(CHECKBOX_KIND,ID_DOBACKPEN,GTCB_Checked, fod.DoBackPen,
  587.                                              TAG_DONE);
  588.  
  589.         CreateGad(CHECKBOX_KIND,ID_DOSTYLE,GTCB_Checked, fod.DoStyle,
  590.                                            TAG_DONE);
  591.  
  592.         CreateGad(CHECKBOX_KIND,ID_DODRAWMODE,GTCB_Checked, fod.DoDrawMode,
  593.                                               TAG_DONE);
  594.  
  595.         CreateGad(CHECKBOX_KIND,ID_FIXEDWIDTHONLY,GTCB_Checked, fod.FixedWidthOnly,
  596.                                                   TAG_DONE);
  597.  
  598.         CreateGad(SLIDER_KIND,ID_MINHEIGHT,GTSL_MaxLevelLen, 3,
  599.                                            GTSL_LevelFormat, "%3ld",
  600.                                            GTSL_Level,       fod.MinHeight,
  601.                                            GTSL_Min,         4,
  602.                                            GTSL_Max,         127,
  603.                                            TAG_DONE);
  604.  
  605.         CreateGad(SLIDER_KIND,ID_MAXHEIGHT,GTSL_MaxLevelLen, 3,
  606.                                            GTSL_LevelFormat, "%3ld",
  607.                                            GTSL_Level,       fod.MaxHeight,
  608.                                            GTSL_Min,         4,
  609.                                            GTSL_Max,         127,
  610.                                            TAG_DONE);
  611.  
  612.         CreateGad(SLIDER_KIND,ID_MAXFRONTPEN,GTSL_MaxLevelLen, 3,
  613.                                              GTSL_LevelFormat, "%3ld",
  614.                                              GTSL_Level,       fod.MaxFrontPen,
  615.                                              GTSL_Min,         1,
  616.                                              GTSL_Max,         255,
  617.                                              TAG_DONE);
  618.  
  619.         CreateGad(SLIDER_KIND,ID_MAXBACKPEN,GTSL_MaxLevelLen, 3,
  620.                                             GTSL_LevelFormat, "%3ld",
  621.                                             GTSL_Level,       fod.MaxBackPen,
  622.                                             GTSL_Min,         1,
  623.                                             GTSL_Max,         255,
  624.                                             TAG_DONE);
  625.  
  626.         CreateGad(CHECKBOX_KIND,ID_FRONTPENS,GTCB_Checked, fod.FrontPens,
  627.                                              GA_Disabled,  TRUE,  // Not implemented in demo
  628.                                              TAG_DONE);
  629.  
  630.         CreateGad(CHECKBOX_KIND,ID_BACKPENS,GTCB_Checked, fod.BackPens,
  631.                                             GA_Disabled,  TRUE,   // Not implemented in demo
  632.                                             TAG_DONE);
  633.  
  634.         CreateGad(CHECKBOX_KIND,ID_MODELIST,GTCB_Checked, fod.ModeList,
  635.                                             TAG_DONE);
  636.  
  637.         RenderWindow(); /* to get the little lines drawn */
  638.     }
  639.     else /* if (requesterType == REQ_SCREENMODE) */
  640.     {
  641.         CreateHexGad(ID_INITIALDISPLAYID,smrd.InitialDisplayID);
  642.  
  643.         CreateGad(INTEGER_KIND,ID_INITIALDISPLAYWIDTH,GTIN_MaxChars, 5,
  644.                                                       GTIN_Number,   smrd.InitialDisplayWidth,
  645.                                                       TAG_DONE);
  646.  
  647.         CreateGad(INTEGER_KIND,ID_INITIALDISPLAYHEIGHT,GTIN_MaxChars, 5,
  648.                                                        GTIN_Number,   smrd.InitialDisplayHeight,
  649.                                                        TAG_DONE);
  650.  
  651.         CreateGad(SLIDER_KIND,ID_INITIALDISPLAYDEPTH,GTSL_MaxLevelLen, 2,
  652.                                                      GTSL_LevelFormat, "%2ld",
  653.                                                      GTSL_Level,       smrd.InitialDisplayDepth,
  654.                                                      GTSL_Min,         1,
  655.                                                      GTSL_Max,         32,
  656.                                                      TAG_DONE);
  657.  
  658.         CreateGad(CYCLE_KIND,ID_INITIALOVERSCANTYPE,GTCY_Labels, &OverscanTypeLabels,
  659.                                                     GTCY_Active, smrd.InitialOverscanType - 1,
  660.                                                     TAG_DONE);
  661.  
  662.         CreateGad(INTEGER_KIND,ID_INITIALINFOLEFTEDGE,GTIN_MaxChars, 5,
  663.                                                       GTIN_Number,   smrd.InitialInfoLeftEdge,
  664.                                                       TAG_DONE);
  665.  
  666.         CreateGad(INTEGER_KIND,ID_INITIALINFOTOPEDGE,GTIN_MaxChars, 5,
  667.                                                      GTIN_Number,   smrd.InitialInfoTopEdge,
  668.                                                      TAG_DONE);
  669.  
  670.         CreateGad(CHECKBOX_KIND,ID_INITIALINFOOPENED,GTCB_Checked, smrd.InitialInfoOpened,
  671.                                                      TAG_DONE);
  672.  
  673.         CreateGad(CHECKBOX_KIND,ID_INITIALAUTOSCROLL,GTCB_Checked, smrd.InitialAutoScroll,
  674.                                                      TAG_DONE);
  675.  
  676.         CreateGad(CHECKBOX_KIND,ID_DOWIDTH,GTCB_Checked, smrd.DoWidth,
  677.                                            TAG_DONE);
  678.  
  679.         CreateGad(CHECKBOX_KIND,ID_DOHEIGHT,GTCB_Checked, smrd.DoHeight,
  680.                                             TAG_DONE);
  681.  
  682.         CreateGad(CHECKBOX_KIND,ID_DODEPTH,GTCB_Checked, smrd.DoDepth,
  683.                                            TAG_DONE);
  684.  
  685.         CreateGad(CHECKBOX_KIND,ID_DOOVERSCANTYPE,GTCB_Checked, smrd.DoOverscanType,
  686.                                                   TAG_DONE);
  687.  
  688.         CreateGad(CHECKBOX_KIND,ID_DOAUTOSCROLL,GTCB_Checked, smrd.DoAutoScroll,
  689.                                                 TAG_DONE);
  690.  
  691.         CreateGad(CHECKBOX_KIND,ID_CUSTOMSMLIST,GTCB_Checked, smrd.CustomSMList,
  692.                                                 TAG_DONE);
  693.  
  694.         CreateHexGad(ID_PROPERTYFLAGS,smrd.PropertyFlags);
  695.         CreateHexGad(ID_PROPERTYMASK,smrd.PropertyMask);
  696.  
  697.         CreateGad(INTEGER_KIND,ID_MINWIDTH_SM,GTIN_MaxChars, 5,
  698.                                               GTIN_Number,   smrd.MinWidth,
  699.                                               TAG_DONE);
  700.  
  701.         CreateGad(INTEGER_KIND,ID_MAXWIDTH_SM,GTIN_MaxChars, 5,
  702.                                               GTIN_Number,   smrd.MaxWidth,
  703.                                               TAG_DONE);
  704.  
  705.         CreateGad(INTEGER_KIND,ID_MINHEIGHT_SM,GTIN_MaxChars, 5,
  706.                                                GTIN_Number,   smrd.MinHeight,
  707.                                                TAG_DONE);
  708.  
  709.         CreateGad(INTEGER_KIND,ID_MAXHEIGHT_SM,GTIN_MaxChars, 5,
  710.                                                GTIN_Number,   smrd.MaxHeight,
  711.                                                TAG_DONE);
  712.  
  713.         CreateGad(SLIDER_KIND,ID_MINDEPTH,GTSL_MaxLevelLen, 2,
  714.                                           GTSL_LevelFormat, "%2ld",
  715.                                           GTSL_Level,       smrd.MinDepth,
  716.                                           GTSL_Min,         1,
  717.                                           GTSL_Max,         32,
  718.                                           TAG_DONE);
  719.  
  720.         CreateGad(SLIDER_KIND,ID_MAXDEPTH,GTSL_MaxLevelLen, 2,
  721.                                           GTSL_LevelFormat, "%2ld",
  722.                                           GTSL_Level,       smrd.MaxDepth,
  723.                                           GTSL_Min,         1,
  724.                                           GTSL_Max,         32,
  725.                                           TAG_DONE);
  726.  
  727.     }
  728.  
  729.     if (!lastAdded)
  730.     {
  731.         FreeGadgets(gadgetList);
  732.         return(FALSE);
  733.     }
  734.  
  735.     AddGList(window,gadgetList,-1,-1,NULL);
  736.     RefreshGList(gadgetList,window,NULL,-1);
  737.     GT_RefreshWindow(window,NULL);
  738.  
  739.     return(TRUE);
  740. }
  741.  
  742.  
  743. /*****************************************************************************/
  744.  
  745.  
  746. /* Standard range check of all gadgets that need it */
  747. static VOID RangeCheckGadgets(VOID)
  748. {
  749.     RangeCheckGad(ID_INITIALLEFTEDGE,0,10000);
  750.     RangeCheckGad(ID_INITIALTOPEDGE,0,10000);
  751.     RangeCheckGad(ID_INITIALWIDTH,10,10000);
  752.     RangeCheckGad(ID_INITIALHEIGHT,10,10000);
  753.     RangeCheckGad(ID_INITIALDISPLAYWIDTH,16,32000);
  754.     RangeCheckGad(ID_INITIALDISPLAYHEIGHT,16,32000);
  755.     RangeCheckGad(ID_FONTSIZE,4,127);
  756. }
  757.  
  758.  
  759. /*****************************************************************************/
  760.  
  761.  
  762. /* This function reads the current values of the gadgets in the window,
  763.  * and updates the contents of the global requester data variables (cd,
  764.  * frd, fod, and smrd) to match what the gadgets indicate.
  765.  */
  766. static VOID ReadGadgets(VOID)
  767. {
  768.     RangeCheckGadgets();
  769.  
  770.     cd.RefObject       = GetGadAttr(ID_REFOBJECT,GTCY_Active);
  771.     cd.InitialLeftEdge = GetGadAttr(ID_INITIALLEFTEDGE,GTIN_Number);
  772.     cd.InitialTopEdge  = GetGadAttr(ID_INITIALTOPEDGE,GTIN_Number);
  773.     cd.InitialWidth    = GetGadAttr(ID_INITIALWIDTH,GTIN_Number);
  774.     cd.InitialHeight   = GetGadAttr(ID_INITIALHEIGHT,GTIN_Number);
  775.     strcpy(cd.TitleText,(STRPTR)GetGadAttr(ID_TITLETEXT,GTST_String));
  776.     strcpy(cd.PositiveText,(STRPTR)GetGadAttr(ID_POSITIVETEXT,GTST_String));
  777.     strcpy(cd.NegativeText,(STRPTR)GetGadAttr(ID_NEGATIVETEXT,GTST_String));
  778.     strcpy(cd.FontName,(STRPTR)GetGadAttr(ID_FONTNAME,GTST_String));
  779.     cd.FontSize       = GetGadAttr(ID_FONTSIZE,GTIN_Number);
  780.     strcpy(cd.Locale,(STRPTR)GetGadAttr(ID_LOCALE,GTST_String));
  781.     cd.PrivateIDCMP   = GetGadAttr(ID_PRIVATEIDCMP,GTCB_Checked);
  782.     cd.SleepWindow    = GetGadAttr(ID_SLEEPWINDOW,GTCB_Checked);
  783.     cd.IntuiMsgFunc   = GetGadAttr(ID_INTUIMSGFUNC,GTCB_Checked);
  784.     cd.FilterFunc     = GetGadAttr(ID_FILTERFUNC,GTCB_Checked);
  785.  
  786.     if (requesterType == REQ_FILE)
  787.     {
  788.         strcpy(frd.InitialFile,(STRPTR)GetGadAttr(ID_INITIALFILE,GTST_String));
  789.         strcpy(frd.InitialDrawer,(STRPTR)GetGadAttr(ID_INITIALDRAWER,GTST_String));
  790.         strcpy(frd.InitialPattern,(STRPTR)GetGadAttr(ID_INITIALPATTERN,GTST_String));
  791.         strcpy(frd.AcceptPattern,(STRPTR)GetGadAttr(ID_ACCEPTPATTERN,GTST_String));
  792.         strcpy(frd.RejectPattern,(STRPTR)GetGadAttr(ID_REJECTPATTERN,GTST_String));
  793.         frd.DoSaveMode    = GetGadAttr(ID_DOSAVEMODE,GTCB_Checked);
  794.         frd.DoMultiSelect = GetGadAttr(ID_DOMULTISELECT,GTCB_Checked);
  795.         frd.DoPatterns    = GetGadAttr(ID_DOPATTERNS,GTCB_Checked);
  796.         frd.DrawersOnly   = GetGadAttr(ID_DRAWERSONLY,GTCB_Checked);
  797.         frd.RejectIcons   = GetGadAttr(ID_REJECTICONS,GTCB_Checked);
  798.         frd.FilterDrawers = GetGadAttr(ID_FILTERDRAWERS,GTCB_Checked);
  799.     }
  800.     else if (requesterType == REQ_FONT)
  801.     {
  802.         strcpy(fod.InitialName,(STRPTR)GetGadAttr(ID_INITIALNAME,GTST_String));
  803.         fod.InitialSize     = GetGadAttr(ID_INITIALSIZE,GTSL_Level);
  804.         fod.InitialFrontPen = GetGadAttr(ID_INITIALFRONTPEN,GTSL_Level);
  805.         fod.InitialBackPen  = GetGadAttr(ID_INITIALBACKPEN,GTSL_Level);
  806.         fod.InitialDrawMode = GetGadAttr(ID_INITIALDRAWMODE,GTCY_Active);
  807.         fod.DoFrontPen      = GetGadAttr(ID_DOFRONTPEN,GTCB_Checked);
  808.         fod.DoBackPen       = GetGadAttr(ID_DOBACKPEN,GTCB_Checked);
  809.         fod.DoStyle         = GetGadAttr(ID_DOSTYLE,GTCB_Checked);
  810.         fod.DoDrawMode      = GetGadAttr(ID_DODRAWMODE,GTCB_Checked);
  811.         fod.FixedWidthOnly  = GetGadAttr(ID_FIXEDWIDTHONLY,GTCB_Checked);
  812.         fod.MinHeight       = GetGadAttr(ID_MINHEIGHT,GTSL_Level);
  813.         fod.MaxHeight       = GetGadAttr(ID_MAXHEIGHT,GTSL_Level);
  814.         fod.MaxFrontPen     = GetGadAttr(ID_MAXFRONTPEN,GTSL_Level);
  815.         fod.MaxBackPen      = GetGadAttr(ID_MAXBACKPEN,GTSL_Level);
  816.         fod.FrontPens       = GetGadAttr(ID_FRONTPENS,GTCB_Checked);
  817.         fod.BackPens        = GetGadAttr(ID_BACKPENS,GTCB_Checked);
  818.         fod.ModeList        = GetGadAttr(ID_MODELIST,GTCB_Checked);
  819.  
  820.         fod.InitialStyle    = (GetGadAttr(ID_INITIALSTYLE_BOLD,GTCB_Checked) << FSB_BOLD)
  821.                               | (GetGadAttr(ID_INITIALSTYLE_ITALIC,GTCB_Checked) << FSB_ITALIC)
  822.                               | (GetGadAttr(ID_INITIALSTYLE_UNDERLINE,GTCB_Checked) << FSB_UNDERLINED);
  823.     }
  824.     else /* if (requesterType == REQ_SCREENMODE) */
  825.     {
  826.         smrd.InitialDisplayID     = (ULONG)gadgets[ID_INITIALDISPLAYID]->UserData;
  827.         smrd.InitialDisplayWidth  = GetGadAttr(ID_INITIALDISPLAYWIDTH,GTIN_Number);
  828.         smrd.InitialDisplayHeight = GetGadAttr(ID_INITIALDISPLAYHEIGHT,GTIN_Number);
  829.         smrd.InitialDisplayDepth  = GetGadAttr(ID_INITIALDISPLAYDEPTH,GTSL_Level);
  830.         smrd.InitialOverscanType  = GetGadAttr(ID_INITIALOVERSCANTYPE,GTCY_Active) + 1;
  831.         smrd.InitialInfoLeftEdge  = GetGadAttr(ID_INITIALINFOLEFTEDGE,GTIN_Number);
  832.         smrd.InitialInfoTopEdge   = GetGadAttr(ID_INITIALINFOTOPEDGE,GTIN_Number);
  833.         smrd.InitialInfoOpened    = GetGadAttr(ID_INITIALINFOOPENED,GTCB_Checked);
  834.         smrd.InitialAutoScroll    = GetGadAttr(ID_INITIALAUTOSCROLL,GTCB_Checked);
  835.         smrd.DoWidth              = GetGadAttr(ID_DOWIDTH,GTCB_Checked);
  836.         smrd.DoHeight             = GetGadAttr(ID_DOHEIGHT,GTCB_Checked);
  837.         smrd.DoDepth              = GetGadAttr(ID_DODEPTH,GTCB_Checked);
  838.         smrd.DoOverscanType       = GetGadAttr(ID_DOOVERSCANTYPE,GTCB_Checked);
  839.         smrd.DoAutoScroll         = GetGadAttr(ID_DOAUTOSCROLL,GTCB_Checked);
  840.         smrd.CustomSMList         = GetGadAttr(ID_CUSTOMSMLIST,GTCB_Checked);
  841.         smrd.PropertyFlags        = (ULONG)gadgets[ID_PROPERTYFLAGS]->UserData;
  842.         smrd.PropertyMask         = (ULONG)gadgets[ID_PROPERTYMASK]->UserData;
  843.         smrd.MinWidth             = GetGadAttr(ID_MINWIDTH_SM,GTIN_Number);
  844.         smrd.MaxWidth             = GetGadAttr(ID_MAXWIDTH_SM,GTIN_Number);
  845.         smrd.MinHeight            = GetGadAttr(ID_MINHEIGHT_SM,GTIN_Number);
  846.         smrd.MaxHeight            = GetGadAttr(ID_MAXHEIGHT_SM,GTIN_Number);
  847.         smrd.MinDepth             = GetGadAttr(ID_MINDEPTH,GTSL_Level);
  848.         smrd.MaxDepth             = GetGadAttr(ID_MAXDEPTH,GTSL_Level);
  849.     }
  850. }
  851.  
  852.  
  853. /*****************************************************************************/
  854.  
  855.  
  856. /* Main event loop.
  857.  * Collect all events, and act on them...
  858.  */
  859. static VOID EventLoop(VOID)
  860. {
  861. ULONG                sigs;
  862. struct IntuiMessage *intuiMsg;
  863. BOOL                 quit;
  864. UWORD                icode;
  865.  
  866.     quit = FALSE;
  867.     while (!quit)
  868.     {
  869.         sigs = Wait((1 << window->UserPort->mp_SigBit) | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_F);
  870.  
  871.         /* if ctrl-c, quit */
  872.         if (sigs & SIGBREAKF_CTRL_C)
  873.             break;
  874.  
  875.         /* if ctrl-f, activate and bring to front */
  876.         if (sigs & SIGBREAKF_CTRL_F)
  877.         {
  878.             WindowToFront(window);
  879.             ActivateWindow(window);
  880.         }
  881.  
  882.         /* drain IDCMP */
  883.         while (intuiMsg = GT_GetIMsg(window->UserPort))
  884.         {
  885.             icode = intuiMsg->Code;
  886.  
  887.             switch (intuiMsg->Class)
  888.             {
  889.                 case IDCMP_VANILLAKEY   : if (icode != 0x1b) /* ESC key */
  890.                                               break;
  891.  
  892.                 case IDCMP_CLOSEWINDOW  : quit = TRUE;
  893.                                           break;
  894.  
  895.                 case IDCMP_REFRESHWINDOW: GT_BeginRefresh(window);
  896.                                           RenderWindow();
  897.                                           GT_EndRefresh(window,TRUE);
  898.                                           break;
  899.  
  900.                 case IDCMP_GADGETDOWN   :
  901.                 case IDCMP_MOUSEMOVE    :
  902.                 case IDCMP_GADGETUP     : switch (((struct Gadget *)intuiMsg->IAddress)->GadgetID)
  903.                                           {
  904.                                               case ID_REQTYPE: ReadGadgets();
  905.                                                                RemoveGList(window,gadgetList,-1);
  906.                                                                EraseRect(window->RPort,window->BorderLeft + 319,window->BorderTop + 48,
  907.                                                                                        window->Width - window->BorderRight - 1,window->Height - window->BorderBottom - 1);
  908.                                                                FreeGadgets(gadgetList);
  909.  
  910.                                                                requesterType = intuiMsg->Code;
  911.                                                                if (!InstallGadgets())
  912.                                                                    quit = TRUE;
  913.  
  914.                                                                break;
  915.  
  916.                                               case ID_INITIALSTYLE_PLAIN:
  917.                                                                if (!icode)
  918.                                                                    SetGadAttrs(ID_INITIALSTYLE_PLAIN,GTCB_Checked,TRUE,TAG_DONE);
  919.  
  920.                                                                SetGadAttrs(ID_INITIALSTYLE_BOLD,GTCB_Checked,FALSE,TAG_DONE);
  921.                                                                SetGadAttrs(ID_INITIALSTYLE_ITALIC,GTCB_Checked,FALSE,TAG_DONE);
  922.                                                                SetGadAttrs(ID_INITIALSTYLE_UNDERLINE,GTCB_Checked,FALSE,TAG_DONE);
  923.                                                                break;
  924.  
  925.                                               case ID_INITIALSTYLE_BOLD:
  926.                                                                if (icode)
  927.                                                                    SetGadAttrs(ID_INITIALSTYLE_PLAIN,GTCB_Checked,FALSE,TAG_DONE);
  928.                                                                else if (!GetGadAttr(ID_INITIALSTYLE_ITALIC,GTCB_Checked) && !GetGadAttr(ID_INITIALSTYLE_UNDERLINE,GTCB_Checked))
  929.                                                                    SetGadAttrs(ID_INITIALSTYLE_PLAIN,GTCB_Checked,TRUE,TAG_DONE);
  930.                                                                break;
  931.  
  932.                                               case ID_INITIALSTYLE_ITALIC:
  933.                                                                if (icode)
  934.                                                                    SetGadAttrs(ID_INITIALSTYLE_PLAIN,GTCB_Checked,FALSE,TAG_DONE);
  935.                                                                else if (!GetGadAttr(ID_INITIALSTYLE_BOLD,GTCB_Checked) && !GetGadAttr(ID_INITIALSTYLE_UNDERLINE,GTCB_Checked))
  936.                                                                    SetGadAttrs(ID_INITIALSTYLE_PLAIN,GTCB_Checked,TRUE,TAG_DONE);
  937.                                                                break;
  938.  
  939.                                               case ID_INITIALSTYLE_UNDERLINE:
  940.                                                                if (icode)
  941.                                                                    SetGadAttrs(ID_INITIALSTYLE_PLAIN,GTCB_Checked,FALSE,TAG_DONE);
  942.                                                                else if (!GetGadAttr(ID_INITIALSTYLE_BOLD,GTCB_Checked) && !GetGadAttr(ID_INITIALSTYLE_ITALIC,GTCB_Checked))
  943.                                                                    SetGadAttrs(ID_INITIALSTYLE_PLAIN,GTCB_Checked,TRUE,TAG_DONE);
  944.                                                                break;
  945.  
  946.                                               case ID_MINHEIGHT: if (GetGadAttr(ID_MAXHEIGHT,GTSL_Level) < icode)
  947.                                                                      SetGadAttrs(ID_MAXHEIGHT,GTSL_Level,icode,TAG_DONE);
  948.                                                                  break;
  949.  
  950.                                               case ID_MAXHEIGHT: if (GetGadAttr(ID_MINHEIGHT,GTSL_Level) > icode)
  951.                                                                      SetGadAttrs(ID_MINHEIGHT,GTSL_Level,icode,TAG_DONE);
  952.                                                                  break;
  953.  
  954.                                               case ID_MINDEPTH: if (GetGadAttr(ID_MAXDEPTH,GTSL_Level) < icode)
  955.                                                                     SetGadAttrs(ID_MAXDEPTH,GTSL_Level,icode,TAG_DONE);
  956.                                                                 break;
  957.  
  958.                                               case ID_MAXDEPTH: if (GetGadAttr(ID_MINDEPTH,GTSL_Level) > icode)
  959.                                                                     SetGadAttrs(ID_MINDEPTH,GTSL_Level,icode,TAG_DONE);
  960.                                                                 break;
  961.  
  962.                                               case ID_INITIALLEFTEDGE     :
  963.                                               case ID_INITIALTOPEDGE      :
  964.                                               case ID_INITIALWIDTH        :
  965.                                               case ID_INITIALHEIGHT       :
  966.                                               case ID_INITIALDISPLAYWIDTH :
  967.                                               case ID_INITIALDISPLAYHEIGHT:
  968.                                               case ID_FONTSIZE            : RangeCheckGadgets();
  969.                                                                             break;
  970.  
  971.  
  972.                                               case ID_TEST   : ReadGadgets();
  973.                                                                TestRequester(&cd,&frd,&fod,&smrd,requesterType);
  974.                                                                break;
  975.                                           }
  976.             }
  977.  
  978.             GT_ReplyIMsg(intuiMsg);
  979.  
  980.             if (quit)
  981.                 break;
  982.         }
  983.     }
  984. }
  985.  
  986.  
  987. /*****************************************************************************/
  988.  
  989.  
  990. /* Main entry point. Init the universe, and enter the event loop */
  991. LONG main(VOID)
  992. {
  993.     requesterType   = REQ_FILE;
  994.     hexHook.h_Entry = (HOOKFUNC)HexHook;
  995.  
  996.     /* open all basic libraries in case we need 'em later */
  997.     if (IntuitionBase = OpenLibrary("intuition.library" VERSTAG, 39))
  998.     {
  999.         GfxBase       = OpenLibrary("graphics.library", 39);
  1000.         GadToolsBase  = OpenLibrary("gadtools.library", 39);
  1001.         UtilityBase   = OpenLibrary("utility.library", 39);
  1002.         LocaleBase    = OpenLibrary("locale.library", 38);
  1003.     }
  1004.  
  1005.     /* check if we got everything we need */
  1006.     if (IntuitionBase && GfxBase && GadToolsBase && UtilityBase && LocaleBase)
  1007.     {
  1008.         if (screen = LockPubScreen(NULL))
  1009.         {
  1010.             if (drawInfo = GetScreenDrawInfo(screen))
  1011.             {
  1012.                 if (visualInfo = GetVisualInfoA(screen,NULL))
  1013.                 {
  1014.                     if (textFont = OpenFont(&topazAttr))
  1015.                     {
  1016.                         if (window = OpenWindowTags(NULL,
  1017.                                           WA_InnerWidth,   630,
  1018.                                           WA_InnerHeight,  375,
  1019.                                           WA_IDCMP,        IDCMP_GADGETUP | IDCMP_GADGETDOWN | IDCMP_MOUSEMOVE | IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW | IDCMP_VANILLAKEY | BUTTONIDCMP | CYCLEIDCMP | CHECKBOXIDCMP | STRINGIDCMP | INTEGERIDCMP | SLIDERIDCMP,
  1020.                                           WA_DepthGadget,  TRUE,
  1021.                                           WA_DragBar,      TRUE,
  1022.                                           WA_CloseGadget,  TRUE,
  1023.                                           WA_SimpleRefresh,TRUE,
  1024.                                           WA_Activate,     TRUE,
  1025.                                           WA_Title,        "ASL Tester",
  1026.                                           WA_PubScreen,    screen,
  1027.                                           WA_AutoAdjust,   TRUE,
  1028.                                           TAG_DONE))
  1029.                         {
  1030.                             SetFont(window->RPort,textFont);
  1031.                             RenderWindow();
  1032.  
  1033.                             if (InstallGadgets())
  1034.                                 EventLoop();
  1035.  
  1036.                             CloseWindow(window);
  1037.  
  1038.                             FreeGadgets(gadgetList);
  1039.                         }
  1040.                         CloseFont(textFont);
  1041.                     }
  1042.                     FreeVisualInfo(visualInfo);
  1043.                 }
  1044.                 FreeScreenDrawInfo(screen,drawInfo);
  1045.             }
  1046.             UnlockPubScreen(NULL,screen);
  1047.         }
  1048.     }
  1049.  
  1050.     if (IntuitionBase)
  1051.     {
  1052.         CloseLibrary(LocaleBase);
  1053.         CloseLibrary(UtilityBase);
  1054.         CloseLibrary(GadToolsBase);
  1055.         CloseLibrary(GfxBase);
  1056.         CloseLibrary(IntuitionBase);
  1057.     }
  1058.  
  1059.     return(0);
  1060. }
  1061.