1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/settings.cpp
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/settings.h"
18 #include "wx/gdicmn.h"
21 #include "wx/osx/private.h"
22 #include "wx/fontenum.h"
24 // ----------------------------------------------------------------------------
25 // wxSystemSettingsNative
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 wxColour
wxSystemSettingsNative::GetColour(wxSystemColour index
)
35 #if wxOSX_USE_COCOA_OR_CARBON
36 ThemeBrush colorBrushID
;
41 case wxSYS_COLOUR_WINDOW
:
42 #if wxOSX_USE_COCOA_OR_CARBON
43 resultColor
= wxColour(wxMacCreateCGColorFromHITheme( 15 /* kThemeBrushDocumentWindowBackground */ )) ;
45 resultColor
= *wxWHITE
;
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
:
58 #if wxOSX_USE_COCOA_OR_CARBON
59 resultColor
= wxColour(wxMacCreateCGColorFromHITheme( 3 /* kThemeBrushDialogBackgroundActive */));
61 resultColor
= wxColour( 0xBE, 0xBE, 0xBE ) ;
65 case wxSYS_COLOUR_LISTBOX
:
66 resultColor
= *wxWHITE
;
69 case wxSYS_COLOUR_BTNSHADOW
:
70 resultColor
= wxColour( 0xBE, 0xBE, 0xBE );
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
:
79 case wxSYS_COLOUR_LISTBOXTEXT
:
80 resultColor
= *wxBLACK
;
83 case wxSYS_COLOUR_HIGHLIGHT
:
85 #if wxOSX_USE_COCOA_OR_CARBON
87 // NB: enable this case as desired
88 colorBrushID
= kThemeBrushAlternatePrimaryHighlightColor
;
90 colorBrushID
= -3 /* kThemeBrushPrimaryHighlightColor */;
92 resultColor
= wxColour( wxMacCreateCGColorFromHITheme(colorBrushID
) );
94 resultColor
= wxColor( 0xCC, 0xCC, 0xFF );
99 case wxSYS_COLOUR_BTNHIGHLIGHT
:
100 case wxSYS_COLOUR_GRAYTEXT
:
101 resultColor
= wxColor( 0xCC, 0xCC, 0xCC );
104 case wxSYS_COLOUR_3DDKSHADOW
:
105 resultColor
= wxColor( 0x44, 0x44, 0x44 );
108 case wxSYS_COLOUR_3DLIGHT
:
109 resultColor
= wxColor( 0xCC, 0xCC, 0xCC );
112 case wxSYS_COLOUR_HIGHLIGHTTEXT
:
113 case wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT
:
114 #if wxOSX_USE_COCOA_OR_CARBON
116 wxColour
highlightcolor( wxMacCreateCGColorFromHITheme(-3 /* kThemeBrushPrimaryHighlightColor */) );
117 if ((highlightcolor
.Red() + highlightcolor
.Green() + highlightcolor
.Blue() ) == 0)
118 resultColor
= *wxWHITE
;
120 resultColor
= *wxBLACK
;
123 resultColor
= *wxWHITE
;
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 ) ;
132 case wxSYS_COLOUR_APPWORKSPACE
:
133 resultColor
= wxColor( 0x80, 0x80, 0x80 ); ;
136 case wxSYS_COLOUR_HOTLIGHT
:
137 case wxSYS_COLOUR_GRADIENTACTIVECAPTION
:
138 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION
:
139 case wxSYS_COLOUR_MENUHILIGHT
:
141 resultColor
= *wxBLACK
;
144 // case wxSYS_COLOUR_MAX:
146 resultColor
= *wxWHITE
;
147 // wxCHECK_MSG( index >= wxSYS_COLOUR_MAX, false, wxT("unknown system colour index") );
151 //wxASSERT(resultColor.IsOk());
156 // ----------------------------------------------------------------------------
158 // ----------------------------------------------------------------------------
160 wxFont
wxSystemSettingsNative::GetFont(wxSystemFont index
)
166 case wxSYS_ANSI_VAR_FONT
:
167 case wxSYS_SYSTEM_FONT
:
168 case wxSYS_DEVICE_DEFAULT_FONT
:
169 case wxSYS_DEFAULT_GUI_FONT
:
170 font
= *wxSMALL_FONT
;
174 font
= *wxNORMAL_FONT
;
178 //wxASSERT(font.IsOk() && wxFontEnumerator::IsValidFacename(font.GetFaceName()));
183 // ----------------------------------------------------------------------------
184 // system metrics/features
185 // ----------------------------------------------------------------------------
187 // Get a system metric, e.g. scrollbar size
188 int wxSystemSettingsNative::GetMetric(wxSystemMetric index
, wxWindow
* WXUNUSED(win
))
194 case wxSYS_MOUSE_BUTTONS
:
195 // we emulate a two button mouse (ctrl + click = right button)
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:
209 case wxSYS_HSCROLL_ARROW_X
:
210 case wxSYS_HSCROLL_ARROW_Y
:
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:
222 wxDisplaySize( &value
, NULL
);
226 wxDisplaySize( NULL
, &value
);
229 // TODO case wxSYS_FRAMESIZE_X:
230 // TODO case wxSYS_FRAMESIZE_Y:
231 // TODO case wxSYS_SMALLICON_X:
232 // TODO case wxSYS_SMALLICON_Y:
234 case wxSYS_HSCROLL_Y
:
235 case wxSYS_VSCROLL_X
:
236 case wxSYS_VSCROLL_ARROW_X
:
237 case wxSYS_VSCROLL_ARROW_Y
:
241 case wxSYS_PENWINDOWS_PRESENT
:
244 case wxSYS_SWAP_BUTTONS
:
247 // TODO: case wxSYS_CAPTION_Y:
248 // TODO: case wxSYS_MENU_Y:
249 // TODO: case wxSYS_NETWORK_PRESENT:
250 // TODO: case wxSYS_SHOW_SOUNDS:
252 case wxSYS_DCLICK_MSEC
:
254 return (int)(GetDblTime() * 1000. / 60.);
256 // default on mac is 30 ticks, we shouldn't really use wxSYS_DCLICK_MSEC anyway
257 // but rather rely on the 'click-count' by the system delivered in a mouse event
261 // unsupported metric
268 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index
)
272 case wxSYS_CAN_ICONIZE_FRAME
:
273 case wxSYS_CAN_DRAW_FRAME_DECORATIONS
: