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