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>
25 #import <Cocoa/Cocoa.h>
29 extern NSRect
wxToNSRect( NSView
* parent
, const wxRect
& r
);
30 extern wxRect
wxFromNSRect( NSView
* parent
, const NSRect
& rect
);
31 extern NSPoint
wxToNSPoint( NSView
* parent
, const wxPoint
& p
);
32 extern wxPoint
wxFromNSPoint( NSView
* parent
, const NSPoint
& p
);
34 // used for many wxControls
36 @interface wxNSButton
: NSButton
41 - (void)setImplementation
: (wxWidgetImpl
*) theImplementation
;
42 - (wxWidgetImpl
*) implementation
;
44 - (void) clickedAction
: (id
) sender
;
48 @interface wxNSBox
: NSBox
53 - (void)setImplementation
: (wxWidgetImpl
*) theImplementation
;
54 - (wxWidgetImpl
*) implementation
;
59 @interface wxNSTextField
: NSTextField
64 - (void)setImplementation
: (wxWidgetImpl
*) theImplementation
;
65 - (wxWidgetImpl
*) implementation
;
70 NSRect WXDLLIMPEXP_CORE
wxOSXGetFrameForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
,
71 bool adjustForOrigin
= true );
78 // shared between Cocoa and Carbon
81 // bring in themeing types without pulling in the headers
84 typedef SInt16 ThemeBrush
;
85 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
86 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
87 CGContextRef inContext
,
88 const CGRect
* inBounds
,
90 WX_NSImage WXDLLIMPEXP_CORE
wxOSXCreateNSImageFromCGImage( CGImageRef image
);
93 long UMAGetSystemVersion() ;
94 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
95 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
96 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
97 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
105 class WXDLLIMPEXP_CORE wxWidgetCocoaImpl
: public wxWidgetImpl
108 wxWidgetCocoaImpl( wxWindowMac
* peer
, WXWidget w
, bool isRootControl
= false ) ;
109 wxWidgetCocoaImpl() ;
110 ~wxWidgetCocoaImpl();
114 virtual bool IsVisible() const ;
115 virtual void SetVisibility(bool);
117 virtual void Raise();
119 virtual void Lower();
121 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
123 virtual WXWidget
GetWXWidget() const { return m_osxView
; }
125 virtual void SetBackgroundColour(const wxColour
&);
127 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
128 virtual void Move(int x
, int y
, int width
, int height
);
129 virtual void GetPosition( int &x
, int &y
) const;
130 virtual void GetSize( int &width
, int &height
) const;
131 virtual void SetControlSize( wxWindowVariant variant
);
133 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
134 virtual bool GetNeedsDisplay() const;
136 virtual bool CanFocus() const;
137 // return true if successful
138 virtual bool SetFocus();
139 virtual bool HasFocus() const;
141 void RemoveFromParent();
142 void Embed( wxWidgetImpl
*parent
);
144 void SetDefaultButton( bool isDefault
);
146 void SetLabel(const wxString
& title
, wxFontEncoding encoding
);
148 wxInt32
GetValue() const;
149 void SetValue( wxInt32 v
);
150 void SetBitmap( const wxBitmap
& bitmap
);
151 void SetupTabs( const wxNotebook
¬ebook
);
152 void GetBestRect( wxRect
*r
) const;
153 bool IsEnabled() const;
154 void Enable( bool enable
);
155 bool ButtonClickDidStateChange() { return true ;}
156 void SetMinimum( wxInt32 v
);
157 void SetMaximum( wxInt32 v
);
159 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
161 void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
165 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl
)
168 class wxNonOwnedWindowCocoaImpl
: public wxNonOwnedWindowImpl
171 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow
* nonownedwnd
) ;
172 wxNonOwnedWindowCocoaImpl();
174 virtual ~wxNonOwnedWindowCocoaImpl();
176 virtual void Destroy() ;
177 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
178 long style
, long extraStyle
, const wxString
& name
) ;
180 WXWindow
GetWXWindow() const;
183 bool Show(bool show
);
184 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
187 bool SetTransparent(wxByte alpha
);
188 bool SetBackgroundColour(const wxColour
& col
);
189 void SetExtraStyle( long exStyle
);
190 bool SetBackgroundStyle(wxBackgroundStyle style
);
191 bool CanSetTransparent();
193 void MoveWindow(int x
, int y
, int width
, int height
);
194 void GetPosition( int &x
, int &y
) const;
195 void GetSize( int &width
, int &height
) const;
197 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
198 bool SetShape(const wxRegion
& region
);
200 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
202 virtual bool IsMaximized() const;
204 virtual bool IsIconized() const;
206 virtual void Iconize( bool iconize
);
208 virtual void Maximize(bool maximize
);
210 virtual bool IsFullScreen() const;
212 virtual bool ShowFullScreen(bool show
, long style
);
214 virtual void RequestUserAttention(int flags
);
216 virtual void ScreenToWindow( int *x
, int *y
);
218 virtual void WindowToScreen( int *x
, int *y
);
220 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
222 WX_NSWindow m_macWindow
;
223 void * m_macFullScreenData
;
224 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl
)
229 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
230 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
231 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
232 void wxMacCocoaHideCursor();
233 void wxMacCocoaShowCursor();
235 typedef struct tagClassicCursor
242 const short kwxCursorBullseye
= 0;
243 const short kwxCursorBlank
= 1;
244 const short kwxCursorPencil
= 2;
245 const short kwxCursorMagnifier
= 3;
246 const short kwxCursorNoEntry
= 4;
247 const short kwxCursorPaintBrush
= 5;
248 const short kwxCursorPointRight
= 6;
249 const short kwxCursorPointLeft
= 7;
250 const short kwxCursorQuestionArrow
= 8;
251 const short kwxCursorRightArrow
= 9;
252 const short kwxCursorSizeNS
= 10;
253 const short kwxCursorSize
= 11;
254 const short kwxCursorSizeNESW
= 12;
255 const short kwxCursorSizeNWSE
= 13;
256 const short kwxCursorRoller
= 14;
257 const short kwxCursorLast
= kwxCursorRoller
;
259 // exposing our fallback cursor map
261 extern ClassicCursor gMacCursors
[];
266 // _WX_PRIVATE_COCOA_H_