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(
34 MUIA_Background
, MUII_ButtonBack
,
35 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
37 TAG_MORE
, (IPTR
) msg
->ops_AttrList
);
41 data
= INST_DATA(cl
, obj
);
42 data
->wintitle
= NULL
;
43 data
->adjust_type
= MUIV_Imageadjust_Type_All
;
45 /* parse initial taglist */
46 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
50 case MUIA_Window_Title
:
51 data
->wintitle
= (CONST_STRPTR
) tag
->ti_Data
;
54 case MUIA_Imageadjust_Type
:
55 data
->adjust_type
= tag
->ti_Data
;
60 DoMethod(obj
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
) obj
, 1,
61 MUIM_Popimage_OpenWindow
);
66 IPTR
Popimage__OM_DISPOSE(struct IClass
*cl
, Object
*obj
, Msg msg
)
68 struct Popimage_DATA
*data
= INST_DATA(cl
, obj
);
72 D(bug("Popimage_Dispose(%p) : MUI_DisposeObject(%p)\n", obj
,
74 MUI_DisposeObject(data
->wnd
);
77 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
80 IPTR
Popimage__MUIM_Hide(struct IClass
*cl
, Object
*obj
,
84 struct Popimage_DATA
*data
= INST_DATA(cl
, obj
);
87 D(bug("Popimage_Hide(%p) : closing window %p\n", obj
, data
->wnd
));
88 set(data
->wnd
, MUIA_Window_Open
, FALSE
);
89 D(bug("Popimage_Hide(%p) : app REMMEMBER win (%p)\n", obj
,
91 DoMethod(_app(obj
), OM_REMMEMBER
, (IPTR
) data
->wnd
);
92 D(bug("Popimage_Hide(%p) : MUI_DisposeObject(%p)\n", obj
,
94 MUI_DisposeObject(data
->wnd
);
98 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
101 IPTR
Popimage__MUIM_Popimage_OpenWindow(struct IClass
*cl
, Object
*obj
,
104 struct Popimage_DATA
*data
= INST_DATA(cl
, obj
);
108 Object
*ok_button
, *cancel_button
;
109 char *img_spec
= NULL
;
112 get(_win(obj
), MUIA_Window_LeftEdge
, &x
);
113 get(_win(obj
), MUIA_Window_TopEdge
, &y
);
115 get(obj
, MUIA_Imagedisplay_Spec
, &img_spec
);
117 data
->wnd
= (Object
*) WindowObject
,
118 MUIA_Window_Title
, (IPTR
) data
->wintitle
,
119 MUIA_Window_Activate
, TRUE
,
120 MUIA_Window_IsSubWindow
, TRUE
,
121 MUIA_Window_AppWindow
, TRUE
,
122 MUIA_Window_LeftEdge
, _left(obj
) + x
,
123 MUIA_Window_TopEdge
, _bottom(obj
) + y
+ 1,
124 WindowContents
, (IPTR
) VGroup
,
125 Child
, (IPTR
) (data
->imageadjust
=
126 MUI_NewObject(MUIC_Imageadjust
,
128 MUIA_Imageadjust_Spec
, (IPTR
) img_spec
,
129 MUIA_Imageadjust_Type
, data
->adjust_type
,
130 MUIA_Imageadjust_Originator
, (IPTR
) obj
,
132 Child
, (IPTR
) HGroup
,
133 MUIA_Group_SameWidth
, TRUE
,
134 Child
, (IPTR
) (ok_button
= MUI_MakeObject(MUIO_Button
,
136 Child
, (IPTR
) HVSpace
,
137 Child
, (IPTR
) HVSpace
,
138 Child
, (IPTR
) (cancel_button
= MUI_MakeObject(MUIO_Button
,
146 set(ok_button
, MUIA_CycleChain
, 1);
147 set(cancel_button
, MUIA_CycleChain
, 1);
149 DoMethod(_app(obj
), OM_ADDMEMBER
, (IPTR
) data
->wnd
);
152 (ok_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
153 (IPTR
) _app(obj
), 5, MUIM_Application_PushMethod
,
154 (IPTR
) obj
, 2, MUIM_Popimage_CloseWindow
, TRUE
);
156 (cancel_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
157 (IPTR
) _app(obj
), 5, MUIM_Application_PushMethod
,
158 (IPTR
) obj
, 2, MUIM_Popimage_CloseWindow
, FALSE
);
160 (data
->wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
161 (IPTR
) _app(obj
), 5, MUIM_Application_PushMethod
,
162 (IPTR
) obj
, 2, MUIM_Popimage_CloseWindow
, FALSE
);
168 ULONG opened
= FALSE
;
170 set(data
->wnd
, MUIA_Window_Open
, TRUE
);
171 get(data
->wnd
, MUIA_Window_Open
, &opened
);
174 DoMethod(obj
, MUIM_Popimage_CloseWindow
, FALSE
);
181 IPTR
Popimage__MUIM_Popimage_CloseWindow(struct IClass
*cl
, Object
*obj
,
182 struct MUIP_Popimage_CloseWindow
*msg
)
184 struct Popimage_DATA
*data
= INST_DATA(cl
, obj
);
187 set(data
->wnd
, MUIA_Window_Open
, FALSE
);
192 get(data
->imageadjust
, MUIA_Imageadjust_Spec
, &spec
);
193 /* D(bug("popimage: got %s\n", spec)); */
194 set(obj
, MUIA_Imagedisplay_Spec
, (IPTR
) spec
);
197 DoMethod(_app(obj
), OM_REMMEMBER
, (IPTR
) data
->wnd
);
198 MUI_DisposeObject(data
->wnd
);
200 data
->imageadjust
= NULL
;
204 IPTR
Popimage__MUIM_DisconnectParent(struct IClass
*cl
, Object
*obj
,
205 struct MUIP_DisconnectParent
*msg
)
207 struct Popimage_DATA
*data
= INST_DATA(cl
, obj
);
210 DoMethod(obj
, MUIM_Popimage_CloseWindow
, FALSE
);
211 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
214 #if ZUNE_BUILTIN_POPIMAGE
215 BOOPSI_DISPATCHER(IPTR
, Popimage_Dispatcher
, cl
, obj
, msg
)
217 switch (msg
->MethodID
)
220 return Popimage__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
222 return Popimage__OM_DISPOSE(cl
, obj
, msg
);
224 return Popimage__MUIM_Hide(cl
, obj
, (APTR
) msg
);
225 case MUIM_Popimage_OpenWindow
:
226 return Popimage__MUIM_Popimage_OpenWindow(cl
, obj
, (APTR
) msg
);
227 case MUIM_Popimage_CloseWindow
:
228 return Popimage__MUIM_Popimage_CloseWindow(cl
, obj
, (APTR
) msg
);
229 case MUIM_DisconnectParent
:
230 return Popimage__MUIM_DisconnectParent(cl
, obj
, (APTR
) msg
);
232 return DoSuperMethodA(cl
, obj
, msg
);
235 BOOPSI_DISPATCHER_END
237 const struct __MUIBuiltinClass _MUI_Popimage_desc
=
241 sizeof(struct Popimage_DATA
),
242 (void *) Popimage_Dispatcher
244 #endif /* ZUNE_BUILTIN_POPIMAGE */