]> git.saurik.com Git - wxWidgets.git/blob - src/os2/settings.cpp
Add virtual ~wxAnyScrollHelperBase() to fix compiler warning.
[wxWidgets.git] / src / os2 / settings.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/settings.cpp
3 // Purpose: wxSettings
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/15/99
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifndef WX_PRECOMP
15 #include <stdio.h>
16 #include "wx/pen.h"
17 #include "wx/brush.h"
18 #include "wx/gdicmn.h"
19 #include "wx/window.h"
20 #include "wx/settings.h"
21 #include "wx/module.h"
22 #endif
23
24 #include "wx/fontutil.h"
25
26 #include "wx/os2/private.h"
27
28 // the module which is used to clean up wxSystemSettings data (this is a
29 // singleton class so it can't be done in the dtor)
30 class wxSystemSettingsModule : public wxModule
31 {
32 friend class wxSystemSettings;
33 public:
34 virtual bool OnInit();
35 virtual void OnExit();
36
37 private:
38 DECLARE_DYNAMIC_CLASS(wxSystemSettingsModule)
39
40 static wxArrayString sm_optionNames;
41 static wxArrayString sm_optionValues;
42 };
43
44 // ----------------------------------------------------------------------------
45 // global data
46 // ----------------------------------------------------------------------------
47
48 static wxFont *gs_fontDefault = NULL;
49
50 // ============================================================================
51 // implementation
52 // ============================================================================
53
54 // ----------------------------------------------------------------------------
55 // wxSystemSettingsModule
56 // ----------------------------------------------------------------------------
57
58 IMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule, wxModule)
59
60 wxArrayString wxSystemSettingsModule::sm_optionNames;
61 wxArrayString wxSystemSettingsModule::sm_optionValues;
62
63 bool wxSystemSettingsModule::OnInit()
64 {
65 return true;
66 }
67
68 void wxSystemSettingsModule::OnExit()
69 {
70 sm_optionNames.Clear();
71 sm_optionValues.Clear();
72 wxDELETE(gs_fontDefault);
73 }
74
75 wxColour wxSystemSettingsNative::GetColour(
76 wxSystemColour nIndex
77 )
78 {
79 COLORREF vRef;
80 wxColour vCol;
81 LONG vSysClr;
82 switch (nIndex)
83 {
84 //
85 // PM actually has values for these
86 //
87 case wxSYS_COLOUR_WINDOW:
88 vSysClr = SYSCLR_WINDOW;
89 break;
90
91 case wxSYS_COLOUR_WINDOWFRAME:
92 vSysClr = SYSCLR_WINDOWFRAME;
93 break;
94
95 case wxSYS_COLOUR_MENUTEXT:
96 vSysClr = SYSCLR_MENUTEXT;
97 break;
98
99 case wxSYS_COLOUR_MENUHILIGHT:
100 vSysClr = SYSCLR_MENUHILITE;
101 break;
102
103 case wxSYS_COLOUR_BTNFACE:
104 vSysClr = SYSCLR_BUTTONMIDDLE;
105 break;
106
107 case wxSYS_COLOUR_BTNSHADOW:
108 vSysClr = SYSCLR_BUTTONDARK;
109 break;
110
111 case wxSYS_COLOUR_BTNHIGHLIGHT:
112 vSysClr = SYSCLR_BUTTONLIGHT;
113 break;
114
115 case wxSYS_COLOUR_BACKGROUND:
116 vSysClr = SYSCLR_BACKGROUND;
117 break;
118
119 case wxSYS_COLOUR_APPWORKSPACE:
120 vSysClr = SYSCLR_APPWORKSPACE;
121 break;
122
123 case wxSYS_COLOUR_MENUBAR:
124 case wxSYS_COLOUR_MENU:
125 vSysClr = SYSCLR_MENU;
126 break;
127
128 case wxSYS_COLOUR_INACTIVECAPTION:
129 vSysClr = SYSCLR_INACTIVETITLE;
130 break;
131
132 case wxSYS_COLOUR_INACTIVEBORDER:
133 vSysClr = SYSCLR_INACTIVEBORDER;
134 break;
135
136 case wxSYS_COLOUR_LISTBOX:
137 vSysClr = SYSCLR_ENTRYFIELD;
138 break;
139
140 case wxSYS_COLOUR_CAPTIONTEXT:
141 vSysClr = SYSCLR_TITLETEXT;
142 break;
143
144 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
145 vSysClr = SYSCLR_INACTIVETITLETEXT;
146 break;
147
148 case wxSYS_COLOUR_WINDOWTEXT:
149 case wxSYS_COLOUR_BTNTEXT:
150 vSysClr = SYSCLR_WINDOWTEXT;
151 break;
152
153 case wxSYS_COLOUR_INFOTEXT:
154 vSysClr = SYSCLR_HELPTEXT;
155 break;
156
157 case wxSYS_COLOUR_ACTIVECAPTION:
158 vSysClr = SYSCLR_ACTIVETITLE;
159 break;
160
161 case wxSYS_COLOUR_ACTIVEBORDER:
162 vSysClr = SYSCLR_ACTIVEBORDER;
163 break;
164
165 case wxSYS_COLOUR_HIGHLIGHT:
166 vSysClr = SYSCLR_HILITEBACKGROUND;
167 break;
168
169 case wxSYS_COLOUR_SCROLLBAR:
170 vSysClr = SYSCLR_SCROLLBAR;
171 break;
172
173 case wxSYS_COLOUR_HIGHLIGHTTEXT:
174 case wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT:
175 vSysClr = SYSCLR_HILITEFOREGROUND;
176 break;
177
178 case wxSYS_COLOUR_INFOBK:
179 vSysClr = SYSCLR_HELPBACKGROUND;
180 break;
181
182 // Don't know what these should be, so leave them grey (normally)
183 case wxSYS_COLOUR_GRAYTEXT:
184 case wxSYS_COLOUR_3DDKSHADOW:
185 case wxSYS_COLOUR_3DLIGHT:
186 case wxSYS_COLOUR_HOTLIGHT:
187 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
188 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
189 vSysClr = SYSCLR_BUTTONMIDDLE;
190 break;
191
192 default:
193 vSysClr = SYSCLR_WINDOW;
194 break;
195 }
196 vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP,
197 vSysClr,
198 0L );
199 vCol.Set( GetRValue(vRef),
200 GetGValue(vRef),
201 GetBValue(vRef) );
202 return(vCol);
203 } // end of wxSystemSettingsNative::GetColour
204
205 // ----------------------------------------------------------------------------
206 // fonts
207 // ----------------------------------------------------------------------------
208
209 wxFont wxSystemSettingsNative::GetFont(
210 wxSystemFont index
211 )
212 {
213 const bool isDefaultRequested = index == wxSYS_DEFAULT_GUI_FONT;
214 if ( isDefaultRequested )
215 {
216 if ( gs_fontDefault )
217 return *gs_fontDefault;
218 }
219
220 wxFont font;
221 // FIXME: The mapping could be improved and also OS/2 system fonts
222 // should be taken into account e.g. by using PrfQueryProfileString
223 // to look for PM_System_Fonts in HINI_USERPROFILE.
224 // FIXME2: Creating a font from the native font info does not
225 // seem to work properly.
226 switch (index)
227 {
228 case wxSYS_SYSTEM_FIXED_FONT:
229 case wxSYS_OEM_FIXED_FONT:
230 case wxSYS_ANSI_FIXED_FONT:
231 font.Create( 10,
232 wxFONTFAMILY_TELETYPE,
233 wxFONTSTYLE_NORMAL,
234 wxFONTWEIGHT_NORMAL );
235 break;
236 case wxSYS_ANSI_VAR_FONT:
237 font.Create( 10,
238 wxFONTFAMILY_MODERN,
239 wxFONTSTYLE_NORMAL,
240 wxFONTWEIGHT_NORMAL );
241 break;
242 case wxSYS_SYSTEM_FONT:
243 case wxSYS_DEFAULT_GUI_FONT:
244 font.Create( 10,
245 wxFONTFAMILY_SWISS,
246 wxFONTSTYLE_NORMAL,
247 wxFONTWEIGHT_NORMAL );
248 break;
249 default:
250 wxFAIL_MSG( wxT("stock font not found") );
251 return GetFont(wxSYS_ANSI_VAR_FONT);
252 }
253
254
255 if ( isDefaultRequested )
256 {
257 // if we got here it means we hadn't cached it yet - do now
258 gs_fontDefault = new wxFont(font);
259 }
260
261 return font;
262 }
263
264 // Get a system metric, e.g. scrollbar size
265 int wxSystemSettingsNative::GetMetric( wxSystemMetric index,
266 wxWindow* WXUNUSED(win) )
267 {
268 switch ( index)
269 {
270 // TODO case wxSYS_MOUSE_BUTTONS:
271 // TODO case wxSYS_BORDER_X:
272 // TODO case wxSYS_BORDER_Y:
273 // TODO case wxSYS_CURSOR_X:
274 // TODO case wxSYS_CURSOR_Y:
275 // TODO case wxSYS_DCLICK_X:
276 // TODO case wxSYS_DCLICK_Y:
277 // TODO case wxSYS_DRAG_X:
278 // TODO case wxSYS_DRAG_Y:
279 // TODO case wxSYS_EDGE_X:
280 // TODO case wxSYS_EDGE_Y:
281 // TODO case wxSYS_HSCROLL_ARROW_X:
282 // TODO case wxSYS_HSCROLL_ARROW_Y:
283 // TODO case wxSYS_HTHUMB_X:
284 // TODO case wxSYS_ICON_X:
285 // TODO case wxSYS_ICON_Y:
286 // TODO case wxSYS_ICONSPACING_X:
287 // TODO case wxSYS_ICONSPACING_Y:
288 // TODO case wxSYS_WINDOWMIN_X:
289 // TODO case wxSYS_WINDOWMIN_Y:
290
291 case wxSYS_SCREEN_X:
292 return ::WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN);
293 case wxSYS_SCREEN_Y:
294 return ::WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN);
295
296 // TODO case wxSYS_FRAMESIZE_X:
297 // TODO case wxSYS_FRAMESIZE_Y:
298 // TODO case wxSYS_SMALLICON_X:
299 // TODO case wxSYS_SMALLICON_Y:
300
301 case wxSYS_HSCROLL_Y:
302 return ::WinQuerySysValue(HWND_DESKTOP,SV_CYHSCROLL);
303 case wxSYS_VSCROLL_X:
304 return ::WinQuerySysValue(HWND_DESKTOP,SV_CXVSCROLL);
305
306 // TODO case wxSYS_VSCROLL_ARROW_X:
307 // TODO case wxSYS_VSCROLL_ARROW_Y:
308 // TODO case wxSYS_VTHUMB_Y:
309 // TODO case wxSYS_CAPTION_Y:
310 // TODO case wxSYS_MENU_Y:
311 // TODO case wxSYS_NETWORK_PRESENT:
312 // TODO case wxSYS_PENWINDOWS_PRESENT:
313 // TODO case wxSYS_SHOW_SOUNDS:
314 // TODO case wxSYS_SWAP_BUTTONS:
315
316 default:
317 break;
318 }
319 return -1; // unsupported metric
320 }
321
322 bool wxSystemSettingsNative::HasFeature( wxSystemFeature index )
323 {
324 switch (index)
325 {
326 case wxSYS_CAN_ICONIZE_FRAME:
327 return true;
328
329 // TODO case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
330 // TODO case wxSYS_TABLET_PRESENT:
331
332 default:
333 break;
334 }
335
336 return false;
337 }