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