]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/settings.mm
more non-const string literal warnings correction
[wxWidgets.git] / src / cocoa / settings.mm
CommitLineData
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
0c28d824
DE
12#include <wx/wxprec.h>
13#ifndef WX_PRECOMP
a24aff65
DE
14#endif
15
16#include "wx/settings.h"
17#include "wx/gdicmn.h"
18#include "wx/utils.h"
19
0c28d824
DE
20#include "wx/cocoa/autorelease.h"
21
22#import <AppKit/NSColor.h>
23
a24aff65
DE
24// ----------------------------------------------------------------------------
25// wxSystemSettingsNative
26// ----------------------------------------------------------------------------
27
28// ----------------------------------------------------------------------------
29// colours
30// ----------------------------------------------------------------------------
31
32wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
33{
0c28d824 34 wxAutoNSAutoreleasePool pool;
a24aff65
DE
35 switch( index )
36 {
c3c916e3 37 case wxSYS_COLOUR_SCROLLBAR:
0c28d824
DE
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
c3c916e3 45 case wxSYS_COLOUR_MENU:
0c28d824 46 case wxSYS_COLOUR_MENUBAR:
c3c916e3
DE
47 case wxSYS_COLOUR_WINDOW:
48 case wxSYS_COLOUR_WINDOWFRAME:
49 case wxSYS_COLOUR_ACTIVEBORDER:
50 case wxSYS_COLOUR_INACTIVEBORDER:
0c28d824 51 return wxColour([NSColor windowFrameColor]);
c3c916e3 52 case wxSYS_COLOUR_BTNFACE:
0c28d824 53 return wxColour([NSColor knobColor]); // close enough?
c3c916e3 54 case wxSYS_COLOUR_LISTBOX:
0c28d824 55 return wxColour([NSColor controlBackgroundColor]);
c3c916e3 56 case wxSYS_COLOUR_BTNSHADOW:
0c28d824 57 return wxColour([NSColor controlShadowColor]);
c3c916e3
DE
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:
0c28d824 64 return wxColour([NSColor controlTextColor]);
c3c916e3 65 case wxSYS_COLOUR_HIGHLIGHT:
0c28d824 66 return wxColour([NSColor selectedControlColor]);
c3c916e3 67 case wxSYS_COLOUR_BTNHIGHLIGHT:
0c28d824 68 return wxColour([NSColor controlHighlightColor]);
c3c916e3 69 case wxSYS_COLOUR_GRAYTEXT:
0c28d824 70 return wxColour([NSColor disabledControlTextColor]);
c3c916e3 71 case wxSYS_COLOUR_3DDKSHADOW:
0c28d824 72 return wxColour([NSColor controlShadowColor]);
c3c916e3 73 case wxSYS_COLOUR_3DLIGHT:
0c28d824 74 return wxColour([NSColor controlHighlightColor]);
c3c916e3 75 case wxSYS_COLOUR_HIGHLIGHTTEXT:
0c28d824 76 return wxColour([NSColor selectedControlTextColor]);
c3c916e3 77 case wxSYS_COLOUR_INFOBK:
0c28d824
DE
78 // tooltip (bogus)
79 return wxColour([NSColor controlBackgroundColor]);
c3c916e3 80 case wxSYS_COLOUR_APPWORKSPACE:
0c28d824
DE
81 // MDI window color (bogus)
82 return wxColour([NSColor windowBackgroundColor]);
c3c916e3 83 case wxSYS_COLOUR_HOTLIGHT:
0c28d824 84 break; // what is this?
c3c916e3
DE
85 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
86 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
0c28d824 87 break; // Doesn't really apply to Cocoa.
c3c916e3 88 case wxSYS_COLOUR_MENUHILIGHT:
0c28d824 89 return wxColour([NSColor selectedMenuItemColor]);
c3c916e3 90 case wxSYS_COLOUR_MAX:
0c28d824
DE
91 default:
92 if(index>=wxSYS_COLOUR_MAX)
93 {
94 wxFAIL_MSG(wxT("Invalid system colour index"));
95 return wxColour();
96 }
a24aff65 97 }
0c28d824
DE
98 wxFAIL_MSG(wxT("Unimplemented system colour index"));
99 return wxColour();
a24aff65
DE
100}
101
102// ----------------------------------------------------------------------------
103// fonts
104// ----------------------------------------------------------------------------
105
106wxFont 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
9b0b5ba7 138int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win))
a24aff65
DE
139{
140 switch ( index)
141 {
142 case wxSYS_MOUSE_BUTTONS:
143 return 2; // we emulate a two button mouse (ctrl + click = right button )
1d451c5b
RD
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
a24aff65
DE
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;
1d451c5b
RD
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
a24aff65
DE
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;
1d451c5b
RD
186
187 // TODO case wxSYS_CAPTION_Y:
188 // TODO case wxSYS_MENU_Y:
189 // TODO case wxSYS_NETWORK_PRESENT:
190
a24aff65
DE
191 case wxSYS_PENWINDOWS_PRESENT:
192 return 0;
1d451c5b
RD
193
194 // TODO case wxSYS_SHOW_SOUNDS:
195
a24aff65
DE
196 case wxSYS_SWAP_BUTTONS:
197 return 0;
1d451c5b 198
a24aff65 199 default:
1d451c5b 200 return -1; // unsupported metric
a24aff65
DE
201 }
202 return 0;
203}
204
205bool 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}