]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/settings.mm
build fixes for WXWIN_COMPATIBILITY_2_6=0
[wxWidgets.git] / src / cocoa / settings.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/settings.mm
3 // Purpose: wxSettings
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2005/01/11
7 // RCS-ID: $Id$
8 // Copyright: (c) 2005 David Elliott
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/cocoa/autorelease.h"
22
23 #import <AppKit/NSColor.h>
24
25 // ----------------------------------------------------------------------------
26 // wxSystemSettingsNative
27 // ----------------------------------------------------------------------------
28
29 // ----------------------------------------------------------------------------
30 // colours
31 // ----------------------------------------------------------------------------
32
33 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
34 {
35 wxAutoNSAutoreleasePool pool;
36 switch( index )
37 {
38 case wxSYS_COLOUR_SCROLLBAR:
39 return wxColour([NSColor scrollBarColor]); // color of slot
40 case wxSYS_COLOUR_BACKGROUND: // No idea how to get desktop background
41 break; // break so we return an invalid colour.
42 case wxSYS_COLOUR_ACTIVECAPTION: // No idea how to get this
43 // fall through, window background is reasonable
44 case wxSYS_COLOUR_INACTIVECAPTION: // No idea how to get this
45 // fall through, window background is reasonable
46 case wxSYS_COLOUR_MENU:
47 case wxSYS_COLOUR_MENUBAR:
48 case wxSYS_COLOUR_WINDOW:
49 case wxSYS_COLOUR_WINDOWFRAME:
50 case wxSYS_COLOUR_ACTIVEBORDER:
51 case wxSYS_COLOUR_INACTIVEBORDER:
52 return wxColour([NSColor windowFrameColor]);
53 case wxSYS_COLOUR_BTNFACE:
54 return wxColour([NSColor knobColor]); // close enough?
55 case wxSYS_COLOUR_LISTBOX:
56 return wxColour([NSColor controlBackgroundColor]);
57 case wxSYS_COLOUR_BTNSHADOW:
58 return wxColour([NSColor controlShadowColor]);
59 case wxSYS_COLOUR_BTNTEXT:
60 case wxSYS_COLOUR_MENUTEXT:
61 case wxSYS_COLOUR_WINDOWTEXT:
62 case wxSYS_COLOUR_CAPTIONTEXT:
63 case wxSYS_COLOUR_INFOTEXT:
64 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
65 return wxColour([NSColor controlTextColor]);
66 case wxSYS_COLOUR_HIGHLIGHT:
67 return wxColour([NSColor selectedControlColor]);
68 case wxSYS_COLOUR_BTNHIGHLIGHT:
69 return wxColour([NSColor controlHighlightColor]);
70 case wxSYS_COLOUR_GRAYTEXT:
71 return wxColour([NSColor disabledControlTextColor]);
72 case wxSYS_COLOUR_3DDKSHADOW:
73 return wxColour([NSColor controlShadowColor]);
74 case wxSYS_COLOUR_3DLIGHT:
75 return wxColour([NSColor controlHighlightColor]);
76 case wxSYS_COLOUR_HIGHLIGHTTEXT:
77 return wxColour([NSColor selectedControlTextColor]);
78 case wxSYS_COLOUR_INFOBK:
79 // tooltip (bogus)
80 return wxColour([NSColor controlBackgroundColor]);
81 case wxSYS_COLOUR_APPWORKSPACE:
82 // MDI window color (bogus)
83 return wxColour([NSColor windowBackgroundColor]);
84 case wxSYS_COLOUR_HOTLIGHT:
85 break; // what is this?
86 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
87 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
88 break; // Doesn't really apply to Cocoa.
89 case wxSYS_COLOUR_MENUHILIGHT:
90 return wxColour([NSColor selectedMenuItemColor]);
91 case wxSYS_COLOUR_MAX:
92 default:
93 if(index>=wxSYS_COLOUR_MAX)
94 {
95 wxFAIL_MSG(wxT("Invalid system colour index"));
96 return wxColour();
97 }
98 }
99 wxFAIL_MSG(wxT("Unimplemented system colour index"));
100 return wxColour();
101 }
102
103 // ----------------------------------------------------------------------------
104 // fonts
105 // ----------------------------------------------------------------------------
106
107 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
108 {
109 // return a nonworking font object, crash from wxInitializeStockObjects
110 return wxFont();
111 switch (index)
112 {
113 case wxSYS_ANSI_VAR_FONT :
114 case wxSYS_SYSTEM_FONT :
115 case wxSYS_DEVICE_DEFAULT_FONT :
116 case wxSYS_DEFAULT_GUI_FONT :
117 {
118 return *wxSMALL_FONT ;
119 } ;
120 break ;
121 case wxSYS_OEM_FIXED_FONT :
122 case wxSYS_ANSI_FIXED_FONT :
123 case wxSYS_SYSTEM_FIXED_FONT :
124 default :
125 {
126 return *wxNORMAL_FONT ;
127 } ;
128 break ;
129
130 }
131 return *wxNORMAL_FONT;
132 }
133
134 // ----------------------------------------------------------------------------
135 // system metrics/features
136 // ----------------------------------------------------------------------------
137
138 // Get a system metric, e.g. scrollbar size
139 int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win))
140 {
141 switch ( index)
142 {
143 case wxSYS_MOUSE_BUTTONS:
144 return 2; // we emulate a two button mouse (ctrl + click = right button )
145
146 // TODO case wxSYS_BORDER_X:
147 // TODO case wxSYS_BORDER_Y:
148 // TODO case wxSYS_CURSOR_X:
149 // TODO case wxSYS_CURSOR_Y:
150 // TODO case wxSYS_DCLICK_X:
151 // TODO case wxSYS_DCLICK_Y:
152 // TODO case wxSYS_DRAG_X:
153 // TODO case wxSYS_DRAG_Y:
154 // TODO case wxSYS_EDGE_X:
155 // TODO case wxSYS_EDGE_Y:
156
157 case wxSYS_HSCROLL_ARROW_X:
158 return 16;
159 case wxSYS_HSCROLL_ARROW_Y:
160 return 16;
161 case wxSYS_HTHUMB_X:
162 return 16;
163
164 // TODO case wxSYS_ICON_X:
165 // TODO case wxSYS_ICON_Y:
166 // TODO case wxSYS_ICONSPACING_X:
167 // TODO case wxSYS_ICONSPACING_Y:
168 // TODO case wxSYS_WINDOWMIN_X:
169 // TODO case wxSYS_WINDOWMIN_Y:
170 // TODO case wxSYS_SCREEN_X:
171 // TODO case wxSYS_SCREEN_Y:
172 // TODO case wxSYS_FRAMESIZE_X:
173 // TODO case wxSYS_FRAMESIZE_Y:
174 // TODO case wxSYS_SMALLICON_X:
175 // TODO case wxSYS_SMALLICON_Y:
176
177 case wxSYS_HSCROLL_Y:
178 return 16;
179 case wxSYS_VSCROLL_X:
180 return 16;
181 case wxSYS_VSCROLL_ARROW_X:
182 return 16;
183 case wxSYS_VSCROLL_ARROW_Y:
184 return 16;
185 case wxSYS_VTHUMB_Y:
186 return 16;
187
188 // TODO case wxSYS_CAPTION_Y:
189 // TODO case wxSYS_MENU_Y:
190 // TODO case wxSYS_NETWORK_PRESENT:
191
192 case wxSYS_PENWINDOWS_PRESENT:
193 return 0;
194
195 // TODO case wxSYS_SHOW_SOUNDS:
196
197 case wxSYS_SWAP_BUTTONS:
198 return 0;
199
200 default:
201 return -1; // unsupported metric
202 }
203 return 0;
204 }
205
206 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
207 {
208 switch (index)
209 {
210 case wxSYS_CAN_ICONIZE_FRAME:
211 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
212 return true;
213
214 default:
215 return false;
216 }
217 }