home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / CDTools / ClassAct / Examples / SpeedBar / speedbarexample.c < prev    next >
C/C++ Source or Header  |  1997-07-09  |  14KB  |  574 lines

  1. ;/* SpeedBar Example
  2. sc link speedbarexample.c lib lib:classact.lib
  3. quit
  4. */
  5.  
  6. /* system includes
  7.  */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11.  
  12. #include <exec/types.h>
  13. #include <exec/memory.h>
  14. #include <intuition/intuition.h>
  15. #include <intuition/gadgetclass.h>
  16. #include <graphics/gfxbase.h>
  17. #include <graphics/text.h>
  18. #include <graphics/gfxmacros.h>
  19. #include <utility/tagitem.h>
  20. #include <workbench/startup.h>
  21. #include <workbench/workbench.h>
  22.  
  23. #include <proto/intuition.h>
  24. #include <proto/graphics.h>
  25. #include <proto/exec.h>
  26. #include <proto/dos.h>
  27. #include <proto/utility.h>
  28. #include <proto/wb.h>
  29. #include <proto/icon.h>
  30.  
  31. /* ClassAct includes
  32.  */
  33. #include <classact.h>
  34.  
  35. /* Local function prototypes.
  36.  */
  37. BOOL make_speedbar_list(struct List *, struct Image *, UBYTE **);
  38. VOID free_speedbar_list(struct List *);
  39.  
  40.  
  41. /* Image data definitions.
  42.  */
  43. __chip UWORD sb_data[][64] =
  44. {
  45.     /* Cut
  46.      */
  47.     {
  48.         /* Plane 0 */
  49.         0x0000, 0x0000, 0x0000, 0x0000,
  50.         0x0000, 0x0000, 0x0000, 0x0000,
  51.         0x0e01, 0xc000, 0x1107, 0x8000,
  52.         0x191e, 0x0000, 0x0f78, 0x0000,
  53.         0x01e0, 0x0000, 0x0f78, 0x0000,
  54.         0x191e, 0x0000, 0x1107, 0x8000,
  55.         0x0e01, 0xc000, 0x0000, 0x0000,
  56.         0x0000, 0x0000, 0x0000, 0x0000,
  57.         /* Plane 1 */
  58.         0x0000, 0x0000, 0x0000, 0x0000,
  59.         0x0000, 0x0000, 0x0000, 0x0000,
  60.         0x0000, 0x0000, 0x0000, 0x0000,
  61.         0x0000, 0x0000, 0x0000, 0x0000,
  62.         0x0000, 0x0000, 0x0000, 0x0000,
  63.         0x0000, 0x0000, 0x0000, 0x0000,
  64.         0x0000, 0x0000, 0x0000, 0x0000,
  65.         0x0000, 0x0000, 0x0000, 0x0000 
  66.     },
  67.     /* Copy
  68.      */
  69.     {
  70.         /* Plane 0 */
  71.         0x0000, 0x0000, 0x0000, 0x0000,
  72.         0x01fe, 0x0000, 0x0186, 0x0000,
  73.         0x01fe, 0x0000, 0x0630, 0x8000,
  74.         0x1fff, 0xe000, 0x1f87, 0xe000,
  75.         0x1f03, 0xe000, 0x1f03, 0xe000,
  76.         0x1f03, 0xe000, 0x1f87, 0xe000,
  77.         0x1fff, 0xe000, 0x1fff, 0xe000,
  78.         0x0000, 0x0000, 0x0000, 0x0000,
  79.         /* Plane 1 */
  80.         0x0000, 0x0000, 0x0000, 0x0000,
  81.         0x0000, 0x0000, 0x0078, 0x0000,
  82.         0x0000, 0x0000, 0x0000, 0x0000,
  83.         0x0000, 0x0000, 0x0000, 0x0000,
  84.         0x0060, 0x0000, 0x0044, 0x0000,
  85.         0x0004, 0x0000, 0x0018, 0x0000,
  86.         0x0000, 0x0000, 0x0000, 0x0000,
  87.         0x0000, 0x0000, 0x0000, 0x0000 
  88.     },
  89.     /* Paste
  90.      */
  91.     {
  92.         /* Plane 0 */
  93.         0x0000, 0x0000, 0x003f, 0x0000,
  94.         0x0021, 0x0000, 0x007f, 0x8000,
  95.         0x0080, 0x4000, 0x0081, 0xc000,
  96.         0x0780, 0x4000, 0x0861, 0xc000,
  97.         0x0f20, 0x4000, 0x0891, 0xc000,
  98.         0x0950, 0x4000, 0x0251, 0xc000,
  99.         0x05e0, 0x4000, 0x0880, 0xc000,
  100.         0x307f, 0x8000, 0x0000, 0x0000,
  101.         /* Plane 1 */
  102.         0x0000, 0x0000, 0x0000, 0x0000,
  103.         0x0006, 0x0000, 0x0000, 0x0000,
  104.         0x0007, 0x0000, 0x0002, 0x0000,
  105.         0x0002, 0x0000, 0x0782, 0x0000,
  106.         0x00c2, 0x0000, 0x0062, 0x0000,
  107.         0x0222, 0x0000, 0x0422, 0x0000,
  108.         0x0802, 0x0000, 0x1002, 0x0000,
  109.         0x0000, 0x0000, 0x0000, 0x0000 
  110.     },
  111.     /* Erase
  112.      */
  113.     {
  114.         /* Plane 0 */
  115.         0x0000, 0x0000, 0x002e, 0xb800,
  116.         0x005d, 0x7800, 0x00ba, 0xf800,
  117.         0x01f5, 0xf000, 0x03eb, 0xe000,
  118.         0x05f7, 0xc000, 0x08ff, 0x8000,
  119.         0x107f, 0x0000, 0x103e, 0x0000,
  120.         0x101c, 0x0000, 0x0828, 0x0000,
  121.         0x0450, 0x0000, 0x02a0, 0x0000,
  122.         0x01ff, 0xf800, 0x0000, 0x0000,
  123.         /* Plane 1 */
  124.         0x0000, 0x0000, 0x001a, 0xa800,
  125.         0x0035, 0x5000, 0x006a, 0xa000,
  126.         0x0015, 0x4000, 0x000a, 0x8000,
  127.         0x0205, 0x0000, 0x0502, 0x0000,
  128.         0x0a80, 0x0000, 0x0540, 0x0000,
  129.         0x0aa0, 0x0000, 0x0540, 0x0000,
  130.         0x0280, 0x0000, 0x0100, 0x0000,
  131.         0x0000, 0x0000, 0x0000, 0x0000 
  132.     },
  133.     /* Mail
  134.      */
  135.     {
  136.         /* Plane 0 */
  137.         0x0000, 0x0000, 0x0000, 0x0000,
  138.         0x0000, 0x0000, 0x0000, 0x0000,
  139.         0x0000, 0x0000, 0x0000, 0x0000,
  140.         0x0000, 0x0000, 0x0800, 0xd000,
  141.         0x0094, 0xd000, 0x0000, 0x1000,
  142.         0x0060, 0x1000, 0x0000, 0x1000,
  143.         0x00d0, 0x1000, 0x0000, 0x1000,
  144.         0x1fff, 0xf000, 0x0000, 0x0000,
  145.         /* Plane 1 */
  146.         0x0000, 0x0000, 0x0000, 0x0000,
  147.         0x0018, 0x0000, 0x007c, 0x0000,
  148.         0x01ca, 0x0000, 0x0515, 0x0000,
  149.         0x3fff, 0xe000, 0x2bff, 0xe000,
  150.         0x3e97, 0xe000, 0x3fff, 0xe000,
  151.         0x3f6f, 0xe000, 0x3fff, 0xe000,
  152.         0x3fd7, 0xe000, 0x3fff, 0xe000,
  153.         0x0000, 0x0000, 0x0000, 0x0000 
  154.     },
  155.     /* Time
  156.      */
  157.     {
  158.         /* Plane 0 */
  159.         0x0000, 0x0000, 0x0070, 0x0000,
  160.         0x0376, 0x0000, 0x06db, 0x0000,
  161.         0x0505, 0x0000, 0x0262, 0x0000,
  162.         0x0421, 0x0000, 0x0421, 0x0000,
  163.         0x0439, 0x0000, 0x0401, 0x0000,
  164.         0x0401, 0x0000, 0x0202, 0x0000,
  165.         0x0104, 0x0000, 0x01fc, 0x0000,
  166.         0x0306, 0x0000, 0x0000, 0x0000,
  167.         /* Plane 1 */
  168.         0x0000, 0x0000, 0x0000, 0x0000,
  169.         0x0000, 0x0000, 0x0020, 0x0000,
  170.         0x0000, 0x0000, 0x0098, 0x0000,
  171.         0x01dc, 0x0000, 0x01dc, 0x0000,
  172.         0x01c4, 0x0000, 0x01fc, 0x0000,
  173.         0x01fc, 0x0000, 0x00f8, 0x0000,
  174.         0x0000, 0x0000, 0x0000, 0x0000,
  175.         0x0000, 0x0000, 0x0000, 0x0000 
  176.     },
  177.     /* Date
  178.      */
  179.     {
  180.         /* Plane 0 */
  181.         0x0000, 0x0000, 0x037b, 0x0000,
  182.         0x0285, 0x8000, 0x0201, 0x8000,
  183.         0x0201, 0x8000, 0x0299, 0x8000,
  184.         0x02a7, 0x8000, 0x052b, 0x8000,
  185.         0x0535, 0x8000, 0x080d, 0x8000,
  186.         0x1ff5, 0x8000, 0x0205, 0x8000,
  187.         0x0201, 0x8000, 0x03ff, 0x8000,
  188.         0x01ff, 0x8000, 0x0000, 0x0000,
  189.         /* Plane 1 */
  190.         0x0000, 0x0000, 0x0000, 0x0000,
  191.         0x017a, 0x0000, 0x01fe, 0x0000,
  192.         0x01fe, 0x0000, 0x0166, 0x0000,
  193.         0x0158, 0x0000, 0x02d4, 0x0000,
  194.         0x02c8, 0x0000, 0x07f2, 0x0000,
  195.         0x0000, 0x0000, 0x00aa, 0x0000,
  196.         0x0154, 0x0000, 0x0000, 0x0000,
  197.         0x0000, 0x0000, 0x0000, 0x0000 
  198.     },
  199.     /* Disk
  200.      */
  201.     {
  202.         /* Plane 0 */
  203.         0x0000, 0x0000, 0x0038, 0x0000,
  204.         0x0054, 0x0000, 0x008e, 0x0000,
  205.         0x0107, 0x0000, 0x0207, 0x8000,
  206.         0x040b, 0xc000, 0x0417, 0xe000,
  207.         0x0e29, 0xe000, 0x0750, 0xc000,
  208.         0x03a0, 0x8000, 0x01d9, 0x8000,
  209.         0x00eb, 0x0000, 0x0076, 0x0000,
  210.         0x003c, 0x0000, 0x0010, 0x0000,
  211.         /* Plane 1 */
  212.         0x0020, 0x0000, 0x0070, 0x0000,
  213.         0x00c0, 0x0000, 0x01a4, 0x0000,
  214.         0x0352, 0x0000, 0x06ab, 0x0000,
  215.         0x0d53, 0x8000, 0x12a1, 0xc000,
  216.         0x1d46, 0xc000, 0x0e89, 0x0000,
  217.         0x0710, 0x0000, 0x03ac, 0x8000,
  218.         0x01d1, 0x0000, 0x00e2, 0x0000,
  219.         0x0074, 0x0000, 0x0000, 0x0000 
  220.     },
  221.     /* Spray Paint
  222.      */
  223.     {
  224.         /* Plane 0 */
  225.         0x0000, 0x0000, 0x0186, 0xc000,
  226.         0x01bf, 0x0000, 0x07ec, 0xc000,
  227.         0x0423, 0x0000, 0x0ff0, 0xc000,
  228.         0x1008, 0x0000, 0x1078, 0x0000,
  229.         0x1078, 0x0000, 0x1078, 0x0000,
  230.         0x1078, 0x0000, 0x1078, 0x0000,
  231.         0x1008, 0x0000, 0x1038, 0x0000,
  232.         0x1008, 0x0000, 0x0000, 0x0000,
  233.         /* Plane 1 */
  234.         0x0000, 0x0000, 0x0006, 0xc000,
  235.         0x003f, 0x0000, 0x000c, 0xc000,
  236.         0x0243, 0x0000, 0x0000, 0xc000,
  237.         0x02e0, 0x0000, 0x0440, 0x0000,
  238.         0x0470, 0x0000, 0x0440, 0x0000,
  239.         0x0470, 0x0000, 0x0440, 0x0000,
  240.         0x0440, 0x0000, 0x0440, 0x0000,
  241.         0x0440, 0x0000, 0x0000, 0x0000 
  242.     },
  243.     /* Print
  244.      */
  245.     {
  246.         /* Plane 0 */
  247.         0x0000, 0x0000, 0x03fe, 0x0000,
  248.         0x0205, 0x0000, 0x02a7, 0x0000,
  249.         0x0201, 0x0000, 0x02d5, 0x0000,
  250.         0x0201, 0x0000, 0x0601, 0x8000,
  251.         0x1fff, 0xe000, 0x2000, 0x1000,
  252.         0x2803, 0xd000, 0x2000, 0x1000,
  253.         0x3fff, 0xf000, 0x1fff, 0xe000,
  254.         0x0fff, 0xc000, 0x0000, 0x0000,
  255.         /* Plane 1 */
  256.         0x0000, 0x0000, 0x0000, 0x0000,
  257.         0x01fa, 0x0000, 0x0118, 0x0000,
  258.         0x01fe, 0x0000, 0x0102, 0x0000,
  259.         0x01fe, 0x0000, 0x01fe, 0x0000,
  260.         0x0000, 0x0000, 0x1555, 0x4000,
  261.         0x0000, 0x0000, 0x0000, 0x0000,
  262.         0x0000, 0x0000, 0x0000, 0x0000,
  263.         0x0000, 0x0000, 0x0000, 0x0000 
  264.     }
  265. };
  266.  
  267. /* Image structures for above data.
  268.  */
  269. struct Image sb_images[] =
  270. {
  271.     { 0, 0, 22, 16, 2, sb_data[0], 0x03, 0x00, NULL },
  272.     { 0, 0, 22, 16, 2, sb_data[1], 0x03, 0x00, NULL },
  273.     { 0, 0, 22, 16, 2, sb_data[2], 0x03, 0x00, NULL },
  274.     { 0, 0, 22, 16, 2, sb_data[3], 0x03, 0x00, NULL },
  275.     { 0, 0, 22, 16, 2, sb_data[4], 0x03, 0x00, NULL },
  276.     { 0, 0, 22, 16, 2, sb_data[5], 0x03, 0x00, NULL },
  277.     { 0, 0, 22, 16, 2, sb_data[6], 0x03, 0x00, NULL },
  278.     { 0, 0, 22, 16, 2, sb_data[7], 0x03, 0x00, NULL },
  279.     { 0, 0, 22, 16, 2, sb_data[8], 0x03, 0x00, NULL },
  280.     { 0, 0, 22, 16, 2, sb_data[9], 0x03, 0x00, NULL },
  281. };
  282.  
  283. /* speedbar window-title help strings.
  284.  */
  285. UBYTE *help_strs[] =
  286. {
  287.     "Erase block and copy it to the clipboard",
  288.     "Copy block to the clipboard",
  289.     "Paste from clipboard to your project",
  290.     "Erase block",
  291.     "Mail someone",
  292.     "Insert current time",
  293.     "Insert current date",
  294.     "Disk",
  295.     "Spray Paint",
  296.     "Print project",
  297.     NULL
  298. };
  299.  
  300. /* object/gadget/button id's
  301.  */
  302.  
  303. enum
  304. {
  305.     SBID_ERASECLIP=0,
  306.     SBID_COPYCLIP,
  307.     SBID_PASTECLIP,
  308.     SBID_DELETE,
  309.     SBID_EMAIL,
  310.     SBID_INSTIME,
  311.     SBID_INSDATE,
  312.     SBID_SAVEDISK,
  313.     SBID_PAINT,
  314.     SBID_PRINT,
  315.     SBID_LAST
  316. };
  317.  
  318. enum
  319. {
  320.     GID_SPEEDBAR=0,
  321.     GID_QUIT,
  322.     GID_LAST
  323. };
  324.  
  325. enum
  326. {
  327.     WID_MAIN=0,
  328.     WID_LAST
  329. };
  330.  
  331. enum
  332. {
  333.     OID_MAIN=0,
  334.     OID_LAST
  335. };
  336.  
  337.  
  338. /* Create the SpeedBar Exec list.
  339.  */
  340. BOOL make_speedbar_list(struct List *list, struct Image *images, UBYTE **help)
  341. {
  342.     struct Node *node;
  343.     WORD i = SBID_ERASECLIP;
  344.  
  345.     NewList(list);
  346.  
  347.     while (i < SBID_LAST)
  348.     {
  349.         if (node = (struct Node *)AllocSpeedButtonNode(
  350.             i, /* speed button id! */
  351.             SBNA_Image, images,
  352.             SBNA_Help, *help,
  353.             SBNA_Enabled, TRUE,
  354.             SBNA_Spacing, 2,
  355.             SBNA_Highlight, SBH_RECESS,
  356.             TAG_DONE))
  357.         {
  358.             AddTail(list, node);
  359.         }
  360.         else
  361.         {
  362.             PutStr("Allocation failed\n");
  363.             return (FALSE);
  364.         }
  365.  
  366.         images++;
  367.         i++;
  368.         help++;
  369.     }
  370.     return(TRUE);
  371. }
  372.  
  373.  
  374. /* Function to free a SpeedBar Exec List.
  375.  */
  376. VOID free_speedbar_list(struct List *list)
  377. {
  378.     struct Node *node, *nextnode;
  379.  
  380.     node = list->lh_Head;
  381.     while (nextnode = node->ln_Succ)
  382.     {
  383.         FreeSpeedButtonNode(node);
  384.         node = nextnode;
  385.     }
  386.     NewList(list);
  387. }
  388.  
  389.  
  390.  
  391. int main(void)
  392. {
  393.     struct MsgPort *AppPort;
  394.  
  395.     struct Window *windows[WID_LAST];
  396.  
  397.     struct Gadget *gadgets[GID_LAST];
  398.  
  399.     Object *objects[OID_LAST];
  400.  
  401.     struct List speedbar_list;
  402.  
  403.     /* make sure our classes opened... */
  404.     if (!ButtonBase || !SpeedBarBase || !WindowBase || !LayoutBase)
  405.         return(30);
  406.  
  407.     if ( make_speedbar_list(&speedbar_list, sb_images, help_strs) )
  408.     {
  409.         if ( AppPort = CreateMsgPort() )
  410.         {
  411.             /* Create the window object.
  412.              */
  413.             objects[OID_MAIN] = WindowObject,
  414.                 WA_ScreenTitle, "ClassAct Release 2.0",
  415.                 WA_Title, "ClassAct SpeedBar Example",
  416.                 WA_Activate, TRUE,
  417.                 WA_DepthGadget, TRUE,
  418.                 WA_DragBar, TRUE,
  419.                 WA_CloseGadget, TRUE,
  420.                 WA_SizeGadget, TRUE,
  421.                 WINDOW_IconifyGadget, TRUE,
  422.                 WINDOW_IconTitle, "SpeedBar",
  423.                 WINDOW_AppPort, AppPort,
  424.                 WINDOW_Position, WPOS_CENTERMOUSE,
  425.                 WINDOW_ParentGroup, VGroupObject,
  426.                     LAYOUT_SpaceOuter, TRUE,
  427.                     LAYOUT_DeferLayout, TRUE,
  428.  
  429.                     LAYOUT_AddChild, gadgets[GID_SPEEDBAR] = SpeedBarObject,
  430.                         GA_ID, GID_SPEEDBAR,
  431.                         GA_RelVerify, TRUE,
  432.                         SPEEDBAR_Orientation, SPEEDBAR_HORIZONTAL,
  433.                         SPEEDBAR_Buttons, &speedbar_list,
  434.                         SPEEDBAR_Background, 4,
  435.                     SpeedBarEnd,
  436.                     CHILD_MinWidth, 160,
  437.  
  438.                     LAYOUT_AddChild, VGroupObject,
  439.                         CLASSACT_BackFill, NULL,
  440.                         LAYOUT_SpaceOuter, TRUE,
  441.                         LAYOUT_VertAlignment, LALIGN_CENTER,
  442.                         LAYOUT_HorizAlignment, LALIGN_CENTER,
  443.                         LAYOUT_BevelStyle, BVS_FIELD,
  444.  
  445.                         LAYOUT_AddImage, LabelObject,
  446.                             LABEL_Text, "The speedbar supports scrolling list of image\n",
  447.                             LABEL_Text, "buttons. When more buttons are available than\n",
  448.                             LABEL_Text, "the visible space, you may scroll the list by\n",
  449.                             LABEL_Text, "pressing the SHIFT key while clicking the LMB and\n",
  450.                             LABEL_Text, "dragging the mouse. The speedbar also supports\n",
  451.                             LABEL_Text, "several options such boolean buttons, and MX groups!\n",
  452.                         LabelEnd,
  453.                     LayoutEnd,
  454.  
  455.  
  456.                     LAYOUT_AddChild, gadgets[GID_QUIT] = ButtonObject,
  457.                         GA_ID, GID_QUIT,
  458.                         GA_RelVerify, TRUE,
  459.                         GA_Text,"_Quit",
  460.                     ButtonEnd,
  461.                     CHILD_WeightedHeight, 0,
  462.  
  463.                 EndGroup,
  464.             EndWindow;
  465.  
  466.              /*  Object creation sucessful?
  467.               */
  468.             if (objects[OID_MAIN])
  469.             {
  470.                 /*  Open the window.
  471.                  */
  472.                 if (windows[WID_MAIN] = (struct Window *) CA_OpenWindow(objects[OID_MAIN]))
  473.                 {
  474.                     ULONG wait, signal, app = (1L << AppPort->mp_SigBit);
  475.                     ULONG done = FALSE;
  476.                     ULONG result;
  477.                     UWORD code;
  478.  
  479.                      /* Obtain the window wait signal mask.
  480.                      */
  481.                     GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);
  482.  
  483.                     /* Input Event Loop
  484.                      */
  485.                     while (!done)
  486.                     {
  487.                         wait = Wait( signal | SIGBREAKF_CTRL_C | app );
  488.  
  489.                         if ( wait & SIGBREAKF_CTRL_C )
  490.                         {
  491.                             done = TRUE;
  492.                         }
  493.                         else
  494.                         {
  495.                             while ( (result = CA_HandleInput(objects[OID_MAIN], &code) ) != WMHI_LASTMSG )
  496.                             {
  497.                                 switch (result & WMHI_CLASSMASK)
  498.                                 {
  499.                                     case WMHI_CLOSEWINDOW:
  500.                                         windows[WID_MAIN] = NULL;
  501.                                         done = TRUE;
  502.                                         break;
  503.  
  504.                                     case WMHI_GADGETUP:
  505.                                         switch (result & WMHI_GADGETMASK)
  506.                                         {
  507.                                             case GID_SPEEDBAR:
  508.                                                 printf("Speed Button Selected: %d\n", (int)code );
  509.                                                 switch ((int)code)
  510.                                                 {
  511.                                                     case SBID_ERASECLIP:
  512.                                                         break;
  513.  
  514.                                                     case SBID_COPYCLIP:
  515.                                                         break;
  516.  
  517.                                                     case SBID_PASTECLIP:
  518.                                                         break;
  519.                                                     /* ... */
  520.                                                 }
  521.                                                 break;
  522.  
  523.                                             case GID_QUIT:
  524.                                                 done = TRUE;
  525.                                                 break;
  526.                                         }
  527.                                         break;
  528.  
  529.                                     case WMHI_ICONIFY:
  530.                                         CA_Iconify(objects[OID_MAIN]);
  531.                                         SetAttrs(gadgets[GID_SPEEDBAR], SPEEDBAR_Window, NULL, TAG_DONE);
  532.                                         windows[WID_MAIN] = NULL;
  533.                                         break;
  534.  
  535.                                     case WMHI_UNICONIFY:
  536.                                         windows[WID_MAIN] = (struct Window *) CA_OpenWindow(objects[OID_MAIN]);
  537.  
  538.                                         if (windows[WID_MAIN])
  539.                                         {
  540.                                             GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);
  541.  
  542.                                             if (gadgets[GID_SPEEDBAR])
  543.                                             {
  544.                                                 SetAttrs(gadgets[GID_SPEEDBAR], SPEEDBAR_Window, windows[WID_MAIN], TAG_DONE);
  545.                                             }
  546.                                         }
  547.                                         else
  548.                                         {
  549.                                             done = TRUE;    // error re-opening window!
  550.                                         }
  551.                                          break;
  552.                                 }
  553.                             }
  554.                         }
  555.                     }
  556.                 }
  557.  
  558.                 /* Disposing of the window object will
  559.                  * also close the window if it is
  560.                  * already opened and it will dispose of
  561.                  * all objects attached to it.
  562.                  */
  563.                 DisposeObject(objects[OID_MAIN]);
  564.             }
  565.  
  566.             DeleteMsgPort(AppPort);
  567.         }
  568.     }
  569.  
  570.     free_speedbar_list(&speedbar_list);
  571.  
  572.     return(0);
  573. }
  574.