]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/cocoa/private.h
disable new event code unconditionally for now
[wxWidgets.git] / include / wx / osx / cocoa / private.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/cocoa/private.h
3 // Purpose: Private declarations: as this header is only included by
4 // wxWidgets itself, it may contain identifiers which don't start
5 // with "wx".
6 // Author: Stefan Csomor
7 // Modified by:
8 // Created: 1998-01-01
9 // RCS-ID: $Id: private.h 53819 2008-05-29 14:11:45Z SC $
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
13
14 #ifndef _WX_PRIVATE_COCOA_H_
15 #define _WX_PRIVATE_COCOA_H_
16
17 #include "wx/osx/core/private.h"
18
19 #include "wx/defs.h"
20
21 #include <ApplicationServices/ApplicationServices.h>
22
23 #if wxOSX_USE_ATSU_TEXT
24 // we need theming and atsu
25 #include <Carbon/Carbon.h>
26 #endif
27
28 #ifdef __OBJC__
29 #import <Cocoa/Cocoa.h>
30 #endif
31
32 //
33 // shared between Cocoa and Carbon
34 //
35
36 // bring in themeing types without pulling in the headers
37
38 #if wxUSE_GUI
39 typedef SInt16 ThemeBrush;
40 CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
41 OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
42 CGContextRef inContext,
43 const CGRect * inBounds,
44 CGImageRef inImage) ;
45 WX_NSImage WXDLLIMPEXP_CORE wxOSXCreateNSImageFromCGImage( CGImageRef image );
46 #endif
47
48 long UMAGetSystemVersion() ;
49 WXDLLIMPEXP_BASE void wxMacStringToPascal( const wxString&from , StringPtr to );
50 WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL );
51 WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef );
52 WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname );
53
54 //
55 //
56 //
57
58 #if wxUSE_GUI
59
60 class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl
61 {
62 public :
63 wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false ) ;
64 wxWidgetCocoaImpl() ;
65 ~wxWidgetCocoaImpl();
66
67 void Init();
68
69 virtual bool IsVisible() const ;
70 virtual void SetVisibility(bool);
71
72 virtual void Raise();
73
74 virtual void Lower();
75
76 virtual void ScrollRect( const wxRect *rect, int dx, int dy );
77
78 virtual WXWidget GetWXWidget() const { return m_osxView; }
79
80 virtual void SetBackgroundColour(const wxColour&);
81
82 virtual void GetContentArea( int &left , int &top , int &width , int &height ) const;
83 virtual void Move(int x, int y, int width, int height);
84 virtual void GetPosition( int &x, int &y ) const;
85 virtual void GetSize( int &width, int &height ) const;
86 virtual void SetControlSize( wxWindowVariant variant );
87
88 virtual void SetNeedsDisplay( const wxRect* where = NULL );
89 virtual bool GetNeedsDisplay() const;
90
91 virtual bool CanFocus() const;
92 // return true if successful
93 virtual bool SetFocus();
94 virtual bool HasFocus() const;
95
96 void RemoveFromParent();
97 void Embed( wxWidgetImpl *parent );
98
99 void SetDefaultButton( bool isDefault );
100 void PerformClick();
101 void SetLabel(const wxString& title, wxFontEncoding encoding);
102
103 wxInt32 GetValue() const;
104 void SetValue( wxInt32 v );
105 void SetBitmap( const wxBitmap& bitmap );
106 void SetupTabs( const wxNotebook &notebook );
107 void GetBestRect( wxRect *r ) const;
108 bool IsEnabled() const;
109 void Enable( bool enable );
110 bool ButtonClickDidStateChange() { return true ;}
111 void SetMinimum( wxInt32 v );
112 void SetMaximum( wxInt32 v );
113 void PulseGauge();
114 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
115
116 void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
117
118 void InstallEventHandler( WXWidget control = NULL );
119
120 virtual void DoHandleMouseEvent(NSEvent *event);
121
122 protected:
123 WXWidget m_osxView;
124 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
125 };
126
127 class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
128 {
129 public :
130 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ;
131 wxNonOwnedWindowCocoaImpl();
132
133 virtual ~wxNonOwnedWindowCocoaImpl();
134
135 virtual void Destroy() ;
136 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
137 long style, long extraStyle, const wxString& name ) ;
138
139 WXWindow GetWXWindow() const;
140 void Raise();
141 void Lower();
142 bool Show(bool show);
143 bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout);
144
145 void Update();
146 bool SetTransparent(wxByte alpha);
147 bool SetBackgroundColour(const wxColour& col );
148 void SetExtraStyle( long exStyle );
149 bool SetBackgroundStyle(wxBackgroundStyle style);
150 bool CanSetTransparent();
151
152 void MoveWindow(int x, int y, int width, int height);
153 void GetPosition( int &x, int &y ) const;
154 void GetSize( int &width, int &height ) const;
155
156 void GetContentArea( int &left , int &top , int &width , int &height ) const;
157 bool SetShape(const wxRegion& region);
158
159 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
160
161 virtual bool IsMaximized() const;
162
163 virtual bool IsIconized() const;
164
165 virtual void Iconize( bool iconize );
166
167 virtual void Maximize(bool maximize);
168
169 virtual bool IsFullScreen() const;
170
171 virtual bool ShowFullScreen(bool show, long style);
172
173 virtual void RequestUserAttention(int flags);
174
175 virtual void ScreenToWindow( int *x, int *y );
176
177 virtual void WindowToScreen( int *x, int *y );
178
179 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
180 protected :
181 WX_NSWindow m_macWindow;
182 void * m_macFullScreenData ;
183 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
184 };
185
186 #ifdef __OBJC__
187
188 extern NSRect wxToNSRect( NSView* parent, const wxRect& r );
189 extern wxRect wxFromNSRect( NSView* parent, const NSRect& rect );
190 extern NSPoint wxToNSPoint( NSView* parent, const wxPoint& p );
191 extern wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p );
192
193 // used for many wxControls
194
195 @interface wxNSButton : NSButton
196 {
197 wxWidgetCocoaImpl* impl;
198 }
199
200 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;
201 - (wxWidgetCocoaImpl*) implementation;
202 - (BOOL) isFlipped;
203 - (void) clickedAction: (id) sender;
204
205 @end
206
207 @interface wxNSBox : NSBox
208 {
209 wxWidgetCocoaImpl* impl;
210 }
211
212 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;
213 - (wxWidgetCocoaImpl*) implementation;
214 - (BOOL) isFlipped;
215
216 @end
217
218 @interface wxNSTextField : NSTextField
219 {
220 wxWidgetCocoaImpl* impl;
221 }
222
223 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;
224 - (wxWidgetCocoaImpl*) implementation;
225 - (BOOL) isFlipped;
226
227 @end
228
229 NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
230 bool adjustForOrigin = true );
231
232 // common code snippets for cocoa implementations
233 // later to be done using injection in method table
234
235 #define WXCOCOAIMPL_COMMON_MOUSE_INTERFACE -(void)mouseDown:(NSEvent *)event ;\
236 -(void)rightMouseDown:(NSEvent *)event ;\
237 -(void)otherMouseDown:(NSEvent *)event ;\
238 -(void)mouseUp:(NSEvent *)event ;\
239 -(void)rightMouseUp:(NSEvent *)event ;\
240 -(void)otherMouseUp:(NSEvent *)event ;\
241 -(void)handleMouseEvent:(NSEvent *)event;
242
243 #define WXCOCOAIMPL_COMMON_MOUSE_IMPLEMENTATION -(void)mouseDown:(NSEvent *)event \
244 {\
245 [self handleMouseEvent:event];\
246 }\
247 -(void)rightMouseDown:(NSEvent *)event\
248 {\
249 [self handleMouseEvent:event];\
250 }\
251 -(void)otherMouseDown:(NSEvent *)event\
252 {\
253 [self handleMouseEvent:event];\
254 }\
255 -(void)mouseUp:(NSEvent *)event\
256 {\
257 [self handleMouseEvent:event];\
258 }\
259 -(void)rightMouseUp:(NSEvent *)event\
260 {\
261 [self handleMouseEvent:event];\
262 }\
263 -(void)otherMouseUp:(NSEvent *)event\
264 {\
265 [self handleMouseEvent:event];\
266 }\
267 -(void)handleMouseEvent:(NSEvent *)event\
268 {\
269 impl->DoHandleMouseEvent(event);\
270 }
271
272 #endif // __OBJC__
273
274 // NSCursor
275
276 WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type );
277 WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY );
278 void wxMacCocoaSetCursor( WX_NSCursor cursor );
279 void wxMacCocoaHideCursor();
280 void wxMacCocoaShowCursor();
281
282 typedef struct tagClassicCursor
283 {
284 wxUint16 bits[16];
285 wxUint16 mask[16];
286 wxInt16 hotspot[2];
287 }ClassicCursor;
288
289 const short kwxCursorBullseye = 0;
290 const short kwxCursorBlank = 1;
291 const short kwxCursorPencil = 2;
292 const short kwxCursorMagnifier = 3;
293 const short kwxCursorNoEntry = 4;
294 const short kwxCursorPaintBrush = 5;
295 const short kwxCursorPointRight = 6;
296 const short kwxCursorPointLeft = 7;
297 const short kwxCursorQuestionArrow = 8;
298 const short kwxCursorRightArrow = 9;
299 const short kwxCursorSizeNS = 10;
300 const short kwxCursorSize = 11;
301 const short kwxCursorSizeNESW = 12;
302 const short kwxCursorSizeNWSE = 13;
303 const short kwxCursorRoller = 14;
304 const short kwxCursorLast = kwxCursorRoller;
305
306 // exposing our fallback cursor map
307
308 extern ClassicCursor gMacCursors[];
309
310 #endif
311
312 #endif
313 // _WX_PRIVATE_COCOA_H_
314