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