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"
14 #include "wx/settings.h"
18 #include "wx/gdicmn.h"
21 #include "wx/cocoa/autorelease.h"
23 #import <AppKit/NSColor.h>
25 // ----------------------------------------------------------------------------
26 // wxSystemSettingsNative
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
35 wxAutoNSAutoreleasePool pool;
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:
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:
93 if(index>=wxSYS_COLOUR_MAX)
95 wxFAIL_MSG(wxT("Invalid system colour index"));
99 wxFAIL_MSG(wxT("Unimplemented system colour index"));
103 // ----------------------------------------------------------------------------
105 // ----------------------------------------------------------------------------
107 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
109 // return a nonworking font object, crash from wxInitializeStockObjects
113 case wxSYS_ANSI_VAR_FONT :
114 case wxSYS_SYSTEM_FONT :
115 case wxSYS_DEVICE_DEFAULT_FONT :
116 case wxSYS_DEFAULT_GUI_FONT :
118 return *wxSMALL_FONT ;
121 case wxSYS_OEM_FIXED_FONT :
122 case wxSYS_ANSI_FIXED_FONT :
123 case wxSYS_SYSTEM_FIXED_FONT :
126 return *wxNORMAL_FONT ;
131 return *wxNORMAL_FONT;
134 // ----------------------------------------------------------------------------
135 // system metrics/features
136 // ----------------------------------------------------------------------------
138 // Get a system metric, e.g. scrollbar size
139 int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win))
143 case wxSYS_MOUSE_BUTTONS:
144 return 2; // we emulate a two button mouse (ctrl + click = right button )
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:
157 case wxSYS_HSCROLL_ARROW_X:
159 case wxSYS_HSCROLL_ARROW_Y:
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:
177 case wxSYS_HSCROLL_Y:
179 case wxSYS_VSCROLL_X:
181 case wxSYS_VSCROLL_ARROW_X:
183 case wxSYS_VSCROLL_ARROW_Y:
188 // TODO case wxSYS_CAPTION_Y:
189 // TODO case wxSYS_MENU_Y:
190 // TODO case wxSYS_NETWORK_PRESENT:
192 case wxSYS_PENWINDOWS_PRESENT:
195 // TODO case wxSYS_SHOW_SOUNDS:
197 case wxSYS_SWAP_BUTTONS:
201 return -1; // unsupported metric
206 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
210 case wxSYS_CAN_ICONIZE_FRAME:
211 case wxSYS_CAN_DRAW_FRAME_DECORATIONS: