]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/settings.cpp
use wx-style header and commets; fix indentation to be 4 spaces; move Doxygen comment...
[wxWidgets.git] / src / mac / carbon / settings.cpp
CommitLineData
e9576ca5 1/////////////////////////////////////////////////////////////////////////////
de6185e2 2// Name: src/mac/carbon/settings.cpp
e9576ca5 3// Purpose: wxSettings
a31a5f85 4// Author: Stefan Csomor
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878
SC
12#include "wx/wxprec.h"
13
e9576ca5 14#include "wx/settings.h"
de6185e2
WS
15
16#ifndef WX_PRECOMP
17 #include "wx/utils.h"
dd05139a 18 #include "wx/gdicmn.h"
de6185e2
WS
19#endif
20
76a5e5d2
SC
21#include "wx/mac/uma.h"
22
a174f139
GD
23// ----------------------------------------------------------------------------
24// wxSystemSettingsNative
25// ----------------------------------------------------------------------------
26
27// ----------------------------------------------------------------------------
28// colours
29// ----------------------------------------------------------------------------
30
31wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
e9576ca5 32{
76e36d43 33 wxColour resultColor;
76e36d43
DS
34 ThemeBrush colorBrushID;
35
76e36d43 36 switch ( index )
00500f40 37 {
26af4dbd
SC
38 case wxSYS_COLOUR_WINDOW:
39 resultColor = *wxWHITE ;
40 break ;
00500f40
RR
41 case wxSYS_COLOUR_SCROLLBAR :
42 case wxSYS_COLOUR_BACKGROUND:
43 case wxSYS_COLOUR_ACTIVECAPTION:
44 case wxSYS_COLOUR_INACTIVECAPTION:
45 case wxSYS_COLOUR_MENU:
00500f40
RR
46 case wxSYS_COLOUR_WINDOWFRAME:
47 case wxSYS_COLOUR_ACTIVEBORDER:
48 case wxSYS_COLOUR_INACTIVEBORDER:
49 case wxSYS_COLOUR_BTNFACE:
fc1f7cd5 50 case wxSYS_COLOUR_MENUBAR:
76e36d43 51 resultColor = wxColor( 0xDD, 0xDD, 0xDD );
00500f40 52 break ;
519cb848 53
00500f40 54 case wxSYS_COLOUR_LISTBOX :
a01d9a25 55 resultColor = *wxWHITE ;
00500f40 56 break ;
76e36d43 57
00500f40 58 case wxSYS_COLOUR_BTNSHADOW:
a01d9a25 59 resultColor = wxColor( 0xBE, 0xBE, 0xBE );
00500f40 60 break ;
519cb848 61
00500f40
RR
62 case wxSYS_COLOUR_BTNTEXT:
63 case wxSYS_COLOUR_MENUTEXT:
64 case wxSYS_COLOUR_WINDOWTEXT:
65 case wxSYS_COLOUR_CAPTIONTEXT:
66 case wxSYS_COLOUR_INFOTEXT:
67 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
76e36d43 68 resultColor = *wxBLACK;
00500f40 69 break ;
76e36d43 70
00500f40 71 case wxSYS_COLOUR_HIGHLIGHT:
276ee533 72 {
80f3f3be 73#if 0
76e36d43 74 // NB: enable this case as desired
276ee533 75 colorBrushID = kThemeBrushAlternatePrimaryHighlightColor;
76e36d43 76#else
276ee533 77 colorBrushID = kThemeBrushPrimaryHighlightColor;
76e36d43 78#endif
a01d9a25 79 resultColor = wxColor( wxMacCreateCGColorFromHITheme(colorBrushID) );
276ee533 80 }
00500f40 81 break ;
76e36d43 82
00500f40
RR
83 case wxSYS_COLOUR_BTNHIGHLIGHT:
84 case wxSYS_COLOUR_GRAYTEXT:
76e36d43 85 resultColor = wxColor( 0xCC, 0xCC, 0xCC );
00500f40 86 break ;
902725ee 87
00500f40 88 case wxSYS_COLOUR_3DDKSHADOW:
76e36d43 89 resultColor = wxColor( 0x44, 0x44, 0x44 );
00500f40 90 break ;
76e36d43 91
00500f40 92 case wxSYS_COLOUR_3DLIGHT:
76e36d43 93 resultColor = wxColor( 0xCC, 0xCC, 0xCC );
00500f40 94 break ;
76e36d43 95
00500f40 96 case wxSYS_COLOUR_HIGHLIGHTTEXT :
80f3f3be 97#if 0
76e36d43
DS
98 // NB: enable this case as desired
99 resultColor = *wxWHITE ;
100#else
276ee533 101 {
a01d9a25 102 wxColour highlightcolor( wxMacCreateCGColorFromHITheme(kThemeBrushPrimaryHighlightColor) );
276ee533
SC
103 if ((highlightcolor.Red() + highlightcolor.Green() + highlightcolor.Blue() ) == 0)
104 resultColor = *wxWHITE ;
105 else
106 resultColor = *wxBLACK ;
107 }
76e36d43 108#endif
00500f40 109 break ;
76e36d43 110
00500f40 111 case wxSYS_COLOUR_INFOBK :
bea6ba2d
VS
112 // we don't have a way to detect tooltip color, so use the
113 // standard value used at least on 10.4:
114 resultColor = wxColour( 0xFF, 0xFF, 0xD3 ) ;
00500f40 115 break ;
26af4dbd
SC
116 case wxSYS_COLOUR_APPWORKSPACE:
117 resultColor = wxColor( 0x80, 0x80, 0x80 ); ;
118 break ;
fc1f7cd5
GD
119
120 case wxSYS_COLOUR_HOTLIGHT:
121 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
122 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
123 case wxSYS_COLOUR_MENUHILIGHT:
76e36d43
DS
124 // TODO:
125 resultColor = *wxBLACK;
126 break ;
902725ee 127
76e36d43
DS
128 // case wxSYS_COLOUR_MAX:
129 default:
130 resultColor = *wxWHITE;
131 // wxCHECK_MSG( index >= wxSYS_COLOUR_MAX, false, _T("unknown system colour index") );
fc1f7cd5 132 break ;
00500f40 133 }
76e36d43
DS
134
135 return resultColor;
e9576ca5
SC
136}
137
a174f139
GD
138// ----------------------------------------------------------------------------
139// fonts
140// ----------------------------------------------------------------------------
141
142wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
e9576ca5 143{
e9576ca5
SC
144 switch (index)
145 {
519cb848
SC
146 case wxSYS_ANSI_VAR_FONT :
147 case wxSYS_SYSTEM_FONT :
148 case wxSYS_DEVICE_DEFAULT_FONT :
149 case wxSYS_DEFAULT_GUI_FONT :
76e36d43 150 return *wxSMALL_FONT ;
00500f40 151 break ;
902725ee 152
519cb848 153 default :
00500f40 154 break ;
e9576ca5 155 }
76e36d43 156
519cb848 157 return *wxNORMAL_FONT;
e9576ca5
SC
158}
159
a174f139
GD
160// ----------------------------------------------------------------------------
161// system metrics/features
162// ----------------------------------------------------------------------------
163
e9576ca5 164// Get a system metric, e.g. scrollbar size
9b0b5ba7 165int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win))
e9576ca5 166{
e8ca7105
GD
167 int value;
168
76e36d43 169 switch ( index )
00500f40 170 {
e9576ca5 171 case wxSYS_MOUSE_BUTTONS:
76e36d43 172 // we emulate a two button mouse (ctrl + click = right button)
e8ca7105 173 return 2;
902725ee 174
1d451c5b
RD
175 // TODO case wxSYS_BORDER_X:
176 // TODO case wxSYS_BORDER_Y:
177 // TODO case wxSYS_CURSOR_X:
178 // TODO case wxSYS_CURSOR_Y:
179 // TODO case wxSYS_DCLICK_X:
180 // TODO case wxSYS_DCLICK_Y:
181 // TODO case wxSYS_DRAG_X:
182 // TODO case wxSYS_DRAG_Y:
183 // TODO case wxSYS_EDGE_X:
184 // TODO case wxSYS_EDGE_Y:
902725ee 185
e9576ca5 186 case wxSYS_HSCROLL_ARROW_X:
e9576ca5 187 case wxSYS_HSCROLL_ARROW_Y:
e9576ca5 188 case wxSYS_HTHUMB_X:
a174f139 189 return 16;
902725ee 190
1d451c5b
RD
191 // TODO case wxSYS_ICON_X:
192 // TODO case wxSYS_ICON_Y:
193 // TODO case wxSYS_ICONSPACING_X:
194 // TODO case wxSYS_ICONSPACING_Y:
195 // TODO case wxSYS_WINDOWMIN_X:
196 // TODO case wxSYS_WINDOWMIN_Y:
197
e9576ca5 198 case wxSYS_SCREEN_X:
76e36d43 199 wxDisplaySize( &value, NULL );
e8ca7105 200 return value;
76e36d43 201
e9576ca5 202 case wxSYS_SCREEN_Y:
76e36d43 203 wxDisplaySize( NULL, &value );
e8ca7105 204 return value;
902725ee 205
1d451c5b
RD
206 // TODO case wxSYS_FRAMESIZE_X:
207 // TODO case wxSYS_FRAMESIZE_Y:
208 // TODO case wxSYS_SMALLICON_X:
209 // TODO case wxSYS_SMALLICON_Y:
902725ee 210
e9576ca5 211 case wxSYS_HSCROLL_Y:
e9576ca5 212 case wxSYS_VSCROLL_X:
e9576ca5 213 case wxSYS_VSCROLL_ARROW_X:
e9576ca5 214 case wxSYS_VSCROLL_ARROW_Y:
e9576ca5 215 case wxSYS_VTHUMB_Y:
a174f139 216 return 16;
902725ee 217
e9576ca5 218 case wxSYS_PENWINDOWS_PRESENT:
a174f139 219 return 0;
902725ee 220
e9576ca5 221 case wxSYS_SWAP_BUTTONS:
a174f139 222 return 0;
1d451c5b 223
76e36d43
DS
224 // TODO: case wxSYS_CAPTION_Y:
225 // TODO: case wxSYS_MENU_Y:
226 // TODO: case wxSYS_NETWORK_PRESENT:
227 // TODO: case wxSYS_SHOW_SOUNDS:
228
9cd80843 229 case wxSYS_DCLICK_MSEC:
276ee533
SC
230#ifdef __LP64__
231 // default on mac is 30 ticks, we shouldn't really use wxSYS_DCLICK_MSEC anyway
232 // but rather rely on the 'click-count' by the system delivered in a mouse event
233 return 500;
234#else
9cd80843 235 return (int)(GetDblTime() * 1000. / 60.);
276ee533 236#endif
a174f139 237 default:
76e36d43
DS
238 // unsupported metric
239 break;
00500f40 240 }
76e36d43 241
902725ee 242 return -1;
e9576ca5
SC
243}
244
a174f139 245bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
253293c1
VS
246{
247 switch (index)
248 {
902725ee 249 case wxSYS_CAN_ICONIZE_FRAME:
253293c1 250 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
902725ee
WS
251 return true;
252
253293c1 253 default:
902725ee 254 return false;
253293c1
VS
255 }
256}