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
);
151 void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
155 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl
)
158 class wxNonOwnedWindowCocoaImpl
: public wxNonOwnedWindowImpl
161 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow
* nonownedwnd
) ;
162 wxNonOwnedWindowCocoaImpl();
164 virtual ~wxNonOwnedWindowCocoaImpl();
166 virtual void Destroy() ;
167 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
168 long style
, long extraStyle
, const wxString
& name
) ;
170 WXWindow
GetWXWindow() const;
173 bool Show(bool show
);
174 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
177 bool SetTransparent(wxByte alpha
);
178 bool SetBackgroundColour(const wxColour
& col
);
179 void SetExtraStyle( long exStyle
);
180 bool SetBackgroundStyle(wxBackgroundStyle style
);
181 bool CanSetTransparent();
183 void MoveWindow(int x
, int y
, int width
, int height
);
184 void GetPosition( int &x
, int &y
) const;
185 void GetSize( int &width
, int &height
) const;
187 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
188 bool SetShape(const wxRegion
& region
);
190 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
192 virtual bool IsMaximized() const;
194 virtual bool IsIconized() const;
196 virtual void Iconize( bool iconize
);
198 virtual void Maximize(bool maximize
);
200 virtual bool IsFullScreen() const;
202 virtual bool ShowFullScreen(bool show
, long style
);
204 virtual void RequestUserAttention(int flags
);
206 virtual void ScreenToWindow( int *x
, int *y
);
208 virtual void WindowToScreen( int *x
, int *y
);
210 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
212 WX_NSWindow m_macWindow
;
213 void * m_macFullScreenData
;
214 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl
)
219 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
220 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
221 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
222 void wxMacCocoaHideCursor();
223 void wxMacCocoaShowCursor();
225 typedef struct tagClassicCursor
232 const short kwxCursorBullseye
= 0;
233 const short kwxCursorBlank
= 1;
234 const short kwxCursorPencil
= 2;
235 const short kwxCursorMagnifier
= 3;
236 const short kwxCursorNoEntry
= 4;
237 const short kwxCursorPaintBrush
= 5;
238 const short kwxCursorPointRight
= 6;
239 const short kwxCursorPointLeft
= 7;
240 const short kwxCursorQuestionArrow
= 8;
241 const short kwxCursorRightArrow
= 9;
242 const short kwxCursorSizeNS
= 10;
243 const short kwxCursorSize
= 11;
244 const short kwxCursorSizeNESW
= 12;
245 const short kwxCursorSizeNWSE
= 13;
246 const short kwxCursorRoller
= 14;
247 const short kwxCursorLast
= kwxCursorRoller
;
249 // exposing our fallback cursor map
251 extern ClassicCursor gMacCursors
[];
256 // _WX_PRIVATE_COCOA_H_