]>
Commit | Line | Data |
---|---|---|
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 | #endif | |
19 | ||
20 | #include "wx/gdicmn.h" | |
21 | ||
22 | #include "wx/cocoa/autorelease.h" | |
23 | ||
24 | #import <AppKit/NSColor.h> | |
25 | ||
26 | // ---------------------------------------------------------------------------- | |
27 | // wxSystemSettingsNative | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
30 | // ---------------------------------------------------------------------------- | |
31 | // colours | |
32 | // ---------------------------------------------------------------------------- | |
33 | ||
34 | wxColour wxSystemSettingsNative::GetColour(wxSystemColour index) | |
35 | { | |
36 | wxAutoNSAutoreleasePool pool; | |
37 | switch( index ) | |
38 | { | |
39 | case wxSYS_COLOUR_SCROLLBAR: | |
40 | return wxColour([NSColor scrollBarColor]); // color of slot | |
41 | case wxSYS_COLOUR_BACKGROUND: // No idea how to get desktop background | |
42 | break; // break so we return an invalid colour. | |
43 | case wxSYS_COLOUR_ACTIVECAPTION: // No idea how to get this | |
44 | // fall through, window background is reasonable | |
45 | case wxSYS_COLOUR_INACTIVECAPTION: // No idea how to get this | |
46 | // fall through, window background is reasonable | |
47 | case wxSYS_COLOUR_MENU: | |
48 | case wxSYS_COLOUR_MENUBAR: | |
49 | case wxSYS_COLOUR_WINDOW: | |
50 | case wxSYS_COLOUR_WINDOWFRAME: | |
51 | case wxSYS_COLOUR_ACTIVEBORDER: | |
52 | case wxSYS_COLOUR_INACTIVEBORDER: | |
53 | return wxColour([NSColor windowFrameColor]); | |
54 | case wxSYS_COLOUR_BTNFACE: | |
55 | return wxColour([NSColor knobColor]); // close enough? | |
56 | case wxSYS_COLOUR_LISTBOX: | |
57 | return wxColour([NSColor controlBackgroundColor]); | |
58 | case wxSYS_COLOUR_BTNSHADOW: | |
59 | return wxColour([NSColor controlShadowColor]); | |
60 | case wxSYS_COLOUR_BTNTEXT: | |
61 | case wxSYS_COLOUR_MENUTEXT: | |
62 | case wxSYS_COLOUR_WINDOWTEXT: | |
63 | case wxSYS_COLOUR_CAPTIONTEXT: | |
64 | case wxSYS_COLOUR_INFOTEXT: | |
65 | case wxSYS_COLOUR_INACTIVECAPTIONTEXT: | |
66 | return wxColour([NSColor controlTextColor]); | |
67 | case wxSYS_COLOUR_HIGHLIGHT: | |
68 | return wxColour([NSColor selectedControlColor]); | |
69 | case wxSYS_COLOUR_BTNHIGHLIGHT: | |
70 | return wxColour([NSColor controlHighlightColor]); | |
71 | case wxSYS_COLOUR_GRAYTEXT: | |
72 | return wxColour([NSColor disabledControlTextColor]); | |
73 | case wxSYS_COLOUR_3DDKSHADOW: | |
74 | return wxColour([NSColor controlShadowColor]); | |
75 | case wxSYS_COLOUR_3DLIGHT: | |
76 | return wxColour([NSColor controlHighlightColor]); | |
77 | case wxSYS_COLOUR_HIGHLIGHTTEXT: | |
78 | return wxColour([NSColor selectedControlTextColor]); | |
79 | case wxSYS_COLOUR_INFOBK: | |
80 | // tooltip (bogus) | |
81 | return wxColour([NSColor controlBackgroundColor]); | |
82 | case wxSYS_COLOUR_APPWORKSPACE: | |
83 | // MDI window color (bogus) | |
84 | return wxColour([NSColor windowBackgroundColor]); | |
85 | case wxSYS_COLOUR_HOTLIGHT: | |
86 | break; // what is this? | |
87 | case wxSYS_COLOUR_GRADIENTACTIVECAPTION: | |
88 | case wxSYS_COLOUR_GRADIENTINACTIVECAPTION: | |
89 | break; // Doesn't really apply to Cocoa. | |
90 | case wxSYS_COLOUR_MENUHILIGHT: | |
91 | return wxColour([NSColor selectedMenuItemColor]); | |
92 | case wxSYS_COLOUR_MAX: | |
93 | default: | |
94 | if(index>=wxSYS_COLOUR_MAX) | |
95 | { | |
96 | wxFAIL_MSG(wxT("Invalid system colour index")); | |
97 | return wxColour(); | |
98 | } | |
99 | } | |
100 | wxFAIL_MSG(wxT("Unimplemented system colour index")); | |
101 | return wxColour(); | |
102 | } | |
103 | ||
104 | // ---------------------------------------------------------------------------- | |
105 | // fonts | |
106 | // ---------------------------------------------------------------------------- | |
107 | ||
108 | wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) | |
109 | { | |
110 | // return a nonworking font object, crash from wxInitializeStockObjects | |
111 | return wxFont(); | |
112 | switch (index) | |
113 | { | |
114 | case wxSYS_ANSI_VAR_FONT : | |
115 | case wxSYS_SYSTEM_FONT : | |
116 | case wxSYS_DEVICE_DEFAULT_FONT : | |
117 | case wxSYS_DEFAULT_GUI_FONT : | |
118 | { | |
119 | return *wxSMALL_FONT ; | |
120 | } ; | |
121 | break ; | |
122 | case wxSYS_OEM_FIXED_FONT : | |
123 | case wxSYS_ANSI_FIXED_FONT : | |
124 | case wxSYS_SYSTEM_FIXED_FONT : | |
125 | default : | |
126 | { | |
127 | return *wxNORMAL_FONT ; | |
128 | } ; | |
129 | break ; | |
130 | ||
131 | } | |
132 | return *wxNORMAL_FONT; | |
133 | } | |
134 | ||
135 | // ---------------------------------------------------------------------------- | |
136 | // system metrics/features | |
137 | // ---------------------------------------------------------------------------- | |
138 | ||
139 | // Get a system metric, e.g. scrollbar size | |
140 | int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win)) | |
141 | { | |
142 | switch ( index) | |
143 | { | |
144 | case wxSYS_MOUSE_BUTTONS: | |
145 | return 2; // we emulate a two button mouse (ctrl + click = right button ) | |
146 | ||
147 | // TODO case wxSYS_BORDER_X: | |
148 | // TODO case wxSYS_BORDER_Y: | |
149 | // TODO case wxSYS_CURSOR_X: | |
150 | // TODO case wxSYS_CURSOR_Y: | |
151 | // TODO case wxSYS_DCLICK_X: | |
152 | // TODO case wxSYS_DCLICK_Y: | |
153 | // TODO case wxSYS_DRAG_X: | |
154 | // TODO case wxSYS_DRAG_Y: | |
155 | // TODO case wxSYS_EDGE_X: | |
156 | // TODO case wxSYS_EDGE_Y: | |
157 | ||
158 | case wxSYS_HSCROLL_ARROW_X: | |
159 | return 16; | |
160 | case wxSYS_HSCROLL_ARROW_Y: | |
161 | return 16; | |
162 | case wxSYS_HTHUMB_X: | |
163 | return 16; | |
164 | ||
165 | // TODO case wxSYS_ICON_X: | |
166 | // TODO case wxSYS_ICON_Y: | |
167 | // TODO case wxSYS_ICONSPACING_X: | |
168 | // TODO case wxSYS_ICONSPACING_Y: | |
169 | // TODO case wxSYS_WINDOWMIN_X: | |
170 | // TODO case wxSYS_WINDOWMIN_Y: | |
171 | // TODO case wxSYS_SCREEN_X: | |
172 | // TODO case wxSYS_SCREEN_Y: | |
173 | // TODO case wxSYS_FRAMESIZE_X: | |
174 | // TODO case wxSYS_FRAMESIZE_Y: | |
175 | // TODO case wxSYS_SMALLICON_X: | |
176 | // TODO case wxSYS_SMALLICON_Y: | |
177 | ||
178 | case wxSYS_HSCROLL_Y: | |
179 | return 16; | |
180 | case wxSYS_VSCROLL_X: | |
181 | return 16; | |
182 | case wxSYS_VSCROLL_ARROW_X: | |
183 | return 16; | |
184 | case wxSYS_VSCROLL_ARROW_Y: | |
185 | return 16; | |
186 | case wxSYS_VTHUMB_Y: | |
187 | return 16; | |
188 | ||
189 | // TODO case wxSYS_CAPTION_Y: | |
190 | // TODO case wxSYS_MENU_Y: | |
191 | // TODO case wxSYS_NETWORK_PRESENT: | |
192 | ||
193 | case wxSYS_PENWINDOWS_PRESENT: | |
194 | return 0; | |
195 | ||
196 | // TODO case wxSYS_SHOW_SOUNDS: | |
197 | ||
198 | case wxSYS_SWAP_BUTTONS: | |
199 | return 0; | |
200 | ||
201 | default: | |
202 | return -1; // unsupported metric | |
203 | } | |
204 | return 0; | |
205 | } | |
206 | ||
207 | bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) | |
208 | { | |
209 | switch (index) | |
210 | { | |
211 | case wxSYS_CAN_ICONIZE_FRAME: | |
212 | case wxSYS_CAN_DRAW_FRAME_DECORATIONS: | |
213 | return true; | |
214 | ||
215 | default: | |
216 | return false; | |
217 | } | |
218 | } |