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