]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/settings.cpp
cleanup:
[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 RGBColor macRGB;
36 ThemeBrush colorBrushID;
37
38 wxGetOsVersion( &major, &minor );
39
40 switch ( index )
41 {
42 case wxSYS_COLOUR_WINDOW:
43 resultColor = *wxWHITE ;
44 break ;
45 case wxSYS_COLOUR_SCROLLBAR :
46 case wxSYS_COLOUR_BACKGROUND:
47 case wxSYS_COLOUR_ACTIVECAPTION:
48 case wxSYS_COLOUR_INACTIVECAPTION:
49 case wxSYS_COLOUR_MENU:
50 case wxSYS_COLOUR_WINDOWFRAME:
51 case wxSYS_COLOUR_ACTIVEBORDER:
52 case wxSYS_COLOUR_INACTIVEBORDER:
53 case wxSYS_COLOUR_BTNFACE:
54 case wxSYS_COLOUR_MENUBAR:
55 resultColor = wxColor( 0xDD, 0xDD, 0xDD );
56 break ;
57
58 case wxSYS_COLOUR_LISTBOX :
59 if (major >= 10)
60 resultColor = *wxWHITE ;
61 else
62 resultColor = wxColor( 0xEE, 0xEE, 0xEE );
63 break ;
64
65 case wxSYS_COLOUR_BTNSHADOW:
66 if (major >= 10)
67 resultColor = wxColor( 0xBE, 0xBE, 0xBE );
68 else
69 resultColor = wxColor( 0x44, 0x44, 0x44 );
70 break ;
71
72 case wxSYS_COLOUR_BTNTEXT:
73 case wxSYS_COLOUR_MENUTEXT:
74 case wxSYS_COLOUR_WINDOWTEXT:
75 case wxSYS_COLOUR_CAPTIONTEXT:
76 case wxSYS_COLOUR_INFOTEXT:
77 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
78 resultColor = *wxBLACK;
79 break ;
80
81 case wxSYS_COLOUR_HIGHLIGHT:
82
83 #if 0 && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
84 // NB: enable this case as desired
85 colorBrushID = kThemeBrushAlternatePrimaryHighlightColor;
86 #else
87 colorBrushID = kThemeBrushPrimaryHighlightColor;
88 #endif
89
90 GetThemeBrushAsColor( colorBrushID, 32, true, &macRGB );
91 resultColor = wxColor( macRGB.red >> 8, macRGB.green >> 8, macRGB.blue >> 8 );
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 && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
109 // NB: enable this case as desired
110 resultColor = *wxWHITE ;
111 #else
112 GetThemeBrushAsColor( kThemeBrushPrimaryHighlightColor, 32, true, &macRGB );
113 if ((macRGB.red + macRGB.green + macRGB.blue) == 0)
114 resultColor = *wxWHITE ;
115 else
116 resultColor = *wxBLACK ;
117 #endif
118 break ;
119
120 case wxSYS_COLOUR_INFOBK :
121 resultColor = *wxWHITE ;
122 break ;
123 case wxSYS_COLOUR_APPWORKSPACE:
124 resultColor = wxColor( 0x80, 0x80, 0x80 ); ;
125 break ;
126
127 case wxSYS_COLOUR_HOTLIGHT:
128 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
129 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
130 case wxSYS_COLOUR_MENUHILIGHT:
131 // TODO:
132 resultColor = *wxBLACK;
133 break ;
134
135 // case wxSYS_COLOUR_MAX:
136 default:
137 resultColor = *wxWHITE;
138 // wxCHECK_MSG( index >= wxSYS_COLOUR_MAX, false, _T("unknown system colour index") );
139 break ;
140 }
141
142 return resultColor;
143 }
144
145 // ----------------------------------------------------------------------------
146 // fonts
147 // ----------------------------------------------------------------------------
148
149 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
150 {
151 switch (index)
152 {
153 case wxSYS_ANSI_VAR_FONT :
154 case wxSYS_SYSTEM_FONT :
155 case wxSYS_DEVICE_DEFAULT_FONT :
156 case wxSYS_DEFAULT_GUI_FONT :
157 return *wxSMALL_FONT ;
158 break ;
159
160 default :
161 break ;
162 }
163
164 return *wxNORMAL_FONT;
165 }
166
167 // ----------------------------------------------------------------------------
168 // system metrics/features
169 // ----------------------------------------------------------------------------
170
171 // Get a system metric, e.g. scrollbar size
172 int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win))
173 {
174 int value;
175
176 switch ( index )
177 {
178 case wxSYS_MOUSE_BUTTONS:
179 // we emulate a two button mouse (ctrl + click = right button)
180 return 2;
181
182 // TODO case wxSYS_BORDER_X:
183 // TODO case wxSYS_BORDER_Y:
184 // TODO case wxSYS_CURSOR_X:
185 // TODO case wxSYS_CURSOR_Y:
186 // TODO case wxSYS_DCLICK_X:
187 // TODO case wxSYS_DCLICK_Y:
188 // TODO case wxSYS_DRAG_X:
189 // TODO case wxSYS_DRAG_Y:
190 // TODO case wxSYS_EDGE_X:
191 // TODO case wxSYS_EDGE_Y:
192
193 case wxSYS_HSCROLL_ARROW_X:
194 case wxSYS_HSCROLL_ARROW_Y:
195 case wxSYS_HTHUMB_X:
196 return 16;
197
198 // TODO case wxSYS_ICON_X:
199 // TODO case wxSYS_ICON_Y:
200 // TODO case wxSYS_ICONSPACING_X:
201 // TODO case wxSYS_ICONSPACING_Y:
202 // TODO case wxSYS_WINDOWMIN_X:
203 // TODO case wxSYS_WINDOWMIN_Y:
204
205 case wxSYS_SCREEN_X:
206 wxDisplaySize( &value, NULL );
207 return value;
208
209 case wxSYS_SCREEN_Y:
210 wxDisplaySize( NULL, &value );
211 return value;
212
213 // TODO case wxSYS_FRAMESIZE_X:
214 // TODO case wxSYS_FRAMESIZE_Y:
215 // TODO case wxSYS_SMALLICON_X:
216 // TODO case wxSYS_SMALLICON_Y:
217
218 case wxSYS_HSCROLL_Y:
219 case wxSYS_VSCROLL_X:
220 case wxSYS_VSCROLL_ARROW_X:
221 case wxSYS_VSCROLL_ARROW_Y:
222 case wxSYS_VTHUMB_Y:
223 return 16;
224
225 case wxSYS_PENWINDOWS_PRESENT:
226 return 0;
227
228 case wxSYS_SWAP_BUTTONS:
229 return 0;
230
231 // TODO: case wxSYS_CAPTION_Y:
232 // TODO: case wxSYS_MENU_Y:
233 // TODO: case wxSYS_NETWORK_PRESENT:
234 // TODO: case wxSYS_SHOW_SOUNDS:
235
236 default:
237 // unsupported metric
238 break;
239 }
240
241 return -1;
242 }
243
244 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
245 {
246 switch (index)
247 {
248 case wxSYS_CAN_ICONIZE_FRAME:
249 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
250 return true;
251
252 default:
253 return false;
254 }
255 }