2 Copyright © 2009, The AROS Development Team. All rights reserved.
6 #include <libraries/mui.h>
7 #include <proto/muimaster.h>
8 #include <proto/intuition.h>
9 #include <proto/alib.h>
10 #include <proto/exec.h>
11 #include <utility/hooks.h>
13 static void UseFunc(struct Hook
*hook
, Object
*app
, void *arg
)
15 DoMethod(app
, MUIM_Application_Save
, MUIV_Application_Save_ENV
);
16 DoMethod(app
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
19 static void SaveFunc(struct Hook
*hook
, Object
*app
, void *arg
)
21 DoMethod(app
, MUIM_Application_Save
, MUIV_Application_Save_ENV
);
22 DoMethod(app
, MUIM_Application_Save
, MUIV_Application_Save_ENVARC
);
23 DoMethod(app
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
26 int main(int argc
,char *argv
[])
28 Object
*app
, *window
, *bt_save
, *bt_use
, *bt_cancel
, *checkbox
;
30 struct Hook saveHook
, useHook
;
39 const char *hair_color
[] =
47 useHook
.h_Entry
= HookEntry
;
48 useHook
.h_SubEntry
= (HOOKFUNC
) UseFunc
;
49 saveHook
.h_Entry
= HookEntry
;
50 saveHook
.h_SubEntry
= (HOOKFUNC
) SaveFunc
;
52 app
= ApplicationObject
,
53 MUIA_Application_Base
, "SETTINGS",
54 SubWindow
, window
= WindowObject
,
55 MUIA_Window_Title
, "MUIM_Application_Load / MUIM_Application_Save test",
56 WindowContents
, VGroup
,
58 Child
, Label2("Username:"),
59 Child
, StringObject
, StringFrame
, MUIA_ObjectID
, 1, MUIA_CycleChain
, 1, End
,
60 Child
, Label1("Password:"),
61 Child
, StringObject
, StringFrame
, MUIA_ObjectID
, 4, MUIA_String_Secret
, TRUE
, MUIA_CycleChain
, 1, End
,
62 Child
, Label1("Sex:"),
63 Child
, CycleObject
, MUIA_Cycle_Entries
, sex
, MUIA_ObjectID
, 6, MUIA_CycleChain
, 1, End
,
65 Child
, SliderObject
, MUIA_ObjectID
, 5, MUIA_Numeric_Min
, 0, MUIA_Numeric_Max
, 99, MUIA_CycleChain
, 1, End
,
66 Child
, Label("Hair color:"),
67 Child
, RadioObject
, MUIA_ObjectID
, 7, MUIA_Radio_Entries
, hair_color
, MUIA_CycleChain
, 1, End
,
68 Child
, Label("AROS user:"),
69 Child
, checkbox
= MUI_MakeObject(MUIO_Checkmark
, FALSE
),
72 Child
, bt_save
= SimpleButton("Save"),
73 Child
, bt_use
= SimpleButton("Use"),
74 Child
, bt_cancel
= SimpleButton("Cancel"),
83 set(checkbox
, MUIA_ObjectID
, 8);
85 DoMethod(window
, MUIM_Notify
, MUIA_Window_CloseRequest
,TRUE
,
87 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
89 DoMethod(bt_cancel
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
91 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
93 DoMethod(bt_save
,MUIM_Notify
,MUIA_Pressed
,FALSE
,
95 MUIM_CallHook
, &saveHook
, NULL
);
97 DoMethod(bt_use
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
99 MUIM_CallHook
, &useHook
, NULL
);
101 DoMethod(app
, MUIM_Application_Load
, MUIV_Application_Load_ENV
);
103 set(window
, MUIA_Window_Open
, TRUE
);
106 while((LONG
)DoMethod(app
, MUIM_Application_NewInput
, (IPTR
)&sigs
)
107 != MUIV_Application_ReturnID_Quit
)
111 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
112 if (sigs
& SIGBREAKF_CTRL_C
)
117 set(window
, MUIA_Window_Open
, FALSE
);
119 MUI_DisposeObject(app
);