2 ** OpenURL - MUI preferences for openurl.library
4 ** Written by Troels Walsted Hansen <troels@thule.no>
5 ** Placed in the public domain.
8 ** - Alfonso Ranieri <alforan@tin.it>
9 ** - Stefan Kost <ensonic@sonicpulse.de>
17 #define CATCOMP_NUMBERS
20 /**************************************************************************/
22 ** A Poppen that Impot/Export its spec
25 static struct MUI_CustomClass
*penClass
= NULL
;
27 #define penObject BOOPSIOBJMACRO_START(penClass->mcc_Class)
29 #define penObject NewObject(penClass->mcc_Class,NULL
34 struct MUI_PenSpec spec
; /* Needed to check changes */
37 /**************************************************************************/
43 mPenImport(struct IClass
*cl
,Object
*obj
,struct MUIP_Import
*msg
)
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
);
62 /**************************************************************************/
68 mPenExport(struct IClass
*cl
,Object
*obj
,struct MUIP_Export
*msg
)
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
);
83 /**************************************************************************/
85 ** Check if pen spec changed
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
)
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 /***********************************************************************/
123 return (ULONG
)(penClass
= MUI_CreateCustomClass(NULL
,MUIC_Poppen
,NULL
,sizeof(struct penData
),DISP(penDispatcher
)));
126 /**************************************************************************/
129 disposePenClass(void)
131 if (penClass
) MUI_DeleteCustomClass(penClass
);
134 /**************************************************************************/
143 struct MUI_PenSpec
*specs
[3];
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
,
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
,
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
,
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
,
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
);
212 /**************************************************************************/
214 ** Called when a pen spec is changed by the user
218 mChange(struct IClass
*cl
,Object
*obj
,Msg msg
)
220 struct data
*data
= INST_DATA(cl
,obj
);
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
);
234 /***********************************************************************/
237 mGet(struct IClass
*cl
,Object
*obj
,struct opGet
*msg
)
239 struct data
*data
= INST_DATA(cl
,obj
);
241 switch (msg
->opg_AttrID
)
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
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 /**************************************************************************/
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 /**************************************************************************/
298 if (g_pensClass
= MUI_CreateCustomClass(NULL
,MUIC_Window
,NULL
,sizeof(struct data
),DISP(dispatcher
)))
309 /**************************************************************************/
312 disposePensClass(void)
315 if (g_pensClass
) MUI_DeleteCustomClass(g_pensClass
);
318 /**************************************************************************/