home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / MUI / muitoolkit / developer / C / examples / mt_demo.c < prev   
Encoding:
C/C++ Source or Header  |  1999-09-18  |  31.4 KB  |  791 lines

  1.  
  2. /*
  3. $Id: mt_demo.c,v 1.2 1999/09/02 19:22:06 carlos Exp $.
  4. */
  5.  
  6. #include <exec/types.h>
  7. #include <exec/memory.h>
  8.  
  9. #include <proto/exec.h>
  10. #include <proto/muimaster.h>
  11.  
  12. #include <proto/muitoolkit.h>
  13. #include <libraries/muitoolkit.h>
  14.  
  15. #include "mt_demo_revision.h"
  16.  
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19.  
  20. char *ScreenTitle = "MuiToolkit demo " VERSIONREVISION " (" DATE ") · © 1999 Marcin Orlowski <carlos@amiga.com.pl>";
  21. char *Title       = "MuiToolkit demo " VERSIONREVISION ;
  22.  
  23. struct Library *MUIMasterBase  = NULL;
  24. struct Library *MuiToolkitBase = NULL;
  25.  
  26. Object *app;
  27.  
  28. char *_Ok       = "*_Ok";
  29. char *_Sorry    = "*_I'm sorry";
  30.  
  31. char *ShortHelp = "This is short help ;-)";
  32.  
  33. /// ShowRapidGUI
  34.  
  35.  
  36. void ShowRapidGUI( void )
  37. {
  38. char *RadioLabel  = "_Radio";
  39. char *StringLabel = "_Type something";
  40.  
  41. Object *win1, *c1,*c2, *c3,*c4, *bt1_src, *win1a;
  42. Object *win2, *bt2_src, *win2a;
  43.  
  44.  
  45. /// win1src
  46. char *win1_src = "win1 = WindowObject,\n"
  47. "    MUIA_Window_Title      , Title,\n"
  48. "    MUIA_Window_ID         , 0x0000,\n"
  49. "    MUIA_Window_ScreenTitle, ScreenTitle,\n"
  50. "    WindowContents,\n"
  51. "        VGroup,\n"
  52. "            Child, TextObject,\n"
  53. "                   TextFrame, TextBack,\n"
  54. "                   MUIA_Text_Contents, \"Classic window\\nClose to proceed\",\n"
  55. "                   MUIA_Text_PreParse, \"\\033c\",\n"
  56. "                   End,\n"
  57. "            Child, HGroup,\n"
  58. "                   Child, Label( StringLabel ),\n"
  59. "                   Child, StringObject, StringFrame,\n"
  60. "                          MUIA_String_Contents, \"A bit of text\",\n"
  61. "                          MUIA_String_MaxLen, 40,\n"
  62. "                          MUIA_CycleChain, TRUE,\n"
  63. "                          MUIA_String_AdvanceOnCR, TRUE,\n"
  64. "                          MUIA_ShortHelp, \"Type something\",\n"
  65. "                          End,\n"
  66. "                   End,\n"
  67. "            Child, ColGroup(3),\n"
  68. "                   Child, TextObject,\n"
  69. "                          ButtonFrame,\n"
  70. "                          MUIA_Text_Contents, \"Button 1\",\n"
  71. "                          MUIA_Text_PreParse, \"\\33c\",\n"
  72. "                          MUIA_Text_HiChar  , '1',\n"
  73. "                          MUIA_ControlChar  , '1',\n"
  74. "                          MUIA_InputMode    , MUIV_InputMode_RelVerify,\n"
  75. "                          MUIA_Background   , MUII_ButtonBack,\n"
  76. "                          MUIA_CycleChain   , TRUE,\n"
  77. "                          MUIA_ShortHelp    , \"Button numer 1\",\n"
  78. "                          End,\n"
  79. "                   Child, TextObject,\n"
  80. "                          ButtonFrame,\n"
  81. "                          MUIA_Text_Contents, \"Button 2\",\n"
  82. "                          MUIA_Text_PreParse, \"\\33c\",\n"
  83. "                          MUIA_Text_HiChar  , '2',\n"
  84. "                          MUIA_ControlChar  , '2',\n"
  85. "                          MUIA_InputMode    , MUIV_InputMode_RelVerify,\n"
  86. "                          MUIA_Background   , MUII_ButtonBack,\n"
  87. "                          MUIA_CycleChain   , TRUE,\n"
  88. "                          MUIA_ShortHelp    , \"Button numer 2\",\n"
  89. "                          End,\n"
  90. "                   Child, TextObject,\n"
  91. "                          ButtonFrame,\n"
  92. "                          MUIA_Text_Contents, \"Button 3\",\n"
  93. "                          MUIA_Text_PreParse, \"\\33c\",\n"
  94. "                          MUIA_Text_HiChar  , '3',\n"
  95. "                          MUIA_ControlChar  , '3',\n"
  96. "                          MUIA_InputMode    , MUIV_InputMode_RelVerify,\n"
  97. "                          MUIA_Background   , MUII_ButtonBack,\n"
  98. "                          MUIA_CycleChain   , TRUE,\n"
  99. "                          MUIA_ShortHelp    , \"Button numer 3\",\n"
  100. "                          End,\n"
  101. "                   Child, TextObject,\n"
  102. "                          ButtonFrame,\n"
  103. "                          MUIA_Text_Contents, \"Button 4\",\n"
  104. "                          MUIA_Text_PreParse, \"\\33c\",\n"
  105. "                          MUIA_Text_HiChar  , '4',\n"
  106. "                          MUIA_ControlChar  , '4',\n"
  107. "                          MUIA_InputMode    , MUIV_InputMode_RelVerify,\n"
  108. "                          MUIA_Background   , MUII_ButtonBack,\n"
  109. "                          MUIA_CycleChain   , TRUE,\n"
  110. "                          MUIA_ShortHelp    , \"Button numer 4\",\n"
  111. "                          End,\n"
  112. "                   Child, TextObject,\n"
  113. "                          ButtonFrame,\n"
  114. "                          MUIA_Text_Contents, \"Button 5\",\n"
  115. "                          MUIA_Text_PreParse, \"\\33c\",\n"
  116. "                          MUIA_Text_HiChar  , '5',\n"
  117. "                          MUIA_ControlChar  , '5',\n"
  118. "                          MUIA_InputMode    , MUIV_InputMode_RelVerify,\n"
  119. "                          MUIA_Background   , MUII_ButtonBack,\n"
  120. "                          MUIA_CycleChain   , TRUE,\n"
  121. "                          MUIA_ShortHelp    , \"Button numer 5\",\n"
  122. "                          End,\n"
  123. "                   Child, TextObject,\n"
  124. "                          ButtonFrame,\n"
  125. "                          MUIA_Text_Contents, \"Button 6\",\n"
  126. "                          MUIA_Text_PreParse, \"\\33c\",\n"
  127. "                          MUIA_Text_HiChar  , '6',\n"
  128. "                          MUIA_ControlChar  , '6',\n"
  129. "                          MUIA_InputMode    , MUIV_InputMode_RelVerify,\n"
  130. "                          MUIA_Background   , MUII_ButtonBack,\n"
  131. "                          MUIA_CycleChain   , TRUE,\n"
  132. "                          MUIA_ShortHelp    , \"Button numer 6\",\n"
  133. "                          End,\n"
  134. "                   End,\n"
  135. "            Child, HGroup,\n"
  136. "                   Child, HGroup,\n"
  137. "                          Child, Label( RadioLabel ),\n"
  138. "                          Child, RadioObject,\n"
  139. "                                 MUIA_Radio_Entries, radio,\n"
  140. "                                 MUIA_CycleChain, TRUE,\n"
  141. "                                 MUIA_ShortHelp, ShortHelp,\n"
  142. "                                 End,\n"
  143. "                          End,\n"
  144. "                   Child, ColGroup(3),\n"
  145. "                          Child, HVSpace,\n"
  146. "                          Child, Label( \"_Check 1\" ),\n"
  147. "                          Child, c1 = KeyCheckMark( FALSE, 'c' ),\n"
  148. "                          Child, c2 = KeyCheckMark( TRUE , 'h' ),\n"
  149. "                          Child, Label( \"C_heck 2\" ),\n"
  150. "                          Child, HVSpace,\n"
  151. "                          Child, c3 = KeyCheckMark( TRUE , 'e' ),\n"
  152. "                          Child, Label( \"Ch_eck 3\" ),\n"
  153. "                          Child, HVSpace,\n"
  154. "                          Child, HVSpace,\n"
  155. "                          Child, Label( \"Chec_k 4\" ),\n"
  156. "                          Child, c4 = KeyCheckMark( FALSE, 'k' ),\n"
  157. "                          End,\n"
  158. "                    End,\n"
  159. "             Child, bt1_src = TextObject,\n"
  160. "                          ButtonFrame,\n"
  161. "                          MUIA_Text_Contents, \"Show source\",\n"
  162. "                          MUIA_Text_PreParse, \"\\33c\",\n"
  163. "                          MUIA_Text_HiChar  , 's',\n"
  164. "                          MUIA_ControlChar  , 's',\n"
  165. "                          MUIA_InputMode    , MUIV_InputMode_RelVerify,\n"
  166. "                          MUIA_Background   , MUII_ButtonBack,\n"
  167. "                          MUIA_CycleChain   , TRUE,\n"
  168. "                          MUIA_ShortHelp    , \"Yes, it should\",\n"
  169. "                          End,\n"
  170. "             End,\n"
  171. "        End;\n"
  172. "if( win1 )\n"
  173. "    {\n"
  174. "    set( c1, MUIA_ShortHelp, ShortHelp );\n"
  175. "    set( c2, MUIA_ShortHelp, ShortHelp );\n"
  176. "    set( c3, MUIA_ShortHelp, ShortHelp );\n"
  177. "    set( c4, MUIA_ShortHelp, ShortHelp );\n"
  178. "    }\n";
  179.  
  180. //|
  181. /// win2src
  182. char *win2_src = "win2 = WindowObject,\n"
  183. "    MUIA_Window_Title      , Title,\n"
  184. "    MUIA_Window_ID         , 0x0001,\n"
  185. "    MUIA_Window_ScreenTitle, ScreenTitle,\n"
  186. "    WindowContents,\n"
  187. "       VGroup,\n"
  188. "         Child, mt_Text(\"MuiToolkit window\\nClose to proceed\", \"\\033c\"),\n"
  189. "         Child, HGroup,\n"
  190. "                Child, mt_Label(StringLabel),\n"
  191. "                Child, mt_String(\"A bit of text\", 40, StringLabel, \"Type something\"),\n"
  192. "                End,\n"
  193. "         Child, ColGroup(3),\n"
  194. "                Child, mt_Button(\"Button _1\", \"This is button no.1\"),\n"
  195. "                Child, mt_Button(\"Button _2\", \"This is button no.2\"),\n"
  196. "                Child, mt_Button(\"Button _3\", \"This is button no.3\"),\n"
  197. "                Child, mt_Button(\"Button _4\", \"This is button no.4\"),\n"
  198. "                Child, mt_Button(\"Button _5\", \"This is button no.5\"),\n"
  199. "                Child, mt_Button(\"Button _6\", \"This is button no.6\"),\n"
  200. "                End,\n"
  201. "         Child, HGroup,\n"
  202. "                Child, HGroup,\n"
  203. "                       Child, mt_Label( RadioLabel ),\n"
  204. "                       Child, mt_Radio( radio, RadioLabel, ShortHelp ),\n"
  205. "                       End,\n"
  206. "                Child, VGroup,\n"
  207. "                       Child, mt_Check( \"_Check 1\", mt_Check_AlignRight, FALSE, ShortHelp ),\n"
  208. "                       Child, mt_Check( \"C_heck 2\", mt_Check_AlignLeft , TRUE , ShortHelp ),\n"
  209. "                       Child, mt_Check( \"Ch_eck 3\", mt_Check_AlignLeft , TRUE , ShortHelp ),\n"
  210. "                       Child, mt_Check( \"Chec_k 4\", mt_Check_AlignRight, FALSE, ShortHelp ),\n"
  211. "                       End,\n"
  212. "                End,\n"
  213. "         Child, bt2_src = mt_Button(\"_Show source\", \"Yes, it does so ;)\"),\n"
  214. "         End,\n"
  215. "    End;";
  216.  
  217. //|
  218.  
  219. char *radio[] = { "Apples",
  220.                   "Bananas",
  221.                   "Plums",
  222.                   NULL };
  223.  
  224.  
  225.  
  226.     win1 = win1a = win2 = win2a = NULL;
  227.  
  228.  
  229.     // ...let's construct some dynamically added windows
  230.  
  231.     // this window is created using standard MUI
  232.     // macros and calls
  233.  
  234.     win1 = WindowObject,
  235.                MUIA_Window_Title      , Title,
  236.                MUIA_Window_ID         , 0x0000,
  237.                MUIA_Window_ScreenTitle, ScreenTitle,
  238.                WindowContents,
  239.                    VGroup,
  240.                        Child, TextObject,
  241.                               TextFrame, TextBack,
  242.                               MUIA_Text_Contents, "Classic window\nClose to proceed",
  243.                               MUIA_Text_PreParse, "\033c",
  244.                               End,
  245.  
  246.                        Child, HGroup,
  247.  
  248.                        Child, Label( StringLabel ),
  249.                        Child, StringObject, StringFrame,
  250.                               MUIA_String_Contents, "A bit of text",
  251.                               MUIA_String_MaxLen, 40,
  252.                               MUIA_CycleChain, TRUE,
  253.                               MUIA_String_AdvanceOnCR, TRUE,
  254.                               MUIA_ShortHelp, "Type something",
  255.                               End,
  256.                        End,
  257.  
  258.                        Child, ColGroup(3),
  259.                               Child, TextObject,
  260.                                      ButtonFrame,
  261.                                      MUIA_Text_Contents, "Button 1",
  262.                                      MUIA_Text_PreParse, "\33c",
  263.                                      MUIA_Text_HiChar  , '1',
  264.                                      MUIA_ControlChar  , '1',
  265.                                      MUIA_InputMode    , MUIV_InputMode_RelVerify,
  266.                                      MUIA_Background   , MUII_ButtonBack,
  267.                                      MUIA_CycleChain   , TRUE,
  268.                                      MUIA_ShortHelp    , "Button numer 1",
  269.                                      End,
  270.                               Child, TextObject,
  271.                                      ButtonFrame,
  272.                                      MUIA_Text_Contents, "Button 2",
  273.                                      MUIA_Text_PreParse, "\33c",
  274.                                      MUIA_Text_HiChar  , '2',
  275.                                      MUIA_ControlChar  , '2',
  276.                                      MUIA_InputMode    , MUIV_InputMode_RelVerify,
  277.                                      MUIA_Background   , MUII_ButtonBack,
  278.                                      MUIA_CycleChain   , TRUE,
  279.                                      MUIA_ShortHelp    , "Button numer 2",
  280.                                      End,
  281.                               Child, TextObject,
  282.                                      ButtonFrame,
  283.                                      MUIA_Text_Contents, "Button 3",
  284.                                      MUIA_Text_PreParse, "\33c",
  285.                                      MUIA_Text_HiChar  , '3',
  286.                                      MUIA_ControlChar  , '3',
  287.                                      MUIA_InputMode    , MUIV_InputMode_RelVerify,
  288.                                      MUIA_Background   , MUII_ButtonBack,
  289.                                      MUIA_CycleChain   , TRUE,
  290.                                      MUIA_ShortHelp    , "Button numer 3",
  291.                                      End,
  292.  
  293.                               Child, TextObject,
  294.                                      ButtonFrame,
  295.                                      MUIA_Text_Contents, "Button 4",
  296.                                      MUIA_Text_PreParse, "\33c",
  297.                                      MUIA_Text_HiChar  , '4',
  298.                                      MUIA_ControlChar  , '4',
  299.                                      MUIA_InputMode    , MUIV_InputMode_RelVerify,
  300.                                      MUIA_Background   , MUII_ButtonBack,
  301.                                      MUIA_CycleChain   , TRUE,
  302.                                      MUIA_ShortHelp    , "Button numer 4",
  303.                                      End,
  304.                               Child, TextObject,
  305.                                      ButtonFrame,
  306.                                      MUIA_Text_Contents, "Button 5",
  307.                                      MUIA_Text_PreParse, "\33c",
  308.                                      MUIA_Text_HiChar  , '5',
  309.                                      MUIA_ControlChar  , '5',
  310.                                      MUIA_InputMode    , MUIV_InputMode_RelVerify,
  311.                                      MUIA_Background   , MUII_ButtonBack,
  312.                                      MUIA_CycleChain   , TRUE,
  313.                                      MUIA_ShortHelp    , "Button numer 5",
  314.                                      End,
  315.                               Child, TextObject,
  316.                                      ButtonFrame,
  317.                                      MUIA_Text_Contents, "Button 6",
  318.                                      MUIA_Text_PreParse, "\33c",
  319.                                      MUIA_Text_HiChar  , '6',
  320.                                      MUIA_ControlChar  , '6',
  321.                                      MUIA_InputMode    , MUIV_InputMode_RelVerify,
  322.                                      MUIA_Background   , MUII_ButtonBack,
  323.                                      MUIA_CycleChain   , TRUE,
  324.                                      MUIA_ShortHelp    , "Button numer 6",
  325.                                      End,
  326.                               End,
  327.  
  328.                        Child, HGroup,
  329.                               Child, HGroup,
  330.                                   Child, Label( RadioLabel ),
  331.                                   Child, RadioObject,
  332.                                          MUIA_Radio_Entries, radio,
  333.                                          MUIA_CycleChain, TRUE,
  334.                                          MUIA_ShortHelp, ShortHelp,
  335.                                          End,
  336.                                   End,
  337.                               Child, ColGroup(3),
  338.                                   Child, HVSpace,
  339.                                   Child, Label( "_Check 1" ),
  340.                                   Child, c1 = KeyCheckMark( FALSE, 'c' ),
  341.  
  342.                                   Child, c2 = KeyCheckMark( TRUE , 'h' ),
  343.                                   Child, Label( "C_heck 2" ),
  344.                                   Child, HVSpace,
  345.  
  346.                                   Child, c3 = KeyCheckMark( TRUE , 'e' ),
  347.                                   Child, Label( "Ch_eck 3" ),
  348.                                   Child, HVSpace,
  349.  
  350.                                   Child, HVSpace,
  351.                                   Child, Label( "Chec_k 4" ),
  352.                                   Child, c4 = KeyCheckMark( FALSE, 'k' ),
  353.                                   End,
  354.                               End,
  355.  
  356.  
  357.                        Child, bt1_src = TextObject,
  358.                               ButtonFrame,
  359.                               MUIA_Text_Contents, "Show source",
  360.                               MUIA_Text_PreParse, "\33c",
  361.                               MUIA_Text_HiChar  , 's',
  362.                               MUIA_ControlChar  , 's',
  363.                               MUIA_InputMode    , MUIV_InputMode_RelVerify,
  364.                               MUIA_Background   , MUII_ButtonBack,
  365.                               MUIA_CycleChain   , TRUE,
  366.                               MUIA_ShortHelp    , "Yes, it should",
  367.                               End,
  368.                     End,
  369.                 End;
  370.  
  371.  
  372.        if( win1 )
  373.            {
  374.            set( c1, MUIA_ShortHelp, ShortHelp );
  375.            set( c2, MUIA_ShortHelp, ShortHelp );
  376.            set( c3, MUIA_ShortHelp, ShortHelp );
  377.            set( c4, MUIA_ShortHelp, ShortHelp );
  378.            }
  379.  
  380.  
  381.     win1a = WindowObject,
  382.                MUIA_Window_Title      , "133 lines (100 more!) · Source of classic window",
  383.                MUIA_Window_ID         , 0x0002,
  384.                MUIA_Window_ScreenTitle, ScreenTitle,
  385.                WindowContents,
  386.                    ScrollgroupObject,
  387.                         MUIA_CycleChain, TRUE,
  388.                         MUIA_Scrollgroup_Contents,
  389.                            VirtgroupObject,
  390.                                  Child, mt_Text( win1_src, NULL ),
  391.                                  End,
  392.                         End,
  393.                    End;
  394.  
  395.  
  396.  
  397.  
  398.     // this window is created with the help of MuiToolkit
  399.     // Taste the difference:
  400.     //  - all objects are automatically cyclechained
  401.     //  - all objects are automatically hotkey driven
  402.     //  - at least 50% of your typing is saved
  403.     //  - adding bubble helps made easy ;-)
  404.  
  405.     win2 = WindowObject,
  406.                MUIA_Window_Title      , Title,
  407.                MUIA_Window_ID         , 0x0001,
  408.                MUIA_Window_ScreenTitle, ScreenTitle,
  409.                WindowContents,
  410.                    VGroup,
  411.                        Child, mt_Text("MuiToolkit window\nClose to proceed", "\033c"),
  412.  
  413.                        Child, HGroup,
  414.                               Child, mt_Label( StringLabel ),
  415.                               Child, mt_String("A bit of text", 40, StringLabel, "Type something"),
  416.                               End,
  417.  
  418.                        Child, ColGroup(3),
  419.                               Child, mt_Button("Button _1", "This is button no.1"),
  420.                               Child, mt_Button("Button _2", "This is button no.2"),
  421.                               Child, mt_Button("Button _3", "This is button no.3"),
  422.  
  423.                               Child, mt_Button("Button _4", "This is button no.4"),
  424.                               Child, mt_Button("Button _5", "This is button no.5"),
  425.                               Child, mt_Button("Button _6", "This is button no.6"),
  426.                               End,
  427.  
  428.                        Child, HGroup,
  429.                               Child, HGroup,
  430.                                   Child, mt_Label( RadioLabel ),
  431.                                   Child, mt_Radio( radio, RadioLabel, ShortHelp ),
  432.                                   End,
  433.                               Child, VGroup,
  434.                                   Child, mt_Check( "_Check 1", mt_Check_AlignRight, FALSE, ShortHelp ),
  435.                                   Child, mt_Check( "C_heck 2", mt_Check_AlignLeft , TRUE , ShortHelp ),
  436.                                   Child, mt_Check( "Ch_eck 3", mt_Check_AlignLeft , TRUE , ShortHelp ),
  437.                                   Child, mt_Check( "Chec_k 4", mt_Check_AlignRight, FALSE, ShortHelp ),
  438.                                   End,
  439.                               End,
  440.  
  441.                        Child, bt2_src = mt_Button("_Show source", "Yes, it does so ;)"),
  442.  
  443.                        End,
  444.                 End;
  445.  
  446.  
  447.     win2a = WindowObject,
  448.                MUIA_Window_Title      , "33 lines - Source of MT powered window",
  449.                MUIA_Window_ID         , 0x0003,
  450.                MUIA_Window_ScreenTitle, ScreenTitle,
  451.                WindowContents,
  452.                    ScrollgroupObject,
  453.                         MUIA_CycleChain, TRUE,
  454.                         MUIA_Scrollgroup_Contents,
  455.                            VirtgroupObject,
  456.                                  Child, mt_Text( win2_src, NULL ),
  457.                                  End,
  458.                            End,
  459.                    End;
  460.  
  461.  
  462.     if( win1 && win2 && win1a && win2a )
  463.        {
  464.        DoMethod( win1, MUIM_Notify, MUIA_Window_CloseRequest, TRUE ,MUIV_Notify_Application, 2 ,MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
  465.        DoMethod( win2, MUIM_Notify, MUIA_Window_CloseRequest, TRUE ,MUIV_Notify_Application, 2 ,MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
  466.  
  467.        DoMethod( win1a, MUIM_Notify, MUIA_Window_CloseRequest, TRUE ,MUIV_Notify_Self, 3 , MUIM_Set, MUIA_Window_Open, FALSE );
  468.        DoMethod( bt1_src, MUIM_Notify, MUIA_Pressed, FALSE, win1a, 3 ,MUIM_Set, MUIA_Window_Open, TRUE );
  469.  
  470.        DoMethod( win2a, MUIM_Notify, MUIA_Window_CloseRequest, TRUE ,MUIV_Notify_Self, 3 , MUIM_Set, MUIA_Window_Open, FALSE );
  471.        DoMethod( bt2_src, MUIM_Notify, MUIA_Pressed, FALSE, win2a, 3 ,MUIM_Set, MUIA_Window_Open, TRUE );
  472.  
  473.  
  474.        MUI_Request(app, NULL, 0, Title, "*Show me",
  475.            "\033u\033bGoal #1:\033n\n\n"
  476.            "Rapid GUI creation.\n\n"
  477.  
  478.            "I guess you probably realized, there\n"
  479.            "is no GUI builder for making good\n"
  480.            "object oriented GUI. The best results can\n"
  481.            "as usual, be reached by creating it by hand.\n"
  482.            "And MT is gonna help you at this field,\n"
  483.            "offering basic object creation functions.\n"
  484.            "Instead of writting lines of calls, tags etc\n"
  485.            "to get useable and good GUI, just call one\n"
  486.            "MT call...");
  487.  
  488.        MUI_Request(app, NULL, 0, Title, "*Wanna see this",
  489.            "I now show you two, almost same windows.\n"
  490.            "the \033b\"Classic\"\033n one is created using\n"
  491.            "all the default MUI functions and macros.\n"
  492.            "The next one \033b\"MT\"\033n is powered by MT.\n\n"
  493.            "Click the \033b\"Show source\"\033n to taste the difference\n"
  494.            "(and close any of these windows to proceed)");
  495.  
  496.  
  497.        mt_WinAttach( app, win1  );
  498.        mt_WinAttach( app, win1a );
  499.        mt_WinAttach( app, win2  );
  500.        mt_WinAttach( app, win2a );
  501.  
  502.  
  503.        if( mt_WinOpen( win1 ) && mt_WinOpen( win2 ) )
  504.            {
  505.            ULONG sigs = 0;
  506.  
  507.            // the main loop
  508.            while(DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  509.                {
  510.                if(sigs)
  511.                    {
  512.                    sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  513.                    if(sigs & SIGBREAKF_CTRL_C) break;
  514.                    }
  515.                }
  516.  
  517.  
  518.            // not necessary, as disposing window object
  519.            // will make it closed, but it's GoodThing{tm}
  520.            // to always clean up
  521.            mt_WinClose( win1 );
  522.            mt_WinClose( win2 );
  523.            }
  524.        else
  525.            {
  526.            printf("Can't create windows!\n");
  527.            }
  528.        }
  529.  
  530.        // let's destroy our windows
  531.        // it's safe to pass NULL as argument
  532.        mt_WinDetach( app, win1  );
  533.        mt_WinDetach( app, win1a );
  534.        mt_WinDetach( app, win2  );
  535.        mt_WinDetach( app, win2a );
  536.  
  537.  
  538. }
  539. //|
  540. /// ShowGetString
  541.  
  542. #define STR_ANSWER  MUI_Request(app, NULL, 0, Title, _Ok, "You entered:\n\"%s\"", tmp); else MUI_Request(app, NULL, 0, Title, _Sorry, "Requester cancelled" );
  543.  
  544. void ShowGetString( void )
  545. {
  546. char tmp[50];
  547.  
  548.  
  549.     MUI_Request(app, NULL, 0, Title, "*Pop it up",
  550.            "\033u\033bmt_GetString()\033n\n\n"
  551.            "Now, asking user for any string won't be\n"
  552.            "a pain any longer..." );
  553.  
  554.  
  555.     if( mt_GetString( app, tmp, sizeof( tmp ),
  556.                            mt_StrReq_Contents, "Hello",
  557.                            TAG_DONE )
  558.       )
  559.     STR_ANSWER
  560.  
  561.  
  562.     MUI_Request(app, NULL, 0, Title, "*Really?",
  563.            "The appearance of the requester is\n"
  564.            "highly configurable...");
  565.  
  566.  
  567.     if( mt_GetString( app, tmp, sizeof( tmp ),
  568.                            mt_StrReq_WinTitle  , "Tricky day",
  569.                            mt_StrReq_GroupTitle, "Clap your hands!",
  570.                            mt_StrReq_Ok        , "_Cancel",
  571.                            mt_StrReq_Cancel    , "_Ok",
  572.                            mt_StrReq_Contents  , "Well, the 'Cancel' is 'Ok' ;)",
  573.                            TAG_DONE )
  574.       )
  575.     STR_ANSWER
  576.  
  577.  
  578.     if( mt_GetString( app, tmp, sizeof( tmp ),
  579.                            mt_StrReq_Info    , "\033cAdditional info panel "
  580.                                                "appears to be quite useful for "
  581.                                                "many purposes, don't you think?\n\n"
  582.                                                "By the way, this requester won't "
  583.                                                "accept empty positive answers...",
  584.                            mt_StrReq_StringHelp, "Ah, custom short help ;)",
  585.                            mt_StrReq_NoEmpty , TRUE,
  586.                            TAG_DONE )
  587.       )
  588.     STR_ANSWER
  589.  
  590.  
  591. }
  592. //|
  593. /// ShowGetInteger
  594.  
  595. #define INT_ANSWER       MUI_Request(app, NULL, 0, Title, _Ok, "You entered:\n\"%ld\"", tmp); else MUI_Request(app, NULL, 0, Title, _Sorry, "Requester cancelled" );
  596.  
  597.  
  598. void ShowGetInteger(void)
  599. {
  600.  
  601. LONG tmp;
  602.  
  603.  
  604.     MUI_Request(app, NULL, 0, Title, "*Pop it up",
  605.            "\033u\033bmt_GetInteger()\033n\n\n"
  606.            "Integer value? No problem..." );
  607.  
  608.  
  609.     if( mt_GetInteger( app, &tmp,
  610.                        mt_IntReq_Value, 0,
  611.                        TAG_DONE )
  612.       )
  613.     INT_ANSWER
  614.  
  615.  
  616.     if( mt_GetInteger( app, &tmp,
  617.                        mt_IntReq_Info, "\033cThe requester accepts "
  618.                                        "negative values as well!",
  619.                        TAG_DONE )
  620.       )
  621.     INT_ANSWER
  622.  
  623.  
  624.     MUI_Request(app, NULL, 0, Title, "*Marvelous",
  625.                        "Bounds are also supported...\n"
  626.                        "Both separately...");
  627.  
  628.     if( mt_GetInteger( app, &tmp,
  629.                            mt_IntReq_Min, 30,
  630.                            TAG_DONE )
  631.       )
  632.     INT_ANSWER
  633.  
  634.  
  635.     if( mt_GetInteger( app, &tmp,
  636.                            mt_IntReq_Max, -50,
  637.                            TAG_DONE )
  638.       )
  639.     INT_ANSWER
  640.  
  641.  
  642.     MUI_Request(app, NULL, 0, Title, "*Oh, my God!",
  643.                        "...and together..." );
  644.  
  645.     if( mt_GetInteger( app, &tmp,
  646.                            mt_IntReq_Min, 30,
  647.                            mt_IntReq_Max, 50,
  648.                            TAG_DONE )
  649.       )
  650.     INT_ANSWER
  651.  
  652.  
  653.     MUI_Request(app, NULL, 0, Title, "*Really?",
  654.            "As usual the appearance of the\n"
  655.            "requester is highly configurable...");
  656.  
  657.  
  658.     if( mt_GetInteger( app, &tmp,
  659.                            mt_IntReq_Info      , "You have no Windows installed yet?\n\n"
  660.                                                  "Good boy...",
  661.                            mt_IntReq_WinTitle  , "Tricky day",
  662.                            mt_IntReq_Ok        , "_Cancel",
  663.                            mt_IntReq_Cancel    , "_Ok",
  664.                            mt_IntReq_Value     , 666,
  665.                            mt_IntReq_StringHelp, "Well, the 'Cancel' is 'Ok' ;)",
  666.                            TAG_DONE )
  667.       )
  668.     INT_ANSWER
  669.  
  670.  
  671. }
  672.  
  673. //|
  674. /// main
  675. void main( void )
  676. {
  677.  
  678.  
  679.     MUIMasterBase = (APTR) OpenLibrary( MUIMASTER_NAME, MUIMASTER_VMIN );
  680.     MuiToolkitBase = (APTR) OpenLibrary( MUITOOLKIT_NAME, MUITOOLKIT_VMIN );
  681.  
  682.  
  683.     if( MuiToolkitBase && MUIMasterBase )
  684.        {
  685.  
  686.        // application object is a must ;)
  687.        app = ApplicationObject,
  688.                  MUIA_Application_Title      , "MT-Demo",
  689.                  MUIA_Application_Version    , VERSTAG,
  690.                  MUIA_Application_Copyright  , "© 1999 W.F.M.H.",
  691.                  MUIA_Application_Author     , "Marcin Orlowski <carlos@amiga.com.pl>",
  692.                  MUIA_Application_Description, Title,
  693.                  MUIA_Application_Base       , "MTDEMO",
  694.                  End;
  695.  
  696.  
  697.        // let's go
  698.        if( app )
  699.            {
  700.            MUI_Request(app, NULL, 0, Title, "*Let's go",
  701.                    "\033u\033b%s (%s)\033n\n\n"
  702.                    "This library is designed to help\n"
  703.                    "you make better MUI applications.\n"
  704.                    "It features many helpful functions\n"
  705.                    "for both rapid gui programming as\n"
  706.                    "well as support functions.\n\n"
  707.  
  708.                    "As it's programmer's toolbox, you won't\n"
  709.                    "see all the adventages just by watching\n"
  710.                    "this demo, you have to see the enclosed\n"
  711.                    "source code of it. But we try to show you\n"
  712.                    "as much as possible too.", VERS, DATE
  713.                    );
  714.  
  715.  
  716.            ShowRapidGUI();
  717.  
  718.  
  719.            MUI_Request(app, NULL, 0, Title, "*Show me",
  720.                    "\033u\033bGoal #2:\033n\n\n"
  721.                    "\033iSupport functions\033n\n\n"
  722.                    "Among object creation calls, MT features\n"
  723.                    "other helpful functions, like for instance\n"
  724.                    "requesters. No, not like this one...");
  725.  
  726.            ShowGetString();
  727.            ShowGetInteger();
  728.  
  729.  
  730.            MUI_Request(app, NULL, 0, Title, "*I like it",
  731.                    "\033u\033bThat's it for now\033n\n\n"
  732.                    "You recently reached the end of this\n"
  733.                    "little demonstration. Hope you like it.\n\n"
  734.                    "This is freeware software, so feel free to\n"
  735.                    "use it in your own projects (I don't mind\n"
  736.                    "a credit of course ;)" );
  737.  
  738.            MUI_Request(app, NULL, 0, Title, "*Great",
  739.                    "\033u\033bNobody's perfect...\033n\n\n"
  740.                    "So if this library lacks any function you\n"
  741.                    "think is basic and would be nice to appear\n"
  742.                    "among the available calls, please contact me.\n"
  743.                    "I don't mind ready-to-use C sources and so on.\n\n"
  744.                    "\033bAny contribution is warmly welcome!\033n");
  745.  
  746.  
  747.            MUI_Request(app, NULL, 0, Title, "*Fine",
  748.                    "\033u\033bQuestions, bug reports, anything?\033n\n\n"
  749.                    "Marcin Orlowski\n"
  750.                    "P.O. Box 91\n"
  751.                    "71-507 Szczecin 5\n"
  752.                    "Poland\n\n"
  753.                    "e-mail: carlos@amiga.com.pl\n"
  754.                    "Home site: http://wfmh.org.pl/~carlos/" );
  755.  
  756.            }
  757.        else
  758.            {
  759.            printf("Can't create MUI application!\n");
  760.            }
  761.        }
  762.     else
  763.        {
  764.        if( MUIMasterBase )
  765.            {
  766.            MUI_Request(app, NULL, 0, Title, "*I'll check",
  767.                            "Can't open %s v%ld\n"
  768.                            "Make sure it's in either \"MUI:Libs/\"\n"
  769.                            "or \"LIBS:\" or in home directory of this\n"
  770.                            "demonstration program!",
  771.                            MUITOOLKIT_NAME, MUITOOLKIT_VMIN );
  772.            }
  773.        else
  774.            {
  775.            printf("** Can't open %s, v%ld\n", MUIMASTER_NAME, MUIMASTER_VMIN );
  776.  
  777.            if( !MuiToolkitBase )
  778.                printf("** Can't open %s, v%ld\n", MUITOOLKIT_NAME, MUITOOLKIT_VMIN );
  779.            }
  780.        exit(20);
  781.        }
  782.  
  783.  
  784.     if( MuiToolkitBase)  CloseLibrary( MuiToolkitBase );
  785.     if( MUIMasterBase )  CloseLibrary( MUIMasterBase  );
  786.  
  787.  
  788.     exit(0);
  789. }
  790. //|
  791.