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 delete gs_fontDefault
;
74 gs_fontDefault
= NULL
;
77 wxColour
wxSystemSettingsNative::GetColour(
87 // PM actually has values for these
89 case wxSYS_COLOUR_WINDOW
:
90 vSysClr
= SYSCLR_WINDOW
;
93 case wxSYS_COLOUR_WINDOWFRAME
:
94 vSysClr
= SYSCLR_WINDOWFRAME
;
97 case wxSYS_COLOUR_MENUTEXT
:
98 vSysClr
= SYSCLR_MENUTEXT
;
101 case wxSYS_COLOUR_MENUHILIGHT
:
102 vSysClr
= SYSCLR_MENUHILITE
;
105 case wxSYS_COLOUR_BTNFACE
:
106 vSysClr
= SYSCLR_BUTTONMIDDLE
;
109 case wxSYS_COLOUR_BTNSHADOW
:
110 vSysClr
= SYSCLR_BUTTONDARK
;
113 case wxSYS_COLOUR_BTNHIGHLIGHT
:
114 vSysClr
= SYSCLR_BUTTONLIGHT
;
117 case wxSYS_COLOUR_BACKGROUND
:
118 vSysClr
= SYSCLR_BACKGROUND
;
121 case wxSYS_COLOUR_APPWORKSPACE
:
122 vSysClr
= SYSCLR_APPWORKSPACE
;
125 case wxSYS_COLOUR_MENUBAR
:
126 case wxSYS_COLOUR_MENU
:
127 vSysClr
= SYSCLR_MENU
;
130 case wxSYS_COLOUR_INACTIVECAPTION
:
131 vSysClr
= SYSCLR_INACTIVETITLE
;
134 case wxSYS_COLOUR_INACTIVEBORDER
:
135 vSysClr
= SYSCLR_INACTIVEBORDER
;
138 case wxSYS_COLOUR_LISTBOX
:
139 vSysClr
= SYSCLR_ENTRYFIELD
;
142 case wxSYS_COLOUR_CAPTIONTEXT
:
143 vSysClr
= SYSCLR_TITLETEXT
;
146 case wxSYS_COLOUR_INACTIVECAPTIONTEXT
:
147 vSysClr
= SYSCLR_INACTIVETITLETEXT
;
150 case wxSYS_COLOUR_WINDOWTEXT
:
151 case wxSYS_COLOUR_BTNTEXT
:
152 vSysClr
= SYSCLR_WINDOWTEXT
;
155 case wxSYS_COLOUR_INFOTEXT
:
156 vSysClr
= SYSCLR_HELPTEXT
;
159 case wxSYS_COLOUR_ACTIVECAPTION
:
160 vSysClr
= SYSCLR_ACTIVETITLE
;
163 case wxSYS_COLOUR_ACTIVEBORDER
:
164 vSysClr
= SYSCLR_ACTIVEBORDER
;
167 case wxSYS_COLOUR_HIGHLIGHT
:
168 vSysClr
= SYSCLR_HILITEBACKGROUND
;
171 case wxSYS_COLOUR_SCROLLBAR
:
172 vSysClr
= SYSCLR_SCROLLBAR
;
175 case wxSYS_COLOUR_HIGHLIGHTTEXT
:
176 vSysClr
= SYSCLR_HILITEFOREGROUND
;
179 case wxSYS_COLOUR_INFOBK
:
180 vSysClr
= SYSCLR_HELPBACKGROUND
;
183 // Don't know what these should be, so leave them grey (normally)
184 case wxSYS_COLOUR_GRAYTEXT
:
185 case wxSYS_COLOUR_3DDKSHADOW
:
186 case wxSYS_COLOUR_3DLIGHT
:
187 case wxSYS_COLOUR_HOTLIGHT
:
188 case wxSYS_COLOUR_GRADIENTACTIVECAPTION
:
189 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION
:
190 vSysClr
= SYSCLR_BUTTONMIDDLE
;
194 vSysClr
= SYSCLR_WINDOW
;
197 vRef
= (ULONG
)::WinQuerySysColor( HWND_DESKTOP
,
200 vCol
.Set( GetRValue(vRef
),
204 } // end of wxSystemSettingsNative::GetColour
206 // ----------------------------------------------------------------------------
208 // ----------------------------------------------------------------------------
210 wxFont
wxCreateFontFromStockObject(int WXUNUSED(index
))
215 HPS hPS
= ::WinGetScreenPS(HWND_DESKTOP
);
216 if (::GpiQueryFontMetrics(hPS
, sizeof(FONTMETRICS
), &metrics
))
218 wxNativeFontInfo info
;
222 else // GetStockObject() failed
224 wxFAIL_MSG( _T("stock font not found") );
230 wxFont
wxSystemSettingsNative::GetFont(
234 const bool isDefaultRequested
= index
== wxSYS_DEFAULT_GUI_FONT
;
235 if ( isDefaultRequested
)
237 if ( gs_fontDefault
)
238 return *gs_fontDefault
;
241 wxFont font
= wxCreateFontFromStockObject(index
);
243 if ( isDefaultRequested
)
245 // if we got here it means we hadn't cached it yet - do now
246 gs_fontDefault
= new wxFont(font
);
252 // Get a system metric, e.g. scrollbar size
253 int wxSystemSettingsNative::GetMetric( wxSystemMetric index
,
254 wxWindow
* WXUNUSED(win
) )
258 // TODO case wxSYS_MOUSE_BUTTONS:
259 // TODO case wxSYS_BORDER_X:
260 // TODO case wxSYS_BORDER_Y:
261 // TODO case wxSYS_CURSOR_X:
262 // TODO case wxSYS_CURSOR_Y:
263 // TODO case wxSYS_DCLICK_X:
264 // TODO case wxSYS_DCLICK_Y:
265 // TODO case wxSYS_DRAG_X:
266 // TODO case wxSYS_DRAG_Y:
267 // TODO case wxSYS_EDGE_X:
268 // TODO case wxSYS_EDGE_Y:
269 // TODO case wxSYS_HSCROLL_ARROW_X:
270 // TODO case wxSYS_HSCROLL_ARROW_Y:
271 // TODO case wxSYS_HTHUMB_X:
272 // TODO case wxSYS_ICON_X:
273 // TODO case wxSYS_ICON_Y:
274 // TODO case wxSYS_ICONSPACING_X:
275 // TODO case wxSYS_ICONSPACING_Y:
276 // TODO case wxSYS_WINDOWMIN_X:
277 // TODO case wxSYS_WINDOWMIN_Y:
280 return ::WinQuerySysValue(HWND_DESKTOP
,SV_CXSCREEN
);
282 return ::WinQuerySysValue(HWND_DESKTOP
,SV_CYSCREEN
);
284 // TODO case wxSYS_FRAMESIZE_X:
285 // TODO case wxSYS_FRAMESIZE_Y:
286 // TODO case wxSYS_SMALLICON_X:
287 // TODO case wxSYS_SMALLICON_Y:
289 case wxSYS_HSCROLL_Y
:
290 return ::WinQuerySysValue(HWND_DESKTOP
,SV_CYHSCROLL
);
291 case wxSYS_VSCROLL_X
:
292 return ::WinQuerySysValue(HWND_DESKTOP
,SV_CXVSCROLL
);
294 // TODO case wxSYS_VSCROLL_ARROW_X:
295 // TODO case wxSYS_VSCROLL_ARROW_Y:
296 // TODO case wxSYS_VTHUMB_Y:
297 // TODO case wxSYS_CAPTION_Y:
298 // TODO case wxSYS_MENU_Y:
299 // TODO case wxSYS_NETWORK_PRESENT:
300 // TODO case wxSYS_PENWINDOWS_PRESENT:
301 // TODO case wxSYS_SHOW_SOUNDS:
302 // TODO case wxSYS_SWAP_BUTTONS:
307 return -1; // unsupported metric
310 bool wxSystemSettingsNative::HasFeature( wxSystemFeature index
)
314 case wxSYS_CAN_ICONIZE_FRAME
:
317 // TODO case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
318 // TODO case wxSYS_TABLET_PRESENT: