added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / libs / muimaster / classes / popframe.c
bloba1e49dbf91748273985366cf7489c3ce1694389e
1 /*
2 Copyright © 2002-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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 */
16 #include "debug.h"
17 #include "mui.h"
18 #include "muimaster_intern.h"
19 #include "support.h"
20 #include "support_classes.h"
21 #include "popframe_private.h"
23 extern struct Library *MUIMasterBase;
25 IPTR Popframe__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg)
27 struct Popframe_DATA *data;
28 struct TagItem *tag, *tags;
30 obj = (Object *) DoSuperNewTags
32 cl, obj, NULL,
34 ButtonFrame,
35 InnerSpacing(4,4),
36 MUIA_Background, MUII_ButtonBack,
37 MUIA_InputMode, MUIV_InputMode_RelVerify,
38 MUIA_Draggable, TRUE,
40 TAG_MORE, (IPTR) msg->ops_AttrList
43 if (!obj) return FALSE;
45 data = INST_DATA(cl, obj);
46 data->wintitle = NULL;
48 /* parse initial taglist */
49 for (tags = msg->ops_AttrList; (tag = NextTagItem((const struct TagItem**)&tags)); )
51 switch (tag->ti_Tag)
53 case MUIA_Window_Title:
54 data->wintitle = (CONST_STRPTR)tag->ti_Data;
55 break;
59 DoMethod(obj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)obj, 1,
60 MUIM_Popframe_OpenWindow);
62 return (IPTR)obj;
65 IPTR Popframe__OM_DISPOSE(struct IClass *cl, Object *obj, Msg msg)
67 struct Popframe_DATA *data = INST_DATA(cl, obj);
69 if (data->wnd)
71 D(bug("Popframe_Dispose(%p) : MUI_DisposeObject(%p)\n", obj, data->wnd));
72 MUI_DisposeObject(data->wnd);
73 data->wnd = NULL;
75 return DoSuperMethodA(cl,obj,(Msg)msg);
78 IPTR Popframe__MUIM_Hide(struct IClass *cl, Object *obj, struct opGet *msg)
80 #if 0
81 struct Popframe_DATA *data = INST_DATA(cl, obj);
82 if (data->wnd)
84 D(bug("Popframe_Hide(%p) : closing window %p\n", obj, data->wnd));
85 set(data->wnd,MUIA_Window_Open,FALSE);
86 D(bug("Popframe_Hide(%p) : app REMMEMBER win (%p)\n", obj, data->wnd));
87 DoMethod(_app(obj),OM_REMMEMBER,(IPTR)data->wnd);
88 D(bug("Popframe_Hide(%p) : MUI_DisposeObject(%p)\n", obj, data->wnd));
89 MUI_DisposeObject(data->wnd);
90 data->wnd = NULL;
92 #endif
93 return DoSuperMethodA(cl,obj,(Msg)msg);
96 IPTR Popframe__MUIM_Popframe_OpenWindow(struct IClass *cl, Object *obj, Msg msg)
98 struct Popframe_DATA *data = INST_DATA(cl, obj);
100 if (!data->wnd)
102 Object *ok_button, *cancel_button;
103 struct MUI_Frame_Spec *frame_spec;
104 ULONG x = 0, y = 0;
106 get(_win(obj), MUIA_Window_LeftEdge, &x);
107 get(_win(obj), MUIA_Window_TopEdge, &y);
109 get(obj, MUIA_Framedisplay_Spec, &frame_spec);
111 data->wnd = WindowObject,
112 MUIA_Window_Title, (IPTR)data->wintitle,
113 MUIA_Window_Activate, TRUE,
114 MUIA_Window_IsSubWindow, TRUE,
115 MUIA_Window_LeftEdge, _left(obj) + x,
116 MUIA_Window_TopEdge, _bottom(obj) + y + 1,
117 WindowContents, (IPTR)VGroup,
118 Child, (IPTR)(data->frameadjust = MUI_NewObject(
119 MUIC_Frameadjust,
120 MUIA_CycleChain, 1,
121 MUIA_Frameadjust_Spec, (IPTR)frame_spec,
122 TAG_DONE)),
123 Child, (IPTR)HGroup,
124 MUIA_Group_SameWidth, TRUE,
125 Child, (IPTR)(ok_button = MUI_MakeObject(MUIO_Button, (IPTR)"_Ok")),
126 Child, (IPTR)HVSpace,
127 Child, (IPTR)HVSpace,
128 Child, (IPTR)(cancel_button = MUI_MakeObject(MUIO_Button, (IPTR)"_Cancel")),
129 End,
130 End,
131 End;
133 if (data->wnd)
135 set(ok_button, MUIA_CycleChain, 1);
136 set(cancel_button, MUIA_CycleChain, 1);
138 DoMethod(_app(obj),OM_ADDMEMBER,(IPTR)data->wnd);
140 DoMethod(ok_button, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)_app(obj), 5,
141 MUIM_Application_PushMethod, (IPTR)obj, 2,
142 MUIM_Popframe_CloseWindow, TRUE);
143 DoMethod(cancel_button, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)_app(obj), 5,
144 MUIM_Application_PushMethod, (IPTR)obj, 2,
145 MUIM_Popframe_CloseWindow, FALSE);
146 DoMethod(data->wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)_app(obj), 5,
147 MUIM_Application_PushMethod, (IPTR)obj, 2,
148 MUIM_Popframe_CloseWindow, FALSE);
152 if (data->wnd)
154 ULONG opened;
156 set(data->wnd, MUIA_Window_Open,TRUE);
157 get(data->wnd, MUIA_Window_Open, &opened);
158 if (!opened)
160 DoMethod(obj, MUIM_Popframe_CloseWindow, FALSE);
164 return 1;
167 IPTR Popframe__MUIM_Popframe_CloseWindow(struct IClass *cl, Object *obj,
168 struct MUIP_Popframe_CloseWindow *msg)
170 struct Popframe_DATA *data = INST_DATA(cl, obj);
171 int ok = msg->ok;
173 set(data->wnd, MUIA_Window_Open, FALSE);
175 if (ok)
177 STRPTR spec;
178 get(data->frameadjust, MUIA_Frameadjust_Spec, &spec);
179 /* D(bug("popframe: got %s\n", spec)); */
180 set(obj, MUIA_Framedisplay_Spec, (IPTR)spec);
183 DoMethod(_app(obj), OM_REMMEMBER, (IPTR)data->wnd);
184 MUI_DisposeObject(data->wnd);
185 data->wnd = NULL;
186 data->frameadjust = NULL;
187 return 1;
190 IPTR Popframe__MUIM_DisconnectParent(struct IClass *cl, Object *obj,
191 struct MUIP_DisconnectParent *msg)
193 struct Popframe_DATA *data = INST_DATA(cl, obj);
195 if (data->wnd) DoMethod(obj, MUIM_Popframe_CloseWindow, FALSE);
196 return DoSuperMethodA(cl, obj, (Msg)msg);
199 #if ZUNE_BUILTIN_POPFRAME
200 BOOPSI_DISPATCHER(IPTR, Popframe_Dispatcher, cl, obj, msg)
202 switch (msg->MethodID)
204 case OM_NEW: return Popframe__OM_NEW(cl, obj, (struct opSet *)msg);
205 case OM_DISPOSE: return Popframe__OM_DISPOSE(cl, obj, msg);
206 case MUIM_Hide: return Popframe__MUIM_Hide(cl, obj, (APTR)msg);
207 case MUIM_Popframe_OpenWindow: return Popframe__MUIM_Popframe_OpenWindow(cl, obj, (APTR)msg);
208 case MUIM_Popframe_CloseWindow: return Popframe__MUIM_Popframe_CloseWindow(cl, obj, (APTR)msg);
209 case MUIM_DisconnectParent: return Popframe__MUIM_DisconnectParent(cl, obj, (APTR)msg);
210 default: return DoSuperMethodA(cl, obj, msg);
213 BOOPSI_DISPATCHER_END
215 const struct __MUIBuiltinClass _MUI_Popframe_desc =
217 MUIC_Popframe,
218 MUIC_Framedisplay,
219 sizeof(struct Popframe_DATA),
220 (void*)Popframe_Dispatcher
222 #endif /* ZUNE_BUILTIN_POPFRAME */