]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/osx/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( 15 /* 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( 3 /* 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 | case wxSYS_COLOUR_LISTBOXTEXT: | |
79 | resultColor = *wxBLACK; | |
80 | break ; | |
81 | ||
82 | case wxSYS_COLOUR_HIGHLIGHT: | |
83 | { | |
84 | #if wxOSX_USE_COCOA_OR_CARBON | |
85 | #if 0 | |
86 | // NB: enable this case as desired | |
87 | colorBrushID = kThemeBrushAlternatePrimaryHighlightColor; | |
88 | #else | |
89 | colorBrushID = -3 /* kThemeBrushPrimaryHighlightColor */; | |
90 | #endif | |
91 | resultColor = wxColour( wxMacCreateCGColorFromHITheme(colorBrushID) ); | |
92 | #else | |
93 | resultColor = wxColor( 0xCC, 0xCC, 0xFF ); | |
94 | #endif | |
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 : | |
112 | #if wxOSX_USE_COCOA_OR_CARBON | |
113 | { | |
114 | wxColour highlightcolor( wxMacCreateCGColorFromHITheme(-3 /* kThemeBrushPrimaryHighlightColor */) ); | |
115 | if ((highlightcolor.Red() + highlightcolor.Green() + highlightcolor.Blue() ) == 0) | |
116 | resultColor = *wxWHITE ; | |
117 | else | |
118 | resultColor = *wxBLACK ; | |
119 | } | |
120 | #else | |
121 | resultColor = *wxWHITE ; | |
122 | #endif | |
123 | break ; | |
124 | ||
125 | case wxSYS_COLOUR_INFOBK : | |
126 | // we don't have a way to detect tooltip color, so use the | |
127 | // standard value used at least on 10.4: | |
128 | resultColor = wxColour( 0xFF, 0xFF, 0xD3 ) ; | |
129 | break ; | |
130 | case wxSYS_COLOUR_APPWORKSPACE: | |
131 | resultColor = wxColor( 0x80, 0x80, 0x80 ); ; | |
132 | break ; | |
133 | ||
134 | case wxSYS_COLOUR_HOTLIGHT: | |
135 | case wxSYS_COLOUR_GRADIENTACTIVECAPTION: | |
136 | case wxSYS_COLOUR_GRADIENTINACTIVECAPTION: | |
137 | case wxSYS_COLOUR_MENUHILIGHT: | |
138 | // TODO: | |
139 | resultColor = *wxBLACK; | |
140 | break ; | |
141 | ||
142 | // case wxSYS_COLOUR_MAX: | |
143 | default: | |
144 | resultColor = *wxWHITE; | |
145 | // wxCHECK_MSG( index >= wxSYS_COLOUR_MAX, false, _T("unknown system colour index") ); | |
146 | break ; | |
147 | } | |
148 | ||
149 | return resultColor; | |
150 | } | |
151 | ||
152 | // ---------------------------------------------------------------------------- | |
153 | // fonts | |
154 | // ---------------------------------------------------------------------------- | |
155 | ||
156 | wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) | |
157 | { | |
158 | switch (index) | |
159 | { | |
160 | case wxSYS_ANSI_VAR_FONT : | |
161 | case wxSYS_SYSTEM_FONT : | |
162 | case wxSYS_DEVICE_DEFAULT_FONT : | |
163 | case wxSYS_DEFAULT_GUI_FONT : | |
164 | return *wxSMALL_FONT ; | |
165 | break ; | |
166 | ||
167 | default : | |
168 | break ; | |
169 | } | |
170 | ||
171 | return *wxNORMAL_FONT; | |
172 | } | |
173 | ||
174 | // ---------------------------------------------------------------------------- | |
175 | // system metrics/features | |
176 | // ---------------------------------------------------------------------------- | |
177 | ||
178 | // Get a system metric, e.g. scrollbar size | |
179 | int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win)) | |
180 | { | |
181 | int value; | |
182 | ||
183 | switch ( index ) | |
184 | { | |
185 | case wxSYS_MOUSE_BUTTONS: | |
186 | // we emulate a two button mouse (ctrl + click = right button) | |
187 | return 2; | |
188 | ||
189 | // TODO case wxSYS_BORDER_X: | |
190 | // TODO case wxSYS_BORDER_Y: | |
191 | // TODO case wxSYS_CURSOR_X: | |
192 | // TODO case wxSYS_CURSOR_Y: | |
193 | // TODO case wxSYS_DCLICK_X: | |
194 | // TODO case wxSYS_DCLICK_Y: | |
195 | // TODO case wxSYS_DRAG_X: | |
196 | // TODO case wxSYS_DRAG_Y: | |
197 | // TODO case wxSYS_EDGE_X: | |
198 | // TODO case wxSYS_EDGE_Y: | |
199 | ||
200 | case wxSYS_HSCROLL_ARROW_X: | |
201 | case wxSYS_HSCROLL_ARROW_Y: | |
202 | case wxSYS_HTHUMB_X: | |
203 | return 16; | |
204 | ||
205 | // TODO case wxSYS_ICON_X: | |
206 | // TODO case wxSYS_ICON_Y: | |
207 | // TODO case wxSYS_ICONSPACING_X: | |
208 | // TODO case wxSYS_ICONSPACING_Y: | |
209 | // TODO case wxSYS_WINDOWMIN_X: | |
210 | // TODO case wxSYS_WINDOWMIN_Y: | |
211 | ||
212 | case wxSYS_SCREEN_X: | |
213 | wxDisplaySize( &value, NULL ); | |
214 | return value; | |
215 | ||
216 | case wxSYS_SCREEN_Y: | |
217 | wxDisplaySize( NULL, &value ); | |
218 | return value; | |
219 | ||
220 | // TODO case wxSYS_FRAMESIZE_X: | |
221 | // TODO case wxSYS_FRAMESIZE_Y: | |
222 | // TODO case wxSYS_SMALLICON_X: | |
223 | // TODO case wxSYS_SMALLICON_Y: | |
224 | ||
225 | case wxSYS_HSCROLL_Y: | |
226 | case wxSYS_VSCROLL_X: | |
227 | case wxSYS_VSCROLL_ARROW_X: | |
228 | case wxSYS_VSCROLL_ARROW_Y: | |
229 | case wxSYS_VTHUMB_Y: | |
230 | return 16; | |
231 | ||
232 | case wxSYS_PENWINDOWS_PRESENT: | |
233 | return 0; | |
234 | ||
235 | case wxSYS_SWAP_BUTTONS: | |
236 | return 0; | |
237 | ||
238 | // TODO: case wxSYS_CAPTION_Y: | |
239 | // TODO: case wxSYS_MENU_Y: | |
240 | // TODO: case wxSYS_NETWORK_PRESENT: | |
241 | // TODO: case wxSYS_SHOW_SOUNDS: | |
242 | ||
243 | case wxSYS_DCLICK_MSEC: | |
244 | #if wxOSX_USE_CARBON | |
245 | return (int)(GetDblTime() * 1000. / 60.); | |
246 | #else | |
247 | // default on mac is 30 ticks, we shouldn't really use wxSYS_DCLICK_MSEC anyway | |
248 | // but rather rely on the 'click-count' by the system delivered in a mouse event | |
249 | return 500; | |
250 | #endif | |
251 | default: | |
252 | // unsupported metric | |
253 | break; | |
254 | } | |
255 | ||
256 | return -1; | |
257 | } | |
258 | ||
259 | bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) | |
260 | { | |
261 | switch (index) | |
262 | { | |
263 | case wxSYS_CAN_ICONIZE_FRAME: | |
264 | case wxSYS_CAN_DRAW_FRAME_DECORATIONS: | |
265 | return true; | |
266 | ||
267 | default: | |
268 | return false; | |
269 | } | |
270 | } |