Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / openurl / prefs / pens.c
blob0f23b4e2597729f450bb517005426b9ae82b9b41
1 /*
2 ** OpenURL - MUI preferences for openurl.library
3 **
4 ** Written by Troels Walsted Hansen <troels@thule.no>
5 ** Placed in the public domain.
6 **
7 ** Developed by:
8 ** - Alfonso Ranieri <alforan@tin.it>
9 ** - Stefan Kost <ensonic@sonicpulse.de>
12 ** Pens adjust window
16 #include "OpenURL.h"
17 #define CATCOMP_NUMBERS
18 #include "loc.h"
20 /**************************************************************************/
22 ** A Poppen that Impot/Export its spec
25 static struct MUI_CustomClass *penClass = NULL;
26 #ifdef __AROS__
27 #define penObject BOOPSIOBJMACRO_START(penClass->mcc_Class)
28 #else
29 #define penObject NewObject(penClass->mcc_Class,NULL
30 #endif
32 struct penData
34 struct MUI_PenSpec spec; /* Needed to check changes */
37 /**************************************************************************/
39 ** Import pen spec
42 static ULONG
43 mPenImport(struct IClass *cl,Object *obj,struct MUIP_Import *msg)
45 register ULONG id;
47 if (id = (muiNotifyData(obj)->mnd_ObjectID))
49 struct penData *data = INST_DATA(cl,obj);
50 struct MUI_PenSpec *spec;
52 if (spec = (struct MUI_PenSpec *)DoMethod(msg->dataspace,MUIM_Dataspace_Find,id))
54 strcpy((STRPTR)&data->spec,(STRPTR)spec);
55 set(obj,MUIA_Pendisplay_Spec,&data->spec);
59 return 0;
62 /**************************************************************************/
64 ** Export pen spec
67 static ULONG
68 mPenExport(struct IClass *cl,Object *obj,struct MUIP_Export *msg)
70 register ULONG id;
72 if (id = (muiNotifyData(obj)->mnd_ObjectID))
74 struct MUI_PenSpec *spec;
76 get(obj,MUIA_Pendisplay_Spec,&spec);
77 DoMethod(msg->dataspace,MUIM_Dataspace_Add,(ULONG)spec,sizeof(struct MUI_PenSpec),id);
80 return 0;
83 /**************************************************************************/
85 ** Check if pen spec changed
88 static ULONG
89 mPenCheckSave(struct IClass *cl,Object *obj,Msg msg)
91 struct penData *data = INST_DATA(cl,obj);
92 struct MUI_PenSpec *spec;
94 get(obj,MUIA_Pendisplay_Spec,&spec);
96 return (ULONG)strcmp((STRPTR)spec,(STRPTR)&data->spec);
99 /**************************************************************************/
101 M_DISP(penDispatcher)
103 M_DISPSTART
105 switch(msg->MethodID)
107 case MUIM_Import: return mPenImport(cl,obj,(APTR)msg);
108 case MUIM_Export: return mPenExport(cl,obj,(APTR)msg);
110 case MUIM_App_CheckSave: return mPenCheckSave(cl,obj,(APTR)msg);
112 default: return DoSuperMethodA(cl,obj,msg);
116 M_DISPEND(penDispatcher)
118 /***********************************************************************/
120 static ULONG
121 initPenClass(void)
123 return (ULONG)(penClass = MUI_CreateCustomClass(NULL,MUIC_Poppen,NULL,sizeof(struct penData),DISP(penDispatcher)));
126 /**************************************************************************/
128 static void
129 disposePenClass(void)
131 if (penClass) MUI_DeleteCustomClass(penClass);
134 /**************************************************************************/
136 struct data
139 Object *enabled;
140 Object *disabled;
141 Object *detail;
143 struct MUI_PenSpec *specs[3];
145 ULONG flags;
148 static ULONG
149 mNew(struct IClass *cl,Object *obj,struct opSet *msg)
151 Object *enabled, *disabled, *detail;
153 if (obj = (Object *)DoSuperNew(cl,obj,
154 MUIA_HelpNode, "PWIN",
155 MUIA_Window_ID, MAKE_ID('P', 'W', 'I', 'N'),
156 MUIA_Window_Title, getString(MSG_Pens_WinTitle),
157 MUIA_Window_ScreenTitle, getString(MSG_App_ScreenTitle),
159 WindowContents, VGroup,
160 Child, ColGroup(6),
162 Child, oflabel(MSG_Pens_EnabledPen),
163 Child, enabled = penObject,
164 MUIA_ObjectID, MAKE_ID('E','P', 'E', 'N'),
165 MUIA_ShortHelp, getString(MSG_Pens_EnabledPen_Help),
166 MUIA_ControlChar, getKeyChar(NULL,MSG_Pens_EnabledPen),
167 MUIA_Window_Title, (ULONG)getString(MSG_Pens_EnabledPen_WinTitle),
168 MUIA_Draggable, TRUE,
169 MUIA_CycleChain, TRUE,
170 MUIA_Pendisplay_Spec, DEF_EnabledPen,
171 End,
173 Child, oflabel(MSG_Pens_DisabledPen),
174 Child, disabled = penObject,
175 MUIA_ObjectID, MAKE_ID('D','P', 'E', 'N'),
176 MUIA_ShortHelp, getString(MSG_Pens_DisabledPen_Help),
177 MUIA_ControlChar, getKeyChar(NULL,MSG_Pens_DisabledPen),
178 MUIA_Window_Title, (ULONG)getString(MSG_Pens_DisabledPen_WinTitle),
179 MUIA_Draggable, TRUE,
180 MUIA_CycleChain, TRUE,
181 MUIA_Pendisplay_Spec, DEF_DisabledPen,
182 End,
184 Child, oflabel(MSG_Pens_DetailPen),
185 Child, detail = penObject,
186 MUIA_ObjectID, MAKE_ID('I','P', 'E', 'N'),
187 MUIA_ShortHelp, getString(MSG_Pens_DetailPen_Help),
188 MUIA_ControlChar, getKeyChar(NULL,MSG_Pens_DetailPen),
189 MUIA_Window_Title, (ULONG)getString(MSG_Pens_DetailPen_WinTitle),
190 MUIA_Draggable, TRUE,
191 MUIA_CycleChain, TRUE,
192 MUIA_Pendisplay_Spec, DEF_DetailPen,
193 End,
194 End,
195 End,
196 TAG_MORE, msg->ops_AttrList))
198 struct data *data = INST_DATA(cl,obj);
200 data->enabled = enabled;
201 data->disabled = disabled;
202 data->detail = detail;
204 DoMethod(enabled,MUIM_Notify,MUIA_Pendisplay_Spec,MUIV_EveryTime,(ULONG)obj,1,MUIM_Pens_Change);
205 DoMethod(disabled,MUIM_Notify,MUIA_Pendisplay_Spec,MUIV_EveryTime,(ULONG)obj,1,MUIM_Pens_Change);
206 DoMethod(detail,MUIM_Notify,MUIA_Pendisplay_Spec,MUIV_EveryTime,(ULONG)obj,1,MUIM_Pens_Change);
209 return (ULONG)obj;
212 /**************************************************************************/
214 ** Called when a pen spec is changed by the user
217 static ULONG
218 mChange(struct IClass *cl,Object *obj,Msg msg)
220 struct data *data = INST_DATA(cl,obj);
221 Object *app;
223 get(data->enabled,MUIA_Pendisplay_Spec,data->specs);
224 get(data->disabled,MUIA_Pendisplay_Spec,data->specs+1);
225 get(data->detail,MUIA_Pendisplay_Spec,data->specs+2);
227 /* To App -> Main win -> Applist -> list -> lamp */
228 get(obj,MUIA_ApplicationObject,&app);
229 set(app,MUIA_App_Pens,data->specs);
231 return 0;
234 /***********************************************************************/
236 static ULONG
237 mGet(struct IClass *cl,Object *obj,struct opGet *msg)
239 struct data *data = INST_DATA(cl,obj);
241 switch (msg->opg_AttrID)
243 case MUIA_App_Pens:
245 get(data->enabled, MUIA_Pendisplay_Spec,data->specs);
246 get(data->disabled,MUIA_Pendisplay_Spec,data->specs+1);
247 get(data->detail, MUIA_Pendisplay_Spec,data->specs+2);
249 *msg->opg_Storage = (ULONG)&data->specs; return TRUE;
252 default: return DoSuperMethodA(cl,obj,(Msg)msg);
256 /**************************************************************************/
258 ** Check if pen spec changed
261 static ULONG
262 mCheckSave(struct IClass *cl,Object *obj,Msg msg)
264 struct data *data = INST_DATA(cl,obj);
266 return (ULONG)(DoMethodA(data->enabled,msg) ||
267 DoMethodA(data->disabled,msg) ||
268 DoMethodA(data->detail,msg));
271 /**************************************************************************/
273 M_DISP(dispatcher)
275 M_DISPSTART
277 switch (msg->MethodID)
279 case OM_NEW: return mNew(cl,obj,(APTR)msg);
280 case OM_GET: return mGet(cl,obj,(APTR)msg);
282 case MUIM_Pens_Change: return mChange(cl,obj,(APTR)msg);
283 case MUIM_App_CheckSave: return mCheckSave(cl,obj,(APTR)msg);
285 default: return DoSuperMethodA(cl,obj,msg);
289 M_DISPEND(dispatcher)
291 /**************************************************************************/
293 ULONG
294 initPensClass(void)
296 if (initPenClass())
298 if (g_pensClass = MUI_CreateCustomClass(NULL,MUIC_Window,NULL,sizeof(struct data),DISP(dispatcher)))
300 return TRUE;
303 disposePenClass();
306 return FALSE;
309 /**************************************************************************/
311 void
312 disposePensClass(void)
314 disposePenClass();
315 if (g_pensClass) MUI_DeleteCustomClass(g_pensClass);
318 /**************************************************************************/