Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / muimaster / classes / poppen.c
blobb06bff96c1c80e8eff50d35429997a108ce93c87
1 /*
2 Copyright © 2002-2003, 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 #include "mui.h"
16 #include "muimaster_intern.h"
17 #include "support.h"
18 #include "support_classes.h"
19 #include "poppen_private.h"
21 extern struct Library *MUIMasterBase;
24 IPTR Poppen__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg)
26 struct Poppen_DATA *data;
27 struct TagItem *tag, *tags;
28 //Object *image;
30 obj = (Object *)DoSuperNewTags(cl, obj, NULL,
31 ButtonFrame,
32 InnerSpacing(4,4),
33 MUIA_Background, MUII_ButtonBack,
34 MUIA_InputMode, MUIV_InputMode_RelVerify,
35 MUIA_Draggable, TRUE,
36 TAG_MORE, (IPTR)msg->ops_AttrList);
38 if (!obj) return FALSE;
40 data = INST_DATA(cl, obj);
41 data->wintitle = NULL;
43 /* parse initial taglist */
44 for (tags = msg->ops_AttrList; (tag = NextTagItem((const struct TagItem**)&tags)); )
46 switch (tag->ti_Tag)
48 case MUIA_Window_Title:
49 data->wintitle = (CONST_STRPTR)tag->ti_Data;
50 break;
55 DoMethod(obj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)obj, 1,
56 MUIM_Poppen_OpenWindow);
58 return (IPTR)obj;
61 IPTR Poppen__MUIM_Hide(struct IClass *cl, Object *obj, struct opGet *msg)
63 struct Poppen_DATA *data = INST_DATA(cl, obj);
65 if (data->wnd)
67 set(data->wnd,MUIA_Window_Open,FALSE);
68 DoMethod(_app(obj),OM_REMMEMBER,(IPTR)data->wnd);
69 MUI_DisposeObject(data->wnd);
70 data->wnd = NULL;
72 return DoSuperMethodA(cl,obj,(Msg)msg);
75 IPTR Poppen__MUIM_Poppen_OpenWindow(struct IClass *cl, Object *obj, Msg msg)
77 struct Poppen_DATA *data = INST_DATA(cl, obj);
79 if (!data->wnd)
81 Object *ok_button, *cancel_button;
82 char *penspec;
84 get(obj,MUIA_Pendisplay_Spec, &penspec);
86 data->wnd = (Object *)(WindowObject,
87 MUIA_Window_Title, (IPTR)data->wintitle,
88 MUIA_Window_Activate, TRUE,
89 WindowContents, (IPTR)VGroup,
90 Child, (IPTR)(data->penadjust = (Object *)PenadjustObject,
91 MUIA_CycleChain, 1,
92 MUIA_Penadjust_Spec, (IPTR)penspec,
93 End),
94 Child, (IPTR)HGroup,
95 Child, (IPTR)(ok_button = MUI_MakeObject(MUIO_Button,(IPTR)"_Ok")),
96 Child, (IPTR)(cancel_button = MUI_MakeObject(MUIO_Button,(IPTR)"_Cancel")),
97 End,
98 End,
99 End);
101 if (data->wnd)
103 set(ok_button, MUIA_CycleChain, 1);
104 set(cancel_button, MUIA_CycleChain, 1);
106 DoMethod(_app(obj),OM_ADDMEMBER,(IPTR)data->wnd);
108 DoMethod(ok_button, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)_app(obj), 5,
109 MUIM_Application_PushMethod, (IPTR)obj, 2,
110 MUIM_Poppen_CloseWindow, TRUE);
111 DoMethod(cancel_button, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)_app(obj), 5,
112 MUIM_Application_PushMethod, (IPTR)obj, 2,
113 MUIM_Poppen_CloseWindow, FALSE);
114 DoMethod(data->wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)_app(obj), 5,
115 MUIM_Application_PushMethod, (IPTR)obj, 2,
116 MUIM_Poppen_CloseWindow, FALSE);
120 if (data->wnd)
122 IPTR opened;
124 set(data->wnd, MUIA_Window_Open,TRUE);
125 get(data->wnd, MUIA_Window_Open, &opened);
127 if (!opened)
129 DoMethod(obj, MUIM_Poppen_CloseWindow, FALSE);
133 return 1;
136 IPTR Poppen__MUIM_Poppen_CloseWindow(struct IClass *cl, Object *obj,
137 struct MUIP_Poppen_CloseWindow *msg)
139 struct Poppen_DATA *data = INST_DATA(cl, obj);
140 int ok = msg->ok;
142 set(data->wnd, MUIA_Window_Open, FALSE);
144 if (ok)
146 char *spec;
148 get(data->penadjust, MUIA_Penadjust_Spec, &spec);
150 set(obj, MUIA_Pendisplay_Spec, (IPTR)spec);
153 DoMethod(_app(obj), OM_REMMEMBER, (IPTR)data->wnd);
154 MUI_DisposeObject(data->wnd);
155 data->wnd = NULL;
156 data->penadjust = NULL;
157 return 1;
160 IPTR Poppen__MUIM_DisconnectParent(struct IClass *cl, Object *obj,
161 struct MUIP_DisconnectParent *msg)
163 struct Poppen_DATA *data = INST_DATA(cl, obj);
165 if (data->wnd) DoMethod(obj, MUIM_Poppen_CloseWindow, FALSE);
166 return DoSuperMethodA(cl, obj, (Msg)msg);
169 #if ZUNE_BUILTIN_POPPEN
170 BOOPSI_DISPATCHER(IPTR, Poppen_Dispatcher, cl, obj, msg)
172 switch (msg->MethodID)
174 case OM_NEW: return Poppen__OM_NEW(cl, obj, (struct opSet *)msg);
175 case MUIM_Hide: return Poppen__MUIM_Hide(cl, obj, (APTR)msg);
176 case MUIM_Poppen_OpenWindow: return Poppen__MUIM_Poppen_OpenWindow(cl, obj, (APTR)msg);
177 case MUIM_Poppen_CloseWindow: return Poppen__MUIM_Poppen_CloseWindow(cl, obj, (APTR)msg);
178 case MUIM_DisconnectParent: return Poppen__MUIM_DisconnectParent(cl, obj, (APTR)msg);
179 default: return DoSuperMethodA(cl, obj, msg);
182 BOOPSI_DISPATCHER_END
184 const struct __MUIBuiltinClass _MUI_Poppen_desc =
186 MUIC_Poppen,
187 MUIC_Pendisplay,
188 sizeof(struct Poppen_DATA),
189 (void*)Poppen_Dispatcher
191 #endif /* ZUNE_BUILTIN_POPPEN */