]> git.saurik.com Git - wxWidgets.git/blob - src/msw/settings.cpp
added wxFrame::Command()
[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 != (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 #if defined(__WIN32__) && defined(SM_CXDRAG)
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
126 #if defined(__WIN32__) && defined(SM_CXSIZEFRAME)
127 case wxSYS_FRAMESIZE_X:
128 return ::GetSystemMetrics(SM_CXSIZEFRAME);
129 case wxSYS_FRAMESIZE_Y:
130 return ::GetSystemMetrics(SM_CYSIZEFRAME);
131 case wxSYS_SMALLICON_X:
132 return ::GetSystemMetrics(SM_CXSMICON);
133 case wxSYS_SMALLICON_Y:
134 return ::GetSystemMetrics(SM_CYSMICON);
135 #endif
136 case wxSYS_HSCROLL_Y:
137 return ::GetSystemMetrics(SM_CYHSCROLL);
138 case wxSYS_VSCROLL_X:
139 return ::GetSystemMetrics(SM_CXVSCROLL);
140 case wxSYS_VSCROLL_ARROW_X:
141 return ::GetSystemMetrics(SM_CXVSCROLL);
142 case wxSYS_VSCROLL_ARROW_Y:
143 return ::GetSystemMetrics(SM_CYVSCROLL);
144 case wxSYS_VTHUMB_Y:
145 return ::GetSystemMetrics(SM_CYVTHUMB);
146 case wxSYS_CAPTION_Y:
147 return ::GetSystemMetrics(SM_CYCAPTION);
148 case wxSYS_MENU_Y:
149 return ::GetSystemMetrics(SM_CYMENU);
150 #if defined(__WIN32__) && defined(SM_NETWORK)
151 case wxSYS_NETWORK_PRESENT:
152 return ::GetSystemMetrics(SM_NETWORK) & 0x0001;
153 #endif
154 case wxSYS_PENWINDOWS_PRESENT:
155 return ::GetSystemMetrics(SM_PENWINDOWS);
156 #if defined(__WIN32__) && defined(SM_SHOWSOUNDS)
157 case wxSYS_SHOW_SOUNDS:
158 return ::GetSystemMetrics(SM_SHOWSOUNDS);
159 #endif
160 case wxSYS_SWAP_BUTTONS:
161 return ::GetSystemMetrics(SM_SWAPBUTTON);
162 default:
163 return 0;
164 }
165 return 0;
166 }
167