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
6 // Author: Stefan Csomor
9 // RCS-ID: $Id: private.h 53819 2008-05-29 14:11:45Z SC $
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_PRIVATE_COCOA_H_
15 #define _WX_PRIVATE_COCOA_H_
17 #include "wx/osx/core/private.h"
21 #include <ApplicationServices/ApplicationServices.h>
23 #if wxOSX_USE_ATSU_TEXT
24 // we need theming and atsu
25 #include <Carbon/Carbon.h>
29 #import <Cocoa/Cocoa.h>
33 // shared between Cocoa and Carbon
36 // bring in themeing types without pulling in the headers
39 typedef SInt16 ThemeBrush
;
40 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
41 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
42 CGContextRef inContext
,
43 const CGRect
* inBounds
,
45 WX_NSImage WXDLLIMPEXP_CORE
wxOSXCreateNSImageFromCGImage( CGImageRef image
);
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
);
60 class WXDLLIMPEXP_CORE wxWidgetCocoaImpl
: public wxWidgetImpl
63 wxWidgetCocoaImpl( wxWindowMac
* peer
, WXWidget w
, bool isRootControl
= false ) ;
69 virtual bool IsVisible() const ;
70 virtual void SetVisibility(bool);
76 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
78 virtual WXWidget
GetWXWidget() const { return m_osxView
; }
80 virtual void SetBackgroundColour(const wxColour
&);
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
);
88 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
89 virtual bool GetNeedsDisplay() const;
91 virtual bool CanFocus() const;
92 // return true if successful
93 virtual bool SetFocus();
94 virtual bool HasFocus() const;
96 void RemoveFromParent();
97 void Embed( wxWidgetImpl
*parent
);
99 void SetDefaultButton( bool isDefault
);
101 void SetLabel(const wxString
& title
, wxFontEncoding encoding
);
103 wxInt32
GetValue() const;
104 void SetValue( wxInt32 v
);
105 void SetBitmap( const wxBitmap
& bitmap
);
106 void SetupTabs( const wxNotebook
¬ebook
);
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
);
114 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
116 void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
118 void InstallEventHandler( WXWidget control
= NULL
);
120 virtual bool DoHandleMouseEvent(NSEvent
*event
);
124 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl
)
127 class wxNonOwnedWindowCocoaImpl
: public wxNonOwnedWindowImpl
130 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow
* nonownedwnd
) ;
131 wxNonOwnedWindowCocoaImpl();
133 virtual ~wxNonOwnedWindowCocoaImpl();
135 virtual void Destroy() ;
136 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
137 long style
, long extraStyle
, const wxString
& name
) ;
139 WXWindow
GetWXWindow() const;
142 bool Show(bool show
);
143 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
146 bool SetTransparent(wxByte alpha
);
147 bool SetBackgroundColour(const wxColour
& col
);
148 void SetExtraStyle( long exStyle
);
149 bool SetBackgroundStyle(wxBackgroundStyle style
);
150 bool CanSetTransparent();
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;
156 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
157 bool SetShape(const wxRegion
& region
);
159 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
161 virtual bool IsMaximized() const;
163 virtual bool IsIconized() const;
165 virtual void Iconize( bool iconize
);
167 virtual void Maximize(bool maximize
);
169 virtual bool IsFullScreen() const;
171 virtual bool ShowFullScreen(bool show
, long style
);
173 virtual void RequestUserAttention(int flags
);
175 virtual void ScreenToWindow( int *x
, int *y
);
177 virtual void WindowToScreen( int *x
, int *y
);
179 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
181 WX_NSWindow m_macWindow
;
182 void * m_macFullScreenData
;
183 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl
)
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
);
193 NSRect WXDLLIMPEXP_CORE
wxOSXGetFrameForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
,
194 bool adjustForOrigin
= true );
196 // common code snippets for cocoa implementations
197 // later to be done using injection in method table
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 ;\
206 #define WXCOCOAIMPL_COMMON_MOUSE_IMPLEMENTATION -(void)mouseDown:(NSEvent *)event \
208 if ( !impl->DoHandleMouseEvent(event) )\
209 [super mouseDown:event];\
211 -(void)rightMouseDown:(NSEvent *)event\
213 if ( !impl->DoHandleMouseEvent(event) )\
214 [super rightMouseDown:event];\
216 -(void)otherMouseDown:(NSEvent *)event\
218 if ( !impl->DoHandleMouseEvent(event) )\
219 [super otherMouseDown:event];\
221 -(void)mouseUp:(NSEvent *)event\
223 if ( !impl->DoHandleMouseEvent(event) )\
224 [super mouseUp:event];\
226 -(void)rightMouseUp:(NSEvent *)event\
228 if ( !impl->DoHandleMouseEvent(event) )\
229 [super rightMouseUp:event];\
231 -(void)otherMouseUp:(NSEvent *)event\
233 if ( !impl->DoHandleMouseEvent(event) )\
234 [super otherMouseUp:event];\
237 #define WXCOCOAIMPL_COMMON_MEMBERS wxWidgetCocoaImpl* impl;
239 #define WXCOCOAIMPL_COMMON_INTERFACE \
240 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;\
241 - (wxWidgetCocoaImpl*) implementation;\
243 WXCOCOAIMPL_COMMON_MOUSE_INTERFACE
245 #define WXCOCOAIMPL_COMMON_IMPLEMENTATION WXCOCOAIMPL_COMMON_MOUSE_IMPLEMENTATION \
246 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation\
248 impl = theImplementation;\
250 - (wxWidgetCocoaImpl*) implementation\
259 // used for many wxControls
261 @interface wxNSButton
: NSButton
263 WXCOCOAIMPL_COMMON_MEMBERS
266 WXCOCOAIMPL_COMMON_INTERFACE
267 - (void) clickedAction
: (id
) sender
;
271 @interface wxNSBox
: NSBox
273 WXCOCOAIMPL_COMMON_MEMBERS
276 WXCOCOAIMPL_COMMON_INTERFACE
280 @interface wxNSTextField
: NSTextField
282 WXCOCOAIMPL_COMMON_MEMBERS
285 WXCOCOAIMPL_COMMON_INTERFACE
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();
300 typedef struct tagClassicCursor
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
;
324 // exposing our fallback cursor map
326 extern ClassicCursor gMacCursors
[];
331 // _WX_PRIVATE_COCOA_H_