]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/settings.cpp
create stock GDI objects on demand; use const with GDI objects appropriately (patch...
[wxWidgets.git] / src / mac / carbon / settings.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: settings.cpp
3 // Purpose: wxSettings
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/settings.h"
15 #include "wx/gdicmn.h"
16 #include "wx/utils.h"
17
18 #include "wx/mac/uma.h"
19
20 // ----------------------------------------------------------------------------
21 // wxSystemSettingsNative
22 // ----------------------------------------------------------------------------
23
24 // ----------------------------------------------------------------------------
25 // colours
26 // ----------------------------------------------------------------------------
27
28 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
29 {
30 int major, minor;
31 wxColour resultColor;
32 RGBColor macRGB;
33 ThemeBrush colorBrushID;
34
35 wxGetOsVersion( &major, &minor );
36
37 switch ( index )
38 {
39 case wxSYS_COLOUR_SCROLLBAR :
40 case wxSYS_COLOUR_BACKGROUND:
41 case wxSYS_COLOUR_ACTIVECAPTION:
42 case wxSYS_COLOUR_INACTIVECAPTION:
43 case wxSYS_COLOUR_MENU:
44 case wxSYS_COLOUR_WINDOW:
45 case wxSYS_COLOUR_WINDOWFRAME:
46 case wxSYS_COLOUR_ACTIVEBORDER:
47 case wxSYS_COLOUR_INACTIVEBORDER:
48 case wxSYS_COLOUR_BTNFACE:
49 case wxSYS_COLOUR_MENUBAR:
50 resultColor = wxColor( 0xDD, 0xDD, 0xDD );
51 break ;
52
53 case wxSYS_COLOUR_LISTBOX :
54 if (major >= 10)
55 resultColor = *wxWHITE ;
56 else
57 resultColor = wxColor( 0xEE, 0xEE, 0xEE );
58 break ;
59
60 case wxSYS_COLOUR_BTNSHADOW:
61 if (major >= 10)
62 resultColor = wxColor( 0xBE, 0xBE, 0xBE );
63 else
64 resultColor = wxColor( 0x44, 0x44, 0x44 );
65 break ;
66
67 case wxSYS_COLOUR_BTNTEXT:
68 case wxSYS_COLOUR_MENUTEXT:
69 case wxSYS_COLOUR_WINDOWTEXT:
70 case wxSYS_COLOUR_CAPTIONTEXT:
71 case wxSYS_COLOUR_INFOTEXT:
72 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
73 resultColor = *wxBLACK;
74 break ;
75
76 case wxSYS_COLOUR_HIGHLIGHT:
77
78 #if 0 && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
79 // NB: enable this case as desired
80 colorBrushID = kThemeBrushAlternatePrimaryHighlightColor;
81 #else
82 colorBrushID = kThemeBrushPrimaryHighlightColor;
83 #endif
84
85 GetThemeBrushAsColor( colorBrushID, 32, true, &macRGB );
86 resultColor = wxColor( macRGB.red >> 8, macRGB.green >> 8, macRGB.blue >> 8 );
87 break ;
88
89 case wxSYS_COLOUR_BTNHIGHLIGHT:
90 case wxSYS_COLOUR_GRAYTEXT:
91 resultColor = wxColor( 0xCC, 0xCC, 0xCC );
92 break ;
93
94 case wxSYS_COLOUR_3DDKSHADOW:
95 resultColor = wxColor( 0x44, 0x44, 0x44 );
96 break ;
97
98 case wxSYS_COLOUR_3DLIGHT:
99 resultColor = wxColor( 0xCC, 0xCC, 0xCC );
100 break ;
101
102 case wxSYS_COLOUR_HIGHLIGHTTEXT :
103 #if 0 && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
104 // NB: enable this case as desired
105 resultColor = *wxWHITE ;
106 #else
107 GetThemeBrushAsColor( kThemeBrushPrimaryHighlightColor, 32, true, &macRGB );
108 if ((macRGB.red + macRGB.green + macRGB.blue) == 0)
109 resultColor = *wxWHITE ;
110 else
111 resultColor = *wxBLACK ;
112 #endif
113 break ;
114
115 case wxSYS_COLOUR_INFOBK :
116 case wxSYS_COLOUR_APPWORKSPACE:
117 resultColor = *wxWHITE ;
118 break ;
119
120 case wxSYS_COLOUR_HOTLIGHT:
121 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
122 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
123 case wxSYS_COLOUR_MENUHILIGHT:
124 // TODO:
125 resultColor = *wxBLACK;
126 break ;
127
128 // case wxSYS_COLOUR_MAX:
129 default:
130 resultColor = *wxWHITE;
131 // wxCHECK_MSG( index >= wxSYS_COLOUR_MAX, false, _T("unknown system colour index") );
132 break ;
133 }
134
135 return resultColor;
136 }
137
138 // ----------------------------------------------------------------------------
139 // fonts
140 // ----------------------------------------------------------------------------
141
142 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
143 {
144 switch (index)
145 {
146 case wxSYS_ANSI_VAR_FONT :
147 case wxSYS_SYSTEM_FONT :
148 case wxSYS_DEVICE_DEFAULT_FONT :
149 case wxSYS_DEFAULT_GUI_FONT :
150 return *wxSMALL_FONT ;
151 break ;
152
153 default :
154 break ;
155 }
156
157 return *wxNORMAL_FONT;
158 }
159
160 // ----------------------------------------------------------------------------
161 // system metrics/features
162 // ----------------------------------------------------------------------------
163
164 // Get a system metric, e.g. scrollbar size
165 int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win))
166 {
167 int value;
168
169 switch ( index )
170 {
171 case wxSYS_MOUSE_BUTTONS:
172 // we emulate a two button mouse (ctrl + click = right button)
173 return 2;
174
175 // TODO case wxSYS_BORDER_X:
176 // TODO case wxSYS_BORDER_Y:
177 // TODO case wxSYS_CURSOR_X:
178 // TODO case wxSYS_CURSOR_Y:
179 // TODO case wxSYS_DCLICK_X:
180 // TODO case wxSYS_DCLICK_Y:
181 // TODO case wxSYS_DRAG_X:
182 // TODO case wxSYS_DRAG_Y:
183 // TODO case wxSYS_EDGE_X:
184 // TODO case wxSYS_EDGE_Y:
185
186 case wxSYS_HSCROLL_ARROW_X:
187 case wxSYS_HSCROLL_ARROW_Y:
188 case wxSYS_HTHUMB_X:
189 return 16;
190
191 // TODO case wxSYS_ICON_X:
192 // TODO case wxSYS_ICON_Y:
193 // TODO case wxSYS_ICONSPACING_X:
194 // TODO case wxSYS_ICONSPACING_Y:
195 // TODO case wxSYS_WINDOWMIN_X:
196 // TODO case wxSYS_WINDOWMIN_Y:
197
198 case wxSYS_SCREEN_X:
199 wxDisplaySize( &value, NULL );
200 return value;
201
202 case wxSYS_SCREEN_Y:
203 wxDisplaySize( NULL, &value );
204 return value;
205
206 // TODO case wxSYS_FRAMESIZE_X:
207 // TODO case wxSYS_FRAMESIZE_Y:
208 // TODO case wxSYS_SMALLICON_X:
209 // TODO case wxSYS_SMALLICON_Y:
210
211 case wxSYS_HSCROLL_Y:
212 case wxSYS_VSCROLL_X:
213 case wxSYS_VSCROLL_ARROW_X:
214 case wxSYS_VSCROLL_ARROW_Y:
215 case wxSYS_VTHUMB_Y:
216 return 16;
217
218 case wxSYS_PENWINDOWS_PRESENT:
219 return 0;
220
221 case wxSYS_SWAP_BUTTONS:
222 return 0;
223
224 // TODO: case wxSYS_CAPTION_Y:
225 // TODO: case wxSYS_MENU_Y:
226 // TODO: case wxSYS_NETWORK_PRESENT:
227 // TODO: case wxSYS_SHOW_SOUNDS:
228
229 default:
230 // unsupported metric
231 break;
232 }
233
234 return -1;
235 }
236
237 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
238 {
239 switch (index)
240 {
241 case wxSYS_CAN_ICONIZE_FRAME:
242 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
243 return true;
244
245 default:
246 return false;
247 }
248 }