Guest User

netbutton.c

a guest
Apr 11th, 2025
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 22.52 KB | Fixit | 0 0
  1. /*********************************************
  2.  * Project:  NetButton                       *
  3.  * Purpose:  GUI for RoadShow TCP/IP Stack   *
  4.  * File:     NetButton.c                     *
  5.  * Version:  1.0 TEST                        *
  6.  * Author:   Michael Bergmann                *
  7.  * Date:     2025/04/04                      *
  8.  *                                           *
  9.  * GUI made with ReBuild v1.3 beta           *
  10.  * Tested Compilers:                         *
  11.  *         : SAS/C v6.58                     *
  12.  *           VBCC v0.91 pre                  *
  13.  *           amiga-gcc v6.5                  *
  14.  * HINT: Might be linked against             *
  15.  *       amiga.lib and reaction.lib!         *
  16.  *********************************************
  17.  */
  18. /* --- Put INCLUDE-Files here: --- */
  19. #include <clib/macros.h>
  20. #include <clib/alib_protos.h>
  21. #include <clib/compiler-specific.h>
  22.  
  23. #include <proto/exec.h>
  24. #include <proto/dos.h>
  25. #include <proto/utility.h>
  26. #include <proto/graphics.h>
  27. #include <proto/intuition.h>
  28. #include <proto/gadtools.h>
  29. #include <proto/icon.h>
  30.  
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34.  
  35. #include <proto/window.h>
  36. #include <proto/layout.h>
  37. #include <proto/button.h>
  38. #include <proto/string.h>
  39. #include <proto/label.h>
  40. #include <proto/requester.h>
  41. #include <classes/requester.h>
  42.  
  43. #include <libraries/gadtools.h>
  44. #include <reaction/reaction.h>
  45. #include <intuition/gadgetclass.h>
  46. #include <intuition/icclass.h>
  47. #include <reaction/reaction_macros.h>
  48. #include <classes/window.h>
  49. #include <exec/memory.h>
  50.  
  51. #define myDebug TRUE  /* Debugging Texts TRUE or FALSE */
  52. #ifdef myDebug
  53.   #include <stdio.h>  /* used for puts(), printf() */
  54.   char *str_greet = "Hello Stranger!\n We're ready to DEBUG now!\n\n";
  55.   char *str_bye = "\n\nAll Done!\nThis Demo quits now.\n\Hope you liked it?";
  56. #endif
  57.  
  58. /* construct version tag */
  59. #define PROGNAME "NetButton"
  60. #define VERSIONR "1.0.0"
  61. #define COPYRIGHT "Copyright © 2025 by Micha B."
  62.  
  63. /* construct version tag */
  64. #if defined(__VBCC__)
  65.   #define PROGDATE __AMIGADATE__
  66.   #define COMPILER "compiled with VBCC"
  67. #endif
  68. #if defined(__SASC)
  69.   #define PROGDATE __AMIGADATE__
  70.   #define COMPILER "compiled with SAS/C v6.58"
  71. #endif
  72. #if defined(__GNUC__)
  73.   #define PROGDATE __DATE__
  74.   #define COMPILER "compiled with GNU gcc"
  75. #endif
  76.  
  77. #if defined  (_DCC)
  78.   /* AmigaOS Version String */
  79.   #define VERSTAG "\0$VER: NetButton 1.0.0 (6.4.2025) - (compiled with DCC v1.12) - Copyright © 2025 by Micha B."
  80.   char *version = VERSTAG;
  81. #endif
  82.  
  83. #ifndef _DCC
  84.   /* AmigaOS Version String */
  85.   const char *version = "\0$VER: " PROGNAME " " VERSIONR " (" PROGDATE ") - (" COMPILER ") - " COPYRIGHT "\n";
  86. #endif
  87.  
  88. BOOL connected = TRUE;
  89.  
  90. /* Function Proto Types */
  91. int main(void);
  92. void window_main( void );
  93. int setup( void );
  94. void cleanup( void );
  95. void runWindow( Object *window_object, int window_id, struct Menu *menu_strip, struct Gadget *win_gadgets[] );
  96. int reqabout(Object *reactionWindow);
  97. int reqquit(Object *reactionWindow);
  98. int reqnoroadshow(Object *reactionWindow);
  99. void checkConnection(struct Window *main_window, struct Gadget *win_gadgets[]);
  100.  
  101.  
  102. struct Screen   *gScreen = NULL;
  103. struct DrawInfo *gDrawInfo = NULL;
  104. APTR gVisinfo = NULL;
  105. struct MsgPort  *gAppPort = NULL;
  106.  
  107.  
  108. /* --- Menu IDs ----------------------------------------------------------------------------------------- */
  109. enum menus
  110. {
  111.   /* Menu "Project"  */
  112.   MN_INFO, MN_QUIT
  113. };
  114.  
  115. /* --- Requesters ---------------------------------------------------------------------------------------- */
  116. /* 'No OS 3.2' box */
  117. struct EasyStruct warnreq =
  118. {
  119.   sizeof(struct EasyStruct),
  120.   0,
  121.   "Error",
  122.   "Needs AmigaOS 3.2.x\n\nNo Chance to run this program on your machine!",
  123.   "Ok"
  124. };
  125.  
  126. /* 'requester.class' box */
  127. struct EasyStruct noreqclassreq =
  128. {
  129.   sizeof(struct EasyStruct),
  130.   0,
  131.   "Critical Error",
  132.   " requester.class could not be opened.\nThis App refuses to start!",
  133.   "Ok"
  134. };
  135.  
  136. int reqabout(Object *reactionWindow)
  137. {
  138.   Object *reqobj;
  139.   ULONG win;
  140.   int res=0;
  141.  
  142.   GetAttr(WINDOW_Window, reactionWindow, &win);
  143.   reqobj = NewObject(REQUESTER_GetClass(), NULL, REQ_Type, REQTYPE_INFO, REQ_Image, REQIMAGE_INFO,
  144.        REQ_TitleText, "About NetButton",
  145.        REQ_BodyText," NetButton v1.0\n Interface GUI for RoadShow TCP/IP Stack\n\n (c) Micha B. 04/2025\n Mail: [email protected]\nWeb: www.mbergmann-sh.de",
  146.        REQ_GadgetText, "_Ok",
  147.        TAG_DONE);
  148.   if (reqobj)
  149.   {
  150.     res=DoMethod(reqobj, RM_OPENREQ, NULL, win, NULL);
  151.     DisposeObject(reqobj);
  152.   }
  153.   return res;
  154. }
  155.  
  156. int reqquit(Object *reactionWindow)
  157. {
  158.   Object *reqobj;
  159.   ULONG win;
  160.   int res=0;
  161.  
  162.   GetAttr(WINDOW_Window, reactionWindow, &win);
  163.   reqobj = NewObject(REQUESTER_GetClass(), NULL, REQ_Type, REQTYPE_INFO, REQ_Image, REQIMAGE_QUESTION,
  164.        REQ_TitleText, "NetButton Emergency Exit",
  165.        REQ_BodyText," Do you realy want to quit?",
  166.        REQ_GadgetText, "_Yes|_Cancel",
  167.        TAG_DONE);
  168.   if (reqobj)
  169.   {
  170.     res=DoMethod(reqobj, RM_OPENREQ, NULL, win, NULL);
  171.     DisposeObject(reqobj);
  172.   }
  173.   return res;
  174. }
  175.  
  176. int reqnoroadshow(Object *reactionWindow)
  177. {
  178.   Object *reqobj;
  179.   ULONG win;
  180.   int res=0;
  181.  
  182.   GetAttr(WINDOW_Window, reactionWindow, &win);
  183.   reqobj = NewObject(REQUESTER_GetClass(), NULL, REQ_Type, REQTYPE_INFO, REQ_Image, REQIMAGE_WARNING,
  184.        REQ_TitleText, "NetButton Warning",
  185.        REQ_BodyText," It looks like you don't have\n the RoadShow TCP/IP Stack\n installed on your System!\n\n NetButton makes no sense.\n Program will quit now!",
  186.        REQ_GadgetText, "_Ok",
  187.        TAG_DONE);
  188.   if (reqobj)
  189.   {
  190.     res=DoMethod(reqobj, RM_OPENREQ, NULL, win, NULL);
  191.     DisposeObject(reqobj);
  192.   }
  193.   return res;
  194. }
  195.  
  196. struct Library *WindowBase = NULL,
  197.                *ButtonBase = NULL,
  198.                *StringBase = NULL,
  199.                *LabelBase = NULL,
  200.                *RequesterBase = NULL,
  201.                *GadToolsBase = NULL,
  202.                *LayoutBase = NULL,
  203.                *IconBase = NULL;
  204. struct IntuitionBase *IntuitionBase = NULL;
  205.  
  206. /* --- window ids ------------------------------------------------------------------------------------- */
  207. enum win { window_main_id = 4 };
  208.  
  209. /* --- Window_Main gadgets ---------------------------------------------------------------------------- */
  210. /* THESE are for identification by GetAttr() and SetGadgetAttrs()                   */
  211. /* e.g. GetAttr(STRINGA_TextVal, (APTR)win_gadgets[string_euro], (ULONG *)&myText); */
  212. enum window_main_idx { vert_main, vert_buttons, button_on, button_off, string_status };
  213. /* THOSE are for identification by menu and gadget events */
  214. /* e.g. case string_eur_id:                               */
  215. enum window_main_id { vert_main_id = 6, vert_buttons_id = 7, button_on_id = 8, button_off_id = 10,
  216.   string_status_id = 11 };
  217.  
  218. /* --- Function: checkConnection() ----------------------------------------------------------------------- */
  219. /* --- Check Net status, set Buttons accordingly --------------------------------------------------------- */
  220. void checkConnection(struct Window *main_window, struct Gadget *win_gadgets[])
  221. {
  222.   if(connected)
  223.   {
  224.     SetGadgetAttrs((APTR)win_gadgets[button_on], main_window, NULL, GA_Disabled, TRUE, TAG_END);
  225.     SetGadgetAttrs((APTR)win_gadgets[button_off], main_window, NULL, GA_Disabled, FALSE, TAG_END);
  226.     SetGadgetAttrs((APTR)win_gadgets[string_status], main_window, 0, STRINGA_TextVal, "ONLINE", TAG_END );
  227.   }
  228.   else
  229.   {
  230.     SetGadgetAttrs((APTR)win_gadgets[button_on], main_window, NULL, GA_Disabled, FALSE, TAG_END);
  231.     SetGadgetAttrs((APTR)win_gadgets[button_off], main_window, NULL, GA_Disabled, TRUE, TAG_END);
  232.     SetGadgetAttrs((APTR)win_gadgets[string_status], main_window, 0, STRINGA_TextVal, "OFFLINE", TAG_END );
  233.   }
  234.   printf("connected = %ld\n", connected);
  235. }
  236.  
  237.  
  238. /* --- Function: setup() --------------------------------------------------------------------------------- */
  239. /* --- Open libs, gadgets, classes and other ressources -------------------------------------------------- */
  240. int setup( void )
  241. {
  242.   if( !(IntuitionBase = (struct IntuitionBase*) OpenLibrary("intuition.library",0L)) ) return 0;
  243.   if( !(GadToolsBase = (struct Library*) OpenLibrary("gadtools.library",0L) ) ) return 0;
  244.   if( !(WindowBase = (struct Library*) OpenLibrary("window.class",0L) ) ) return 0;
  245.   if( !(IconBase = (struct Library*) OpenLibrary("icon.library",0L) ) ) return 0;
  246.  
  247.   /* --- Check for a sufficient OS! --- */
  248.   if( !(LayoutBase = (struct Library*) OpenLibrary("gadgets/layout.gadget",47) ) )
  249.   {
  250.     if (myDebug)
  251.        puts(" FAIL: layout.gadget");
  252.     EasyRequest(NULL, &warnreq, NULL);
  253.     return 0;
  254.   }
  255.   if( !(ButtonBase = (struct Library*) OpenLibrary("gadgets/button.gadget",47L) ) ) return 0;
  256.   if( !(StringBase = (struct Library*) OpenLibrary("gadgets/string.gadget",47L) ) ) return 0;
  257.   if( !(LabelBase = (struct Library*) OpenLibrary("images/label.image",47L) ) ) return 0;
  258.   if( !(RequesterBase = (struct Library*) OpenLibrary("classes/requester.class",47L) ) )
  259.   {
  260.     if(myDebug)
  261.       puts("FAIL: requester.class");
  262.     EasyRequest(NULL, &noreqclassreq, NULL);
  263.     return 0;
  264.    }
  265.   if( !(gScreen = LockPubScreen( 0 ) ) ) return 0;
  266.   if( !(gVisinfo = GetVisualInfo( gScreen, TAG_DONE ) ) ) return 0;
  267.   if( !(gDrawInfo = GetScreenDrawInfo ( gScreen ) ) ) return 0;
  268.   if( !(gAppPort = CreateMsgPort() ) ) return 0;
  269.  
  270.   return -1;  
  271. } /* END Function setup() */
  272.  
  273. /* --- Function: cleanup() -------------------------------------------------------------------------------- */
  274. /* --- Close used ressources and clean up for shutdown ---------------------------------------------------- */
  275. void cleanup( void )
  276. {
  277.   if ( gDrawInfo ) FreeScreenDrawInfo( gScreen, gDrawInfo);
  278.   if ( gVisinfo ) FreeVisualInfo( gVisinfo );
  279.   if ( gAppPort ) DeleteMsgPort( gAppPort );
  280.   if ( gScreen ) UnlockPubScreen( 0, gScreen );
  281.  
  282.   if (GadToolsBase) CloseLibrary( (struct Library *)GadToolsBase );
  283.   if (IconBase) CloseLibrary( (struct Library *)IconBase );
  284.   if (IntuitionBase) CloseLibrary( (struct Library *)IntuitionBase );
  285.   if (ButtonBase) CloseLibrary( (struct Library *)ButtonBase );
  286.   if (StringBase) CloseLibrary( (struct Library *)StringBase );
  287.   if (LabelBase) CloseLibrary( (struct Library *)LabelBase );
  288.   if (LayoutBase) CloseLibrary( (struct Library *)LayoutBase );
  289.   if (WindowBase) CloseLibrary( (struct Library *)WindowBase );
  290.   if (RequesterBase) CloseLibrary( (struct Library *)RequesterBase );
  291. } /* END Function cleanup() */
  292.  
  293.  
  294. /* --- Function: runWindow() ------------------------------------------------------------------------------ */
  295. /* --- IDCMP Event Handling is done here ------------------------------------------------------------------ */
  296. void runWindow( Object *window_object, int window_id, struct Menu *menu_strip, struct Gadget *win_gadgets[] )
  297. {
  298.   struct Window *main_window = NULL;  
  299.   struct MenuItem *menuitem = NULL;
  300.   LONG myItem = 0;                  /* GT menu identifier     */
  301.   ULONG selected;                   /* used for Content query */
  302.   ULONG status = 0;                 /* used for Status query  */
  303.   ULONG req_result = 0;
  304.  
  305.   if ( window_object )
  306.   {
  307.     if ( main_window = (struct Window *) RA_OpenWindow( window_object ))
  308.     {
  309.       WORD Code;
  310.       ULONG wait = 0, signal = 0, result = 0, done = FALSE;
  311.       GetAttr( WINDOW_SigMask, window_object, &signal );
  312.       if ( menu_strip)  SetMenuStrip( main_window, menu_strip );
  313.      
  314.       if(myDebug)
  315.         printf("%s\n", str_greet);
  316.        
  317.       /* Check initial connection status */
  318.       checkConnection(main_window, win_gadgets);
  319.        
  320.       while ( !done)
  321.       {
  322.         wait = Wait( signal | SIGBREAKF_CTRL_C );
  323.  
  324.         if ( wait & SIGBREAKF_CTRL_C )
  325.           done = TRUE;
  326.         else
  327.           while (( result = RA_HandleInput( window_object, &Code )) != WMHI_LASTMSG)
  328.           {            
  329.             switch ( result & WMHI_CLASSMASK )
  330.             {
  331.               case WMHI_RAWKEY:
  332.                 puts("RAWKEY!");
  333.                 checkConnection(main_window, win_gadgets);
  334.                 printf("connectet = %ld\n", connected);
  335.                 break;
  336.               case WMHI_VANILLAKEY:
  337.                 puts("VANILLAKEY!");
  338.                 printf("connectet = %ld\n", connected);
  339.                 break;
  340.               case WMHI_INTUITICK:
  341.                 puts("INTUITICK!");
  342.                 break;
  343.               case WMHI_ACTIVE:
  344.                 puts("Active!");
  345.                 checkConnection(main_window, win_gadgets);
  346.                 printf("connectet = %ld\n", connected);
  347.                 break;
  348.            
  349.               /* --- WINDOW -------------------------------------------- */
  350.               case WMHI_CLOSEWINDOW:
  351.                 SetAttrs(window_object, WA_BusyPointer, TRUE, TAG_DONE);  /* Modal: ON */
  352.                 /* call Quit-Requester */
  353.                 req_result = reqquit(window_object);
  354.                 if(myDebug)
  355.                     printf("req_result = %d\n", req_result);
  356.                 if (req_result == 1)
  357.                 {
  358.                   if(myDebug)
  359.                     printf("%s\n", str_bye);
  360.                   done = TRUE;
  361.                 }
  362.                 SetAttrs(window_object, WA_BusyPointer, FALSE, TAG_DONE); /* Modal: OFF */                                
  363.                 break;
  364.                
  365.               /* --- MENUS -------------------------------------------- */
  366.               case WMHI_MENUPICK:
  367.                 if(myDebug)
  368.                   puts("\nMenu pick!");
  369.                   printf("connectet = %ld\n", connected);
  370.                 menuitem = ItemAddress(menu_strip, result & WMHI_MENUMASK);
  371.                 if(myDebug)
  372.                   printf(" ItemAdress = %ld\n", menuitem);
  373.                  
  374.                 checkConnection(main_window, win_gadgets);
  375.                 printf("connectet = %ld\n", connected);
  376.                  
  377.                 /* Check if menuitem equals to Zero. If Zero, an enforcer hit will occour when */
  378.                 /* attempting to examine, so we do not allow switching on menuitem == 0!       */
  379.                 if(!(menuitem == 0))
  380.                 {
  381.                   checkConnection(main_window, win_gadgets);
  382.                   /* --- ...get menu entries by using GadTools' GTMENUITEM_USERDATA field macro --- */
  383.                   myItem = ((long)GTMENUITEM_USERDATA(ItemAddress(menu_strip, result & WMHI_MENUMASK)));
  384.                   /* --- Identify selected menu entry */
  385.                   switch(myItem)
  386.                   {
  387.                     case MN_INFO:
  388.                       if(myDebug)
  389.                         puts("\n Menu 'Project': <INFO> was selected.");
  390.                       SetAttrs(window_object, WA_BusyPointer, TRUE, TAG_DONE);  /* Modal: ON */
  391.                       /* call About-Requester */
  392.                       req_result = reqabout(window_object);
  393.                       checkConnection(main_window, win_gadgets);
  394.                       SetAttrs(window_object, WA_BusyPointer, FALSE, TAG_DONE); /* Modal: OFF */
  395.                       checkConnection(main_window, win_gadgets);                      
  396.                       break;
  397.                      
  398.                     case MN_QUIT:
  399.                       if(myDebug)
  400.                         puts("\n Menu 'Project': <QUIT> was selected.");
  401.                       SetAttrs(window_object, WA_BusyPointer, TRUE, TAG_DONE);  /* Modal: ON */
  402.                       /* call Quit-Requester */
  403.                       req_result = reqquit(window_object);
  404.                       if(myDebug)
  405.                           printf("req_result = %d\n", req_result);
  406.                       if (req_result == 1)
  407.                       {
  408.                         if(myDebug)
  409.                           printf("%s\n", str_bye);
  410.                         done = TRUE;
  411.                       }
  412.                       SetAttrs(window_object, WA_BusyPointer, FALSE, TAG_DONE); /* Modal: OFF */
  413.                       checkConnection(main_window, win_gadgets);                      
  414.                       break;
  415.                   } /* END switch(myItem) */
  416.                 } /* END if(!(menuitem == 0)) */                
  417.                 break;  /* END WMHI_MENUPICK */
  418.  
  419.               /* --- GADGETS ----------------------------------------- */
  420.               case WMHI_GADGETUP:
  421.               checkConnection(main_window, win_gadgets);
  422.                 switch (result & WMHI_GADGETMASK)
  423.                 {
  424.                   /* --- Gadget 1 --- */
  425.                   case button_on_id:
  426.                     if(myDebug)
  427.                       puts("Button: UP pressed");
  428.                      
  429.                     connected = TRUE;
  430.                     checkConnection(main_window, win_gadgets);
  431.                     break;
  432.                   /* --- Gadget 2 --- */
  433.                   case button_off_id:
  434.                     if(myDebug)
  435.                       puts("Button: DOWN pressed");
  436.                      
  437.                     connected = FALSE;
  438.                     checkConnection(main_window, win_gadgets);
  439.                     break;                             
  440.                                    
  441.                 } /* END switch (result & WMHI_GADGETMASK) */
  442.                 break;  /* END case WMHI_GADGETUP */
  443.                
  444.               /* --- ICONIFY ----------------------------------------- */
  445.               case WMHI_ICONIFY:
  446.                 if ( RA_Iconify( window_object ) )
  447.                   main_window = NULL;
  448.                 break;
  449.  
  450.               /* --- UNICONIFY --------------------------------------- */
  451.               case WMHI_UNICONIFY:
  452.                 main_window = RA_OpenWindow( window_object );
  453.                 if ( menu_strip)  SetMenuStrip( main_window, menu_strip );
  454.               break;
  455.             } /* END switch ( result & WMHI_CLASSMASK ) */
  456.           } /* END while (( result = RA_HandleInput( window_object, &Code )) != WMHI_LASTMSG) */
  457.       } /* END while ( !done) */
  458.     } /* END if ( main_window = (struct Window *) RA_OpenWindow( window_object )) */
  459.   } /* END if ( window_object ) */
  460. } /* END Function runWindow() */
  461.  
  462.  
  463. /* --- Function: window_main() ----------------------------------- */
  464. /* --- All window-specific setup for main Window is done here. --- */
  465. /* ---'runWindow()' is called for message handling afterwards. --- */
  466. void window_main( void )
  467. {
  468.   /* We changed ReBuild's menu struct output in order to obey to GadTools Menu handling! */
  469.   /* Replaced: Last NULL argument by (APTR) <Item identifier>                            */
  470.   struct NewMenu menuData[] =
  471.   {
  472.     { NM_TITLE, "Project", 0, 0, 0, NULL },
  473.     { NM_ITEM, "Info...", "I", 0, 6, (APTR)MN_INFO },
  474.     { NM_ITEM, NM_BARLABEL, 0, 0, 5, NULL },
  475.     { NM_ITEM, "Quit", "Q", 0, 3, (APTR)MN_QUIT },
  476.     { NM_END, NULL, 0, 0, 0, (APTR)0 }
  477.   };
  478.  
  479.   struct Menu   *menu_strip = NULL;
  480.   struct Gadget *main_gadgets[ 6 ];
  481.   Object *window_object = NULL;
  482.   struct HintInfo hintInfo[] =
  483.   {
  484.     {vert_main_id,-1,"",0},
  485.     {vert_buttons_id,-1,"",0},
  486.     {button_on_id,-1,"Switch Network ON",0},
  487.     {button_off_id,-1,"Switch Network OFF",0},
  488.     {string_status_id,-1,"Show Network Status",0},
  489.     {-1,-1,NULL,0}
  490.   };
  491.   menu_strip = CreateMenusA( menuData, TAG_END );
  492.   LayoutMenus( menu_strip, gVisinfo,
  493.     GTMN_NewLookMenus, TRUE,
  494.     TAG_DONE );
  495.  
  496.  
  497.   window_object = WindowObject,
  498.     WA_Title, "RoadShow Control",
  499.     WA_ScreenTitle, "NetButton RoadShow Control v1.0",
  500.     WA_Left, 5,
  501.     WA_Top, 20,
  502.     WA_Width, 150,
  503.     WA_Height, 20,
  504.     WA_MinWidth, 150,
  505.     WA_MinHeight, 20,
  506.     WA_MaxWidth, 8192,
  507.     WA_MaxHeight, 8192,
  508.     WINDOW_LockHeight, TRUE,
  509.     WINDOW_IconifyGadget, TRUE,
  510.     WINDOW_HintInfo, hintInfo,
  511.     WINDOW_GadgetHelp, TRUE,
  512.     WINDOW_AppPort, gAppPort,
  513.     WINDOW_IconifyGadget, TRUE,
  514.     WA_CloseGadget, TRUE,
  515.     WA_DepthGadget, TRUE,
  516.     WA_SizeGadget, TRUE,
  517.     WA_DragBar, TRUE,
  518.     WA_Activate, TRUE,
  519.     WINDOW_Position, WPOS_TOPLEFT,
  520.     WINDOW_IconTitle, "NetButton",
  521.     WINDOW_Icon,  GetDiskObject("NetButton"),
  522.     WA_NoCareRefresh, TRUE,
  523.     WA_IDCMP, IDCMP_GADGETDOWN | IDCMP_GADGETUP | IDCMP_CLOSEWINDOW | IDCMP_MENUPICK |
  524.     IDCMP_NEWSIZE | IDCMP_REFRESHWINDOW | IDCMP_VANILLAKEY | IDCMP_RAWKEY | IDCMP_INTUITICKS | IDCMP_IDCMPUPDATE,
  525.     WINDOW_ParentGroup, VLayoutObject,
  526.     LAYOUT_SpaceOuter, TRUE,
  527.     LAYOUT_DeferLayout, TRUE,
  528.       LAYOUT_AddChild, main_gadgets[vert_main] = LayoutObject,
  529.         GA_ID, vert_main_id,
  530.         LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  531.         LAYOUT_AddChild, main_gadgets[vert_buttons] = LayoutObject,
  532.           GA_ID, vert_buttons_id,
  533.           LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  534.           LAYOUT_SpaceOuter, TRUE,
  535.           LAYOUT_FixedVert, FALSE,
  536.           LAYOUT_EvenSize, TRUE,
  537.           LAYOUT_DeferLayout, TRUE,
  538.           LAYOUT_AddChild, main_gadgets[button_on] = ButtonObject,
  539.             GA_ID, button_on_id,
  540.             GA_Text, "Go ONLINE",
  541.             GA_RelVerify, TRUE,
  542.             GA_TabCycle, TRUE,
  543.             GA_Disabled, TRUE,
  544.             BUTTON_TextPen, 1,
  545.             BUTTON_BackgroundPen, 0,
  546.             BUTTON_FillTextPen, 1,
  547.             BUTTON_FillPen, 3,
  548.           ButtonEnd,
  549.           LAYOUT_AddChild, main_gadgets[button_off] = ButtonObject,
  550.             GA_ID, button_off_id,
  551.             GA_Text, "Go OFFLINE",
  552.             GA_RelVerify, TRUE,
  553.             GA_TabCycle, TRUE,
  554.             GA_Disabled, FALSE,
  555.             BUTTON_TextPen, 1,
  556.             BUTTON_BackgroundPen, 0,
  557.             BUTTON_FillTextPen, 1,
  558.             BUTTON_FillPen, 3,
  559.           ButtonEnd,
  560.           LAYOUT_AddChild, main_gadgets[string_status] = StringObject,
  561.             GA_ID, string_status_id,
  562.             GA_RelVerify, TRUE,
  563.             GA_TabCycle, TRUE,
  564.             GA_ReadOnly, TRUE,
  565.             STRINGA_TextVal, "ONLINE",
  566.             STRINGA_MaxChars, 80,
  567.             STRINGA_Justification, GACT_STRINGCENTER,
  568.           StringEnd,
  569.           CHILD_Label, LabelObject,
  570.             LABEL_Text, "Status:",
  571.           LabelEnd,
  572.         LayoutEnd,
  573.       LayoutEnd,
  574.     LayoutEnd,
  575.   WindowEnd;  
  576.   main_gadgets[5] = 0;
  577.  
  578.   runWindow( window_object, window_main_id, menu_strip, main_gadgets );
  579.  
  580.   if ( window_object ) DisposeObject( window_object );
  581.   if ( menu_strip ) FreeMenus( menu_strip );
  582. } /* END Function window_main() */
  583.  
  584.  
  585. /* --- Main Function ---------------------------------------------------------------------------------- */
  586. int main(void)
  587. {
  588.   if ( setup() )    /* This will satisfy all needs... */
  589.   {
  590.     window_main();  /* ...and open Application's main Window + implement Event handling by running 'runWindow()' */
  591.   }
  592.   cleanup();        /* Clean up stuff and exit */
  593. } /* END main() */
Tags: AmigaOs 3.2
Advertisement
Add Comment
Please, Sign In to add comment