2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
6 #include <graphics/gfx.h>
7 #include <graphics/view.h>
8 #include <clib/alib_protos.h>
9 #include <proto/exec.h>
10 #include <proto/graphics.h>
11 #include <proto/utility.h>
12 #include <proto/intuition.h>
13 #include <proto/muimaster.h>
16 #include "muimaster_intern.h"
19 /* #define MYDEBUG 0 */
22 extern struct Library
*MUIMasterBase
;
26 struct Hook
*close_hook
;
27 struct Hook
*open_hook
;
32 struct MUI_EventHandlerNode ehn
;
36 IPTR
Popstring__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
38 struct Popstring_DATA
*data
;
39 struct TagItem
*tag
, *tags
;
40 Object
*string
, *button
;
43 (Object
*) GetTagData(MUIA_Popstring_Button
, 0, msg
->ops_AttrList
);
45 (Object
*) GetTagData(MUIA_Popstring_String
, 0, msg
->ops_AttrList
);
47 obj
= (Object
*) DoSuperNewTags(cl
, obj
, 0,
48 MUIA_Group_Horiz
, TRUE
,
49 MUIA_Group_Spacing
, 0,
50 (string
? Child
: TAG_IGNORE
), (IPTR
) string
,
52 TAG_MORE
, (IPTR
) msg
->ops_AttrList
);
56 data
= INST_DATA(cl
, obj
);
57 data
->button
= button
;
58 data
->string
= string
;
60 data
->ehn
.ehn_Events
= IDCMP_RAWKEY
;
61 data
->ehn
.ehn_Priority
= 0;
62 data
->ehn
.ehn_Flags
= 0;
63 data
->ehn
.ehn_Object
= obj
;
64 data
->ehn
.ehn_Class
= cl
;
66 /* parse initial taglist */
68 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
72 case MUIA_Popstring_Toggle
:
73 data
->toggle
= tag
->ti_Data
;
75 case MUIA_Popstring_CloseHook
:
76 data
->close_hook
= (struct Hook
*)tag
->ti_Data
;
78 case MUIA_Popstring_OpenHook
:
79 data
->open_hook
= (struct Hook
*)tag
->ti_Data
;
84 DoMethod(button
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
) obj
, 1,
90 IPTR
Popstring__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
92 struct TagItem
*tags
, *tag
;
93 struct Popstring_DATA
*data
= INST_DATA(cl
, obj
);
95 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
99 case MUIA_Popstring_Toggle
:
100 data
->toggle
= tag
->ti_Data
;
102 case MUIA_Popstring_CloseHook
:
103 data
->close_hook
= (struct Hook
*)tag
->ti_Data
;
105 case MUIA_Popstring_OpenHook
:
106 data
->open_hook
= (struct Hook
*)tag
->ti_Data
;
111 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
114 #define STORE *(msg->opg_Storage)
115 IPTR
Popstring__OM_GET(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
117 struct Popstring_DATA
*data
= INST_DATA(cl
, obj
);
119 switch (msg
->opg_AttrID
)
121 case MUIA_Popstring_String
:
122 STORE
= (IPTR
) data
->string
;
125 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
129 IPTR
Popstring__MUIM_Setup(struct IClass
*cl
, Object
*obj
,
130 struct MUIP_Setup
*msg
)
132 struct Popstring_DATA
*data
= INST_DATA(cl
, obj
);
134 if (!(DoSuperMethodA(cl
, obj
, (Msg
) msg
)))
137 DoMethod(_win(obj
), MUIM_Window_AddEventHandler
, (IPTR
) & data
->ehn
);
142 IPTR
Popstring__MUIM_Cleanup(struct IClass
*cl
, Object
*obj
,
143 struct MUIP_Cleanup
*msg
)
145 struct Popstring_DATA
*data
= INST_DATA(cl
, obj
);
147 DoMethod(_win(obj
), MUIM_Window_RemEventHandler
, (IPTR
) & data
->ehn
);
149 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
152 IPTR
Popstring__MUIM_HandleEvent(struct IClass
*cl
, Object
*obj
,
153 struct MUIP_HandleEvent
*msg
)
155 if (msg
->muikey
== MUIKEY_POPUP
)
157 D(bug("Popstring__MUIM_HandleEvent %p got MUIKEY_POPUP\n", obj
));
158 DoMethod(obj
, MUIM_Popstring_Open
);
159 return MUI_EventHandlerRC_Eat
;
164 IPTR
Popstring__MUIM_Popstring_Close(struct IClass
*cl
, Object
*obj
,
165 struct MUIP_Popstring_Close
*msg
)
167 struct Popstring_DATA
*data
= INST_DATA(cl
, obj
);
168 if (data
->close_hook
&& data
->open
)
170 DoMethod(_app(obj
), MUIM_Application_PushMethod
, (IPTR
) obj
, 4,
171 MUIM_CallHook
, (IPTR
) data
->close_hook
, (IPTR
) data
->string
,
174 set(data
->button
, MUIA_Disabled
, FALSE
);
179 IPTR
Popstring__MUIM_Popstring_Open(struct IClass
*cl
, Object
*obj
,
180 struct MUIP_Popstring_Open
*msg
)
182 struct Popstring_DATA
*data
= INST_DATA(cl
, obj
);
185 if (data
->open
&& data
->toggle
)
187 DoMethod(obj
, MUIM_Popstring_Close
, FALSE
);
193 if (DoMethod(obj
, MUIM_CallHook
, (IPTR
) data
->open_hook
,
194 (IPTR
) data
->string
))
196 /* Opening the popup window was successful */
199 set(data
->button
, MUIA_Disabled
, TRUE
);
207 BOOPSI_DISPATCHER(IPTR
, Popstring_Dispatcher
, cl
, obj
, msg
)
209 switch (msg
->MethodID
)
212 return Popstring__OM_NEW(cl
, obj
, (APTR
) msg
);
214 return Popstring__OM_SET(cl
, obj
, (APTR
) msg
);
216 return Popstring__OM_GET(cl
, obj
, (APTR
) msg
);
218 return Popstring__MUIM_Setup(cl
, obj
, (APTR
) msg
);
220 return Popstring__MUIM_Cleanup(cl
, obj
, (APTR
) msg
);
221 case MUIM_HandleEvent
:
222 return Popstring__MUIM_HandleEvent(cl
, obj
, (APTR
) msg
);
223 case MUIM_Popstring_Close
:
224 return Popstring__MUIM_Popstring_Close(cl
, obj
, (APTR
) msg
);
225 case MUIM_Popstring_Open
:
226 return Popstring__MUIM_Popstring_Open(cl
, obj
, (APTR
) msg
);
229 return DoSuperMethodA(cl
, obj
, msg
);
231 BOOPSI_DISPATCHER_END
233 const struct __MUIBuiltinClass _MUI_Popstring_desc
=
237 sizeof(struct Popstring_DATA
),
238 (void *) Popstring_Dispatcher