home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga Shareware Floppies / ma21.dms / ma21.adf / MUIBuilder / examplessource / c / click.c next >
C/C++ Source or Header  |  1980-03-18  |  3KB  |  90 lines

  1. #include "code.h"
  2.  
  3. #define    ID_BUTTON1    1
  4. #define ID_BUTTON2    2
  5. #define    ID_BUTTON3    3
  6.  
  7. int main()
  8. {
  9.     ULONG    signal;
  10.     BOOL    running = TRUE;
  11.     APTR    app, WI_try, TX_label_0, BT_1stbutton, BT_2ndbutton, BT_3rdbutton;
  12.     char    STR_TX_label_0 [80];
  13.  
  14.     strcpy( STR_TX_label_0, "\0338\033cClick on buttons" );
  15.     init();
  16.  
  17.     app = ApplicationObject,
  18.         MUIA_Application_Author, "Eric Totel",
  19.                 MUIA_Application_Base, "CLICK",
  20.                 MUIA_Application_Title, "Click",
  21.                 MUIA_Application_Version, "1.0",
  22.                 MUIA_Application_Copyright, "(c) 1993 Eric Totel",
  23.         SubWindow, WI_try = WindowObject,
  24.             MUIA_Window_Title, "Click !!!",
  25.             WindowContents, GroupObject,
  26.                 Child, TX_label_0 = TextObject,
  27.                     MUIA_Background, 131,
  28.                     MUIA_Text_Contents, STR_TX_label_0,
  29.                     MUIA_Text_SetMax, 0,
  30.                     MUIA_Text_SetMin, 1,
  31.                     MUIA_Frame, 9,
  32.                     End,
  33.                 Child, GroupObject,
  34.                     MUIA_Group_Horiz, 1,
  35.                     MUIA_Group_SameWidth, 1,
  36.                     Child, BT_1stbutton = KeyButton( "Button 1",'1' ),
  37.                     Child, BT_2ndbutton = KeyButton( "Button 2",'2' ),
  38.                     Child, BT_3rdbutton = KeyButton( "Button 3",'3' ),
  39.                     End,
  40.                 End,
  41.             End,
  42.         End;
  43.  
  44.     /************************/
  45.     /* Buttons Notification */
  46.     /************************/
  47.  
  48.     DoMethod( BT_1stbutton, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_BUTTON1 );
  49.     DoMethod( BT_2ndbutton, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_BUTTON2 );
  50.     DoMethod( BT_3rdbutton, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_BUTTON3 );
  51.     
  52.     /***********************/
  53.     /* Window closing      */
  54.     /***********************/
  55.  
  56.      DoMethod( WI_try, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
  57.  
  58.     /***********************/
  59.     /* Window Opening      */
  60.     /***********************/
  61.  
  62.     set(WI_try , MUIA_Window_Open , TRUE);
  63.  
  64.     /* main loop */
  65.  
  66.     while (running)
  67.     {
  68.         switch (DoMethod(app,MUIM_Application_Input,&signal))
  69.         {
  70.         case ID_BUTTON1:
  71.             sprintf( STR_TX_label_0, "\033c\0338You pressed first button");
  72.             set( TX_label_0, MUIA_Text_Contents, STR_TX_label_0 );
  73.             break;
  74.         case ID_BUTTON2:
  75.             sprintf( STR_TX_label_0, "\033c\0338You pressed second button");
  76.             set( TX_label_0, MUIA_Text_Contents, STR_TX_label_0 );
  77.             break;
  78.         case ID_BUTTON3:
  79.             sprintf( STR_TX_label_0, "\033c\0338You pressed third button");
  80.             set( TX_label_0, MUIA_Text_Contents, STR_TX_label_0 );
  81.             break;
  82.         case MUIV_Application_ReturnID_Quit:
  83.             running = FALSE;
  84.             break;
  85.         }
  86.     if (signal) Wait(signal);
  87.     }
  88.     MUI_DisposeObject(app);
  89. }
  90.