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