]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/settings.mm
Use unsigned char for XBM bitmaps data.
[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 #include "wx/cocoa/private/fontfactory.h"
23
24 #import <AppKit/NSColor.h>
25 #import <AppKit/NSFont.h>
26
27 // ----------------------------------------------------------------------------
28 // wxSystemSettingsNative
29 // ----------------------------------------------------------------------------
30
31 // ----------------------------------------------------------------------------
32 // colours
33 // ----------------------------------------------------------------------------
34
35 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
36 {
37 wxAutoNSAutoreleasePool pool;
38 switch( index )
39 {
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:
81 // tooltip (bogus)
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:
94 default:
95 if(index>=wxSYS_COLOUR_MAX)
96 {
97 wxFAIL_MSG(wxT("Invalid system colour index"));
98 return wxColour();
99 }
100 }
101 wxFAIL_MSG(wxT("Unimplemented system colour index"));
102 return wxColour();
103 }
104
105 // ----------------------------------------------------------------------------
106 // fonts
107 // ----------------------------------------------------------------------------
108
109 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
110 {
111 // Return the system font for now
112 { wxAutoNSAutoreleasePool pool;
113 return wxCocoaFontFactory::InstanceForNSFont([NSFont systemFontOfSize:0.0], false);
114 }
115 switch (index)
116 {
117 case wxSYS_ANSI_VAR_FONT :
118 case wxSYS_SYSTEM_FONT :
119 case wxSYS_DEVICE_DEFAULT_FONT :
120 case wxSYS_DEFAULT_GUI_FONT :
121 {
122 return *wxSMALL_FONT ;
123 } ;
124 break ;
125 case wxSYS_OEM_FIXED_FONT :
126 case wxSYS_ANSI_FIXED_FONT :
127 case wxSYS_SYSTEM_FIXED_FONT :
128 default :
129 {
130 return *wxNORMAL_FONT ;
131 } ;
132 break ;
133
134 }
135 return *wxNORMAL_FONT;
136 }
137
138 // ----------------------------------------------------------------------------
139 // system metrics/features
140 // ----------------------------------------------------------------------------
141
142 // Get a system metric, e.g. scrollbar size
143 int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win))
144 {
145 switch ( index)
146 {
147 case wxSYS_MOUSE_BUTTONS:
148 return 2; // we emulate a two button mouse (ctrl + click = right button )
149
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:
160
161 case wxSYS_HSCROLL_ARROW_X:
162 return 16;
163 case wxSYS_HSCROLL_ARROW_Y:
164 return 16;
165 case wxSYS_HTHUMB_X:
166 return 16;
167
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:
180
181 case wxSYS_HSCROLL_Y:
182 return 16;
183 case wxSYS_VSCROLL_X:
184 return 16;
185 case wxSYS_VSCROLL_ARROW_X:
186 return 16;
187 case wxSYS_VSCROLL_ARROW_Y:
188 return 16;
189 case wxSYS_VTHUMB_Y:
190 return 16;
191
192 // TODO case wxSYS_CAPTION_Y:
193 // TODO case wxSYS_MENU_Y:
194 // TODO case wxSYS_NETWORK_PRESENT:
195
196 case wxSYS_PENWINDOWS_PRESENT:
197 return 0;
198
199 // TODO case wxSYS_SHOW_SOUNDS:
200
201 case wxSYS_SWAP_BUTTONS:
202 return 0;
203
204 default:
205 return -1; // unsupported metric
206 }
207 return 0;
208 }
209
210 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
211 {
212 switch (index)
213 {
214 case wxSYS_CAN_ICONIZE_FRAME:
215 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
216 return true;
217
218 default:
219 return false;
220 }
221 }