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