Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / classes / zune / betterstring / mcp / Dispatcher.c
blobd74f3d81aea3bc81ced9a7721a29b0b78687abc8
1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005 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"
32 #ifndef __AROS__
33 #include "muiextra.h"
34 #else
35 #define MUIM_Mccprefs_RegisterGadget 0x80424828 // V20
36 #endif
38 struct PrefsExchangeData { ULONG ObjIndex, Tag, CfgItem, Length; STRPTR DefValue; };
40 static struct PrefsExchangeData PrefsInfo[] =
42 { ActiveBack, MUIA_Imagedisplay_Spec, MUICFG_BetterString_ActiveBack, 64, "2:m1" },
43 { ActiveText, MUIA_Pendisplay_Spec, MUICFG_BetterString_ActiveText, 32, "m5" },
44 { InactiveBack, MUIA_Imagedisplay_Spec, MUICFG_BetterString_InactiveBack, 64, "2:m2" },
45 { InactiveText, MUIA_Pendisplay_Spec, MUICFG_BetterString_InactiveText, 32, "m5" },
46 { Cursor, MUIA_Pendisplay_Spec, MUICFG_BetterString_Cursor, 32, "m0" },
47 { MarkedBack, MUIA_Pendisplay_Spec, MUICFG_BetterString_MarkedBack, 32, "m6" },
48 { MarkedText, MUIA_Pendisplay_Spec, MUICFG_BetterString_MarkedText, 32, "m5" },
49 { Font, MUIA_String_Contents, MUICFG_BetterString_Font, 0, "" },
50 { Frame, MUIA_Framedisplay_Spec, MUICFG_BetterString_Frame, 32, "302211" }
53 DISPATCHERPROTO(_DispatcherP)
55 DISPATCHER_INIT
57 struct InstData_MCP *data = (struct InstData_MCP *)INST_DATA(cl, obj);
58 ULONG result = 0;
59 switch(msg->MethodID)
61 case OM_NEW:
63 if((obj = (Object *)DoSuperMethodA(cl, obj, (Msg)msg)))
65 struct InstData_MCP *data = (struct InstData_MCP *)INST_DATA(cl, obj);
67 Object *prefsobject;
68 if((prefsobject = CreatePrefsGroup(data)))
70 ULONG i;
72 DoMethod(obj, OM_ADDMEMBER, prefsobject);
74 /* This is MUI 3.9 stuff: Each registered object will get a context-menu, like normal pref-items */
75 for(i=0; i < NumberOfObject; i++)
76 DoMethod(obj, MUIM_Mccprefs_RegisterGadget, data->Objects[PrefsInfo[i].ObjIndex], PrefsInfo[i].CfgItem, 0L, NULL);
78 result = (ULONG)obj;
80 else
82 CoerceMethod(cl, obj, OM_DISPOSE);
86 break;
88 case MUIM_Settingsgroup_ConfigToGadgets:
90 ULONG i;
91 Object *configdata = ((struct MUIP_Settingsgroup_ConfigToGadgets *)msg)->configdata;
93 for(i=0; i < NumberOfObject; i++)
95 STRPTR cfg_val = (STRPTR)DoMethod(configdata, MUIM_Dataspace_Find, PrefsInfo[i].CfgItem);
96 set(data->Objects[PrefsInfo[i].ObjIndex], PrefsInfo[i].Tag, cfg_val ? cfg_val : PrefsInfo[i].DefValue);
99 break;
101 case MUIM_Settingsgroup_GadgetsToConfig:
103 ULONG i;
104 Object *configdata = ((struct MUIP_Settingsgroup_ConfigToGadgets *)msg)->configdata;
106 for(i=0; i < NumberOfObject; i++)
108 STRPTR cfg_val;
109 ULONG len;
111 #ifdef __AROS__
112 get(data->Objects[PrefsInfo[i].ObjIndex], PrefsInfo[i].Tag, &cfg_val);
113 #else
114 get(data->Objects[PrefsInfo[i].ObjIndex], PrefsInfo[i].Tag, (ULONG)&cfg_val);
115 #endif
116 len = PrefsInfo[i].Length;
118 DoMethod(configdata, MUIM_Dataspace_Add, cfg_val, len ? len : strlen(cfg_val)+1, PrefsInfo[i].CfgItem);
121 break;
123 default:
124 result = DoSuperMethodA(cl, obj, msg);
125 break;
127 return result;
129 DISPATCHER_EXIT