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