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"
20 extern struct Library
*MUIMasterBase
;
24 struct MUI_EventHandlerNode ehn
;
28 struct Hook
*strobj_hook
;
29 struct Hook
*objstr_hook
;
30 struct Hook
*window_hook
;
31 struct Hook open_hook
;
32 struct Hook close_hook
;
37 AROS_UFH3(ULONG
,Popobject_Open_Function
,
38 AROS_UFHA(struct Hook
*, hook
, A0
),
39 AROS_UFHA(Object
*, obj
, A2
),
40 AROS_UFHA(void **, msg
, A1
))
44 struct Popobject_DATA
*data
= (struct Popobject_DATA
*)hook
->h_Data
;
45 Object
*string
= (Object
*)msg
[0];
49 static struct TagItem light_tags
[] =
51 {MUIA_Window_Borderless
, TRUE
},
52 {MUIA_Window_CloseGadget
, FALSE
},
53 {MUIA_Window_SizeGadget
, FALSE
},
54 {MUIA_Window_DepthGadget
, FALSE
},
55 {MUIA_Window_DragBar
, FALSE
},
59 data
->wnd
= WindowObject
,
60 WindowContents
,data
->object
,
61 data
->light
? TAG_MORE
: TAG_IGNORE
, (IPTR
)light_tags
,
64 if (!data
->wnd
) return 0;
66 DoMethod(_app(obj
),OM_ADDMEMBER
,(IPTR
)data
->wnd
);
68 DoMethod(data
->wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
69 (IPTR
)obj
, 2, MUIM_Popstring_Close
, FALSE
);
72 if (data
->strobj_hook
)
74 if (!(CallHookPkt(data
->strobj_hook
,data
->object
,string
)))
78 if (data
->window_hook
)
80 CallHookPkt(data
->window_hook
,data
->object
,data
->wnd
);
84 MUIA_Window_LeftEdge
, _left(obj
) + _window(obj
)->LeftEdge
,
85 MUIA_Window_TopEdge
, _bottom(obj
)+1 + _window(obj
)->TopEdge
,
86 MUIA_Window_Width
, _width(obj
),
87 MUIA_Window_Open
, TRUE
,
90 if (!(data
->ehn
.ehn_Events
& IDCMP_CHANGEWINDOW
))
92 data
->ehn
.ehn_Events
|= IDCMP_CHANGEWINDOW
;
93 DoMethod(_win(obj
), MUIM_Window_AddEventHandler
, (IPTR
)&data
->ehn
);
102 AROS_UFH3(ULONG
,Popobject_Close_Function
,
103 AROS_UFHA(struct Hook
*, hook
, A0
),
104 AROS_UFHA(Object
*, obj
, A2
),
105 AROS_UFHA(void **, msg
, A1
))
109 struct Popobject_DATA
*data
= (struct Popobject_DATA
*)hook
->h_Data
;
110 Object
*string
= (Object
*)msg
[0];
111 LONG suc
= (LONG
)msg
[1];
115 set(data
->wnd
,MUIA_Window_Open
,FALSE
);
117 if (data
->objstr_hook
&& suc
)
118 CallHookPkt(data
->objstr_hook
,data
->object
,string
);
120 if (data
->ehn
.ehn_Events
& IDCMP_CHANGEWINDOW
)
122 DoMethod(_win(obj
), MUIM_Window_RemEventHandler
, (IPTR
)&data
->ehn
);
123 data
->ehn
.ehn_Events
&= ~IDCMP_CHANGEWINDOW
;
132 IPTR
Popobject__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
134 struct Popobject_DATA
*data
;
135 struct TagItem
*tag
, *tags
;
137 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
138 if (!obj
) return FALSE
;
140 data
= INST_DATA(cl
, obj
);
145 data
->ehn
.ehn_Events
= 0;
146 data
->ehn
.ehn_Priority
= 0;
147 data
->ehn
.ehn_Flags
= 0;
148 data
->ehn
.ehn_Object
= obj
;
149 data
->ehn
.ehn_Class
= cl
;
151 data
->open_hook
.h_Entry
= (HOOKFUNC
)Popobject_Open_Function
;
152 data
->open_hook
.h_Data
= data
;
153 data
->close_hook
.h_Entry
= (HOOKFUNC
)Popobject_Close_Function
;
154 data
->close_hook
.h_Data
= data
;
156 /* parse initial taglist */
158 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
162 case MUIA_Popobject_Follow
:
163 data
->follow
= tag
->ti_Data
;
166 case MUIA_Popobject_Light
:
167 data
->light
= tag
->ti_Data
;
170 case MUIA_Popobject_Object
:
171 data
->object
= (Object
*)tag
->ti_Data
;
174 case MUIA_Popobject_ObjStrHook
:
175 data
->objstr_hook
= (struct Hook
*)tag
->ti_Data
;
178 case MUIA_Popobject_StrObjHook
:
179 data
->strobj_hook
= (struct Hook
*)tag
->ti_Data
;
182 case MUIA_Popobject_Volatile
:
183 data
->vol
= tag
->ti_Data
;
186 case MUIA_Popobject_WindowHook
:
187 data
->window_hook
= (struct Hook
*)tag
->ti_Data
;
193 MUIA_Popstring_OpenHook
, (IPTR
)&data
->open_hook
,
194 MUIA_Popstring_CloseHook
, (IPTR
)&data
->close_hook
,
195 MUIA_Popstring_Toggle
, TRUE
,
201 IPTR
Popobject__OM_DISPOSE(struct IClass
*cl
, Object
*obj
, Msg msg
)
203 struct Popobject_DATA
*data
= INST_DATA(cl
, obj
);
205 if (!data
->wnd
&& data
->object
)
206 MUI_DisposeObject(data
->object
);
208 return DoSuperMethodA(cl
, obj
, msg
);
211 IPTR
Popobject__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
213 struct Popobject_DATA
*data
= INST_DATA(cl
, obj
);
214 struct TagItem
*tag
, *tags
;
216 /* parse initial taglist */
218 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
222 case MUIA_Popobject_Follow
:
223 data
->follow
= tag
->ti_Data
;
226 case MUIA_Popobject_ObjStrHook
:
227 data
->objstr_hook
= (struct Hook
*)tag
->ti_Data
;
230 case MUIA_Popobject_StrObjHook
:
231 data
->strobj_hook
= (struct Hook
*)tag
->ti_Data
;
234 case MUIA_Popobject_Volatile
:
235 data
->vol
= tag
->ti_Data
;
238 case MUIA_Popobject_WindowHook
:
239 data
->window_hook
= (struct Hook
*)tag
->ti_Data
;
243 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
247 IPTR
Popobject__MUIM_Get(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
249 struct Popobject_DATA
*data
= INST_DATA(cl
, obj
);
251 switch (msg
->opg_AttrID
)
253 case MUIA_Popobject_Follow
:
254 *msg
->opg_Storage
= data
->follow
;
257 case MUIA_Popobject_Light
:
258 *msg
->opg_Storage
= data
->light
;
261 case MUIA_Popobject_Object
:
262 *msg
->opg_Storage
= (IPTR
)data
->object
;
265 case MUIA_Popobject_ObjStrHook
:
266 *msg
->opg_Storage
= (IPTR
)data
->objstr_hook
;
269 case MUIA_Popobject_StrObjHook
:
270 *msg
->opg_Storage
= (IPTR
)data
->strobj_hook
;
273 case MUIA_Popobject_Volatile
:
274 *msg
->opg_Storage
= data
->vol
;
277 case MUIA_Popobject_WindowHook
:
278 *msg
->opg_Storage
= (IPTR
)data
->window_hook
;
282 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
286 IPTR
Popobject__MUIM_Cleanup(struct IClass
*cl
, Object
*obj
, struct MUIP_Cleanup
*msg
)
288 struct Popobject_DATA
*data
= INST_DATA(cl
, obj
);
290 if (data
->ehn
.ehn_Events
& IDCMP_CHANGEWINDOW
)
292 DoMethod(_win(obj
),MUIM_Window_RemEventHandler
, (IPTR
)&data
->ehn
);
293 data
->ehn
.ehn_Events
&= ~IDCMP_CHANGEWINDOW
;
296 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
299 IPTR
Popobject__MUIM_Show(struct IClass
*cl
, Object
*obj
, struct MUIP_Show
*msg
)
301 IPTR rc
= DoSuperMethodA(cl
,obj
,(Msg
)msg
);
306 IPTR
Popobject__MUIM_Hide(struct IClass
*cl
, Object
*obj
, struct MUIP_Hide
*msg
)
308 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
311 IPTR
Popobject__MUIM_HandleEvent(struct IClass
*cl
, Object
*obj
, struct MUIP_HandleEvent
*msg
)
313 struct Popobject_DATA
*data
= INST_DATA(cl
, obj
);
315 if (data
->follow
&& msg
->imsg
&& data
->wnd
)
317 if (msg
->imsg
->Class
== IDCMP_CHANGEWINDOW
)
319 struct Window
*popwin
= NULL
;
320 struct Window
*parentwin
= _window(obj
);
322 get(data
->wnd
, MUIA_Window_Window
, &popwin
);
324 if (popwin
&& parentwin
)
326 ChangeWindowBox(popwin
, _left(obj
) + parentwin
->LeftEdge
,
327 _bottom(obj
) + parentwin
->TopEdge
+ 1,
334 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
337 BOOPSI_DISPATCHER(IPTR
, Popobject_Dispatcher
, cl
, obj
, msg
)
339 switch (msg
->MethodID
)
341 case OM_NEW
: return Popobject__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
342 case OM_DISPOSE
: return Popobject__OM_DISPOSE(cl
, obj
, msg
);
343 case OM_SET
: return Popobject__OM_SET(cl
, obj
, (struct opSet
*)msg
);
344 case OM_GET
: return Popobject__MUIM_Get(cl
, obj
, (struct opGet
*)msg
);
345 case MUIM_Cleanup
: return Popobject__MUIM_Cleanup(cl
, obj
, (struct MUIP_Cleanup
*)msg
);
346 case MUIM_Show
: return Popobject__MUIM_Show(cl
, obj
, (struct MUIP_Show
*)msg
);
347 case MUIM_Hide
: return Popobject__MUIM_Hide(cl
, obj
, (struct MUIP_Hide
*)msg
);
348 case MUIM_HandleEvent
: return Popobject__MUIM_HandleEvent(cl
, obj
, (struct MUIP_HandleEvent
*)msg
);
351 return DoSuperMethodA(cl
, obj
, msg
);
353 BOOPSI_DISPATCHER_END
355 const struct __MUIBuiltinClass _MUI_Popobject_desc
=
359 sizeof(struct Popobject_DATA
),
360 (void*)Popobject_Dispatcher