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 void 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 // used for many wxControls
195 @interface wxNSButton
: NSButton
197 wxWidgetCocoaImpl
* impl
;
200 - (void)setImplementation
: (wxWidgetCocoaImpl
*) theImplementation
;
201 - (wxWidgetCocoaImpl
*) implementation
;
203 - (void) clickedAction
: (id
) sender
;
207 @interface wxNSBox
: NSBox
209 wxWidgetCocoaImpl
* impl
;
212 - (void)setImplementation
: (wxWidgetCocoaImpl
*) theImplementation
;
213 - (wxWidgetCocoaImpl
*) implementation
;
218 @interface wxNSTextField
: NSTextField
220 wxWidgetCocoaImpl
* impl
;
223 - (void)setImplementation
: (wxWidgetCocoaImpl
*) theImplementation
;
224 - (wxWidgetCocoaImpl
*) implementation
;
229 NSRect WXDLLIMPEXP_CORE
wxOSXGetFrameForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
,
230 bool adjustForOrigin
= true );
232 // common code snippets for cocoa implementations
233 // later to be done using injection in method table
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;
243 #define WXCOCOAIMPL_COMMON_MOUSE_IMPLEMENTATION -(void)mouseDown:(NSEvent *)event \
245 [self handleMouseEvent:event];\
247 -(void)rightMouseDown:(NSEvent *)event\
249 [self handleMouseEvent:event];\
251 -(void)otherMouseDown:(NSEvent *)event\
253 [self handleMouseEvent:event];\
255 -(void)mouseUp:(NSEvent *)event\
257 [self handleMouseEvent:event];\
259 -(void)rightMouseUp:(NSEvent *)event\
261 [self handleMouseEvent:event];\
263 -(void)otherMouseUp:(NSEvent *)event\
265 [self handleMouseEvent:event];\
267 -(void)handleMouseEvent:(NSEvent *)event\
269 impl->DoHandleMouseEvent(event);\
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();
282 typedef struct tagClassicCursor
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
;
306 // exposing our fallback cursor map
308 extern ClassicCursor gMacCursors
[];
313 // _WX_PRIVATE_COCOA_H_