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