Minor code tweeks to stop BCC 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 switch (index)
45 {
46 case wxSYS_COLOUR_LISTBOX:
47 return *wxWHITE;
48
49 default:
50 COLORREF ref = ::GetSysColor(index);
51 wxColour col(GetRValue(ref), GetGValue(ref), GetBValue(ref));
52 return col;
53 }
54 }
55
56 wxFont wxSystemSettings::GetSystemFont(int index)
57 {
58 HFONT hFont = (HFONT) ::GetStockObject(index);
59 if ( hFont != (HFONT) NULL )
60 {
61 LOGFONT lf;
62 if ( ::GetObject(hFont, sizeof(LOGFONT), &lf) != 0 )
63 {
64 // In fontdlg.cpp
65 return wxCreateFontFromLogFont(&lf);
66 }
67 else
68 {
69 return wxNullFont;
70 }
71 }
72 else
73 {
74 return wxNullFont;
75 }
76 }
77
78 // Get a system metric, e.g. scrollbar size
79 int wxSystemSettings::GetSystemMetric(int index)
80 {
81 switch ( index)
82 {
83 #ifdef __WIN32__
84 case wxSYS_MOUSE_BUTTONS:
85 return ::GetSystemMetrics(SM_CMOUSEBUTTONS);
86 #endif
87
88 case wxSYS_BORDER_X:
89 return ::GetSystemMetrics(SM_CXBORDER);
90 case wxSYS_BORDER_Y:
91 return ::GetSystemMetrics(SM_CYBORDER);
92 case wxSYS_CURSOR_X:
93 return ::GetSystemMetrics(SM_CXCURSOR);
94 case wxSYS_CURSOR_Y:
95 return ::GetSystemMetrics(SM_CYCURSOR);
96 case wxSYS_DCLICK_X:
97 return ::GetSystemMetrics(SM_CXDOUBLECLK);
98 case wxSYS_DCLICK_Y:
99 return ::GetSystemMetrics(SM_CYDOUBLECLK);
100 #if defined(__WIN32__) && defined(SM_CXDRAG)
101 case wxSYS_DRAG_X:
102 return ::GetSystemMetrics(SM_CXDRAG);
103 case wxSYS_DRAG_Y:
104 return ::GetSystemMetrics(SM_CYDRAG);
105 case wxSYS_EDGE_X:
106 return ::GetSystemMetrics(SM_CXEDGE);
107 case wxSYS_EDGE_Y:
108 return ::GetSystemMetrics(SM_CYEDGE);
109 #endif
110 case wxSYS_HSCROLL_ARROW_X:
111 return ::GetSystemMetrics(SM_CXHSCROLL);
112 case wxSYS_HSCROLL_ARROW_Y:
113 return ::GetSystemMetrics(SM_CYHSCROLL);
114 case wxSYS_HTHUMB_X:
115 return ::GetSystemMetrics(SM_CXHTHUMB);
116 case wxSYS_ICON_X:
117 return ::GetSystemMetrics(SM_CXICON);
118 case wxSYS_ICON_Y:
119 return ::GetSystemMetrics(SM_CYICON);
120 case wxSYS_ICONSPACING_X:
121 return ::GetSystemMetrics(SM_CXICONSPACING);
122 case wxSYS_ICONSPACING_Y:
123 return ::GetSystemMetrics(SM_CYICONSPACING);
124 case wxSYS_WINDOWMIN_X:
125 return ::GetSystemMetrics(SM_CXMIN);
126 case wxSYS_WINDOWMIN_Y:
127 return ::GetSystemMetrics(SM_CYMIN);
128 case wxSYS_SCREEN_X:
129 return ::GetSystemMetrics(SM_CXSCREEN);
130 case wxSYS_SCREEN_Y:
131 return ::GetSystemMetrics(SM_CYSCREEN);
132
133 #if defined(__WIN32__) && defined(SM_CXSIZEFRAME)
134 case wxSYS_FRAMESIZE_X:
135 return ::GetSystemMetrics(SM_CXSIZEFRAME);
136 case wxSYS_FRAMESIZE_Y:
137 return ::GetSystemMetrics(SM_CYSIZEFRAME);
138 case wxSYS_SMALLICON_X:
139 return ::GetSystemMetrics(SM_CXSMICON);
140 case wxSYS_SMALLICON_Y:
141 return ::GetSystemMetrics(SM_CYSMICON);
142 #endif
143 case wxSYS_HSCROLL_Y:
144 return ::GetSystemMetrics(SM_CYHSCROLL);
145 case wxSYS_VSCROLL_X:
146 return ::GetSystemMetrics(SM_CXVSCROLL);
147 case wxSYS_VSCROLL_ARROW_X:
148 return ::GetSystemMetrics(SM_CXVSCROLL);
149 case wxSYS_VSCROLL_ARROW_Y:
150 return ::GetSystemMetrics(SM_CYVSCROLL);
151 case wxSYS_VTHUMB_Y:
152 return ::GetSystemMetrics(SM_CYVTHUMB);
153 case wxSYS_CAPTION_Y:
154 return ::GetSystemMetrics(SM_CYCAPTION);
155 case wxSYS_MENU_Y:
156 return ::GetSystemMetrics(SM_CYMENU);
157 #if defined(__WIN32__) && defined(SM_NETWORK)
158 case wxSYS_NETWORK_PRESENT:
159 return ::GetSystemMetrics(SM_NETWORK) & 0x0001;
160 #endif
161 case wxSYS_PENWINDOWS_PRESENT:
162 return ::GetSystemMetrics(SM_PENWINDOWS);
163 #if defined(__WIN32__) && defined(SM_SHOWSOUNDS)
164 case wxSYS_SHOW_SOUNDS:
165 return ::GetSystemMetrics(SM_SHOWSOUNDS);
166 #endif
167 case wxSYS_SWAP_BUTTONS:
168 return ::GetSystemMetrics(SM_SWAPBUTTON);
169 default:
170 return 0;
171 }
172 }
173