]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/settings.cpp
adding support for embedded controls in native toolbar
[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
DS
33 int major, minor;
34 wxColour resultColor;
35 RGBColor macRGB;
36 ThemeBrush colorBrushID;
37
00500f40 38 wxGetOsVersion( &major, &minor );
902725ee 39
76e36d43 40 switch ( index )
00500f40
RR
41 {
42 case wxSYS_COLOUR_SCROLLBAR :
43 case wxSYS_COLOUR_BACKGROUND:
44 case wxSYS_COLOUR_ACTIVECAPTION:
45 case wxSYS_COLOUR_INACTIVECAPTION:
46 case wxSYS_COLOUR_MENU:
47 case wxSYS_COLOUR_WINDOW:
48 case wxSYS_COLOUR_WINDOWFRAME:
49 case wxSYS_COLOUR_ACTIVEBORDER:
50 case wxSYS_COLOUR_INACTIVEBORDER:
51 case wxSYS_COLOUR_BTNFACE:
fc1f7cd5 52 case wxSYS_COLOUR_MENUBAR:
76e36d43 53 resultColor = wxColor( 0xDD, 0xDD, 0xDD );
00500f40 54 break ;
519cb848 55
00500f40 56 case wxSYS_COLOUR_LISTBOX :
00500f40 57 if (major >= 10)
76e36d43 58 resultColor = *wxWHITE ;
00500f40 59 else
76e36d43 60 resultColor = wxColor( 0xEE, 0xEE, 0xEE );
00500f40 61 break ;
76e36d43 62
00500f40 63 case wxSYS_COLOUR_BTNSHADOW:
11d1adbf 64 if (major >= 10)
76e36d43 65 resultColor = wxColor( 0xBE, 0xBE, 0xBE );
11d1adbf 66 else
76e36d43 67 resultColor = wxColor( 0x44, 0x44, 0x44 );
00500f40 68 break ;
519cb848 69
00500f40
RR
70 case wxSYS_COLOUR_BTNTEXT:
71 case wxSYS_COLOUR_MENUTEXT:
72 case wxSYS_COLOUR_WINDOWTEXT:
73 case wxSYS_COLOUR_CAPTIONTEXT:
74 case wxSYS_COLOUR_INFOTEXT:
75 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
76e36d43 76 resultColor = *wxBLACK;
00500f40 77 break ;
76e36d43 78
00500f40 79 case wxSYS_COLOUR_HIGHLIGHT:
76e36d43
DS
80
81#if 0 && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
82 // NB: enable this case as desired
83 colorBrushID = kThemeBrushAlternatePrimaryHighlightColor;
84#else
85 colorBrushID = kThemeBrushPrimaryHighlightColor;
86#endif
87
88 GetThemeBrushAsColor( colorBrushID, 32, true, &macRGB );
89 resultColor = wxColor( macRGB.red >> 8, macRGB.green >> 8, macRGB.blue >> 8 );
00500f40 90 break ;
76e36d43 91
00500f40
RR
92 case wxSYS_COLOUR_BTNHIGHLIGHT:
93 case wxSYS_COLOUR_GRAYTEXT:
76e36d43 94 resultColor = wxColor( 0xCC, 0xCC, 0xCC );
00500f40 95 break ;
902725ee 96
00500f40 97 case wxSYS_COLOUR_3DDKSHADOW:
76e36d43 98 resultColor = wxColor( 0x44, 0x44, 0x44 );
00500f40 99 break ;
76e36d43 100
00500f40 101 case wxSYS_COLOUR_3DLIGHT:
76e36d43 102 resultColor = wxColor( 0xCC, 0xCC, 0xCC );
00500f40 103 break ;
76e36d43 104
00500f40 105 case wxSYS_COLOUR_HIGHLIGHTTEXT :
76e36d43
DS
106#if 0 && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
107 // NB: enable this case as desired
108 resultColor = *wxWHITE ;
109#else
110 GetThemeBrushAsColor( kThemeBrushPrimaryHighlightColor, 32, true, &macRGB );
111 if ((macRGB.red + macRGB.green + macRGB.blue) == 0)
112 resultColor = *wxWHITE ;
113 else
114 resultColor = *wxBLACK ;
115#endif
00500f40 116 break ;
76e36d43 117
00500f40 118 case wxSYS_COLOUR_INFOBK :
902725ee 119 case wxSYS_COLOUR_APPWORKSPACE:
76e36d43 120 resultColor = *wxWHITE ;
00500f40 121 break ;
fc1f7cd5
GD
122
123 case wxSYS_COLOUR_HOTLIGHT:
124 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
125 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
126 case wxSYS_COLOUR_MENUHILIGHT:
76e36d43
DS
127 // TODO:
128 resultColor = *wxBLACK;
129 break ;
902725ee 130
76e36d43
DS
131 // case wxSYS_COLOUR_MAX:
132 default:
133 resultColor = *wxWHITE;
134 // wxCHECK_MSG( index >= wxSYS_COLOUR_MAX, false, _T("unknown system colour index") );
fc1f7cd5 135 break ;
00500f40 136 }
76e36d43
DS
137
138 return resultColor;
e9576ca5
SC
139}
140
a174f139
GD
141// ----------------------------------------------------------------------------
142// fonts
143// ----------------------------------------------------------------------------
144
145wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
e9576ca5 146{
e9576ca5
SC
147 switch (index)
148 {
519cb848
SC
149 case wxSYS_ANSI_VAR_FONT :
150 case wxSYS_SYSTEM_FONT :
151 case wxSYS_DEVICE_DEFAULT_FONT :
152 case wxSYS_DEFAULT_GUI_FONT :
76e36d43 153 return *wxSMALL_FONT ;
00500f40 154 break ;
902725ee 155
519cb848 156 default :
00500f40 157 break ;
e9576ca5 158 }
76e36d43 159
519cb848 160 return *wxNORMAL_FONT;
e9576ca5
SC
161}
162
a174f139
GD
163// ----------------------------------------------------------------------------
164// system metrics/features
165// ----------------------------------------------------------------------------
166
e9576ca5 167// Get a system metric, e.g. scrollbar size
9b0b5ba7 168int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win))
e9576ca5 169{
e8ca7105
GD
170 int value;
171
76e36d43 172 switch ( index )
00500f40 173 {
e9576ca5 174 case wxSYS_MOUSE_BUTTONS:
76e36d43 175 // we emulate a two button mouse (ctrl + click = right button)
e8ca7105 176 return 2;
902725ee 177
1d451c5b
RD
178 // TODO case wxSYS_BORDER_X:
179 // TODO case wxSYS_BORDER_Y:
180 // TODO case wxSYS_CURSOR_X:
181 // TODO case wxSYS_CURSOR_Y:
182 // TODO case wxSYS_DCLICK_X:
183 // TODO case wxSYS_DCLICK_Y:
184 // TODO case wxSYS_DRAG_X:
185 // TODO case wxSYS_DRAG_Y:
186 // TODO case wxSYS_EDGE_X:
187 // TODO case wxSYS_EDGE_Y:
902725ee 188
e9576ca5 189 case wxSYS_HSCROLL_ARROW_X:
e9576ca5 190 case wxSYS_HSCROLL_ARROW_Y:
e9576ca5 191 case wxSYS_HTHUMB_X:
a174f139 192 return 16;
902725ee 193
1d451c5b
RD
194 // TODO case wxSYS_ICON_X:
195 // TODO case wxSYS_ICON_Y:
196 // TODO case wxSYS_ICONSPACING_X:
197 // TODO case wxSYS_ICONSPACING_Y:
198 // TODO case wxSYS_WINDOWMIN_X:
199 // TODO case wxSYS_WINDOWMIN_Y:
200
e9576ca5 201 case wxSYS_SCREEN_X:
76e36d43 202 wxDisplaySize( &value, NULL );
e8ca7105 203 return value;
76e36d43 204
e9576ca5 205 case wxSYS_SCREEN_Y:
76e36d43 206 wxDisplaySize( NULL, &value );
e8ca7105 207 return value;
902725ee 208
1d451c5b
RD
209 // TODO case wxSYS_FRAMESIZE_X:
210 // TODO case wxSYS_FRAMESIZE_Y:
211 // TODO case wxSYS_SMALLICON_X:
212 // TODO case wxSYS_SMALLICON_Y:
902725ee 213
e9576ca5 214 case wxSYS_HSCROLL_Y:
e9576ca5 215 case wxSYS_VSCROLL_X:
e9576ca5 216 case wxSYS_VSCROLL_ARROW_X:
e9576ca5 217 case wxSYS_VSCROLL_ARROW_Y:
e9576ca5 218 case wxSYS_VTHUMB_Y:
a174f139 219 return 16;
902725ee 220
e9576ca5 221 case wxSYS_PENWINDOWS_PRESENT:
a174f139 222 return 0;
902725ee 223
e9576ca5 224 case wxSYS_SWAP_BUTTONS:
a174f139 225 return 0;
1d451c5b 226
76e36d43
DS
227 // TODO: case wxSYS_CAPTION_Y:
228 // TODO: case wxSYS_MENU_Y:
229 // TODO: case wxSYS_NETWORK_PRESENT:
230 // TODO: case wxSYS_SHOW_SOUNDS:
231
a174f139 232 default:
76e36d43
DS
233 // unsupported metric
234 break;
00500f40 235 }
76e36d43 236
902725ee 237 return -1;
e9576ca5
SC
238}
239
a174f139 240bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
253293c1
VS
241{
242 switch (index)
243 {
902725ee 244 case wxSYS_CAN_ICONIZE_FRAME:
253293c1 245 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
902725ee
WS
246 return true;
247
253293c1 248 default:
902725ee 249 return false;
253293c1
VS
250 }
251}