]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/settings.cpp
b636a80883f7c256df11390f2965265092f39df4
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/settings.cpp
3 // Purpose: wxSystemSettings
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "settings.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
36 #include "wx/gdicmn.h"
39 #include "wx/settings.h"
40 #include "wx/window.h"
41 #include "wx/msw/private.h"
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 // the module which is used to clean up wxSystemSettings data (this is a
48 // singleton class so it can't be done in the dtor)
49 class wxSystemSettingsModule
: public wxModule
52 virtual bool OnInit();
53 virtual void OnExit();
56 DECLARE_DYNAMIC_CLASS(wxSystemSettingsModule
)
59 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
63 static wxFont
*gs_fontDefault
= NULL
;
65 // ============================================================================
67 // ============================================================================
69 // ----------------------------------------------------------------------------
70 // wxSystemSettingsModule
71 // ----------------------------------------------------------------------------
73 IMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule
, wxModule
)
75 bool wxSystemSettingsModule::OnInit()
80 void wxSystemSettingsModule::OnExit()
82 delete gs_fontDefault
;
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
89 // TODO: see ::SystemParametersInfo for all sorts of Windows settings.
90 // Different args are required depending on the id. How does this differ
91 // from GetSystemMetric, and should it? Perhaps call it GetSystemParameter
92 // and pass an optional void* arg to get further info.
93 // Should also have SetSystemParameter.
94 // Also implement WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95)
96 wxColour
wxSystemSettings::GetSystemColour(int index
)
100 case wxSYS_COLOUR_LISTBOX
:
104 COLORREF ref
= ::GetSysColor(index
);
105 wxColour
col(GetRValue(ref
), GetGValue(ref
), GetBValue(ref
));
110 wxFont
wxSystemSettings::GetSystemFont(int index
)
112 // wxWindow ctor calls GetSystemFont(wxSYS_DEFAULT_GUI_FONT) so we're
113 // called fairly often - this is why we cache this particular font
114 bool isDefaultRequested
= index
== wxSYS_DEFAULT_GUI_FONT
;
115 if ( isDefaultRequested
&& gs_fontDefault
)
117 return *gs_fontDefault
;
122 HFONT hFont
= (HFONT
) ::GetStockObject(index
);
126 if ( ::GetObject(hFont
, sizeof(LOGFONT
), &lf
) != 0 )
128 font
= wxCreateFontFromLogFont(&lf
);
132 wxFAIL_MSG( _T("failed to get LOGFONT") );
135 else // GetStockObject() failed
137 wxFAIL_MSG( _T("stock font not found") );
140 if ( isDefaultRequested
)
142 // if we got here it means we hadn't cached it yet - do now
143 gs_fontDefault
= new wxFont(font
);
149 // Get a system metric, e.g. scrollbar size
150 int wxSystemSettings::GetSystemMetric(int index
)
155 case wxSYS_MOUSE_BUTTONS
:
156 return ::GetSystemMetrics(SM_CMOUSEBUTTONS
);
160 return ::GetSystemMetrics(SM_CXBORDER
);
162 return ::GetSystemMetrics(SM_CYBORDER
);
164 return ::GetSystemMetrics(SM_CXCURSOR
);
166 return ::GetSystemMetrics(SM_CYCURSOR
);
168 return ::GetSystemMetrics(SM_CXDOUBLECLK
);
170 return ::GetSystemMetrics(SM_CYDOUBLECLK
);
171 #if defined(__WIN32__) && defined(SM_CXDRAG)
173 return ::GetSystemMetrics(SM_CXDRAG
);
175 return ::GetSystemMetrics(SM_CYDRAG
);
177 return ::GetSystemMetrics(SM_CXEDGE
);
179 return ::GetSystemMetrics(SM_CYEDGE
);
181 case wxSYS_HSCROLL_ARROW_X
:
182 return ::GetSystemMetrics(SM_CXHSCROLL
);
183 case wxSYS_HSCROLL_ARROW_Y
:
184 return ::GetSystemMetrics(SM_CYHSCROLL
);
186 return ::GetSystemMetrics(SM_CXHTHUMB
);
188 return ::GetSystemMetrics(SM_CXICON
);
190 return ::GetSystemMetrics(SM_CYICON
);
191 case wxSYS_ICONSPACING_X
:
192 return ::GetSystemMetrics(SM_CXICONSPACING
);
193 case wxSYS_ICONSPACING_Y
:
194 return ::GetSystemMetrics(SM_CYICONSPACING
);
195 case wxSYS_WINDOWMIN_X
:
196 return ::GetSystemMetrics(SM_CXMIN
);
197 case wxSYS_WINDOWMIN_Y
:
198 return ::GetSystemMetrics(SM_CYMIN
);
200 return ::GetSystemMetrics(SM_CXSCREEN
);
202 return ::GetSystemMetrics(SM_CYSCREEN
);
204 #if defined(__WIN32__) && defined(SM_CXSIZEFRAME)
205 case wxSYS_FRAMESIZE_X
:
206 return ::GetSystemMetrics(SM_CXSIZEFRAME
);
207 case wxSYS_FRAMESIZE_Y
:
208 return ::GetSystemMetrics(SM_CYSIZEFRAME
);
209 case wxSYS_SMALLICON_X
:
210 return ::GetSystemMetrics(SM_CXSMICON
);
211 case wxSYS_SMALLICON_Y
:
212 return ::GetSystemMetrics(SM_CYSMICON
);
214 case wxSYS_HSCROLL_Y
:
215 return ::GetSystemMetrics(SM_CYHSCROLL
);
216 case wxSYS_VSCROLL_X
:
217 return ::GetSystemMetrics(SM_CXVSCROLL
);
218 case wxSYS_VSCROLL_ARROW_X
:
219 return ::GetSystemMetrics(SM_CXVSCROLL
);
220 case wxSYS_VSCROLL_ARROW_Y
:
221 return ::GetSystemMetrics(SM_CYVSCROLL
);
223 return ::GetSystemMetrics(SM_CYVTHUMB
);
224 case wxSYS_CAPTION_Y
:
225 return ::GetSystemMetrics(SM_CYCAPTION
);
227 return ::GetSystemMetrics(SM_CYMENU
);
228 #if defined(__WIN32__) && defined(SM_NETWORK)
229 case wxSYS_NETWORK_PRESENT
:
230 return ::GetSystemMetrics(SM_NETWORK
) & 0x0001;
232 case wxSYS_PENWINDOWS_PRESENT
:
233 return ::GetSystemMetrics(SM_PENWINDOWS
);
234 #if defined(__WIN32__) && defined(SM_SHOWSOUNDS)
235 case wxSYS_SHOW_SOUNDS
:
236 return ::GetSystemMetrics(SM_SHOWSOUNDS
);
238 case wxSYS_SWAP_BUTTONS
:
239 return ::GetSystemMetrics(SM_SWAPBUTTON
);