2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
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>
15 /* #define MYDEBUG 1 */
18 #include "muimaster_intern.h"
20 #include "support_classes.h"
21 #include "popimage_private.h"
23 extern struct Library
*MUIMasterBase
;
25 IPTR
Popimage__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
27 struct Popimage_DATA
*data
;
28 struct TagItem
*tag
, *tags
;
30 obj
= (Object
*) DoSuperNewTags
36 MUIA_Background
, MUII_ButtonBack
,
37 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
40 TAG_MORE
, (IPTR
) msg
->ops_AttrList
43 if (!obj
) return FALSE
;
44 data
= INST_DATA(cl
, obj
);
45 data
->wintitle
= NULL
;
46 data
->adjust_type
= MUIV_Imageadjust_Type_All
;
48 /* parse initial taglist */
49 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem((const struct TagItem
**)&tags
)); )
53 case MUIA_Window_Title
:
54 data
->wintitle
= (CONST_STRPTR
)tag
->ti_Data
;
57 case MUIA_Imageadjust_Type
:
58 data
->adjust_type
= tag
->ti_Data
;
63 DoMethod(obj
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)obj
, 1,
64 MUIM_Popimage_OpenWindow
);
69 IPTR
Popimage__OM_DISPOSE(struct IClass
*cl
, Object
*obj
, Msg msg
)
71 struct Popimage_DATA
*data
= INST_DATA(cl
, obj
);
75 D(bug("Popimage_Dispose(%p) : MUI_DisposeObject(%p)\n", obj
, data
->wnd
));
76 MUI_DisposeObject(data
->wnd
);
79 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
82 IPTR
Popimage__MUIM_Hide(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
85 struct Popimage_DATA
*data
= INST_DATA(cl
, obj
);
88 D(bug("Popimage_Hide(%p) : closing window %p\n", obj
, data
->wnd
));
89 set(data
->wnd
,MUIA_Window_Open
,FALSE
);
90 D(bug("Popimage_Hide(%p) : app REMMEMBER win (%p)\n", obj
, data
->wnd
));
91 DoMethod(_app(obj
),OM_REMMEMBER
,(IPTR
)data
->wnd
);
92 D(bug("Popimage_Hide(%p) : MUI_DisposeObject(%p)\n", obj
, data
->wnd
));
93 MUI_DisposeObject(data
->wnd
);
97 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
100 IPTR
Popimage__MUIM_Popimage_OpenWindow(struct IClass
*cl
, Object
*obj
, Msg msg
)
102 struct Popimage_DATA
*data
= INST_DATA(cl
, obj
);
106 Object
*ok_button
, *cancel_button
;
110 get(_win(obj
), MUIA_Window_LeftEdge
, &x
);
111 get(_win(obj
), MUIA_Window_TopEdge
, &y
);
113 get(obj
,MUIA_Imagedisplay_Spec
, &img_spec
);
115 data
->wnd
= (Object
*)WindowObject
,
116 MUIA_Window_Title
, (IPTR
) data
->wintitle
,
117 MUIA_Window_Activate
, TRUE
,
118 MUIA_Window_IsSubWindow
, TRUE
,
119 MUIA_Window_LeftEdge
, _left(obj
) + x
,
120 MUIA_Window_TopEdge
, _bottom(obj
) + y
+ 1,
122 WindowContents
, (IPTR
) VGroup
,
123 Child
, (IPTR
) (data
->imageadjust
= MUI_NewObject
127 MUIA_Imageadjust_Spec
, (IPTR
) img_spec
,
128 MUIA_Imageadjust_Type
, data
->adjust_type
,
129 MUIA_Imageadjust_Originator
, (IPTR
) obj
,
132 Child
, (IPTR
) HGroup
,
133 MUIA_Group_SameWidth
, TRUE
,
134 Child
, (IPTR
) (ok_button
= MUI_MakeObject
136 MUIO_Button
, (IPTR
) "_Ok"
138 Child
, (IPTR
) HVSpace
,
139 Child
, (IPTR
) HVSpace
,
140 Child
, (IPTR
) (cancel_button
= MUI_MakeObject
142 MUIO_Button
, (IPTR
) "_Cancel"
150 set(ok_button
, MUIA_CycleChain
, 1);
151 set(cancel_button
, MUIA_CycleChain
, 1);
153 DoMethod(_app(obj
),OM_ADDMEMBER
,(IPTR
)data
->wnd
);
157 ok_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
158 (IPTR
) _app(obj
), 5, MUIM_Application_PushMethod
,
159 (IPTR
) obj
, 2, MUIM_Popimage_CloseWindow
, TRUE
163 cancel_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
164 (IPTR
) _app(obj
), 5, MUIM_Application_PushMethod
,
165 (IPTR
) obj
, 2, MUIM_Popimage_CloseWindow
, FALSE
169 data
->wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
170 (IPTR
) _app(obj
), 5, MUIM_Application_PushMethod
,
171 (IPTR
) obj
, 2, MUIM_Popimage_CloseWindow
, FALSE
180 set(data
->wnd
, MUIA_Window_Open
,TRUE
);
181 get(data
->wnd
, MUIA_Window_Open
, &opened
);
184 DoMethod(obj
, MUIM_Popimage_CloseWindow
, FALSE
);
191 IPTR
Popimage__MUIM_Popimage_CloseWindow(struct IClass
*cl
, Object
*obj
,
192 struct MUIP_Popimage_CloseWindow
*msg
)
194 struct Popimage_DATA
*data
= INST_DATA(cl
, obj
);
197 set(data
->wnd
, MUIA_Window_Open
, FALSE
);
202 get(data
->imageadjust
, MUIA_Imageadjust_Spec
, &spec
);
203 /* D(bug("popimage: got %s\n", spec)); */
204 set(obj
, MUIA_Imagedisplay_Spec
, (IPTR
)spec
);
207 DoMethod(_app(obj
), OM_REMMEMBER
, (IPTR
)data
->wnd
);
208 MUI_DisposeObject(data
->wnd
);
210 data
->imageadjust
= NULL
;
214 IPTR
Popimage__MUIM_DisconnectParent(struct IClass
*cl
, Object
*obj
,
215 struct MUIP_DisconnectParent
*msg
)
217 struct Popimage_DATA
*data
= INST_DATA(cl
, obj
);
219 if (data
->wnd
) DoMethod(obj
, MUIM_Popimage_CloseWindow
, FALSE
);
220 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
223 #if ZUNE_BUILTIN_POPIMAGE
224 BOOPSI_DISPATCHER(IPTR
, Popimage_Dispatcher
, cl
, obj
, msg
)
226 switch (msg
->MethodID
)
228 case OM_NEW
: return Popimage__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
229 case OM_DISPOSE
: return Popimage__OM_DISPOSE(cl
, obj
, msg
);
230 case MUIM_Hide
: return Popimage__MUIM_Hide(cl
, obj
, (APTR
)msg
);
231 case MUIM_Popimage_OpenWindow
: return Popimage__MUIM_Popimage_OpenWindow(cl
, obj
, (APTR
)msg
);
232 case MUIM_Popimage_CloseWindow
: return Popimage__MUIM_Popimage_CloseWindow(cl
, obj
, (APTR
)msg
);
233 case MUIM_DisconnectParent
: return Popimage__MUIM_DisconnectParent(cl
, obj
, (APTR
)msg
);
234 default: return DoSuperMethodA(cl
, obj
, msg
);
237 BOOPSI_DISPATCHER_END
239 const struct __MUIBuiltinClass _MUI_Popimage_desc
=
243 sizeof(struct Popimage_DATA
),
244 (void*)Popimage_Dispatcher
246 #endif /* ZUNE_BUILTIN_POPIMAGE */