Applied patch [ 584885 ] better colour handling in motif
[wxWidgets.git] / src / motif / settings.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: motif/settings.cpp
3 // Purpose: wxSettings
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // TODO: these settings should probably be configurable from some central or
13 // per-user file, which can be edited using a Windows-control-panel clone.
14 // Also they should be documented better. Some are very MS Windows-ish.
15
16 #ifdef __GNUG__
17 #pragma implementation "settings.h"
18 #endif
19
20 #include "wx/settings.h"
21 #include "wx/gdicmn.h"
22 #include "wx/app.h"
23
24 #ifdef __VMS__
25 #pragma message disable nosimpint
26 #endif
27 #include <Xm/Xm.h>
28 #include <Xm/PushB.h>
29 #ifdef __VMS__
30 #pragma message enable nosimpint
31 #endif
32
33 // To correctly read the resources from the database, we create a
34 // sample widget. This has the application shell as the parent and
35 // so will be destroyed when the applicaion is closed.
36 static Widget but_setting_wid = NULL;
37
38 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
39 {
40 if (NULL == but_setting_wid && wxTheApp && wxTheApp->GetTopLevelWidget())
41 {
42 but_setting_wid = XtVaCreateWidget("settings_button", xmPushButtonWidgetClass,
43 (Widget)wxTheApp->GetTopLevelWidget(), NULL);
44 }
45
46 switch (index)
47 {
48 case wxSYS_COLOUR_WINDOW:
49 {
50 return *wxWHITE;
51 }
52 case wxSYS_COLOUR_SCROLLBAR:
53 // case wxSYS_COLOUR_DESKTOP: // Same as wxSYS_COLOUR_BACKGROUND
54 case wxSYS_COLOUR_BACKGROUND:
55 case wxSYS_COLOUR_ACTIVECAPTION:
56 case wxSYS_COLOUR_INACTIVECAPTION:
57 case wxSYS_COLOUR_MENU:
58 case wxSYS_COLOUR_MENUBAR:
59 case wxSYS_COLOUR_WINDOWFRAME:
60 case wxSYS_COLOUR_ACTIVEBORDER:
61 case wxSYS_COLOUR_INACTIVEBORDER:
62 case wxSYS_COLOUR_BTNFACE:
63 // case wxSYS_COLOUR_3DFACE: // Same as wxSYS_COLOUR_BTNFACE
64 case wxSYS_COLOUR_GRAYTEXT:
65 {
66 if (but_setting_wid)
67 {
68 XColor bg;
69 XtVaGetValues(but_setting_wid,
70 XtVaTypedArg, XmNbackground, XtRColor, &bg, sizeof(bg),
71 NULL);
72 return wxColor(bg.red >> 8, bg.green >> 8, bg.blue >> 8);
73 }
74 else
75 {
76 return wxColour("LIGHT GREY");
77 }
78 }
79 case wxSYS_COLOUR_BTNSHADOW:
80 // case wxSYS_COLOUR_3DSHADOW: // Same as wxSYS_COLOUR_BTNSHADOW
81 {
82 return wxColour("GREY");
83 }
84 case wxSYS_COLOUR_3DDKSHADOW:
85 {
86 return *wxBLACK;
87 }
88 case wxSYS_COLOUR_HIGHLIGHT:
89 {
90 return *wxBLUE;
91 }
92 case wxSYS_COLOUR_BTNHIGHLIGHT:
93 case wxSYS_COLOUR_LISTBOX:
94 // case wxSYS_COLOUR_3DHIGHLIGHT: // Same as wxSYS_COLOUR_BTNHIGHLIGHT
95 {
96 return *wxWHITE;
97 }
98 case wxSYS_COLOUR_3DLIGHT:
99 {
100 return wxColour("LIGHT GREY");
101 }
102 case wxSYS_COLOUR_MENUTEXT:
103 case wxSYS_COLOUR_WINDOWTEXT:
104 case wxSYS_COLOUR_CAPTIONTEXT:
105 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
106 case wxSYS_COLOUR_BTNTEXT:
107 case wxSYS_COLOUR_INFOTEXT:
108 {
109 if (but_setting_wid)
110 {
111 XColor fg;
112 XtVaGetValues(but_setting_wid,
113 XtVaTypedArg, XmNforeground, XtRColor, &fg, sizeof(fg),
114 NULL);
115 return wxColor(fg.red >> 8, fg.green >> 8, fg.blue >> 8);
116 }
117 else
118 {
119 return *wxBLACK;
120 }
121 }
122 case wxSYS_COLOUR_HIGHLIGHTTEXT:
123 {
124 return *wxWHITE;
125 }
126 case wxSYS_COLOUR_INFOBK:
127 case wxSYS_COLOUR_APPWORKSPACE:
128 {
129 if (but_setting_wid)
130 {
131 XColor bg;
132 XtVaGetValues(but_setting_wid,
133 XtVaTypedArg, XmNbackground, XtRColor, &bg, sizeof(bg),
134 NULL);
135 return wxColor(bg.red >> 8, bg.green >> 8, bg.blue >> 8);
136 }
137 else
138 {
139 return wxColour("LIGHT GREY");
140 }
141 }
142
143 case wxSYS_COLOUR_HOTLIGHT:
144 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
145 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
146 case wxSYS_COLOUR_MENUHILIGHT:
147 // TODO
148 return wxColour("LIGHT GREY");
149
150 default:
151 case wxSYS_COLOUR_MAX:
152 wxFAIL_MSG( _T("unknown colour") );
153 }
154 return *wxWHITE;
155 }
156
157 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
158 {
159 switch (index)
160 {
161 case wxSYS_SYSTEM_FIXED_FONT:
162 {
163 return wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, FALSE);
164 break;
165 }
166 case wxSYS_DEVICE_DEFAULT_FONT:
167 case wxSYS_SYSTEM_FONT:
168 case wxSYS_DEFAULT_GUI_FONT:
169 default:
170 {
171 return wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE);
172 break;
173 }
174 }
175
176 return wxFont();
177 }
178
179 // Get a system metric, e.g. scrollbar size
180 int wxSystemSettingsNative::GetMetric(wxSystemMetric index)
181 {
182 switch ( index)
183 {
184 case wxSYS_MOUSE_BUTTONS:
185 // TODO
186 case wxSYS_BORDER_X:
187 // TODO
188 case wxSYS_BORDER_Y:
189 // TODO
190 case wxSYS_CURSOR_X:
191 // TODO
192 case wxSYS_CURSOR_Y:
193 // TODO
194 case wxSYS_DCLICK_X:
195 // TODO
196 case wxSYS_DCLICK_Y:
197 // TODO
198 case wxSYS_DRAG_X:
199 // TODO
200 case wxSYS_DRAG_Y:
201 // TODO
202 case wxSYS_EDGE_X:
203 // TODO
204 case wxSYS_EDGE_Y:
205 // TODO
206 case wxSYS_HSCROLL_ARROW_X:
207 // TODO
208 case wxSYS_HSCROLL_ARROW_Y:
209 // TODO
210 case wxSYS_HTHUMB_X:
211 // TODO
212 case wxSYS_ICON_X:
213 // TODO
214 case wxSYS_ICON_Y:
215 // TODO
216 case wxSYS_ICONSPACING_X:
217 // TODO
218 case wxSYS_ICONSPACING_Y:
219 // TODO
220 case wxSYS_WINDOWMIN_X:
221 // TODO
222 case wxSYS_WINDOWMIN_Y:
223 // TODO
224 case wxSYS_SCREEN_X:
225 // TODO
226 case wxSYS_SCREEN_Y:
227 // TODO
228 case wxSYS_FRAMESIZE_X:
229 // TODO
230 case wxSYS_FRAMESIZE_Y:
231 // TODO
232 case wxSYS_SMALLICON_X:
233 // TODO
234 case wxSYS_SMALLICON_Y:
235 // TODO
236 case wxSYS_HSCROLL_Y:
237 // TODO
238 case wxSYS_VSCROLL_X:
239 // TODO
240 case wxSYS_VSCROLL_ARROW_X:
241 // TODO
242 case wxSYS_VSCROLL_ARROW_Y:
243 // TODO
244 case wxSYS_VTHUMB_Y:
245 // TODO
246 case wxSYS_CAPTION_Y:
247 // TODO
248 case wxSYS_MENU_Y:
249 // TODO
250 case wxSYS_NETWORK_PRESENT:
251 // TODO
252 case wxSYS_PENWINDOWS_PRESENT:
253 // TODO
254 case wxSYS_SHOW_SOUNDS:
255 // TODO
256 case wxSYS_SWAP_BUTTONS:
257 // TODO
258 default:
259 ;
260 }
261
262 return 0;
263 }
264
265 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
266 {
267 switch (index)
268 {
269 case wxSYS_CAN_ICONIZE_FRAME:
270 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
271 return TRUE;
272
273 default:
274 return FALSE;
275 }
276 }