2 Copyright © 2009, The AROS Development Team. All rights reserved.
6 #include <exec/types.h>
12 #include <intuition/gadgetclass.h>
13 #include <intuition/icclass.h>
14 #include <proto/exec.h>
15 #include <proto/intuition.h>
16 #include <proto/muimaster.h>
17 #include <clib/alib_protos.h>
19 #include <utility/hooks.h>
20 #include <libraries/mui.h>
23 Object
*wnd
, *str1
, *str2
, *str3
, *bt1
, *bt2
, *bt3
, *list
;
25 static IPTR
DynlistDisplayFunc(struct Hook
*hook
, char **columns
, char **entry
)
29 columns
[0] = "Column 1";
30 columns
[1] = "Column 2";
31 columns
[2] = "Column 3";
35 columns
[0] = entry
[0];
36 columns
[1] = entry
[1];
37 columns
[2] = entry
[2];
42 static IPTR
AddFunc(struct Hook
*hook
, Object
*caller
, void *data
)
44 STRPTR s1
= (STRPTR
) XGET(str1
, MUIA_String_Contents
);
45 STRPTR s2
= (STRPTR
) XGET(str2
, MUIA_String_Contents
);
46 STRPTR s3
= (STRPTR
) XGET(str3
, MUIA_String_Contents
);
47 STRPTR
*item
= (STRPTR
*) malloc(sizeof(STRPTR
) * 4);
52 DoMethod(list
, MUIM_List_InsertSingle
, item
, MUIV_List_Insert_Top
);
57 static IPTR
MutateFunc(struct Hook
*hook
, Object
*caller
, void *data
)
61 get(list
, MUIA_List_Active
, &active
);
62 if (active
== MUIV_List_Active_Off
)
65 DoMethod(list
, MUIM_List_GetEntry
, active
, &entry
);
66 entry
[0] = "A very long entry";
67 entry
[1] = "This is even longer";
68 entry
[2] = "I'm the longest entry in the application";
69 DoMethod(list
, MUIM_List_Redraw
, MUIV_List_Redraw_Active
);
76 struct Hook addHook
, displayHook
, mutateHook
;
77 addHook
.h_Entry
= HookEntry
;
78 addHook
.h_SubEntry
= (HOOKFUNC
) AddFunc
;
79 displayHook
.h_Entry
= HookEntry
;
80 displayHook
.h_SubEntry
= (HOOKFUNC
) DynlistDisplayFunc
;
81 mutateHook
.h_Entry
= HookEntry
;
82 mutateHook
.h_SubEntry
= (HOOKFUNC
) MutateFunc
;
84 app
= ApplicationObject
,
85 SubWindow
, wnd
= WindowObject
,
86 MUIA_Window_Title
, "Dynamic list",
87 MUIA_Window_Activate
, TRUE
,
89 WindowContents
, VGroup
,
90 Child
, list
= ListObject
,
91 MUIA_List_DisplayHook
, &displayHook
,
92 MUIA_List_Format
, "BAR,BAR,",
93 MUIA_List_Title
, TRUE
,
96 Child
, str1
= StringObject
, End
,
97 Child
, str2
= StringObject
, End
,
98 Child
, str3
= StringObject
, End
,
101 Child
, bt1
= SimpleButton("Add"),
102 Child
, bt2
= SimpleButton("Remove"),
103 Child
, bt3
= SimpleButton("Grow"),
113 DoMethod(wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
115 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
117 DoMethod(bt1
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
119 MUIM_CallHook
, &addHook
, list
);
121 DoMethod(bt2
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
123 MUIM_List_Remove
, MUIV_List_Remove_First
);
125 DoMethod(bt3
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
127 MUIM_CallHook
, &mutateHook
, NULL
);
129 set(wnd
,MUIA_Window_Open
,TRUE
);
131 while (DoMethod(app
, MUIM_Application_NewInput
, (IPTR
) &sigs
) != MUIV_Application_ReturnID_Quit
)
135 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
136 if (sigs
& SIGBREAKF_CTRL_C
) break;
140 MUI_DisposeObject(app
);