1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/settings.mm
4 // Author: David Elliott
8 // Copyright: (c) 2005 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/settings.h"
17 #include "wx/gdicmn.h"
20 #include "wx/cocoa/autorelease.h"
22 #import <AppKit/NSColor.h>
24 // ----------------------------------------------------------------------------
25 // wxSystemSettingsNative
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
34 wxAutoNSAutoreleasePool pool;
37 case wxSYS_COLOUR_SCROLLBAR:
38 return wxColour([NSColor scrollBarColor]); // color of slot
39 case wxSYS_COLOUR_BACKGROUND: // No idea how to get desktop background
40 break; // break so we return an invalid colour.
41 case wxSYS_COLOUR_ACTIVECAPTION: // No idea how to get this
42 // fall through, window background is reasonable
43 case wxSYS_COLOUR_INACTIVECAPTION: // No idea how to get this
44 // fall through, window background is reasonable
45 case wxSYS_COLOUR_MENU:
46 case wxSYS_COLOUR_MENUBAR:
47 case wxSYS_COLOUR_WINDOW:
48 case wxSYS_COLOUR_WINDOWFRAME:
49 case wxSYS_COLOUR_ACTIVEBORDER:
50 case wxSYS_COLOUR_INACTIVEBORDER:
51 return wxColour([NSColor windowFrameColor]);
52 case wxSYS_COLOUR_BTNFACE:
53 return wxColour([NSColor knobColor]); // close enough?
54 case wxSYS_COLOUR_LISTBOX:
55 return wxColour([NSColor controlBackgroundColor]);
56 case wxSYS_COLOUR_BTNSHADOW:
57 return wxColour([NSColor controlShadowColor]);
58 case wxSYS_COLOUR_BTNTEXT:
59 case wxSYS_COLOUR_MENUTEXT:
60 case wxSYS_COLOUR_WINDOWTEXT:
61 case wxSYS_COLOUR_CAPTIONTEXT:
62 case wxSYS_COLOUR_INFOTEXT:
63 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
64 return wxColour([NSColor controlTextColor]);
65 case wxSYS_COLOUR_HIGHLIGHT:
66 return wxColour([NSColor selectedControlColor]);
67 case wxSYS_COLOUR_BTNHIGHLIGHT:
68 return wxColour([NSColor controlHighlightColor]);
69 case wxSYS_COLOUR_GRAYTEXT:
70 return wxColour([NSColor disabledControlTextColor]);
71 case wxSYS_COLOUR_3DDKSHADOW:
72 return wxColour([NSColor controlShadowColor]);
73 case wxSYS_COLOUR_3DLIGHT:
74 return wxColour([NSColor controlHighlightColor]);
75 case wxSYS_COLOUR_HIGHLIGHTTEXT:
76 return wxColour([NSColor selectedControlTextColor]);
77 case wxSYS_COLOUR_INFOBK:
79 return wxColour([NSColor controlBackgroundColor]);
80 case wxSYS_COLOUR_APPWORKSPACE:
81 // MDI window color (bogus)
82 return wxColour([NSColor windowBackgroundColor]);
83 case wxSYS_COLOUR_HOTLIGHT:
84 break; // what is this?
85 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
86 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
87 break; // Doesn't really apply to Cocoa.
88 case wxSYS_COLOUR_MENUHILIGHT:
89 return wxColour([NSColor selectedMenuItemColor]);
90 case wxSYS_COLOUR_MAX:
92 if(index>=wxSYS_COLOUR_MAX)
94 wxFAIL_MSG(wxT("Invalid system colour index"));
98 wxFAIL_MSG(wxT("Unimplemented system colour index"));
102 // ----------------------------------------------------------------------------
104 // ----------------------------------------------------------------------------
106 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
108 // return a nonworking font object, crash from wxInitializeStockObjects
112 case wxSYS_ANSI_VAR_FONT :
113 case wxSYS_SYSTEM_FONT :
114 case wxSYS_DEVICE_DEFAULT_FONT :
115 case wxSYS_DEFAULT_GUI_FONT :
117 return *wxSMALL_FONT ;
120 case wxSYS_OEM_FIXED_FONT :
121 case wxSYS_ANSI_FIXED_FONT :
122 case wxSYS_SYSTEM_FIXED_FONT :
125 return *wxNORMAL_FONT ;
130 return *wxNORMAL_FONT;
133 // ----------------------------------------------------------------------------
134 // system metrics/features
135 // ----------------------------------------------------------------------------
137 // Get a system metric, e.g. scrollbar size
138 int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win))
142 case wxSYS_MOUSE_BUTTONS:
143 return 2; // we emulate a two button mouse (ctrl + click = right button )
145 // TODO case wxSYS_BORDER_X:
146 // TODO case wxSYS_BORDER_Y:
147 // TODO case wxSYS_CURSOR_X:
148 // TODO case wxSYS_CURSOR_Y:
149 // TODO case wxSYS_DCLICK_X:
150 // TODO case wxSYS_DCLICK_Y:
151 // TODO case wxSYS_DRAG_X:
152 // TODO case wxSYS_DRAG_Y:
153 // TODO case wxSYS_EDGE_X:
154 // TODO case wxSYS_EDGE_Y:
156 case wxSYS_HSCROLL_ARROW_X:
158 case wxSYS_HSCROLL_ARROW_Y:
163 // TODO case wxSYS_ICON_X:
164 // TODO case wxSYS_ICON_Y:
165 // TODO case wxSYS_ICONSPACING_X:
166 // TODO case wxSYS_ICONSPACING_Y:
167 // TODO case wxSYS_WINDOWMIN_X:
168 // TODO case wxSYS_WINDOWMIN_Y:
169 // TODO case wxSYS_SCREEN_X:
170 // TODO case wxSYS_SCREEN_Y:
171 // TODO case wxSYS_FRAMESIZE_X:
172 // TODO case wxSYS_FRAMESIZE_Y:
173 // TODO case wxSYS_SMALLICON_X:
174 // TODO case wxSYS_SMALLICON_Y:
176 case wxSYS_HSCROLL_Y:
178 case wxSYS_VSCROLL_X:
180 case wxSYS_VSCROLL_ARROW_X:
182 case wxSYS_VSCROLL_ARROW_Y:
187 // TODO case wxSYS_CAPTION_Y:
188 // TODO case wxSYS_MENU_Y:
189 // TODO case wxSYS_NETWORK_PRESENT:
191 case wxSYS_PENWINDOWS_PRESENT:
194 // TODO case wxSYS_SHOW_SOUNDS:
196 case wxSYS_SWAP_BUTTONS:
200 return -1; // unsupported metric
205 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
209 case wxSYS_CAN_ICONIZE_FRAME:
210 case wxSYS_CAN_DRAW_FRAME_DECORATIONS: