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