]>
Commit | Line | Data |
---|---|---|
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 | |
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 | ||
14f355c2 | 16 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
4bb6408c JS |
17 | #pragma implementation "settings.h" |
18 | #endif | |
19 | ||
1248b41f MB |
20 | // For compilers that support precompilation, includes "wx.h". |
21 | #include "wx/wxprec.h" | |
22 | ||
4bb6408c | 23 | #include "wx/settings.h" |
e97f20a0 | 24 | #include "wx/gdicmn.h" |
edc1cd8b JS |
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 | ||
4b7f540b MB |
36 | #include "wx/x11/privx.h" |
37 | ||
edc1cd8b JS |
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; | |
4bb6408c | 42 | |
a103111b | 43 | wxColour wxSystemSettingsNative::GetColour(wxSystemColour index) |
4bb6408c | 44 | { |
edc1cd8b JS |
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 | ||
e97f20a0 JS |
51 | switch (index) |
52 | { | |
3d1b4196 MB |
53 | case wxSYS_COLOUR_WINDOW: |
54 | { | |
55 | return *wxWHITE; | |
56 | } | |
e97f20a0 JS |
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: | |
edc1cd8b | 63 | case wxSYS_COLOUR_MENUBAR: |
e97f20a0 JS |
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 | { | |
edc1cd8b JS |
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 | } | |
e97f20a0 JS |
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: | |
3d1b4196 MB |
94 | { |
95 | return *wxBLUE; | |
96 | } | |
e97f20a0 | 97 | case wxSYS_COLOUR_BTNHIGHLIGHT: |
a103111b GD |
98 | case wxSYS_COLOUR_LISTBOX: |
99 | // case wxSYS_COLOUR_3DHIGHLIGHT: // Same as wxSYS_COLOUR_BTNHIGHLIGHT | |
e97f20a0 JS |
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: | |
a103111b | 111 | case wxSYS_COLOUR_BTNTEXT: |
e97f20a0 JS |
112 | case wxSYS_COLOUR_INFOTEXT: |
113 | { | |
edc1cd8b JS |
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 | } | |
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); | |
140 | return wxColor(bg.red >> 8, bg.green >> 8, bg.blue >> 8); | |
141 | } | |
142 | else | |
143 | { | |
144 | return wxColour("LIGHT GREY"); | |
145 | } | |
e97f20a0 | 146 | } |
1abfd7f3 VZ |
147 | |
148 | case wxSYS_COLOUR_HOTLIGHT: | |
149 | case wxSYS_COLOUR_GRADIENTACTIVECAPTION: | |
150 | case wxSYS_COLOUR_GRADIENTINACTIVECAPTION: | |
151 | case wxSYS_COLOUR_MENUHILIGHT: | |
1abfd7f3 VZ |
152 | // TODO |
153 | return wxColour("LIGHT GREY"); | |
154 | ||
155 | default: | |
156 | case wxSYS_COLOUR_MAX: | |
157 | wxFAIL_MSG( _T("unknown colour") ); | |
e97f20a0 JS |
158 | } |
159 | return *wxWHITE; | |
4bb6408c JS |
160 | } |
161 | ||
a103111b | 162 | wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) |
4bb6408c | 163 | { |
996994c7 MB |
164 | int pointSize = 12; |
165 | ||
166 | if ( wxFont::GetDefaultEncoding() == wxFONTENCODING_SHIFT_JIS | |
167 | || wxFont::GetDefaultEncoding() == wxFONTENCODING_EUC_JP) | |
168 | pointSize = 15; | |
169 | ||
16c1f7f3 JS |
170 | switch (index) |
171 | { | |
16c1f7f3 JS |
172 | case wxSYS_SYSTEM_FIXED_FONT: |
173 | { | |
996994c7 | 174 | return wxFont(pointSize, wxMODERN, wxNORMAL, wxNORMAL, false); |
16c1f7f3 JS |
175 | break; |
176 | } | |
e97f20a0 | 177 | case wxSYS_DEVICE_DEFAULT_FONT: |
16c1f7f3 | 178 | case wxSYS_SYSTEM_FONT: |
16c1f7f3 | 179 | case wxSYS_DEFAULT_GUI_FONT: |
e97f20a0 | 180 | default: |
16c1f7f3 | 181 | { |
996994c7 | 182 | return wxFont(pointSize, wxSWISS, wxNORMAL, wxNORMAL, false); |
16c1f7f3 JS |
183 | break; |
184 | } | |
185 | } | |
186 | ||
4bb6408c JS |
187 | return wxFont(); |
188 | } | |
189 | ||
190 | // Get a system metric, e.g. scrollbar size | |
9b0b5ba7 | 191 | int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win)) |
4bb6408c | 192 | { |
178edd2a MB |
193 | int return_value = 0; |
194 | ||
0af4b6e4 VZ |
195 | switch ( index) |
196 | { | |
e1aae528 MB |
197 | case wxSYS_HSCROLL_Y: |
198 | case wxSYS_VSCROLL_X: | |
199 | return 15; | |
1d451c5b | 200 | |
4bb6408c | 201 | case wxSYS_SCREEN_X: |
178edd2a MB |
202 | return_value = DisplayWidth( wxGlobalDisplay(), 0 ); |
203 | break; | |
4bb6408c | 204 | case wxSYS_SCREEN_Y: |
178edd2a MB |
205 | return_value = DisplayHeight( wxGlobalDisplay(), 0 ); |
206 | break; | |
1d451c5b RD |
207 | |
208 | // TODO case wxSYS_MOUSE_BUTTONS: | |
209 | // TODO case wxSYS_BORDER_X: | |
210 | // TODO case wxSYS_BORDER_Y: | |
211 | // TODO case wxSYS_CURSOR_X: | |
212 | // TODO case wxSYS_CURSOR_Y: | |
213 | // TODO case wxSYS_DCLICK_X: | |
214 | // TODO case wxSYS_DCLICK_Y: | |
215 | // TODO case wxSYS_DRAG_X: | |
216 | // TODO case wxSYS_DRAG_Y: | |
217 | // TODO case wxSYS_EDGE_X: | |
218 | // TODO case wxSYS_EDGE_Y: | |
219 | // TODO case wxSYS_HSCROLL_ARROW_X: | |
220 | // TODO case wxSYS_HSCROLL_ARROW_Y: | |
221 | // TODO case wxSYS_HTHUMB_X: | |
222 | // TODO case wxSYS_ICON_X: | |
223 | // TODO case wxSYS_ICON_Y: | |
224 | // TODO case wxSYS_ICONSPACING_X: | |
225 | // TODO case wxSYS_ICONSPACING_Y: | |
226 | // TODO case wxSYS_WINDOWMIN_X: | |
227 | // TODO case wxSYS_WINDOWMIN_Y: | |
228 | // TODO case wxSYS_FRAMESIZE_X: | |
229 | // TODO case wxSYS_FRAMESIZE_Y: | |
230 | // TODO case wxSYS_SMALLICON_X: | |
231 | // TODO case wxSYS_SMALLICON_Y: | |
232 | // TODO case wxSYS_VSCROLL_ARROW_X: | |
233 | // TODO case wxSYS_VSCROLL_ARROW_Y: | |
234 | // TODO case wxSYS_VTHUMB_Y: | |
235 | // TODO case wxSYS_CAPTION_Y: | |
236 | // TODO case wxSYS_MENU_Y: | |
237 | // TODO case wxSYS_NETWORK_PRESENT: | |
238 | // TODO case wxSYS_PENWINDOWS_PRESENT: | |
239 | // TODO case wxSYS_SHOW_SOUNDS: | |
240 | // TODO case wxSYS_SWAP_BUTTONS: | |
241 | ||
a103111b | 242 | default: |
1d451c5b | 243 | return_value = -1; // unsuported metric |
a103111b | 244 | } |
0af4b6e4 | 245 | |
178edd2a | 246 | return return_value; |
4bb6408c JS |
247 | } |
248 | ||
a103111b | 249 | bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) |
253293c1 VS |
250 | { |
251 | switch (index) | |
252 | { | |
0af4b6e4 | 253 | case wxSYS_CAN_ICONIZE_FRAME: |
253293c1 | 254 | case wxSYS_CAN_DRAW_FRAME_DECORATIONS: |
96be256b | 255 | return true; |
0af4b6e4 | 256 | |
253293c1 | 257 | default: |
96be256b | 258 | return false; |
253293c1 VS |
259 | } |
260 | } |