]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/cocoa/private.h
no real change: divide in groups the wxEvtHandler methods
[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 void SetCursor( const wxCursor & cursor );
104 void CaptureMouse();
105 void ReleaseMouse();
106
107 wxInt32 GetValue() const;
108 void SetValue( wxInt32 v );
109 void SetBitmap( const wxBitmap& bitmap );
110 void SetupTabs( const wxNotebook &notebook );
111 void GetBestRect( wxRect *r ) const;
112 bool IsEnabled() const;
113 void Enable( bool enable );
114 bool ButtonClickDidStateChange() { return true ;}
115 void SetMinimum( wxInt32 v );
116 void SetMaximum( wxInt32 v );
117 void PulseGauge();
118 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
119
120 void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
121
122 void InstallEventHandler( WXWidget control = NULL );
123
124 virtual bool DoHandleMouseEvent(NSEvent *event);
125 virtual bool DoHandleKeyEvent(NSEvent *event);
126 virtual void DoNotifyFocusEvent(bool receivedFocus);
127
128 protected:
129 WXWidget m_osxView;
130 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
131 };
132
133 DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
134
135 class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
136 {
137 public :
138 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ;
139 wxNonOwnedWindowCocoaImpl();
140
141 virtual ~wxNonOwnedWindowCocoaImpl();
142
143 virtual void Destroy() ;
144 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
145 long style, long extraStyle, const wxString& name ) ;
146
147 WXWindow GetWXWindow() const;
148 void Raise();
149 void Lower();
150 bool Show(bool show);
151 bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout);
152
153 void Update();
154 bool SetTransparent(wxByte alpha);
155 bool SetBackgroundColour(const wxColour& col );
156 void SetExtraStyle( long exStyle );
157 bool SetBackgroundStyle(wxBackgroundStyle style);
158 bool CanSetTransparent();
159
160 void MoveWindow(int x, int y, int width, int height);
161 void GetPosition( int &x, int &y ) const;
162 void GetSize( int &width, int &height ) const;
163
164 void GetContentArea( int &left , int &top , int &width , int &height ) const;
165 bool SetShape(const wxRegion& region);
166
167 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
168
169 virtual bool IsMaximized() const;
170
171 virtual bool IsIconized() const;
172
173 virtual void Iconize( bool iconize );
174
175 virtual void Maximize(bool maximize);
176
177 virtual bool IsFullScreen() const;
178
179 virtual bool ShowFullScreen(bool show, long style);
180
181 virtual void RequestUserAttention(int flags);
182
183 virtual void ScreenToWindow( int *x, int *y );
184
185 virtual void WindowToScreen( int *x, int *y );
186
187 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
188 protected :
189 WX_wxNSWindow m_macWindow;
190 void * m_macFullScreenData ;
191 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
192 };
193
194 #ifdef __OBJC__
195
196 extern NSRect wxToNSRect( NSView* parent, const wxRect& r );
197 extern wxRect wxFromNSRect( NSView* parent, const NSRect& rect );
198 extern NSPoint wxToNSPoint( NSView* parent, const wxPoint& p );
199 extern wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p );
200
201 NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
202 bool adjustForOrigin = true );
203
204 // common code snippets for cocoa implementations
205 // later to be done using injection in method table
206
207 #define WXCOCOAIMPL_COMMON_EVENTS_INTERFACE -(void)mouseDown:(NSEvent *)event ;\
208 - (void)rightMouseDown:(NSEvent *)event ;\
209 - (void)otherMouseDown:(NSEvent *)event ;\
210 - (void)mouseUp:(NSEvent *)event ;\
211 - (void)rightMouseUp:(NSEvent *)event ;\
212 - (void)otherMouseUp:(NSEvent *)event ;\
213 - (void)mouseMoved:(NSEvent *)event;\
214 - (void)mouseDragged:(NSEvent *)event;\
215 - (void)rightMouseDragged:(NSEvent *)event;\
216 - (void)otherMouseDragged:(NSEvent *)event;\
217 - (void)scrollWheel:(NSEvent *)theEvent;\
218 - (void)mouseEntered:(NSEvent *)event;\
219 - (void)mouseExited:(NSEvent *)event;\
220 - (void)keyDown:(NSEvent *)event;\
221 - (void)keyUp:(NSEvent *)event;\
222 - (void)flagsChanged:(NSEvent *)event;\
223 - (BOOL) becomeFirstResponder;\
224 - (BOOL) resignFirstResponder;
225
226 #define WXCOCOAIMPL_COMMON_EVENTS_IMPLEMENTATION -(void)mouseDown:(NSEvent *)event \
227 {\
228 if ( !impl->DoHandleMouseEvent(event) )\
229 [super mouseDown:event];\
230 }\
231 -(void)rightMouseDown:(NSEvent *)event\
232 {\
233 if ( !impl->DoHandleMouseEvent(event) )\
234 [super rightMouseDown:event];\
235 }\
236 -(void)otherMouseDown:(NSEvent *)event\
237 {\
238 if ( !impl->DoHandleMouseEvent(event) )\
239 [super otherMouseDown:event];\
240 }\
241 -(void)mouseUp:(NSEvent *)event\
242 {\
243 if ( !impl->DoHandleMouseEvent(event) )\
244 [super mouseUp:event];\
245 }\
246 -(void)rightMouseUp:(NSEvent *)event\
247 {\
248 if ( !impl->DoHandleMouseEvent(event) )\
249 [super rightMouseUp:event];\
250 }\
251 -(void)otherMouseUp:(NSEvent *)event\
252 {\
253 if ( !impl->DoHandleMouseEvent(event) )\
254 [super otherMouseUp:event];\
255 }\
256 -(void)mouseMoved:(NSEvent *)event\
257 {\
258 if ( !impl->DoHandleMouseEvent(event) )\
259 [super mouseMoved:event];\
260 }\
261 -(void)mouseDragged:(NSEvent *)event\
262 {\
263 if ( !impl->DoHandleMouseEvent(event) )\
264 [super mouseDragged:event];\
265 }\
266 -(void)rightMouseDragged:(NSEvent *)event\
267 {\
268 if ( !impl->DoHandleMouseEvent(event) )\
269 [super rightMouseDragged:event];\
270 }\
271 -(void)otherMouseDragged:(NSEvent *)event\
272 {\
273 if ( !impl->DoHandleMouseEvent(event) )\
274 [super otherMouseDragged:event];\
275 }\
276 -(void)scrollWheel:(NSEvent *)event\
277 {\
278 if ( !impl->DoHandleMouseEvent(event) )\
279 [super scrollWheel:event];\
280 }\
281 -(void)mouseEntered:(NSEvent *)event\
282 {\
283 if ( !impl->DoHandleMouseEvent(event) )\
284 [super mouseEntered:event];\
285 }\
286 -(void)mouseExited:(NSEvent *)event\
287 {\
288 if ( !impl->DoHandleMouseEvent(event) )\
289 [super mouseExited:event];\
290 }\
291 -(void)keyDown:(NSEvent *)event\
292 {\
293 if ( !impl->DoHandleKeyEvent(event) )\
294 [super keyDown:event];\
295 }\
296 -(void)keyUp:(NSEvent *)event\
297 {\
298 if ( !impl->DoHandleKeyEvent(event) )\
299 [super keyUp:event];\
300 }\
301 -(void)flagsChanged:(NSEvent *)event\
302 {\
303 if ( !impl->DoHandleKeyEvent(event) )\
304 [super flagsChanged:event];\
305 }\
306 - (BOOL) becomeFirstResponder\
307 {\
308 BOOL r = [super becomeFirstResponder];\
309 if ( r )\
310 impl->DoNotifyFocusEvent( true );\
311 return r;\
312 }\
313 - (BOOL) resignFirstResponder\
314 {\
315 BOOL r = [super resignFirstResponder];\
316 if ( r )\
317 impl->DoNotifyFocusEvent( false );\
318 return r;\
319 }
320
321 #define WXCOCOAIMPL_COMMON_MEMBERS wxWidgetCocoaImpl* impl;
322
323 #define WXCOCOAIMPL_COMMON_INTERFACE \
324 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;\
325 - (wxWidgetCocoaImpl*) implementation;\
326 - (BOOL) isFlipped;\
327 WXCOCOAIMPL_COMMON_EVENTS_INTERFACE
328
329 #define WXCOCOAIMPL_COMMON_IMPLEMENTATION WXCOCOAIMPL_COMMON_EVENTS_IMPLEMENTATION \
330 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation\
331 {\
332 impl = theImplementation;\
333 }\
334 - (wxWidgetCocoaImpl*) implementation\
335 {\
336 return impl;\
337 }\
338 - (BOOL) isFlipped\
339 {\
340 return YES;\
341 }\
342
343 #define WXCOCOAIMPL_COMMON_IMPLEMENTATION_NOT_FLIPPED WXCOCOAIMPL_COMMON_EVENTS_IMPLEMENTATION \
344 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation\
345 {\
346 impl = theImplementation;\
347 }\
348 - (wxWidgetCocoaImpl*) implementation\
349 {\
350 return impl;\
351 }\
352 - (BOOL) isFlipped\
353 {\
354 return NO;\
355 }\
356
357 // used for many wxControls
358
359 @interface wxNSButton : NSButton
360 {
361 WXCOCOAIMPL_COMMON_MEMBERS
362 }
363
364 WXCOCOAIMPL_COMMON_INTERFACE
365 - (void) clickedAction: (id) sender;
366
367 @end
368
369 @interface wxNSBox : NSBox
370 {
371 WXCOCOAIMPL_COMMON_MEMBERS
372 }
373
374 WXCOCOAIMPL_COMMON_INTERFACE
375
376 @end
377
378 @interface wxNSTextField : NSTextField
379 {
380 WXCOCOAIMPL_COMMON_MEMBERS
381 }
382
383 WXCOCOAIMPL_COMMON_INTERFACE
384
385 @end
386
387 @interface wxNSMenu : NSMenu
388 {
389 wxMenuImpl* impl;
390 }
391
392 - (void) setImplementation:(wxMenuImpl*) item;
393 - (wxMenuImpl*) implementation;
394
395 @end
396
397 @interface wxNSMenuItem : NSMenuItem
398 {
399 wxMenuItemImpl* impl;
400 }
401
402 - (void) setImplementation:(wxMenuItemImpl*) item;
403 - (wxMenuItemImpl*) implementation;
404
405 - (void)clickedAction:(id)sender;
406 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
407
408 @end
409
410 #endif // __OBJC__
411
412 // NSCursor
413
414 WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type );
415 WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY );
416 void wxMacCocoaSetCursor( WX_NSCursor cursor );
417 void wxMacCocoaHideCursor();
418 void wxMacCocoaShowCursor();
419
420 typedef struct tagClassicCursor
421 {
422 wxUint16 bits[16];
423 wxUint16 mask[16];
424 wxInt16 hotspot[2];
425 }ClassicCursor;
426
427 const short kwxCursorBullseye = 0;
428 const short kwxCursorBlank = 1;
429 const short kwxCursorPencil = 2;
430 const short kwxCursorMagnifier = 3;
431 const short kwxCursorNoEntry = 4;
432 const short kwxCursorPaintBrush = 5;
433 const short kwxCursorPointRight = 6;
434 const short kwxCursorPointLeft = 7;
435 const short kwxCursorQuestionArrow = 8;
436 const short kwxCursorRightArrow = 9;
437 const short kwxCursorSizeNS = 10;
438 const short kwxCursorSize = 11;
439 const short kwxCursorSizeNESW = 12;
440 const short kwxCursorSizeNWSE = 13;
441 const short kwxCursorRoller = 14;
442 const short kwxCursorLast = kwxCursorRoller;
443
444 // exposing our fallback cursor map
445
446 extern ClassicCursor gMacCursors[];
447
448 #endif
449
450 #endif
451 // _WX_PRIVATE_COCOA_H_
452