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"
22 #include "wx/cocoa/private/fontfactory.h"
24 #import <AppKit/NSColor.h>
25 #import <AppKit/NSFont.h>
27 // ----------------------------------------------------------------------------
28 // wxSystemSettingsNative
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
37 wxAutoNSAutoreleasePool pool;
40 case wxSYS_COLOUR_SCROLLBAR:
41 return wxColour([NSColor scrollBarColor]); // color of slot
42 case wxSYS_COLOUR_BACKGROUND: // No idea how to get desktop background
43 break; // break so we return an invalid colour.
44 case wxSYS_COLOUR_ACTIVECAPTION: // No idea how to get this
45 // fall through, window background is reasonable
46 case wxSYS_COLOUR_INACTIVECAPTION: // No idea how to get this
47 // fall through, window background is reasonable
48 case wxSYS_COLOUR_MENU:
49 case wxSYS_COLOUR_MENUBAR:
50 case wxSYS_COLOUR_WINDOW:
51 case wxSYS_COLOUR_WINDOWFRAME:
52 case wxSYS_COLOUR_ACTIVEBORDER:
53 case wxSYS_COLOUR_INACTIVEBORDER:
54 return wxColour([NSColor windowFrameColor]);
55 case wxSYS_COLOUR_BTNFACE:
56 return wxColour([NSColor knobColor]); // close enough?
57 case wxSYS_COLOUR_LISTBOX:
58 return wxColour([NSColor controlBackgroundColor]);
59 case wxSYS_COLOUR_BTNSHADOW:
60 return wxColour([NSColor controlShadowColor]);
61 case wxSYS_COLOUR_BTNTEXT:
62 case wxSYS_COLOUR_MENUTEXT:
63 case wxSYS_COLOUR_WINDOWTEXT:
64 case wxSYS_COLOUR_CAPTIONTEXT:
65 case wxSYS_COLOUR_INFOTEXT:
66 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
67 return wxColour([NSColor controlTextColor]);
68 case wxSYS_COLOUR_HIGHLIGHT:
69 return wxColour([NSColor selectedControlColor]);
70 case wxSYS_COLOUR_BTNHIGHLIGHT:
71 return wxColour([NSColor controlHighlightColor]);
72 case wxSYS_COLOUR_GRAYTEXT:
73 return wxColour([NSColor disabledControlTextColor]);
74 case wxSYS_COLOUR_3DDKSHADOW:
75 return wxColour([NSColor controlShadowColor]);
76 case wxSYS_COLOUR_3DLIGHT:
77 return wxColour([NSColor controlHighlightColor]);
78 case wxSYS_COLOUR_HIGHLIGHTTEXT:
79 return wxColour([NSColor selectedControlTextColor]);
80 case wxSYS_COLOUR_INFOBK:
82 return wxColour([NSColor controlBackgroundColor]);
83 case wxSYS_COLOUR_APPWORKSPACE:
84 // MDI window color (bogus)
85 return wxColour([NSColor windowBackgroundColor]);
86 case wxSYS_COLOUR_HOTLIGHT:
87 break; // what is this?
88 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
89 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
90 break; // Doesn't really apply to Cocoa.
91 case wxSYS_COLOUR_MENUHILIGHT:
92 return wxColour([NSColor selectedMenuItemColor]);
93 case wxSYS_COLOUR_MAX:
95 if(index>=wxSYS_COLOUR_MAX)
97 wxFAIL_MSG(wxT("Invalid system colour index"));
101 wxFAIL_MSG(wxT("Unimplemented system colour index"));
105 // ----------------------------------------------------------------------------
107 // ----------------------------------------------------------------------------
109 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
111 // Return the system font for now
112 { wxAutoNSAutoreleasePool pool;
113 return wxCocoaFontFactory::InstanceForNSFont([NSFont systemFontOfSize:0.0], false);
117 case wxSYS_ANSI_VAR_FONT :
118 case wxSYS_SYSTEM_FONT :
119 case wxSYS_DEVICE_DEFAULT_FONT :
120 case wxSYS_DEFAULT_GUI_FONT :
122 return *wxSMALL_FONT ;
125 case wxSYS_OEM_FIXED_FONT :
126 case wxSYS_ANSI_FIXED_FONT :
127 case wxSYS_SYSTEM_FIXED_FONT :
130 return *wxNORMAL_FONT ;
135 return *wxNORMAL_FONT;
138 // ----------------------------------------------------------------------------
139 // system metrics/features
140 // ----------------------------------------------------------------------------
142 // Get a system metric, e.g. scrollbar size
143 int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win))
147 case wxSYS_MOUSE_BUTTONS:
148 return 2; // we emulate a two button mouse (ctrl + click = right button )
150 // TODO case wxSYS_BORDER_X:
151 // TODO case wxSYS_BORDER_Y:
152 // TODO case wxSYS_CURSOR_X:
153 // TODO case wxSYS_CURSOR_Y:
154 // TODO case wxSYS_DCLICK_X:
155 // TODO case wxSYS_DCLICK_Y:
156 // TODO case wxSYS_DRAG_X:
157 // TODO case wxSYS_DRAG_Y:
158 // TODO case wxSYS_EDGE_X:
159 // TODO case wxSYS_EDGE_Y:
161 case wxSYS_HSCROLL_ARROW_X:
163 case wxSYS_HSCROLL_ARROW_Y:
168 // TODO case wxSYS_ICON_X:
169 // TODO case wxSYS_ICON_Y:
170 // TODO case wxSYS_ICONSPACING_X:
171 // TODO case wxSYS_ICONSPACING_Y:
172 // TODO case wxSYS_WINDOWMIN_X:
173 // TODO case wxSYS_WINDOWMIN_Y:
174 // TODO case wxSYS_SCREEN_X:
175 // TODO case wxSYS_SCREEN_Y:
176 // TODO case wxSYS_FRAMESIZE_X:
177 // TODO case wxSYS_FRAMESIZE_Y:
178 // TODO case wxSYS_SMALLICON_X:
179 // TODO case wxSYS_SMALLICON_Y:
181 case wxSYS_HSCROLL_Y:
183 case wxSYS_VSCROLL_X:
185 case wxSYS_VSCROLL_ARROW_X:
187 case wxSYS_VSCROLL_ARROW_Y:
192 // TODO case wxSYS_CAPTION_Y:
193 // TODO case wxSYS_MENU_Y:
194 // TODO case wxSYS_NETWORK_PRESENT:
196 case wxSYS_PENWINDOWS_PRESENT:
199 // TODO case wxSYS_SHOW_SOUNDS:
201 case wxSYS_SWAP_BUTTONS:
205 return -1; // unsupported metric
210 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
214 case wxSYS_CAN_ICONIZE_FRAME:
215 case wxSYS_CAN_DRAW_FRAME_DECORATIONS: