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