1 /////////////////////////////////////////////////////////////////////////////
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"
20 #include "wx/gdicmn.h"
23 #include "wx/settings.h"
24 #include "wx/window.h"
25 #include "wx/os2/private.h"
27 // the module which is used to clean up wxSystemSettings data (this is a
28 // singleton class so it can't be done in the dtor)
29 class wxSystemSettingsModule
: public wxModule
31 friend class wxSystemSettings
;
33 virtual bool OnInit();
34 virtual void OnExit();
37 DECLARE_DYNAMIC_CLASS(wxSystemSettingsModule
)
39 static wxArrayString sm_optionNames
;
40 static wxArrayString sm_optionValues
;
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 static wxFont
*gs_fontDefault
= NULL
;
49 // ============================================================================
51 // ============================================================================
53 // ----------------------------------------------------------------------------
54 // wxSystemSettingsModule
55 // ----------------------------------------------------------------------------
57 IMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule
, wxModule
)
59 wxArrayString
wxSystemSettingsModule::sm_optionNames
;
60 wxArrayString
wxSystemSettingsModule::sm_optionValues
;
62 bool wxSystemSettingsModule::OnInit()
67 void wxSystemSettingsModule::OnExit()
69 sm_optionNames
.Clear();
70 sm_optionValues
.Clear();
71 delete gs_fontDefault
;
74 wxColour
wxSystemSettings::GetSystemColour(
83 // PM actually has values for these
85 case wxSYS_COLOUR_WINDOW
:
86 vRef
= (ULONG
)::WinQuerySysColor( HWND_DESKTOP
90 vCol
.Set( GetRValue(vRef
)
96 case wxSYS_COLOUR_WINDOWFRAME
:
97 vRef
= (ULONG
)::WinQuerySysColor( HWND_DESKTOP
101 vCol
.Set( GetRValue(vRef
)
107 case wxSYS_COLOUR_MENUTEXT
:
108 vRef
= (ULONG
)::WinQuerySysColor( HWND_DESKTOP
112 vCol
.Set( GetRValue(vRef
)
118 case wxSYS_COLOUR_BTNFACE
:
119 vRef
= (ULONG
)::WinQuerySysColor( HWND_DESKTOP
120 ,SYSCLR_BUTTONDEFAULT
123 vCol
.Set( GetRValue(vRef
)
129 case wxSYS_COLOUR_BTNSHADOW
:
130 vRef
= (ULONG
)::WinQuerySysColor( HWND_DESKTOP
134 vCol
.Set( GetRValue(vRef
)
140 case wxSYS_COLOUR_BTNHIGHLIGHT
:
141 vRef
= (ULONG
)::WinQuerySysColor( HWND_DESKTOP
145 vCol
.Set( GetRValue(vRef
)
152 // We'll have to just give values to these
154 case wxSYS_COLOUR_LISTBOX
:
155 case wxSYS_COLOUR_CAPTIONTEXT
:
159 case wxSYS_COLOUR_WINDOWTEXT
:
160 case wxSYS_COLOUR_INACTIVECAPTIONTEXT
:
161 case wxSYS_COLOUR_BTNTEXT
:
162 case wxSYS_COLOUR_INFOTEXT
:
167 // We should customize these to look like other ports
170 case wxSYS_COLOUR_ACTIVECAPTION
:
171 case wxSYS_COLOUR_ACTIVEBORDER
:
172 case wxSYS_COLOUR_HIGHLIGHT
:
176 case wxSYS_COLOUR_SCROLLBAR
:
177 case wxSYS_COLOUR_BACKGROUND
:
178 case wxSYS_COLOUR_INACTIVECAPTION
:
179 case wxSYS_COLOUR_MENU
:
180 case wxSYS_COLOUR_INACTIVEBORDER
:
181 case wxSYS_COLOUR_APPWORKSPACE
:
182 case wxSYS_COLOUR_HIGHLIGHTTEXT
:
183 case wxSYS_COLOUR_GRAYTEXT
:
184 case wxSYS_COLOUR_3DDKSHADOW
:
185 case wxSYS_COLOUR_3DLIGHT
:
186 case wxSYS_COLOUR_INFOBK
:
187 vCol
= (*wxLIGHT_GREY
);
191 vRef
= (ULONG
)::WinQuerySysColor( HWND_DESKTOP
195 vCol
.Set( GetRValue(vRef
)
202 } // end of wxSystemSettings::GetSystemColour
204 wxFont
wxSystemSettings::GetSystemFont(int index
)
209 case wxSYS_DEVICE_DEFAULT_FONT
:
213 case wxSYS_DEFAULT_PALETTE
:
217 case wxSYS_SYSTEM_FIXED_FONT
:
221 case wxSYS_SYSTEM_FONT
:
226 case wxSYS_DEFAULT_GUI_FONT
:
232 return *wxSWISS_FONT
;
237 // Get a system metric, e.g. scrollbar size
238 int wxSystemSettings::GetSystemMetric(int index
)
242 case wxSYS_MOUSE_BUTTONS
:
275 case wxSYS_HSCROLL_ARROW_X
:
278 case wxSYS_HSCROLL_ARROW_Y
:
290 case wxSYS_ICONSPACING_X
:
293 case wxSYS_ICONSPACING_Y
:
296 case wxSYS_WINDOWMIN_X
:
299 case wxSYS_WINDOWMIN_Y
:
308 case wxSYS_FRAMESIZE_X
:
311 case wxSYS_FRAMESIZE_Y
:
314 case wxSYS_SMALLICON_X
:
317 case wxSYS_SMALLICON_Y
:
320 case wxSYS_HSCROLL_Y
:
323 case wxSYS_VSCROLL_X
:
326 case wxSYS_VSCROLL_ARROW_X
:
329 case wxSYS_VSCROLL_ARROW_Y
:
335 case wxSYS_CAPTION_Y
:
341 case wxSYS_NETWORK_PRESENT
:
344 case wxSYS_PENWINDOWS_PRESENT
:
347 case wxSYS_SHOW_SOUNDS
:
350 case wxSYS_SWAP_BUTTONS
:
359 // Option functions (arbitrary name/value mapping)
360 void wxSystemSettings::SetOption(
361 const wxString
& rsName
362 , const wxString
& rsValue
365 int nIdx
= wxSystemSettingsModule::sm_optionNames
.Index( rsName
369 if (nIdx
== wxNOT_FOUND
)
371 wxSystemSettingsModule::sm_optionNames
.Add(rsName
);
372 wxSystemSettingsModule::sm_optionValues
.Add(rsValue
);
376 wxSystemSettingsModule::sm_optionNames
[nIdx
] = rsName
;
377 wxSystemSettingsModule::sm_optionValues
[nIdx
] = rsValue
;
381 void wxSystemSettings::SetOption(
382 const wxString
& rsName
388 sValStr
.Printf(wxT("%d"), nValue
);
394 wxString
wxSystemSettings::GetOption(
395 const wxString
& rsName
398 int nIdx
= wxSystemSettingsModule::sm_optionNames
.Index( rsName
402 if (nIdx
== wxNOT_FOUND
)
403 return wxEmptyString
;
405 return wxSystemSettingsModule::sm_optionValues
[nIdx
];
408 int wxSystemSettings::GetOptionInt(
409 const wxString
& rsName
412 return wxAtoi(GetOption(rsName
));
415 bool wxSystemSettings::HasOption(
416 const wxString
& rsName
419 return (wxSystemSettingsModule::sm_optionNames
.Index(rsName
, FALSE
) != wxNOT_FOUND
);
420 } // end of wxSystemSettings::HasOption