home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 18 / amigaformatcd18.iso / mui / mui_developer / c / examples / pages.c < prev    next >
C/C++ Source or Header  |  1997-03-10  |  3KB  |  105 lines

  1. #include "demo.h"
  2.  
  3. static char *Sex[]     = { "male","female",NULL };
  4. static char *Pages[]   = { "Race","Class","Armor","Level",NULL };
  5. static char *Races[]   = { "Human","Elf","Dwarf","Hobbit","Gnome",NULL };
  6. static char *Classes[] = { "Warrior","Rogue","Bard","Monk","Magician","Archmage",NULL };
  7.  
  8. int main(int argc,char *argv[])
  9. {
  10.     APTR app,window;
  11.  
  12.     init();
  13.  
  14.     app = ApplicationObject,
  15.         MUIA_Application_Title      , "Pages-Demo",
  16.         MUIA_Application_Version    , "$VER: Pages-Demo 19.5 (12.02.97)",
  17.         MUIA_Application_Copyright  , "©1992/93, Stefan Stuntz",
  18.         MUIA_Application_Author     , "Stefan Stuntz",
  19.         MUIA_Application_Description, "Show MUIs Page Groups",
  20.         MUIA_Application_Base       , "PAGESDEMO",
  21.  
  22.         SubWindow, window = WindowObject,
  23.             MUIA_Window_Title, "Character Definition",
  24.             MUIA_Window_ID   , MAKE_ID('P','A','G','E'),
  25.  
  26.             WindowContents, VGroup,
  27.  
  28.                 Child, ColGroup(2),
  29.                     Child, Label2("Name:"), Child, String("Frodo",32),
  30.                     Child, Label1("Sex:" ), Child, Cycle(Sex),
  31.                     End,
  32.  
  33.                 Child, VSpace(2),
  34.  
  35.                 Child, RegisterGroup(Pages),
  36.                     MUIA_Register_Frame, TRUE,
  37.  
  38.                     Child, HCenter(Radio(NULL,Races)),
  39.  
  40.                     Child, HCenter(Radio(NULL,Classes)),
  41.  
  42.                     Child, HGroup,
  43.                         Child, HSpace(0),
  44.                         Child, ColGroup(2),
  45.                             Child, Label1("Cloak:" ), Child, CheckMark(TRUE),
  46.                             Child, Label1("Shield:"), Child, CheckMark(TRUE),
  47.                             Child, Label1("Gloves:"), Child, CheckMark(TRUE),
  48.                             Child, Label1("Helmet:"), Child, CheckMark(TRUE),
  49.                             End,
  50.                         Child, HSpace(0),
  51.                         End,
  52.  
  53.                     Child, ColGroup(2),
  54.                         Child, Label("Experience:"  ), Child, Slider(0,100, 3),
  55.                         Child, Label("Strength:"    ), Child, Slider(0,100,42),
  56.                         Child, Label("Dexterity:"   ), Child, Slider(0,100,24),
  57.                         Child, Label("Condition:"   ), Child, Slider(0,100,39),
  58.                         Child, Label("Intelligence:"), Child, Slider(0,100,74),
  59.                         End,
  60.  
  61.                     End,
  62.                 End,
  63.             End,
  64.         End;
  65.  
  66.     if (!app)
  67.         fail(app,"Failed to create Application.");
  68.  
  69.     DoMethod(window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  70.         app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  71.  
  72.  
  73. /*
  74. ** This is the ideal input loop for an object oriented MUI application.
  75. ** Everything is encapsulated in classes, no return ids need to be used,
  76. ** we just check if the program shall terminate.
  77. ** Note that MUIM_Application_NewInput expects sigs to contain the result
  78. ** from Wait() (or 0). This makes the input loop significantly faster.
  79. */
  80.  
  81.     set(window,MUIA_Window_Open,TRUE);
  82.  
  83.     {
  84.         ULONG sigs = 0;
  85.  
  86.         while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  87.         {
  88.             if (sigs)
  89.             {
  90.                 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  91.                 if (sigs & SIGBREAKF_CTRL_C) break;
  92.             }
  93.         }
  94.     }
  95.  
  96.     set(window,MUIA_Window_Open,FALSE);
  97.  
  98.  
  99. /*
  100. ** Shut down...
  101. */
  102.  
  103.     fail(app,NULL);
  104. }
  105.