2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <exec/types.h>
11 #include <proto/alib.h>
12 #include <proto/exec.h>
13 #include <proto/dos.h>
14 #include <proto/intuition.h>
15 #include <proto/muimaster.h>
16 #include <libraries/mui.h>
17 #include <libraries/coolimages.h>
20 #define AddContents(obj) \
21 DoMethod(root, MUIM_Group_InitChange); \
22 DoMethod(root, OM_ADDMEMBER, (IPTR)obj);\
23 DoMethod(root, MUIM_Group_ExitChange);
25 #define DelContents(obj) \
26 DoMethod(root, MUIM_Group_InitChange); \
27 DoMethod(root, OM_REMMEMBER, (IPTR)obj);\
28 DoMethod(root, MUIM_Group_ExitChange); \
29 MUI_DisposeObject(obj);
34 Object
*btabort
, *btproceed
;
45 /* ######################################################################## */
48 const char GuiWinTitle
[] ="String Test";
55 scr
= LockPubScreen(NULL
);
57 app
= ApplicationObject
,
58 MUIA_Application_Title
, "String Test",
60 SubWindow
, wnd
= WindowObject
,
61 MUIA_Window_Title
, GuiWinTitle
,
62 MUIA_Window_Width
, 400,
63 MUIA_Window_Height
, 300,
64 MUIA_Window_CloseGadget
, FALSE
,
65 MUIA_Window_NoMenus
, TRUE
,
66 MUIA_Window_ID
, MAKE_ID('T','E','S','T'),
69 Child
, root
= VGroup
, End
,
72 MUIA_Group_SameSize
, TRUE
,
73 Child
, btproceed
= CoolImageIDButton("Proceed", COOL_USEIMAGE_ID
),
74 Child
, btabort
= CoolImageIDButton("Abort", COOL_CANCELIMAGE_ID
),
82 /* failed to initialize GUI */
83 printf("Failed to intialize Zune GUI\n");
85 set(app
,MUIA_Window_DefaultObject
, (IPTR
)root
);
86 set(btproceed
,MUIA_CycleChain
,1);
87 set(btabort
,MUIA_CycleChain
,1);
89 DoMethod(btproceed
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)app
, 2,
90 MUIM_Application_ReturnID
, Push_Proceed
);
91 DoMethod(btabort
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)app
, 2,
92 MUIM_Application_ReturnID
, Push_Abort
);
93 set(wnd
, MUIA_Window_Open
, TRUE
);
101 set(wnd
, MUIA_Window_Open
, FALSE
);
102 MUI_DisposeObject(app
);
108 * Ask user for a number
110 long int request_number(long int def
)
126 out
= StrDup("TEST");
129 Child
, VGroup
, GroupFrame
,
131 MUIA_Text_Contents
, (IPTR
)(out
),
133 Child
, st
= StringObject
,
135 MUIA_String_Accept
, (IPTR
)"-0123456789",
136 MUIA_String_Integer
, retval
,
137 MUIA_String_AdvanceOnCR
,TRUE
,
138 MUIA_CycleChain
, TRUE
,
149 switch (val
= DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
151 case MUIV_Application_ReturnID_Quit
:
153 quit
= TRUE
; running
= FALSE
;
156 GetAttr(MUIA_String_Integer
, st
, &retval
);
157 if ( retval
< max
&& retval
> min
)
166 sigs
= CheckSignal(SIGBREAKF_CTRL_C
| sigs
);
169 GetAttr(MUIA_String_Integer
, st
, &retval
);
181 char *request_string(char *def
)
183 char *retval
, *string
, *secret
;
186 Object
*st
, *tst
, *wc
;
191 out
= StrDup("test");
194 wc
= VGroup
, GroupFrame
,
196 MUIA_Text_Contents
, (IPTR
)(out
),
198 Child
, st
= StringObject
,
200 MUIA_String_Contents
, (IPTR
)string
,
201 MUIA_String_MaxLen
, 12,
202 MUIA_String_AdvanceOnCR
,TRUE
,
203 MUIA_CycleChain
, TRUE
,
205 Child
, tst
= StringObject
,
207 MUIA_String_Contents
, (IPTR
)secret
,
208 MUIA_String_MaxLen
, 12,
209 MUIA_String_Secret
, TRUE
,
210 MUIA_String_AdvanceOnCR
,TRUE
,
211 MUIA_CycleChain
, TRUE
,
221 switch (val
= DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
223 case MUIV_Application_ReturnID_Quit
:
225 quit
= TRUE
; running
= FALSE
;
233 sigs
= CheckSignal(SIGBREAKF_CTRL_C
| sigs
);
236 get(st
, MUIA_String_Contents
, &string
);
237 if (strlen(string
)==0)
239 get(tst
, MUIA_String_Contents
, &secret
);
240 retval
= StrDup(secret
);
242 else retval
= StrDup(string
);
248 retval
= StrDup(string
);
265 string
= request_string("blah");
266 printf("you entered string <%s>\n",string
);
269 intval
= request_number(99);
270 printf("you entered number <%ld>\n",intval
);