]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/cocoa/private.h
routing native events first to the wx class and only if skipped call native handler
[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 bool 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 NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
194 bool adjustForOrigin = true );
195
196 // common code snippets for cocoa implementations
197 // later to be done using injection in method table
198
199 #define WXCOCOAIMPL_COMMON_MOUSE_INTERFACE -(void)mouseDown:(NSEvent *)event ;\
200 -(void)rightMouseDown:(NSEvent *)event ;\
201 -(void)otherMouseDown:(NSEvent *)event ;\
202 -(void)mouseUp:(NSEvent *)event ;\
203 -(void)rightMouseUp:(NSEvent *)event ;\
204 -(void)otherMouseUp:(NSEvent *)event ;\
205
206 #define WXCOCOAIMPL_COMMON_MOUSE_IMPLEMENTATION -(void)mouseDown:(NSEvent *)event \
207 {\
208 if ( !impl->DoHandleMouseEvent(event) )\
209 [super mouseDown:event];\
210 }\
211 -(void)rightMouseDown:(NSEvent *)event\
212 {\
213 if ( !impl->DoHandleMouseEvent(event) )\
214 [super rightMouseDown:event];\
215 }\
216 -(void)otherMouseDown:(NSEvent *)event\
217 {\
218 if ( !impl->DoHandleMouseEvent(event) )\
219 [super otherMouseDown:event];\
220 }\
221 -(void)mouseUp:(NSEvent *)event\
222 {\
223 if ( !impl->DoHandleMouseEvent(event) )\
224 [super mouseUp:event];\
225 }\
226 -(void)rightMouseUp:(NSEvent *)event\
227 {\
228 if ( !impl->DoHandleMouseEvent(event) )\
229 [super rightMouseUp:event];\
230 }\
231 -(void)otherMouseUp:(NSEvent *)event\
232 {\
233 if ( !impl->DoHandleMouseEvent(event) )\
234 [super otherMouseUp:event];\
235 }
236
237 #define WXCOCOAIMPL_COMMON_MEMBERS wxWidgetCocoaImpl* impl;
238
239 #define WXCOCOAIMPL_COMMON_INTERFACE \
240 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;\
241 - (wxWidgetCocoaImpl*) implementation;\
242 - (BOOL) isFlipped;\
243 WXCOCOAIMPL_COMMON_MOUSE_INTERFACE
244
245 #define WXCOCOAIMPL_COMMON_IMPLEMENTATION WXCOCOAIMPL_COMMON_MOUSE_IMPLEMENTATION \
246 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation\
247 {\
248 impl = theImplementation;\
249 }\
250 - (wxWidgetCocoaImpl*) implementation\
251 {\
252 return impl;\
253 }\
254 - (BOOL) isFlipped\
255 {\
256 return YES;\
257 }\
258
259 // used for many wxControls
260
261 @interface wxNSButton : NSButton
262 {
263 WXCOCOAIMPL_COMMON_MEMBERS
264 }
265
266 WXCOCOAIMPL_COMMON_INTERFACE
267 - (void) clickedAction: (id) sender;
268
269 @end
270
271 @interface wxNSBox : NSBox
272 {
273 WXCOCOAIMPL_COMMON_MEMBERS
274 }
275
276 WXCOCOAIMPL_COMMON_INTERFACE
277
278 @end
279
280 @interface wxNSTextField : NSTextField
281 {
282 WXCOCOAIMPL_COMMON_MEMBERS
283 }
284
285 WXCOCOAIMPL_COMMON_INTERFACE
286
287 @end
288
289
290 #endif // __OBJC__
291
292 // NSCursor
293
294 WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type );
295 WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY );
296 void wxMacCocoaSetCursor( WX_NSCursor cursor );
297 void wxMacCocoaHideCursor();
298 void wxMacCocoaShowCursor();
299
300 typedef struct tagClassicCursor
301 {
302 wxUint16 bits[16];
303 wxUint16 mask[16];
304 wxInt16 hotspot[2];
305 }ClassicCursor;
306
307 const short kwxCursorBullseye = 0;
308 const short kwxCursorBlank = 1;
309 const short kwxCursorPencil = 2;
310 const short kwxCursorMagnifier = 3;
311 const short kwxCursorNoEntry = 4;
312 const short kwxCursorPaintBrush = 5;
313 const short kwxCursorPointRight = 6;
314 const short kwxCursorPointLeft = 7;
315 const short kwxCursorQuestionArrow = 8;
316 const short kwxCursorRightArrow = 9;
317 const short kwxCursorSizeNS = 10;
318 const short kwxCursorSize = 11;
319 const short kwxCursorSizeNESW = 12;
320 const short kwxCursorSizeNWSE = 13;
321 const short kwxCursorRoller = 14;
322 const short kwxCursorLast = kwxCursorRoller;
323
324 // exposing our fallback cursor map
325
326 extern ClassicCursor gMacCursors[];
327
328 #endif
329
330 #endif
331 // _WX_PRIVATE_COCOA_H_
332