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/
21 ***************************************************************************/
24 #include <clib/alib_protos.h>
25 #include <proto/intuition.h>
26 #include <proto/muimaster.h>
27 #include <libraries/mui.h>
30 #include "BetterString_mcp.h"
35 #define MUIM_Mccprefs_RegisterGadget 0x80424828 // V20
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
)
57 struct InstData_MCP
*data
= (struct InstData_MCP
*)INST_DATA(cl
, obj
);
63 if((obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
)))
65 struct InstData_MCP
*data
= (struct InstData_MCP
*)INST_DATA(cl
, obj
);
68 if((prefsobject
= CreatePrefsGroup(data
)))
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
);
82 CoerceMethod(cl
, obj
, OM_DISPOSE
);
88 case MUIM_Settingsgroup_ConfigToGadgets
:
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
);
101 case MUIM_Settingsgroup_GadgetsToConfig
:
104 Object
*configdata
= ((struct MUIP_Settingsgroup_ConfigToGadgets
*)msg
)->configdata
;
106 for(i
=0; i
< NumberOfObject
; i
++)
112 get(data
->Objects
[PrefsInfo
[i
].ObjIndex
], PrefsInfo
[i
].Tag
, &cfg_val
);
114 get(data
->Objects
[PrefsInfo
[i
].ObjIndex
], PrefsInfo
[i
].Tag
, (ULONG
)&cfg_val
);
116 len
= PrefsInfo
[i
].Length
;
118 DoMethod(configdata
, MUIM_Dataspace_Add
, cfg_val
, len
? len
: strlen(cfg_val
)+1, PrefsInfo
[i
].CfgItem
);
124 result
= DoSuperMethodA(cl
, obj
, msg
);