]> git.saurik.com Git - wxWidgets.git/blob - src/msw/settings.cpp
wxLogDebug/Trace in release mode now don't give compiler warnings
[wxWidgets.git] / src / msw / settings.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: settings.cpp
3 // Purpose: wxSettings
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "settings.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include <stdio.h>
25 #include "wx/defs.h"
26 #include "wx/pen.h"
27 #include "wx/brush.h"
28 #include "wx/gdicmn.h"
29 #endif
30
31 #include "wx/settings.h"
32 #include "wx/window.h"
33 #include "wx/msw/private.h"
34
35 // TODO: see ::SystemParametersInfo for all sorts of Windows settings.
36 // Different args are required depending on the id. How does this differ
37 // from GetSystemMetric, and should it? Perhaps call it GetSystemParameter
38 // and pass an optional void* arg to get further info.
39 // Should also have SetSystemParameter.
40 // Also implement WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95)
41
42 wxColour wxSystemSettings::GetSystemColour(int index)
43 {
44 COLORREF ref = ::GetSysColor(index);
45 wxColour col(GetRValue(ref), GetGValue(ref), GetBValue(ref));
46 return col;
47 }
48
49 wxFont wxSystemSettings::GetSystemFont(int index)
50 {
51 HFONT hFont = (HFONT) ::GetStockObject(index);
52 if ( hFont != NULL )
53 {
54 LOGFONT lf;
55 if ( ::GetObject(hFont, sizeof(LOGFONT), &lf) != 0 )
56 {
57 // In fontdlg.cpp
58 return wxCreateFontFromLogFont(&lf);
59 }
60 else
61 {
62 return wxNullFont;
63 }
64 }
65 else
66 {
67 return wxNullFont;
68 }
69 }
70
71 // Get a system metric, e.g. scrollbar size
72 int wxSystemSettings::GetSystemMetric(int index)
73 {
74 switch ( index)
75 {
76 #ifdef __WIN32__
77 case wxSYS_MOUSE_BUTTONS:
78 return ::GetSystemMetrics(SM_CMOUSEBUTTONS);
79 #endif
80
81 case wxSYS_BORDER_X:
82 return ::GetSystemMetrics(SM_CXBORDER);
83 case wxSYS_BORDER_Y:
84 return ::GetSystemMetrics(SM_CYBORDER);
85 case wxSYS_CURSOR_X:
86 return ::GetSystemMetrics(SM_CXCURSOR);
87 case wxSYS_CURSOR_Y:
88 return ::GetSystemMetrics(SM_CYCURSOR);
89 case wxSYS_DCLICK_X:
90 return ::GetSystemMetrics(SM_CXDOUBLECLK);
91 case wxSYS_DCLICK_Y:
92 return ::GetSystemMetrics(SM_CYDOUBLECLK);
93 #ifdef __WIN32__
94 case wxSYS_DRAG_X:
95 return ::GetSystemMetrics(SM_CXDRAG);
96 case wxSYS_DRAG_Y:
97 return ::GetSystemMetrics(SM_CYDRAG);
98 case wxSYS_EDGE_X:
99 return ::GetSystemMetrics(SM_CXEDGE);
100 case wxSYS_EDGE_Y:
101 return ::GetSystemMetrics(SM_CYEDGE);
102 #endif
103 case wxSYS_HSCROLL_ARROW_X:
104 return ::GetSystemMetrics(SM_CXHSCROLL);
105 case wxSYS_HSCROLL_ARROW_Y:
106 return ::GetSystemMetrics(SM_CYHSCROLL);
107 case wxSYS_HTHUMB_X:
108 return ::GetSystemMetrics(SM_CXHTHUMB);
109 case wxSYS_ICON_X:
110 return ::GetSystemMetrics(SM_CXICON);
111 case wxSYS_ICON_Y:
112 return ::GetSystemMetrics(SM_CYICON);
113 case wxSYS_ICONSPACING_X:
114 return ::GetSystemMetrics(SM_CXICONSPACING);
115 case wxSYS_ICONSPACING_Y:
116 return ::GetSystemMetrics(SM_CYICONSPACING);
117 case wxSYS_WINDOWMIN_X:
118 return ::GetSystemMetrics(SM_CXMIN);
119 case wxSYS_WINDOWMIN_Y:
120 return ::GetSystemMetrics(SM_CYMIN);
121 case wxSYS_SCREEN_X:
122 return ::GetSystemMetrics(SM_CXSCREEN);
123 case wxSYS_SCREEN_Y:
124 return ::GetSystemMetrics(SM_CYSCREEN);
125 #ifdef __WIN32__
126 case wxSYS_FRAMESIZE_X:
127 return ::GetSystemMetrics(SM_CXSIZEFRAME);
128 case wxSYS_FRAMESIZE_Y:
129 return ::GetSystemMetrics(SM_CYSIZEFRAME);
130 case wxSYS_SMALLICON_X:
131 return ::GetSystemMetrics(SM_CXSMICON);
132 case wxSYS_SMALLICON_Y:
133 return ::GetSystemMetrics(SM_CYSMICON);
134 #endif
135 case wxSYS_HSCROLL_Y:
136 return ::GetSystemMetrics(SM_CYHSCROLL);
137 case wxSYS_VSCROLL_X:
138 return ::GetSystemMetrics(SM_CXVSCROLL);
139 case wxSYS_VSCROLL_ARROW_X:
140 return ::GetSystemMetrics(SM_CXVSCROLL);
141 case wxSYS_VSCROLL_ARROW_Y:
142 return ::GetSystemMetrics(SM_CYVSCROLL);
143 case wxSYS_VTHUMB_Y:
144 return ::GetSystemMetrics(SM_CYVTHUMB);
145 case wxSYS_CAPTION_Y:
146 return ::GetSystemMetrics(SM_CYCAPTION);
147 case wxSYS_MENU_Y:
148 return ::GetSystemMetrics(SM_CYMENU);
149 #ifdef __WIN32__
150 case wxSYS_NETWORK_PRESENT:
151 return ::GetSystemMetrics(SM_NETWORK) & 0x0001;
152 #endif
153 case wxSYS_PENWINDOWS_PRESENT:
154 return ::GetSystemMetrics(SM_PENWINDOWS);
155 #ifdef __WIN32__
156 case wxSYS_SHOW_SOUNDS:
157 return ::GetSystemMetrics(SM_SHOWSOUNDS);
158 #endif
159 case wxSYS_SWAP_BUTTONS:
160 return ::GetSystemMetrics(SM_SWAPBUTTON);
161 default:
162 return 0;
163 }
164 return 0;
165 }
166