arch/cpu.resource: remove dead code
[AROS.git] / workbench / classes / zune / betterstring / mcp / Dispatcher.c
blob8d8367c23b26376bf6c723fe9148c9280ee3f292
1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2013 by BetterString.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 BetterString class Support Site: http://www.sf.net/projects/bstring-mcc/
19 $Id$
21 ***************************************************************************/
23 #include <string.h>
24 #include <clib/alib_protos.h>
25 #include <proto/intuition.h>
26 #include <proto/muimaster.h>
27 #include <libraries/mui.h>
29 #include "private.h"
30 #include "BetterString_mcp.h"
31 #include "muiextra.h"
33 #include "Debug.h"
35 struct PrefsExchangeData
37 const ULONG ObjIndex;
38 const ULONG Tag;
39 const ULONG CfgItem;
40 const ULONG Type; // 0 = string, 1 = integer
41 const APTR DefValue;
44 static const struct PrefsExchangeData PrefsInfo[] =
46 { ActiveBack, MUIA_Imagedisplay_Spec, MUICFG_BetterString_ActiveBack, 0, (APTR)CFG_BetterString_ActiveBack_Def },
47 { ActiveText, MUIA_Pendisplay_Spec, MUICFG_BetterString_ActiveText, 0, (APTR)CFG_BetterString_ActiveText_Def },
48 { InactiveBack, MUIA_Imagedisplay_Spec, MUICFG_BetterString_InactiveBack, 0, (APTR)CFG_BetterString_InactiveBack_Def },
49 { InactiveText, MUIA_Pendisplay_Spec, MUICFG_BetterString_InactiveText, 0, (APTR)CFG_BetterString_InactiveText_Def },
50 { Cursor, MUIA_Pendisplay_Spec, MUICFG_BetterString_Cursor, 0, (APTR)CFG_BetterString_Cursor_Def },
51 { MarkedBack, MUIA_Pendisplay_Spec, MUICFG_BetterString_MarkedBack, 0, (APTR)CFG_BetterString_MarkedBack_Def },
52 { MarkedText, MUIA_Pendisplay_Spec, MUICFG_BetterString_MarkedText, 0, (APTR)CFG_BetterString_MarkedText_Def },
53 { SelectOnActive, MUIA_Selected, MUICFG_BetterString_SelectOnActive, 1, (APTR)CFG_BetterString_SelectOnActive_Def },
54 { SelectPointer, MUIA_Selected, MUICFG_BetterString_SelectPointer, 1, (APTR)CFG_BetterString_SelectPointer_Def }
57 DISPATCHER(_DispatcherP)
59 struct InstData_MCP *data = (struct InstData_MCP *)INST_DATA(cl, obj);
60 IPTR result = 0;
62 ENTER();
64 switch(msg->MethodID)
66 case OM_NEW:
68 if((obj = (Object *)DoSuperMethodA(cl, obj, (Msg)msg)))
70 struct InstData_MCP *data = (struct InstData_MCP *)INST_DATA(cl, obj);
71 Object *prefsobject;
73 // everything beyond muimaster 20.5500 is considered to be MUI4
74 data->mui4x = LIB_VERSION_IS_AT_LEAST(MUIMasterBase, 20, 5500);
76 if((prefsobject = CreatePrefsGroup(data)))
78 ULONG i;
80 DoMethod(obj, OM_ADDMEMBER, prefsobject);
82 // This is MUI 3.9 stuff: Each registered object will get a context-menu, like normal pref-items
83 if(LIB_VERSION_IS_AT_LEAST(MUIMasterBase, 20, 0))
85 for(i=0; i < NumberOfObject; i++)
86 DoMethod(obj, MUIM_Mccprefs_RegisterGadget, data->Objects[PrefsInfo[i].ObjIndex], PrefsInfo[i].CfgItem, 2, NULL, PrefsInfo[i].Tag);
89 result = (IPTR)obj;
91 else
92 CoerceMethod(cl, obj, OM_DISPOSE);
95 break;
97 case MUIM_Settingsgroup_ConfigToGadgets:
99 ULONG i;
100 Object *configdata = ((struct MUIP_Settingsgroup_ConfigToGadgets *)msg)->configdata;
102 for(i=0; i < NumberOfObject; i++)
104 APTR cfg_val;
106 cfg_val = (APTR)DoMethod(configdata, MUIM_Dataspace_Find, PrefsInfo[i].CfgItem);
108 if(PrefsInfo[i].Type == 0)
110 D(DBF_STARTUP, "0 MUIM_Dataspace_Find[%ld]: %08lx : %lx / %lx", i, PrefsInfo[i].CfgItem, cfg_val, cfg_val ? cfg_val : PrefsInfo[i].DefValue);
112 nnset(data->Objects[PrefsInfo[i].ObjIndex], PrefsInfo[i].Tag, cfg_val ? cfg_val : PrefsInfo[i].DefValue);
114 else
116 D(DBF_STARTUP, "1 MUIM_Dataspace_Find[%ld]: %08lx : %P / %P", i, PrefsInfo[i].CfgItem, cfg_val, cfg_val ? *(IPTR *)cfg_val : (IPTR)PrefsInfo[i].DefValue);
118 nnset(data->Objects[PrefsInfo[i].ObjIndex], PrefsInfo[i].Tag, cfg_val ? *(IPTR *)cfg_val : (IPTR)PrefsInfo[i].DefValue);
122 break;
124 case MUIM_Settingsgroup_GadgetsToConfig:
126 ULONG i;
127 Object *configdata = ((struct MUIP_Settingsgroup_ConfigToGadgets *)msg)->configdata;
129 for(i=0; i < NumberOfObject; i++)
131 SIPTR cfg_val;
133 cfg_val = xget(data->Objects[PrefsInfo[i].ObjIndex], PrefsInfo[i].Tag);
135 if(PrefsInfo[i].Type == 0)
137 if(stricmp((char *)cfg_val, PrefsInfo[i].DefValue) != 0)
139 D(DBF_STARTUP, "0 MUIM_Dataspace_Add[%ld]: %08lx : %lx", i, PrefsInfo[i].CfgItem, cfg_val);
140 DoMethod(configdata, MUIM_Dataspace_Add, cfg_val, strlen((char *)cfg_val)+1, PrefsInfo[i].CfgItem);
142 else
144 D(DBF_STARTUP, "0 MUIM_Dataspace_Remove[%ld]: %08lx", i, PrefsInfo[i].CfgItem);
145 DoMethod(configdata, MUIM_Dataspace_Remove, PrefsInfo[i].CfgItem);
148 else
150 if(cfg_val != (SIPTR)PrefsInfo[i].DefValue)
152 D(DBF_STARTUP, "1 MUIM_Dataspace_Add[%ld]: %08lx : %lx / %lx", i, PrefsInfo[i].CfgItem, &cfg_val, cfg_val);
153 DoMethod(configdata, MUIM_Dataspace_Add, &cfg_val, sizeof(cfg_val), PrefsInfo[i].CfgItem);
155 else
157 D(DBF_STARTUP, "1 MUIM_Dataspace_Remove[%ld]: %08lx", i, PrefsInfo[i].CfgItem);
158 DoMethod(configdata, MUIM_Dataspace_Remove, PrefsInfo[i].CfgItem);
163 // erase obsolete settings
164 DoMethod(configdata, MUIM_Dataspace_Remove, MUICFG_BetterString_Font);
165 DoMethod(configdata, MUIM_Dataspace_Remove, MUICFG_BetterString_Frame);
167 break;
169 default:
170 result = DoSuperMethodA(cl, obj, msg);
171 break;
174 RETURN(result);
175 return result;