2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
6 #include <clib/alib_protos.h>
7 #include <proto/exec.h>
8 #include <proto/utility.h>
9 #include <proto/intuition.h>
10 #include <proto/muimaster.h>
14 /* #define MYDEBUG 1 */
18 #include "muimaster_intern.h"
21 #include "support_classes.h"
22 #include "radio_private.h"
24 extern struct Library
*MUIMasterBase
;
26 IPTR
Radio__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
28 struct Radio_DATA
*data
;
29 struct TagItem
*tag
, *tags
;
31 const char **entries
= NULL
;
32 int entries_active
= 0;
34 struct TagItem
*grouptags
;
38 /* parse initial taglist */
40 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
44 case MUIA_Radio_Entries
:
45 entries
= (const char**)tag
->ti_Data
;
47 case MUIA_Radio_Active
:
48 entries_active
= tag
->ti_Data
;
55 D(bug("Radio_New: No Entries specified!\n"));
56 CoerceMethod(cl
,obj
,OM_DISPOSE
);
60 /* Count the number of entries */
61 for (i
=0;entries
[i
];i
++);
65 if ((entries_active
< 0) || (entries_active
> entries_num
- 1))
68 grouptags
= AllocateTagItems(entries_num
+ 1);
71 buttons
= AllocVec(i
* sizeof(Object
*), MEMF_PUBLIC
);
77 for (i
= 0; i
< entries_num
; i
++)
79 state
= (entries_active
== i
) ? TRUE
: FALSE
;
82 Child
, (IPTR
)ImageObject
,
83 MUIA_Image_FontMatch
, TRUE
,
84 MUIA_InputMode
, MUIV_InputMode_Immediate
,
86 MUIA_ShowSelState
, FALSE
,
87 MUIA_Image_Spec
, MUII_RadioButton
,
88 MUIA_Frame
, MUIV_Frame_None
,
90 Child
, (IPTR
)TextObject
,
91 MUIA_InputMode
, MUIV_InputMode_Immediate
,
92 MUIA_ShowSelState
, FALSE
,
94 MUIA_Text_Contents
, entries
[i
],
95 MUIA_Frame
, MUIV_Frame_None
,
96 MUIA_Text_PreParse
, (IPTR
)"\33l",
100 grouptags
[i
].ti_Tag
= MUIA_Group_Child
;
101 grouptags
[i
].ti_Data
= (IPTR
)buttons
[i
];
104 grouptags
[i
].ti_Tag
= TAG_MORE
;
105 grouptags
[i
].ti_Data
= (IPTR
)msg
->ops_AttrList
;
107 obj
= (Object
*)DoSuperNewTags(cl
, obj
, NULL
,
108 TAG_MORE
, (IPTR
)grouptags
);
109 FreeTagItems(grouptags
);
115 data
= INST_DATA(cl
, obj
);
116 data
->entries_active
= entries_active
;
117 data
->entries_num
= entries_num
;
118 data
->buttons
= buttons
;
120 for (i
= 0; i
< entries_num
; i
++)
122 DoMethod(buttons
[i
], MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
123 (IPTR
)obj
, 3, MUIM_Set
, MUIA_Radio_Active
, i
);
129 IPTR
Radio__OM_DISPOSE(struct IClass
*cl
, Object
*obj
, Msg msg
)
131 struct Radio_DATA
*data
= INST_DATA(cl
,obj
);
132 if (data
->buttons
) FreeVec(data
->buttons
);
133 return DoSuperMethodA(cl
,obj
,msg
);
136 IPTR
Radio__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
138 struct Radio_DATA
*data
;
139 struct TagItem
*tag
, *tags
;
141 data
= INST_DATA(cl
, obj
);
143 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
147 case MUIA_Radio_Active
:
148 D(bug("Radio_Set(%p) MUIA_Radio_Active %ld\n",
150 if (tag
->ti_Data
>= 0 && tag
->ti_Data
< data
->entries_num
&&
151 tag
->ti_Data
!= data
->entries_active
)
153 DoMethod(data
->buttons
[data
->entries_active
],
154 MUIM_NoNotifySet
, MUIA_Selected
, FALSE
);
155 DoMethod(data
->buttons
[tag
->ti_Data
],
156 MUIM_NoNotifySet
, MUIA_Selected
, TRUE
);
157 data
->entries_active
= tag
->ti_Data
;
162 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
165 IPTR
Radio__OM_GET(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
167 struct Radio_DATA
*data
= INST_DATA(cl
, obj
);
168 #define STORE *(msg->opg_Storage)
170 switch(msg
->opg_AttrID
)
172 case MUIA_Radio_Active
:
173 STORE
= data
->entries_active
;
177 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
180 IPTR
Radio__MUIM_Setup(struct IClass
*cl
, Object
*obj
, Msg msg
)
182 if (!DoSuperMethodA(cl
, obj
, msg
))
185 set(obj
, MUIA_Group_HorizSpacing
, muiGlobalInfo(obj
)->mgi_Prefs
->radiobutton_hspacing
);
186 set(obj
, MUIA_Group_VertSpacing
, muiGlobalInfo(obj
)->mgi_Prefs
->radiobutton_vspacing
);
191 #if ZUNE_BUILTIN_RADIO
192 BOOPSI_DISPATCHER(IPTR
, Radio_Dispatcher
, cl
, obj
, msg
)
194 switch (msg
->MethodID
)
196 case OM_NEW
: return Radio__OM_NEW(cl
, obj
, (struct opSet
*) msg
);
197 case OM_DISPOSE
: return Radio__OM_DISPOSE(cl
, obj
, (Msg
) msg
);
198 case OM_SET
: return Radio__OM_SET(cl
, obj
, (struct opSet
*) msg
);
199 case OM_GET
: return Radio__OM_GET(cl
, obj
, (struct opGet
*) msg
);
200 case MUIM_Setup
: return Radio__MUIM_Setup(cl
, obj
, msg
);
201 default: return DoSuperMethodA(cl
, obj
, msg
);
204 BOOPSI_DISPATCHER_END
206 const struct __MUIBuiltinClass _MUI_Radio_desc
= {
209 sizeof(struct Radio_DATA
),
210 (void*)Radio_Dispatcher
212 #endif /* ZUNE_BUILTIN_RADIO */