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 #import <Cocoa/Cocoa.h>
23 extern NSRect
wxToNSRect( NSView
* parent
, const wxRect
& r
);
24 extern wxRect
wxFromNSRect( NSView
* parent
, const NSRect
& rect
);
25 extern NSPoint
wxToNSPoint( NSView
* parent
, const wxPoint
& p
);
26 extern wxPoint
wxFromNSPoint( NSView
* parent
, const NSPoint
& p
);
28 // used for many wxControls
30 @interface wxNSButton
: NSButton
35 - (void)setImplementation
: (wxWidgetImpl
*) theImplementation
;
36 - (wxWidgetImpl
*) implementation
;
38 - (void) clickedAction
: (id
) sender
;
42 @interface wxNSBox
: NSBox
47 - (void)setImplementation
: (wxWidgetImpl
*) theImplementation
;
48 - (wxWidgetImpl
*) implementation
;
53 @interface wxNSTextField
: NSTextField
58 - (void)setImplementation
: (wxWidgetImpl
*) theImplementation
;
59 - (wxWidgetImpl
*) implementation
;
64 NSRect WXDLLIMPEXP_CORE
wxOSXGetFrameForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
,
65 bool adjustForOrigin
= true );
70 // shared between Cocoa and Carbon
73 // bring in themeing types without pulling in the headers
75 typedef SInt16 ThemeBrush
;
76 long UMAGetSystemVersion() ;
77 CGColorRef
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
78 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
79 CGContextRef inContext
,
80 const CGRect
* inBounds
,
82 WX_NSImage
wxOSXCreateNSImageFromCGImage( CGImageRef image
);
84 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
85 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
86 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
87 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
95 class WXDLLIMPEXP_CORE wxWidgetCocoaImpl
: public wxWidgetImpl
98 wxWidgetCocoaImpl( wxWindowMac
* peer
, WXWidget w
, bool isRootControl
= false ) ;
100 ~wxWidgetCocoaImpl();
104 virtual bool IsVisible() const ;
105 virtual void SetVisibility(bool);
107 virtual void Raise();
109 virtual void Lower();
111 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
113 virtual WXWidget
GetWXWidget() const { return m_osxView
; }
115 virtual void SetBackgroundColour(const wxColour
&);
117 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
118 virtual void Move(int x
, int y
, int width
, int height
);
119 virtual void GetPosition( int &x
, int &y
) const;
120 virtual void GetSize( int &width
, int &height
) const;
121 virtual void SetControlSize( wxWindowVariant variant
);
123 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
124 virtual bool GetNeedsDisplay() const;
126 virtual bool CanFocus() const;
127 // return true if successful
128 virtual bool SetFocus();
129 virtual bool HasFocus() const;
131 void RemoveFromParent();
132 void Embed( wxWidgetImpl
*parent
);
134 void SetDefaultButton( bool isDefault
);
136 void SetLabel(const wxString
& title
, wxFontEncoding encoding
);
138 wxInt32
GetValue() const;
139 void SetValue( wxInt32 v
);
140 void SetBitmap( const wxBitmap
& bitmap
);
141 void SetupTabs( const wxNotebook
¬ebook
);
142 void GetBestRect( wxRect
*r
) const;
143 bool IsEnabled() const;
144 void Enable( bool enable
);
145 bool ButtonClickDidStateChange() { return true ;}
146 void SetMinimum( wxInt32 v
);
147 void SetMaximum( wxInt32 v
);
149 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
153 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl
)
156 class wxNonOwnedWindowCocoaImpl
: public wxNonOwnedWindowImpl
159 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow
* nonownedwnd
) ;
160 wxNonOwnedWindowCocoaImpl();
162 virtual ~wxNonOwnedWindowCocoaImpl();
164 virtual void Destroy() ;
165 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
166 long style
, long extraStyle
, const wxString
& name
) ;
168 WXWindow
GetWXWindow() const;
171 bool Show(bool show
);
172 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
175 bool SetTransparent(wxByte alpha
);
176 bool SetBackgroundColour(const wxColour
& col
);
177 void SetExtraStyle( long exStyle
);
178 bool SetBackgroundStyle(wxBackgroundStyle style
);
179 bool CanSetTransparent();
181 void MoveWindow(int x
, int y
, int width
, int height
);
182 void GetPosition( int &x
, int &y
) const;
183 void GetSize( int &width
, int &height
) const;
185 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
186 bool SetShape(const wxRegion
& region
);
188 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
190 virtual bool IsMaximized() const;
192 virtual bool IsIconized() const;
194 virtual void Iconize( bool iconize
);
196 virtual void Maximize(bool maximize
);
198 virtual bool IsFullScreen() const;
200 virtual bool ShowFullScreen(bool show
, long style
);
202 virtual void RequestUserAttention(int flags
);
204 virtual void ScreenToWindow( int *x
, int *y
);
206 virtual void WindowToScreen( int *x
, int *y
);
208 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
210 WX_NSWindow m_macWindow
;
211 void * m_macFullScreenData
;
212 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl
)
217 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
218 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
219 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
220 void wxMacCocoaHideCursor();
221 void wxMacCocoaShowCursor();
223 typedef struct tagClassicCursor
230 const short kwxCursorBullseye
= 0;
231 const short kwxCursorBlank
= 1;
232 const short kwxCursorPencil
= 2;
233 const short kwxCursorMagnifier
= 3;
234 const short kwxCursorNoEntry
= 4;
235 const short kwxCursorPaintBrush
= 5;
236 const short kwxCursorPointRight
= 6;
237 const short kwxCursorPointLeft
= 7;
238 const short kwxCursorQuestionArrow
= 8;
239 const short kwxCursorRightArrow
= 9;
240 const short kwxCursorSizeNS
= 10;
241 const short kwxCursorSize
= 11;
242 const short kwxCursorSizeNESW
= 12;
243 const short kwxCursorSizeNWSE
= 13;
244 const short kwxCursorRoller
= 14;
245 const short kwxCursorLast
= kwxCursorRoller
;
247 // exposing our fallback cursor map
249 extern ClassicCursor gMacCursors
[];
254 // _WX_PRIVATE_COCOA_H_