]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/settings.cpp
bitmap button size was too small when uxtheme functions were used to get the margins
[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 #endif
19
20 #include "wx/gdicmn.h"
21
22 #include "wx/mac/uma.h"
23
24 // ----------------------------------------------------------------------------
25 // wxSystemSettingsNative
26 // ----------------------------------------------------------------------------
27
28 // ----------------------------------------------------------------------------
29 // colours
30 // ----------------------------------------------------------------------------
31
32 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
33 {
34 int major, minor;
35 wxColour resultColor;
36 RGBColor macRGB;
37 ThemeBrush colorBrushID;
38
39 wxGetOsVersion( &major, &minor );
40
41 switch ( index )
42 {
43 case wxSYS_COLOUR_SCROLLBAR :
44 case wxSYS_COLOUR_BACKGROUND:
45 case wxSYS_COLOUR_ACTIVECAPTION:
46 case wxSYS_COLOUR_INACTIVECAPTION:
47 case wxSYS_COLOUR_MENU:
48 case wxSYS_COLOUR_WINDOW:
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 && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
83 // NB: enable this case as desired
84 colorBrushID = kThemeBrushAlternatePrimaryHighlightColor;
85 #else
86 colorBrushID = kThemeBrushPrimaryHighlightColor;
87 #endif
88
89 GetThemeBrushAsColor( colorBrushID, 32, true, &macRGB );
90 resultColor = wxColor( macRGB.red >> 8, macRGB.green >> 8, macRGB.blue >> 8 );
91 break ;
92
93 case wxSYS_COLOUR_BTNHIGHLIGHT:
94 case wxSYS_COLOUR_GRAYTEXT:
95 resultColor = wxColor( 0xCC, 0xCC, 0xCC );
96 break ;
97
98 case wxSYS_COLOUR_3DDKSHADOW:
99 resultColor = wxColor( 0x44, 0x44, 0x44 );
100 break ;
101
102 case wxSYS_COLOUR_3DLIGHT:
103 resultColor = wxColor( 0xCC, 0xCC, 0xCC );
104 break ;
105
106 case wxSYS_COLOUR_HIGHLIGHTTEXT :
107 #if 0 && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
108 // NB: enable this case as desired
109 resultColor = *wxWHITE ;
110 #else
111 GetThemeBrushAsColor( kThemeBrushPrimaryHighlightColor, 32, true, &macRGB );
112 if ((macRGB.red + macRGB.green + macRGB.blue) == 0)
113 resultColor = *wxWHITE ;
114 else
115 resultColor = *wxBLACK ;
116 #endif
117 break ;
118
119 case wxSYS_COLOUR_INFOBK :
120 case wxSYS_COLOUR_APPWORKSPACE:
121 resultColor = *wxWHITE ;
122 break ;
123
124 case wxSYS_COLOUR_HOTLIGHT:
125 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
126 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
127 case wxSYS_COLOUR_MENUHILIGHT:
128 // TODO:
129 resultColor = *wxBLACK;
130 break ;
131
132 // case wxSYS_COLOUR_MAX:
133 default:
134 resultColor = *wxWHITE;
135 // wxCHECK_MSG( index >= wxSYS_COLOUR_MAX, false, _T("unknown system colour index") );
136 break ;
137 }
138
139 return resultColor;
140 }
141
142 // ----------------------------------------------------------------------------
143 // fonts
144 // ----------------------------------------------------------------------------
145
146 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
147 {
148 switch (index)
149 {
150 case wxSYS_ANSI_VAR_FONT :
151 case wxSYS_SYSTEM_FONT :
152 case wxSYS_DEVICE_DEFAULT_FONT :
153 case wxSYS_DEFAULT_GUI_FONT :
154 return *wxSMALL_FONT ;
155 break ;
156
157 default :
158 break ;
159 }
160
161 return *wxNORMAL_FONT;
162 }
163
164 // ----------------------------------------------------------------------------
165 // system metrics/features
166 // ----------------------------------------------------------------------------
167
168 // Get a system metric, e.g. scrollbar size
169 int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win))
170 {
171 int value;
172
173 switch ( index )
174 {
175 case wxSYS_MOUSE_BUTTONS:
176 // we emulate a two button mouse (ctrl + click = right button)
177 return 2;
178
179 // TODO case wxSYS_BORDER_X:
180 // TODO case wxSYS_BORDER_Y:
181 // TODO case wxSYS_CURSOR_X:
182 // TODO case wxSYS_CURSOR_Y:
183 // TODO case wxSYS_DCLICK_X:
184 // TODO case wxSYS_DCLICK_Y:
185 // TODO case wxSYS_DRAG_X:
186 // TODO case wxSYS_DRAG_Y:
187 // TODO case wxSYS_EDGE_X:
188 // TODO case wxSYS_EDGE_Y:
189
190 case wxSYS_HSCROLL_ARROW_X:
191 case wxSYS_HSCROLL_ARROW_Y:
192 case wxSYS_HTHUMB_X:
193 return 16;
194
195 // TODO case wxSYS_ICON_X:
196 // TODO case wxSYS_ICON_Y:
197 // TODO case wxSYS_ICONSPACING_X:
198 // TODO case wxSYS_ICONSPACING_Y:
199 // TODO case wxSYS_WINDOWMIN_X:
200 // TODO case wxSYS_WINDOWMIN_Y:
201
202 case wxSYS_SCREEN_X:
203 wxDisplaySize( &value, NULL );
204 return value;
205
206 case wxSYS_SCREEN_Y:
207 wxDisplaySize( NULL, &value );
208 return value;
209
210 // TODO case wxSYS_FRAMESIZE_X:
211 // TODO case wxSYS_FRAMESIZE_Y:
212 // TODO case wxSYS_SMALLICON_X:
213 // TODO case wxSYS_SMALLICON_Y:
214
215 case wxSYS_HSCROLL_Y:
216 case wxSYS_VSCROLL_X:
217 case wxSYS_VSCROLL_ARROW_X:
218 case wxSYS_VSCROLL_ARROW_Y:
219 case wxSYS_VTHUMB_Y:
220 return 16;
221
222 case wxSYS_PENWINDOWS_PRESENT:
223 return 0;
224
225 case wxSYS_SWAP_BUTTONS:
226 return 0;
227
228 // TODO: case wxSYS_CAPTION_Y:
229 // TODO: case wxSYS_MENU_Y:
230 // TODO: case wxSYS_NETWORK_PRESENT:
231 // TODO: case wxSYS_SHOW_SOUNDS:
232
233 default:
234 // unsupported metric
235 break;
236 }
237
238 return -1;
239 }
240
241 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
242 {
243 switch (index)
244 {
245 case wxSYS_CAN_ICONIZE_FRAME:
246 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
247 return true;
248
249 default:
250 return false;
251 }
252 }