2 Copyright © 2012, The AROS Development Team. All rights reserved.
6 #include <libraries/mui.h>
7 #include <libraries/asl.h>
9 #include <proto/muimaster.h>
10 #include <proto/intuition.h>
11 #include <proto/exec.h>
12 #include <proto/alib.h>
17 #include <aros/debug.h>
23 Object
*application
, *window
;
24 struct Hook execute_btn_hook
;
27 AROS_UFH3(void, execute_btn_func
,
28 AROS_UFHA(struct Hook
*, h
, A0
),
29 AROS_UFHA(Object
*, object
, A2
),
30 AROS_UFHA(struct Req
**, msg
, A1
))
34 D(bug("[R/execute_btn_func] msg %p *msg %p\n", msg
, *msg
));
35 (*msg
)->do_execute
= TRUE
;
36 DoMethod(application
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
42 BOOL
create_gui(struct Req
*req
)
44 Object
*ok_btn
, *cancel_btn
, *str_group
, *chk_group
;
45 struct TagItem str_group_tags
[50];
46 struct TagItem chk_group_tags
[50];
48 LONG i
, str_cnt
, chk_cnt
;
50 execute_btn_hook
.h_Entry
= (HOOKFUNC
)execute_btn_func
;
54 bug(" i Name A F K M N S T\n");
55 for (i
= 0; i
< req
->arg_cnt
; i
++)
59 "%2d %25s %c %c %c %c %c %c\n",
60 i
, req
->cargs
[i
].argname
,
61 req
->cargs
[i
].a_flag
? 'X' : '-',
62 req
->cargs
[i
].f_flag
? 'X' : '-',
63 req
->cargs
[i
].k_flag
? 'X' : '-',
64 req
->cargs
[i
].m_flag
? 'X' : '-',
65 req
->cargs
[i
].n_flag
? 'X' : '-',
66 req
->cargs
[i
].s_flag
? 'X' : '-',
67 req
->cargs
[i
].t_flag
? 'X' : '-'
74 i
= 0, str_cnt
= 0, chk_cnt
= 0;
75 i
< req
->arg_cnt
&& str_cnt
< 40 && chk_cnt
< 40;
79 Object
*new_obj
= NULL
;
80 Object
*new_arg_obj
= NULL
; // the object with the argument's value
82 if (req
->cargs
[i
].s_flag
|| req
->cargs
[i
].t_flag
) // Switch
84 new_obj
= Label(req
->cargs
[i
].argname
);
87 chk_group_tags
[chk_cnt
].ti_Tag
= Child
;
88 chk_group_tags
[chk_cnt
].ti_Data
= (IPTR
)new_obj
;
91 new_arg_obj
= MUI_MakeObject(MUIO_Checkmark
, NULL
);
94 chk_group_tags
[chk_cnt
].ti_Tag
= Child
;
95 chk_group_tags
[chk_cnt
].ti_Data
= (IPTR
)new_arg_obj
;
96 req
->cargs
[i
].object
= new_arg_obj
;
100 else if (req
->cargs
[i
].n_flag
) // Numeric
102 new_obj
= Label(req
->cargs
[i
].argname
);
105 str_group_tags
[str_cnt
].ti_Tag
= Child
;
106 str_group_tags
[str_cnt
].ti_Data
= (IPTR
)new_obj
;
109 new_arg_obj
= StringObject
,
112 MUIA_String_Accept
, "+-0123456879",
116 str_group_tags
[str_cnt
].ti_Tag
= Child
;
117 str_group_tags
[str_cnt
].ti_Data
= (IPTR
)new_arg_obj
;
118 req
->cargs
[i
].object
= new_arg_obj
;
122 else if (req
->cargs
[i
].m_flag
) // Multiple
124 new_obj
= Label(req
->cargs
[i
].argname
);
127 str_group_tags
[str_cnt
].ti_Tag
= Child
;
128 str_group_tags
[str_cnt
].ti_Data
= (IPTR
)new_obj
;
131 new_arg_obj
= PopaslObject
,
132 MUIA_Popasl_Type
, ASL_FileRequest
,
133 ASLFR_DoMultiSelect
, TRUE
,
134 MUIA_Popstring_String
, (IPTR
)(new_arg_obj
= StringObject
,
138 MUIA_Popstring_Button
, (IPTR
)PopButton(MUII_PopUp
),
142 str_group_tags
[str_cnt
].ti_Tag
= Child
;
143 str_group_tags
[str_cnt
].ti_Data
= (IPTR
)new_arg_obj
;
144 req
->cargs
[i
].object
= new_arg_obj
;
150 new_obj
= Label(req
->cargs
[i
].argname
);
153 str_group_tags
[str_cnt
].ti_Tag
= Child
;
154 str_group_tags
[str_cnt
].ti_Data
= (IPTR
)new_obj
;
157 new_arg_obj
= PopaslObject
,
158 MUIA_Popasl_Type
, ASL_FileRequest
,
159 MUIA_Popstring_String
, (IPTR
)(new_arg_obj
= StringObject
,
163 MUIA_Popstring_Button
, (IPTR
)PopButton(MUII_PopUp
),
167 str_group_tags
[str_cnt
].ti_Tag
= Child
;
168 str_group_tags
[str_cnt
].ti_Data
= (IPTR
)new_arg_obj
;
169 req
->cargs
[i
].object
= new_arg_obj
;
175 // create string group
176 str_group_tags
[str_cnt
].ti_Tag
= MUIA_Group_Columns
;
177 str_group_tags
[str_cnt
].ti_Data
= 2;
179 str_group_tags
[str_cnt
].ti_Tag
= TAG_DONE
;
180 str_group
= MUI_NewObjectA(MUIC_Group
, str_group_tags
);
182 // fill empty check slots
183 for (i
= 0; i
< chk_cnt
% 8; i
++)
185 chk_group_tags
[chk_cnt
].ti_Tag
= Child
;
186 chk_group_tags
[chk_cnt
].ti_Data
= (IPTR
)HVSpace
;
190 // create check group
191 chk_group_tags
[chk_cnt
].ti_Tag
= MUIA_Group_Columns
;
192 chk_group_tags
[chk_cnt
].ti_Data
= 8;
194 chk_group_tags
[chk_cnt
].ti_Tag
= TAG_DONE
;
195 chk_group
= MUI_NewObjectA(MUIC_Group
, chk_group_tags
);
197 application
= (Object
*)ApplicationObject
,
198 MUIA_Application_Title
, "R", //__(MSG_TITLE),
199 MUIA_Application_Version
, (IPTR
) VERSION
,
200 MUIA_Application_Description
, "R", //__(MSG_TITLE),
201 MUIA_Application_Base
, (IPTR
) "REQUEST",
202 MUIA_Application_UseCommodities
, FALSE
,
203 SubWindow
, (IPTR
)(window
= (Object
*)WindowObject
,
204 MUIA_Window_Title
, "R - The GUI Generator", //__(MSG_TITLE),
205 MUIA_Window_ID
, MAKE_ID('R','E','Q','U'),
206 WindowContents
, VGroup
,
213 Child
, (IPTR
) (RectangleObject
,
214 MUIA_Rectangle_HBar
, TRUE
,
218 MUIA_Group_SameWidth
, TRUE
,
219 Child
, ok_btn
= SimpleButton("Execute"),
221 Child
, cancel_btn
= SimpleButton("Cancel"),
232 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
233 (IPTR
)application
, 2,
234 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
240 MUIM_Notify
, MUIA_Pressed
, FALSE
,
241 (IPTR
)application
, 2,
242 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
248 MUIM_Notify
, MUIA_Pressed
, FALSE
,
249 (IPTR
)application
, 3,
250 MUIM_CallHook
, &execute_btn_hook
, req
253 SET(window
, MUIA_Window_Open
, TRUE
);
261 BOOL
handle_gui(struct Req
*req
)
263 DoMethod(application
, MUIM_Application_Execute
);
264 SET(window
, MUIA_Window_Open
, FALSE
);
265 return req
->do_execute
;
269 BOOL
get_gui_bool(struct CArg
*carg
)
271 return XGET(carg
->object
, MUIA_Selected
);
275 CONST_STRPTR
get_gui_string(struct CArg
*carg
)
277 return (CONST_STRPTR
)XGET(carg
->object
, MUIA_String_Contents
);
281 void cleanup_gui(void)
283 if (application
) MUI_DisposeObject(application
);