]> git.saurik.com Git - wxWidgets.git/blame - src/motif/settings.cpp
compilation fix for Mac and reformatted the code
[wxWidgets.git] / src / motif / settings.cpp
CommitLineData
4bb6408c 1/////////////////////////////////////////////////////////////////////////////
0af4b6e4 2// Name: motif/settings.cpp
4bb6408c
JS
3// Purpose: wxSettings
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
0af4b6e4 9// Licence: wxWindows licence
4bb6408c
JS
10/////////////////////////////////////////////////////////////////////////////
11
16c1f7f3
JS
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
4bb6408c
JS
16#ifdef __GNUG__
17#pragma implementation "settings.h"
18#endif
19
20#include "wx/settings.h"
e97f20a0 21#include "wx/gdicmn.h"
edc1cd8b
JS
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.
36static Widget but_setting_wid = NULL;
4bb6408c 37
a103111b 38wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
4bb6408c 39{
edc1cd8b
JS
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
e97f20a0
JS
46 switch (index)
47 {
3d1b4196
MB
48 case wxSYS_COLOUR_WINDOW:
49 {
50 return *wxWHITE;
51 }
e97f20a0
JS
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:
edc1cd8b 58 case wxSYS_COLOUR_MENUBAR:
e97f20a0
JS
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 {
edc1cd8b
JS
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 }
e97f20a0
JS
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:
3d1b4196
MB
89 {
90 return *wxBLUE;
91 }
e97f20a0 92 case wxSYS_COLOUR_BTNHIGHLIGHT:
a103111b
GD
93 case wxSYS_COLOUR_LISTBOX:
94 // case wxSYS_COLOUR_3DHIGHLIGHT: // Same as wxSYS_COLOUR_BTNHIGHLIGHT
e97f20a0
JS
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:
a103111b 106 case wxSYS_COLOUR_BTNTEXT:
e97f20a0
JS
107 case wxSYS_COLOUR_INFOTEXT:
108 {
edc1cd8b
JS
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 }
e97f20a0
JS
121 }
122 case wxSYS_COLOUR_HIGHLIGHTTEXT:
123 {
3d1b4196 124 return *wxWHITE;
e97f20a0
JS
125 }
126 case wxSYS_COLOUR_INFOBK:
127 case wxSYS_COLOUR_APPWORKSPACE:
128 {
edc1cd8b
JS
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 }
e97f20a0 141 }
1abfd7f3
VZ
142
143 case wxSYS_COLOUR_HOTLIGHT:
144 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
145 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
146 case wxSYS_COLOUR_MENUHILIGHT:
1abfd7f3
VZ
147 // TODO
148 return wxColour("LIGHT GREY");
149
150 default:
151 case wxSYS_COLOUR_MAX:
152 wxFAIL_MSG( _T("unknown colour") );
e97f20a0
JS
153 }
154 return *wxWHITE;
4bb6408c
JS
155}
156
a103111b 157wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
4bb6408c 158{
16c1f7f3
JS
159 switch (index)
160 {
16c1f7f3
JS
161 case wxSYS_SYSTEM_FIXED_FONT:
162 {
e97f20a0 163 return wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, FALSE);
16c1f7f3
JS
164 break;
165 }
e97f20a0 166 case wxSYS_DEVICE_DEFAULT_FONT:
16c1f7f3 167 case wxSYS_SYSTEM_FONT:
16c1f7f3 168 case wxSYS_DEFAULT_GUI_FONT:
e97f20a0 169 default:
16c1f7f3 170 {
e97f20a0 171 return wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE);
16c1f7f3
JS
172 break;
173 }
174 }
175
4bb6408c
JS
176 return wxFont();
177}
178
179// Get a system metric, e.g. scrollbar size
a103111b 180int wxSystemSettingsNative::GetMetric(wxSystemMetric index)
4bb6408c 181{
0af4b6e4
VZ
182 switch ( index)
183 {
e1aae528
MB
184 case wxSYS_HSCROLL_Y:
185 case wxSYS_VSCROLL_X:
186 return 15;
4bb6408c
JS
187 case wxSYS_MOUSE_BUTTONS:
188 // TODO
4bb6408c
JS
189 case wxSYS_BORDER_X:
190 // TODO
4bb6408c
JS
191 case wxSYS_BORDER_Y:
192 // TODO
4bb6408c
JS
193 case wxSYS_CURSOR_X:
194 // TODO
4bb6408c
JS
195 case wxSYS_CURSOR_Y:
196 // TODO
4bb6408c
JS
197 case wxSYS_DCLICK_X:
198 // TODO
4bb6408c
JS
199 case wxSYS_DCLICK_Y:
200 // TODO
4bb6408c
JS
201 case wxSYS_DRAG_X:
202 // TODO
4bb6408c
JS
203 case wxSYS_DRAG_Y:
204 // TODO
4bb6408c
JS
205 case wxSYS_EDGE_X:
206 // TODO
4bb6408c
JS
207 case wxSYS_EDGE_Y:
208 // TODO
4bb6408c
JS
209 case wxSYS_HSCROLL_ARROW_X:
210 // TODO
4bb6408c
JS
211 case wxSYS_HSCROLL_ARROW_Y:
212 // TODO
4bb6408c
JS
213 case wxSYS_HTHUMB_X:
214 // TODO
4bb6408c
JS
215 case wxSYS_ICON_X:
216 // TODO
4bb6408c
JS
217 case wxSYS_ICON_Y:
218 // TODO
4bb6408c
JS
219 case wxSYS_ICONSPACING_X:
220 // TODO
4bb6408c
JS
221 case wxSYS_ICONSPACING_Y:
222 // TODO
4bb6408c
JS
223 case wxSYS_WINDOWMIN_X:
224 // TODO
4bb6408c
JS
225 case wxSYS_WINDOWMIN_Y:
226 // TODO
4bb6408c
JS
227 case wxSYS_SCREEN_X:
228 // TODO
4bb6408c
JS
229 case wxSYS_SCREEN_Y:
230 // TODO
4bb6408c
JS
231 case wxSYS_FRAMESIZE_X:
232 // TODO
4bb6408c
JS
233 case wxSYS_FRAMESIZE_Y:
234 // TODO
4bb6408c
JS
235 case wxSYS_SMALLICON_X:
236 // TODO
4bb6408c
JS
237 case wxSYS_SMALLICON_Y:
238 // TODO
4bb6408c
JS
239 case wxSYS_VSCROLL_ARROW_X:
240 // TODO
4bb6408c
JS
241 case wxSYS_VSCROLL_ARROW_Y:
242 // TODO
4bb6408c
JS
243 case wxSYS_VTHUMB_Y:
244 // TODO
4bb6408c
JS
245 case wxSYS_CAPTION_Y:
246 // TODO
4bb6408c
JS
247 case wxSYS_MENU_Y:
248 // TODO
4bb6408c
JS
249 case wxSYS_NETWORK_PRESENT:
250 // TODO
4bb6408c
JS
251 case wxSYS_PENWINDOWS_PRESENT:
252 // TODO
4bb6408c
JS
253 case wxSYS_SHOW_SOUNDS:
254 // TODO
4bb6408c
JS
255 case wxSYS_SWAP_BUTTONS:
256 // TODO
a103111b 257 default:
0af4b6e4 258 ;
a103111b 259 }
0af4b6e4
VZ
260
261 return 0;
4bb6408c
JS
262}
263
a103111b 264bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
253293c1
VS
265{
266 switch (index)
267 {
0af4b6e4 268 case wxSYS_CAN_ICONIZE_FRAME:
253293c1 269 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
a103111b 270 return TRUE;
0af4b6e4 271
253293c1
VS
272 default:
273 return FALSE;
274 }
275}