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>
30 #import <Cocoa/Cocoa.h>
34 extern NSRect
wxToNSRect( NSView
* parent
, const wxRect
& r
);
35 extern wxRect
wxFromNSRect( NSView
* parent
, const NSRect
& rect
);
36 extern NSPoint
wxToNSPoint( NSView
* parent
, const wxPoint
& p
);
37 extern wxPoint
wxFromNSPoint( NSView
* parent
, const NSPoint
& p
);
39 // used for many wxControls
41 @interface wxNSButton
: NSButton
46 - (void)setImplementation
: (wxWidgetImpl
*) theImplementation
;
47 - (wxWidgetImpl
*) implementation
;
49 - (void) clickedAction
: (id
) sender
;
53 @interface wxNSBox
: NSBox
58 - (void)setImplementation
: (wxWidgetImpl
*) theImplementation
;
59 - (wxWidgetImpl
*) implementation
;
64 @interface wxNSTextField
: NSTextField
69 - (void)setImplementation
: (wxWidgetImpl
*) theImplementation
;
70 - (wxWidgetImpl
*) implementation
;
75 NSRect WXDLLIMPEXP_CORE
wxOSXGetFrameForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
,
76 bool adjustForOrigin
= true );
83 // shared between Cocoa and Carbon
86 // bring in themeing types without pulling in the headers
89 typedef SInt16 ThemeBrush
;
90 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
91 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
92 CGContextRef inContext
,
93 const CGRect
* inBounds
,
95 WX_NSImage WXDLLIMPEXP_CORE
wxOSXCreateNSImageFromCGImage( CGImageRef image
);
98 long UMAGetSystemVersion() ;
99 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
100 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
101 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
102 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
110 class WXDLLIMPEXP_CORE wxWidgetCocoaImpl
: public wxWidgetImpl
113 wxWidgetCocoaImpl( wxWindowMac
* peer
, WXWidget w
, bool isRootControl
= false ) ;
114 wxWidgetCocoaImpl() ;
115 ~wxWidgetCocoaImpl();
119 virtual bool IsVisible() const ;
120 virtual void SetVisibility(bool);
122 virtual void Raise();
124 virtual void Lower();
126 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
128 virtual WXWidget
GetWXWidget() const { return m_osxView
; }
130 virtual void SetBackgroundColour(const wxColour
&);
132 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
133 virtual void Move(int x
, int y
, int width
, int height
);
134 virtual void GetPosition( int &x
, int &y
) const;
135 virtual void GetSize( int &width
, int &height
) const;
136 virtual void SetControlSize( wxWindowVariant variant
);
138 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
139 virtual bool GetNeedsDisplay() const;
141 virtual bool CanFocus() const;
142 // return true if successful
143 virtual bool SetFocus();
144 virtual bool HasFocus() const;
146 void RemoveFromParent();
147 void Embed( wxWidgetImpl
*parent
);
149 void SetDefaultButton( bool isDefault
);
151 void SetLabel(const wxString
& title
, wxFontEncoding encoding
);
153 wxInt32
GetValue() const;
154 void SetValue( wxInt32 v
);
155 void SetBitmap( const wxBitmap
& bitmap
);
156 void SetupTabs( const wxNotebook
¬ebook
);
157 void GetBestRect( wxRect
*r
) const;
158 bool IsEnabled() const;
159 void Enable( bool enable
);
160 bool ButtonClickDidStateChange() { return true ;}
161 void SetMinimum( wxInt32 v
);
162 void SetMaximum( wxInt32 v
);
164 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
166 void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
168 void InstallEventHandler( WXWidget control
= NULL
);
171 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl
)
174 class wxNonOwnedWindowCocoaImpl
: public wxNonOwnedWindowImpl
177 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow
* nonownedwnd
) ;
178 wxNonOwnedWindowCocoaImpl();
180 virtual ~wxNonOwnedWindowCocoaImpl();
182 virtual void Destroy() ;
183 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
184 long style
, long extraStyle
, const wxString
& name
) ;
186 WXWindow
GetWXWindow() const;
189 bool Show(bool show
);
190 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
193 bool SetTransparent(wxByte alpha
);
194 bool SetBackgroundColour(const wxColour
& col
);
195 void SetExtraStyle( long exStyle
);
196 bool SetBackgroundStyle(wxBackgroundStyle style
);
197 bool CanSetTransparent();
199 void MoveWindow(int x
, int y
, int width
, int height
);
200 void GetPosition( int &x
, int &y
) const;
201 void GetSize( int &width
, int &height
) const;
203 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
204 bool SetShape(const wxRegion
& region
);
206 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
208 virtual bool IsMaximized() const;
210 virtual bool IsIconized() const;
212 virtual void Iconize( bool iconize
);
214 virtual void Maximize(bool maximize
);
216 virtual bool IsFullScreen() const;
218 virtual bool ShowFullScreen(bool show
, long style
);
220 virtual void RequestUserAttention(int flags
);
222 virtual void ScreenToWindow( int *x
, int *y
);
224 virtual void WindowToScreen( int *x
, int *y
);
226 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
228 WX_NSWindow m_macWindow
;
229 void * m_macFullScreenData
;
230 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl
)
235 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
236 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
237 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
238 void wxMacCocoaHideCursor();
239 void wxMacCocoaShowCursor();
241 typedef struct tagClassicCursor
248 const short kwxCursorBullseye
= 0;
249 const short kwxCursorBlank
= 1;
250 const short kwxCursorPencil
= 2;
251 const short kwxCursorMagnifier
= 3;
252 const short kwxCursorNoEntry
= 4;
253 const short kwxCursorPaintBrush
= 5;
254 const short kwxCursorPointRight
= 6;
255 const short kwxCursorPointLeft
= 7;
256 const short kwxCursorQuestionArrow
= 8;
257 const short kwxCursorRightArrow
= 9;
258 const short kwxCursorSizeNS
= 10;
259 const short kwxCursorSize
= 11;
260 const short kwxCursorSizeNESW
= 12;
261 const short kwxCursorSizeNWSE
= 13;
262 const short kwxCursorRoller
= 14;
263 const short kwxCursorLast
= kwxCursorRoller
;
265 // exposing our fallback cursor map
267 extern ClassicCursor gMacCursors
[];
272 // _WX_PRIVATE_COCOA_H_