]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/settings.mm
Fix horizontal mouse wheel scrolling in wxGTK.
[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
0c28d824 7// Copyright: (c) 2005 David Elliott
65571936 8// Licence: wxWindows licence
a24aff65
DE
9/////////////////////////////////////////////////////////////////////////////
10
7ec69821 11#include "wx/wxprec.h"
de6185e2 12
9eddec69
WS
13#include "wx/settings.h"
14
0c28d824 15#ifndef WX_PRECOMP
de6185e2 16 #include "wx/utils.h"
dd05139a 17 #include "wx/gdicmn.h"
a24aff65
DE
18#endif
19
0c28d824 20#include "wx/cocoa/autorelease.h"
51146826 21#include "wx/cocoa/private/fontfactory.h"
0c28d824
DE
22
23#import <AppKit/NSColor.h>
51146826 24#import <AppKit/NSFont.h>
0c28d824 25
a24aff65
DE
26// ----------------------------------------------------------------------------
27// wxSystemSettingsNative
28// ----------------------------------------------------------------------------
29
30// ----------------------------------------------------------------------------
31// colours
32// ----------------------------------------------------------------------------
33
34wxColour 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
108wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
109{
51146826
DE
110 // Return the system font for now
111 { wxAutoNSAutoreleasePool pool;
112 return wxCocoaFontFactory::InstanceForNSFont([NSFont systemFontOfSize:0.0], false);
113 }
a24aff65
DE
114 switch (index)
115 {
116 case wxSYS_ANSI_VAR_FONT :
117 case wxSYS_SYSTEM_FONT :
118 case wxSYS_DEVICE_DEFAULT_FONT :
119 case wxSYS_DEFAULT_GUI_FONT :
120 {
121 return *wxSMALL_FONT ;
122 } ;
123 break ;
124 case wxSYS_OEM_FIXED_FONT :
125 case wxSYS_ANSI_FIXED_FONT :
126 case wxSYS_SYSTEM_FIXED_FONT :
127 default :
128 {
129 return *wxNORMAL_FONT ;
130 } ;
131 break ;
7ec69821 132
a24aff65
DE
133 }
134 return *wxNORMAL_FONT;
135}
136
137// ----------------------------------------------------------------------------
138// system metrics/features
139// ----------------------------------------------------------------------------
140
141// Get a system metric, e.g. scrollbar size
9b0b5ba7 142int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win))
a24aff65
DE
143{
144 switch ( index)
145 {
146 case wxSYS_MOUSE_BUTTONS:
147 return 2; // we emulate a two button mouse (ctrl + click = right button )
7ec69821 148
1d451c5b
RD
149 // TODO case wxSYS_BORDER_X:
150 // TODO case wxSYS_BORDER_Y:
151 // TODO case wxSYS_CURSOR_X:
152 // TODO case wxSYS_CURSOR_Y:
153 // TODO case wxSYS_DCLICK_X:
154 // TODO case wxSYS_DCLICK_Y:
155 // TODO case wxSYS_DRAG_X:
156 // TODO case wxSYS_DRAG_Y:
157 // TODO case wxSYS_EDGE_X:
158 // TODO case wxSYS_EDGE_Y:
159
a24aff65
DE
160 case wxSYS_HSCROLL_ARROW_X:
161 return 16;
162 case wxSYS_HSCROLL_ARROW_Y:
163 return 16;
164 case wxSYS_HTHUMB_X:
165 return 16;
7ec69821 166
1d451c5b
RD
167 // TODO case wxSYS_ICON_X:
168 // TODO case wxSYS_ICON_Y:
169 // TODO case wxSYS_ICONSPACING_X:
170 // TODO case wxSYS_ICONSPACING_Y:
171 // TODO case wxSYS_WINDOWMIN_X:
172 // TODO case wxSYS_WINDOWMIN_Y:
173 // TODO case wxSYS_SCREEN_X:
174 // TODO case wxSYS_SCREEN_Y:
175 // TODO case wxSYS_FRAMESIZE_X:
176 // TODO case wxSYS_FRAMESIZE_Y:
177 // TODO case wxSYS_SMALLICON_X:
178 // TODO case wxSYS_SMALLICON_Y:
7ec69821 179
a24aff65
DE
180 case wxSYS_HSCROLL_Y:
181 return 16;
182 case wxSYS_VSCROLL_X:
183 return 16;
184 case wxSYS_VSCROLL_ARROW_X:
185 return 16;
186 case wxSYS_VSCROLL_ARROW_Y:
187 return 16;
188 case wxSYS_VTHUMB_Y:
189 return 16;
7ec69821 190
1d451c5b
RD
191 // TODO case wxSYS_CAPTION_Y:
192 // TODO case wxSYS_MENU_Y:
193 // TODO case wxSYS_NETWORK_PRESENT:
7ec69821 194
a24aff65
DE
195 case wxSYS_PENWINDOWS_PRESENT:
196 return 0;
7ec69821 197
1d451c5b
RD
198 // TODO case wxSYS_SHOW_SOUNDS:
199
a24aff65
DE
200 case wxSYS_SWAP_BUTTONS:
201 return 0;
7ec69821 202
a24aff65 203 default:
1d451c5b 204 return -1; // unsupported metric
a24aff65
DE
205 }
206 return 0;
207}
208
209bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
210{
211 switch (index)
212 {
7ec69821 213 case wxSYS_CAN_ICONIZE_FRAME:
a24aff65 214 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
7ec69821
WS
215 return true;
216
a24aff65 217 default:
7ec69821 218 return false;
a24aff65
DE
219 }
220}