1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/settings.cpp
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #include "wx/gdicmn.h"
20 #include "wx/window.h"
21 #include "wx/settings.h"
22 #include "wx/module.h"
25 #include "wx/fontutil.h"
27 #include "wx/os2/private.h"
29 // the module which is used to clean up wxSystemSettings data (this is a
30 // singleton class so it can't be done in the dtor)
31 class wxSystemSettingsModule
: public wxModule
33 friend class wxSystemSettings
;
35 virtual bool OnInit();
36 virtual void OnExit();
39 DECLARE_DYNAMIC_CLASS(wxSystemSettingsModule
)
41 static wxArrayString sm_optionNames
;
42 static wxArrayString sm_optionValues
;
45 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
49 static wxFont
*gs_fontDefault
= NULL
;
51 // ============================================================================
53 // ============================================================================
55 // ----------------------------------------------------------------------------
56 // wxSystemSettingsModule
57 // ----------------------------------------------------------------------------
59 IMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule
, wxModule
)
61 wxArrayString
wxSystemSettingsModule::sm_optionNames
;
62 wxArrayString
wxSystemSettingsModule::sm_optionValues
;
64 bool wxSystemSettingsModule::OnInit()
69 void wxSystemSettingsModule::OnExit()
71 sm_optionNames
.Clear();
72 sm_optionValues
.Clear();
73 wxDELETE(gs_fontDefault
);
76 wxColour
wxSystemSettingsNative::GetColour(
86 // PM actually has values for these
88 case wxSYS_COLOUR_WINDOW
:
89 vSysClr
= SYSCLR_WINDOW
;
92 case wxSYS_COLOUR_WINDOWFRAME
:
93 vSysClr
= SYSCLR_WINDOWFRAME
;
96 case wxSYS_COLOUR_MENUTEXT
:
97 vSysClr
= SYSCLR_MENUTEXT
;
100 case wxSYS_COLOUR_MENUHILIGHT
:
101 vSysClr
= SYSCLR_MENUHILITE
;
104 case wxSYS_COLOUR_BTNFACE
:
105 vSysClr
= SYSCLR_BUTTONMIDDLE
;
108 case wxSYS_COLOUR_BTNSHADOW
:
109 vSysClr
= SYSCLR_BUTTONDARK
;
112 case wxSYS_COLOUR_BTNHIGHLIGHT
:
113 vSysClr
= SYSCLR_BUTTONLIGHT
;
116 case wxSYS_COLOUR_BACKGROUND
:
117 vSysClr
= SYSCLR_BACKGROUND
;
120 case wxSYS_COLOUR_APPWORKSPACE
:
121 vSysClr
= SYSCLR_APPWORKSPACE
;
124 case wxSYS_COLOUR_MENUBAR
:
125 case wxSYS_COLOUR_MENU
:
126 vSysClr
= SYSCLR_MENU
;
129 case wxSYS_COLOUR_INACTIVECAPTION
:
130 vSysClr
= SYSCLR_INACTIVETITLE
;
133 case wxSYS_COLOUR_INACTIVEBORDER
:
134 vSysClr
= SYSCLR_INACTIVEBORDER
;
137 case wxSYS_COLOUR_LISTBOX
:
138 vSysClr
= SYSCLR_ENTRYFIELD
;
141 case wxSYS_COLOUR_CAPTIONTEXT
:
142 vSysClr
= SYSCLR_TITLETEXT
;
145 case wxSYS_COLOUR_INACTIVECAPTIONTEXT
:
146 vSysClr
= SYSCLR_INACTIVETITLETEXT
;
149 case wxSYS_COLOUR_WINDOWTEXT
:
150 case wxSYS_COLOUR_BTNTEXT
:
151 vSysClr
= SYSCLR_WINDOWTEXT
;
154 case wxSYS_COLOUR_INFOTEXT
:
155 vSysClr
= SYSCLR_HELPTEXT
;
158 case wxSYS_COLOUR_ACTIVECAPTION
:
159 vSysClr
= SYSCLR_ACTIVETITLE
;
162 case wxSYS_COLOUR_ACTIVEBORDER
:
163 vSysClr
= SYSCLR_ACTIVEBORDER
;
166 case wxSYS_COLOUR_HIGHLIGHT
:
167 vSysClr
= SYSCLR_HILITEBACKGROUND
;
170 case wxSYS_COLOUR_SCROLLBAR
:
171 vSysClr
= SYSCLR_SCROLLBAR
;
174 case wxSYS_COLOUR_HIGHLIGHTTEXT
:
175 vSysClr
= SYSCLR_HILITEFOREGROUND
;
178 case wxSYS_COLOUR_INFOBK
:
179 vSysClr
= SYSCLR_HELPBACKGROUND
;
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
;
193 vSysClr
= SYSCLR_WINDOW
;
196 vRef
= (ULONG
)::WinQuerySysColor( HWND_DESKTOP
,
199 vCol
.Set( GetRValue(vRef
),
203 } // end of wxSystemSettingsNative::GetColour
205 // ----------------------------------------------------------------------------
207 // ----------------------------------------------------------------------------
209 wxFont
wxSystemSettingsNative::GetFont(
213 const bool isDefaultRequested
= index
== wxSYS_DEFAULT_GUI_FONT
;
214 if ( isDefaultRequested
)
216 if ( gs_fontDefault
)
217 return *gs_fontDefault
;
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.
228 case wxSYS_SYSTEM_FIXED_FONT
:
229 case wxSYS_OEM_FIXED_FONT
:
230 case wxSYS_ANSI_FIXED_FONT
:
232 wxFONTFAMILY_TELETYPE
,
234 wxFONTWEIGHT_NORMAL
);
236 case wxSYS_ANSI_VAR_FONT
:
240 wxFONTWEIGHT_NORMAL
);
242 case wxSYS_SYSTEM_FONT
:
243 case wxSYS_DEFAULT_GUI_FONT
:
247 wxFONTWEIGHT_NORMAL
);
250 wxFAIL_MSG( wxT("stock font not found") );
251 return GetFont(wxSYS_ANSI_VAR_FONT
);
255 if ( isDefaultRequested
)
257 // if we got here it means we hadn't cached it yet - do now
258 gs_fontDefault
= new wxFont(font
);
264 // Get a system metric, e.g. scrollbar size
265 int wxSystemSettingsNative::GetMetric( wxSystemMetric index
,
266 wxWindow
* WXUNUSED(win
) )
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:
292 return ::WinQuerySysValue(HWND_DESKTOP
,SV_CXSCREEN
);
294 return ::WinQuerySysValue(HWND_DESKTOP
,SV_CYSCREEN
);
296 // TODO case wxSYS_FRAMESIZE_X:
297 // TODO case wxSYS_FRAMESIZE_Y:
298 // TODO case wxSYS_SMALLICON_X:
299 // TODO case wxSYS_SMALLICON_Y:
301 case wxSYS_HSCROLL_Y
:
302 return ::WinQuerySysValue(HWND_DESKTOP
,SV_CYHSCROLL
);
303 case wxSYS_VSCROLL_X
:
304 return ::WinQuerySysValue(HWND_DESKTOP
,SV_CXVSCROLL
);
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:
319 return -1; // unsupported metric
322 bool wxSystemSettingsNative::HasFeature( wxSystemFeature index
)
326 case wxSYS_CAN_ICONIZE_FRAME
:
329 // TODO case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
330 // TODO case wxSYS_TABLET_PRESENT: