]>
Commit | Line | Data |
---|---|---|
a24aff65 | 1 | ///////////////////////////////////////////////////////////////////////////// |
0c28d824 | 2 | // Name: src/cocoa/settings.mm |
a24aff65 | 3 | // Purpose: wxSettings |
0c28d824 | 4 | // Author: David Elliott |
a24aff65 | 5 | // Modified by: |
0c28d824 | 6 | // Created: 2005/01/11 |
a24aff65 | 7 | // RCS-ID: $Id$ |
0c28d824 | 8 | // Copyright: (c) 2005 David Elliott |
65571936 | 9 | // Licence: wxWindows licence |
a24aff65 DE |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
7ec69821 | 12 | #include "wx/wxprec.h" |
de6185e2 | 13 | |
9eddec69 WS |
14 | #include "wx/settings.h" |
15 | ||
0c28d824 | 16 | #ifndef WX_PRECOMP |
de6185e2 | 17 | #include "wx/utils.h" |
a24aff65 DE |
18 | #endif |
19 | ||
a24aff65 | 20 | #include "wx/gdicmn.h" |
a24aff65 | 21 | |
0c28d824 DE |
22 | #include "wx/cocoa/autorelease.h" |
23 | ||
24 | #import <AppKit/NSColor.h> | |
25 | ||
a24aff65 DE |
26 | // ---------------------------------------------------------------------------- |
27 | // wxSystemSettingsNative | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
30 | // ---------------------------------------------------------------------------- | |
31 | // colours | |
32 | // ---------------------------------------------------------------------------- | |
33 | ||
34 | wxColour wxSystemSettingsNative::GetColour(wxSystemColour index) | |
35 | { | |
0c28d824 | 36 | wxAutoNSAutoreleasePool pool; |
a24aff65 DE |
37 | switch( index ) |
38 | { | |
c3c916e3 | 39 | case wxSYS_COLOUR_SCROLLBAR: |
0c28d824 DE |
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 | |
c3c916e3 | 47 | case wxSYS_COLOUR_MENU: |
0c28d824 | 48 | case wxSYS_COLOUR_MENUBAR: |
c3c916e3 DE |
49 | case wxSYS_COLOUR_WINDOW: |
50 | case wxSYS_COLOUR_WINDOWFRAME: | |
51 | case wxSYS_COLOUR_ACTIVEBORDER: | |
52 | case wxSYS_COLOUR_INACTIVEBORDER: | |
0c28d824 | 53 | return wxColour([NSColor windowFrameColor]); |
c3c916e3 | 54 | case wxSYS_COLOUR_BTNFACE: |
0c28d824 | 55 | return wxColour([NSColor knobColor]); // close enough? |
c3c916e3 | 56 | case wxSYS_COLOUR_LISTBOX: |
0c28d824 | 57 | return wxColour([NSColor controlBackgroundColor]); |
c3c916e3 | 58 | case wxSYS_COLOUR_BTNSHADOW: |
0c28d824 | 59 | return wxColour([NSColor controlShadowColor]); |
c3c916e3 DE |
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: | |
0c28d824 | 66 | return wxColour([NSColor controlTextColor]); |
c3c916e3 | 67 | case wxSYS_COLOUR_HIGHLIGHT: |
0c28d824 | 68 | return wxColour([NSColor selectedControlColor]); |
c3c916e3 | 69 | case wxSYS_COLOUR_BTNHIGHLIGHT: |
0c28d824 | 70 | return wxColour([NSColor controlHighlightColor]); |
c3c916e3 | 71 | case wxSYS_COLOUR_GRAYTEXT: |
0c28d824 | 72 | return wxColour([NSColor disabledControlTextColor]); |
c3c916e3 | 73 | case wxSYS_COLOUR_3DDKSHADOW: |
0c28d824 | 74 | return wxColour([NSColor controlShadowColor]); |
c3c916e3 | 75 | case wxSYS_COLOUR_3DLIGHT: |
0c28d824 | 76 | return wxColour([NSColor controlHighlightColor]); |
c3c916e3 | 77 | case wxSYS_COLOUR_HIGHLIGHTTEXT: |
0c28d824 | 78 | return wxColour([NSColor selectedControlTextColor]); |
c3c916e3 | 79 | case wxSYS_COLOUR_INFOBK: |
0c28d824 DE |
80 | // tooltip (bogus) |
81 | return wxColour([NSColor controlBackgroundColor]); | |
c3c916e3 | 82 | case wxSYS_COLOUR_APPWORKSPACE: |
0c28d824 DE |
83 | // MDI window color (bogus) |
84 | return wxColour([NSColor windowBackgroundColor]); | |
c3c916e3 | 85 | case wxSYS_COLOUR_HOTLIGHT: |
0c28d824 | 86 | break; // what is this? |
c3c916e3 DE |
87 | case wxSYS_COLOUR_GRADIENTACTIVECAPTION: |
88 | case wxSYS_COLOUR_GRADIENTINACTIVECAPTION: | |
0c28d824 | 89 | break; // Doesn't really apply to Cocoa. |
c3c916e3 | 90 | case wxSYS_COLOUR_MENUHILIGHT: |
0c28d824 | 91 | return wxColour([NSColor selectedMenuItemColor]); |
c3c916e3 | 92 | case wxSYS_COLOUR_MAX: |
0c28d824 DE |
93 | default: |
94 | if(index>=wxSYS_COLOUR_MAX) | |
95 | { | |
96 | wxFAIL_MSG(wxT("Invalid system colour index")); | |
97 | return wxColour(); | |
98 | } | |
a24aff65 | 99 | } |
0c28d824 DE |
100 | wxFAIL_MSG(wxT("Unimplemented system colour index")); |
101 | return wxColour(); | |
a24aff65 DE |
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 ; | |
7ec69821 | 130 | |
a24aff65 DE |
131 | } |
132 | return *wxNORMAL_FONT; | |
133 | } | |
134 | ||
135 | // ---------------------------------------------------------------------------- | |
136 | // system metrics/features | |
137 | // ---------------------------------------------------------------------------- | |
138 | ||
139 | // Get a system metric, e.g. scrollbar size | |
9b0b5ba7 | 140 | int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win)) |
a24aff65 DE |
141 | { |
142 | switch ( index) | |
143 | { | |
144 | case wxSYS_MOUSE_BUTTONS: | |
145 | return 2; // we emulate a two button mouse (ctrl + click = right button ) | |
7ec69821 | 146 | |
1d451c5b RD |
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 | ||
a24aff65 DE |
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; | |
7ec69821 | 164 | |
1d451c5b RD |
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: | |
7ec69821 | 177 | |
a24aff65 DE |
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; | |
7ec69821 | 188 | |
1d451c5b RD |
189 | // TODO case wxSYS_CAPTION_Y: |
190 | // TODO case wxSYS_MENU_Y: | |
191 | // TODO case wxSYS_NETWORK_PRESENT: | |
7ec69821 | 192 | |
a24aff65 DE |
193 | case wxSYS_PENWINDOWS_PRESENT: |
194 | return 0; | |
7ec69821 | 195 | |
1d451c5b RD |
196 | // TODO case wxSYS_SHOW_SOUNDS: |
197 | ||
a24aff65 DE |
198 | case wxSYS_SWAP_BUTTONS: |
199 | return 0; | |
7ec69821 | 200 | |
a24aff65 | 201 | default: |
1d451c5b | 202 | return -1; // unsupported metric |
a24aff65 DE |
203 | } |
204 | return 0; | |
205 | } | |
206 | ||
207 | bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) | |
208 | { | |
209 | switch (index) | |
210 | { | |
7ec69821 | 211 | case wxSYS_CAN_ICONIZE_FRAME: |
a24aff65 | 212 | case wxSYS_CAN_DRAW_FRAME_DECORATIONS: |
7ec69821 WS |
213 | return true; |
214 | ||
a24aff65 | 215 | default: |
7ec69821 | 216 | return false; |
a24aff65 DE |
217 | } |
218 | } |