]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/settings.mm
Nuke #pragma implementation/interface's
[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 #ifndef WX_PRECOMP
14 #endif
15
16 #include "wx/settings.h"
17 #include "wx/gdicmn.h"
18 #include "wx/utils.h"
19
20 #include "wx/cocoa/autorelease.h"
21
22 #import <AppKit/NSColor.h>
23
24 // ----------------------------------------------------------------------------
25 // wxSystemSettingsNative
26 // ----------------------------------------------------------------------------
27
28 // ----------------------------------------------------------------------------
29 // colours
30 // ----------------------------------------------------------------------------
31
32 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
33 {
34 wxAutoNSAutoreleasePool pool;
35 switch( index )
36 {
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:
78 // tooltip (bogus)
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:
91 default:
92 if(index>=wxSYS_COLOUR_MAX)
93 {
94 wxFAIL_MSG(wxT("Invalid system colour index"));
95 return wxColour();
96 }
97 }
98 wxFAIL_MSG(wxT("Unimplemented system colour index"));
99 return wxColour();
100 }
101
102 // ----------------------------------------------------------------------------
103 // fonts
104 // ----------------------------------------------------------------------------
105
106 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
107 {
108 // return a nonworking font object, crash from wxInitializeStockObjects
109 return wxFont();
110 switch (index)
111 {
112 case wxSYS_ANSI_VAR_FONT :
113 case wxSYS_SYSTEM_FONT :
114 case wxSYS_DEVICE_DEFAULT_FONT :
115 case wxSYS_DEFAULT_GUI_FONT :
116 {
117 return *wxSMALL_FONT ;
118 } ;
119 break ;
120 case wxSYS_OEM_FIXED_FONT :
121 case wxSYS_ANSI_FIXED_FONT :
122 case wxSYS_SYSTEM_FIXED_FONT :
123 default :
124 {
125 return *wxNORMAL_FONT ;
126 } ;
127 break ;
128
129 }
130 return *wxNORMAL_FONT;
131 }
132
133 // ----------------------------------------------------------------------------
134 // system metrics/features
135 // ----------------------------------------------------------------------------
136
137 // Get a system metric, e.g. scrollbar size
138 int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win))
139 {
140 switch ( index)
141 {
142 case wxSYS_MOUSE_BUTTONS:
143 return 2; // we emulate a two button mouse (ctrl + click = right button )
144
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:
155
156 case wxSYS_HSCROLL_ARROW_X:
157 return 16;
158 case wxSYS_HSCROLL_ARROW_Y:
159 return 16;
160 case wxSYS_HTHUMB_X:
161 return 16;
162
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:
175
176 case wxSYS_HSCROLL_Y:
177 return 16;
178 case wxSYS_VSCROLL_X:
179 return 16;
180 case wxSYS_VSCROLL_ARROW_X:
181 return 16;
182 case wxSYS_VSCROLL_ARROW_Y:
183 return 16;
184 case wxSYS_VTHUMB_Y:
185 return 16;
186
187 // TODO case wxSYS_CAPTION_Y:
188 // TODO case wxSYS_MENU_Y:
189 // TODO case wxSYS_NETWORK_PRESENT:
190
191 case wxSYS_PENWINDOWS_PRESENT:
192 return 0;
193
194 // TODO case wxSYS_SHOW_SOUNDS:
195
196 case wxSYS_SWAP_BUTTONS:
197 return 0;
198
199 default:
200 return -1; // unsupported metric
201 }
202 return 0;
203 }
204
205 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
206 {
207 switch (index)
208 {
209 case wxSYS_CAN_ICONIZE_FRAME:
210 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
211 return TRUE;
212
213 default:
214 return FALSE;
215 }
216 }