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