grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / betterstring / mcc / InitConfig.c
blob44c17a581071c486ceb5719720fabdb3f24e7dff
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>
25 #include <clib/alib_protos.h>
26 #include <proto/intuition.h>
27 #include <proto/muimaster.h>
28 #include <proto/graphics.h>
29 #include <proto/diskfont.h>
30 #include <proto/dos.h>
32 #include "BetterString_mcp.h"
33 #include "private.h"
35 #include "Debug.h"
37 static ULONG GetCol(Object *obj, ULONG item, struct MUI_PenSpec *defaultcol)
39 struct MUI_PenSpec *spec;
41 if(DoMethod(obj, MUIM_GetConfigItem, item, &spec) == 0)
42 spec = defaultcol;
44 return MUI_ObtainPen(muiRenderInfo(obj), spec, 0L);
47 void InitConfig(Object *obj, struct InstData *data)
49 IPTR setting;
51 ENTER();
53 data->InactiveText = GetCol(obj, MUICFG_BetterString_InactiveText, (struct MUI_PenSpec *)CFG_BetterString_InactiveText_Def);
54 data->ActiveText = GetCol(obj, MUICFG_BetterString_ActiveText, (struct MUI_PenSpec *)CFG_BetterString_ActiveText_Def);
55 data->CursorColor = GetCol(obj, MUICFG_BetterString_Cursor, (struct MUI_PenSpec *)CFG_BetterString_Cursor_Def);
56 data->MarkedColor = GetCol(obj, MUICFG_BetterString_MarkedBack, (struct MUI_PenSpec *)CFG_BetterString_MarkedBack_Def);
57 data->MarkedTextColor = GetCol(obj, MUICFG_BetterString_MarkedText, (struct MUI_PenSpec *)CFG_BetterString_MarkedText_Def);
59 if(DoMethod(obj, MUIM_GetConfigItem, MUICFG_BetterString_InactiveBack, &setting))
61 // don't remember the string from the configuration but copy it
62 // with MUI4's realtime prefs the configuration might change upon
63 // canceling MUI prefs and hence we would operate on invalid data.
64 strlcpy(data->InactiveBackgroundBuffer, (STRPTR)setting, sizeof(data->InactiveBackgroundBuffer));
65 data->InactiveBackground = data->InactiveBackgroundBuffer;
67 else
68 data->InactiveBackground = (STRPTR)CFG_BetterString_InactiveBack_Def;
70 if(DoMethod(obj, MUIM_GetConfigItem, MUICFG_BetterString_ActiveBack, &setting))
72 // don't remember the string from the configuration but copy it
73 // with MUI4's realtime prefs the configuration might change upon
74 // canceling MUI prefs and hence we would operate on invalid data.
75 strlcpy(data->ActiveBackgroundBuffer, (STRPTR)setting, sizeof(data->ActiveBackgroundBuffer));
76 data->ActiveBackground = data->ActiveBackgroundBuffer;
78 else
79 data->ActiveBackground = (STRPTR)CFG_BetterString_ActiveBack_Def;
81 if(DoMethod(obj, MUIM_GetConfigItem, MUICFG_BetterString_SelectOnActive, &setting))
82 data->SelectOnActive = *(IPTR*)setting;
83 else
84 data->SelectOnActive = CFG_BetterString_SelectOnActive_Def;
86 if(DoMethod(obj, MUIM_GetConfigItem, MUICFG_BetterString_SelectPointer, &setting))
87 data->SelectPointer = *(IPTR*)setting;
88 else
89 data->SelectPointer = CFG_BetterString_SelectPointer_Def;
91 if(isFlagSet(data->Flags, FLG_OwnBackground))
92 set(obj, MUIA_Background, data->OwnBackground);
93 else if(data->mui4x == TRUE)
94 set(obj, MUIA_Background, MUII_StringBack);
95 else
96 set(obj, MUIA_Background, data->InactiveBackground);
98 LEAVE();
101 VOID FreeConfig(struct MUI_RenderInfo *mri, struct InstData *data)
103 ENTER();
105 MUI_ReleasePen(mri, data->InactiveText);
106 MUI_ReleasePen(mri, data->ActiveText);
107 MUI_ReleasePen(mri, data->CursorColor);
108 MUI_ReleasePen(mri, data->MarkedColor);
109 MUI_ReleasePen(mri, data->MarkedTextColor);
111 LEAVE();