1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/core/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_CORE_H_
15 #define _WX_PRIVATE_CORE_H_
19 #include <CoreFoundation/CoreFoundation.h>
21 #include "wx/osx/core/cfstring.h"
22 #include "wx/osx/core/cfdataref.h"
27 #include <CoreGraphics/CoreGraphics.h>
29 #include <ApplicationServices/ApplicationServices.h>
32 #include "wx/bitmap.h"
33 #include "wx/window.h"
35 class WXDLLIMPEXP_CORE wxMacCGContextStateSaver
37 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
40 wxMacCGContextStateSaver( CGContextRef cg
)
43 CGContextSaveGState( cg
);
45 ~wxMacCGContextStateSaver()
47 CGContextRestoreGState( m_cg
);
53 class WXDLLIMPEXP_CORE wxDeferredObjectDeleter
: public wxObject
56 wxDeferredObjectDeleter( wxObject
* obj
) : m_obj(obj
)
59 virtual ~wxDeferredObjectDeleter()
69 WXDLLIMPEXP_CORE CGImageRef
wxMacCreateCGImageFromBitmap( const wxBitmap
& bitmap
);
71 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithCFData( CFDataRef data
);
72 WXDLLIMPEXP_CORE CGDataConsumerRef
wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data
);
73 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer
& buf
);
75 CGColorSpaceRef WXDLLIMPEXP_CORE
wxMacGetGenericRGBColorSpace(void);
79 extern wxWindow
* g_MacLastWindow
;
80 class wxNonOwnedWindow
;
82 class WXDLLIMPEXP_CORE wxWidgetImpl
: public wxObject
85 wxWidgetImpl( wxWindowMac
* peer
, bool isRootControl
= false );
87 virtual ~wxWidgetImpl();
91 virtual void Destroy();
93 bool IsRootControl() const { return m_isRootControl
; }
95 wxWindowMac
* GetWXPeer() const { return m_wxPeer
; }
97 bool IsOk() const { return GetWXWidget() != NULL
; }
99 // not only the control itself, but also all its parents must be visible
100 // in order for this function to return true
101 virtual bool IsVisible() const = 0;
102 // set the visibility of this widget (maybe latent)
103 virtual void SetVisibility( bool visible
) = 0;
105 virtual void Raise() = 0;
107 virtual void Lower() = 0;
109 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
) = 0;
111 virtual WXWidget
GetWXWidget() const = 0;
113 virtual void SetBackgroundColour( const wxColour
& col
) = 0;
115 // all coordinates in native parent widget relative coordinates
116 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const = 0;
117 virtual void Move(int x
, int y
, int width
, int height
) = 0;
118 virtual void GetPosition( int &x
, int &y
) const = 0;
119 virtual void GetSize( int &width
, int &height
) const = 0;
121 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
) = 0;
122 virtual bool GetNeedsDisplay() const = 0;
124 virtual bool NeedsFocusRect() const;
125 virtual void SetNeedsFocusRect( bool needs
);
127 virtual bool CanFocus() const = 0;
128 // return true if successful
129 virtual bool SetFocus() = 0;
130 virtual bool HasFocus() const = 0;
132 virtual void RemoveFromParent() = 0;
133 virtual void Embed( wxWidgetImpl
*parent
) = 0;
135 // static creation methods, must be implemented by all toolkits
137 static wxWidgetImpl
* CreateUserPane( wxWindowMac
* wxpeer
, const wxPoint
& pos
, const wxSize
& size
,
138 long style
, long extraStyle
, const wxString
& name
) ;
139 static wxWidgetImpl
* CreateContentView( wxNonOwnedWindow
* now
) ;
141 // converts from Toplevel-Content relative to local
142 static void Convert( wxPoint
*pt
, wxWidgetImpl
*from
, wxWidgetImpl
*to
);
144 bool m_isRootControl
;
145 wxWindowMac
* m_wxPeer
;
146 bool m_needsFocusRect
;
148 DECLARE_ABSTRACT_CLASS(wxWidgetImpl
)
151 class wxNonOwnedWindowImpl
: public wxObject
154 wxNonOwnedWindowImpl( wxNonOwnedWindow
* nonownedwnd
) : m_wxPeer(nonownedwnd
)
157 wxNonOwnedWindowImpl()
160 virtual ~wxNonOwnedWindowImpl()
164 virtual void Destroy()
168 virtual void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
169 long style
, long extraStyle
, const wxString
& name
) = 0;
172 virtual WXWindow
GetWXWindow() const = 0;
182 virtual bool Show(bool WXUNUSED(show
))
187 virtual bool ShowWithEffect(bool show
, wxShowEffect
WXUNUSED(effect
), unsigned WXUNUSED(timeout
))
192 virtual void Update()
196 virtual bool SetTransparent(wxByte
WXUNUSED(alpha
))
201 virtual bool SetBackgroundColour(const wxColour
& WXUNUSED(col
) )
206 virtual void SetExtraStyle( long WXUNUSED(exStyle
) )
210 virtual bool SetBackgroundStyle(wxBackgroundStyle
WXUNUSED(style
))
215 bool CanSetTransparent()
220 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const = 0;
221 virtual void MoveWindow(int x
, int y
, int width
, int height
) = 0;
222 virtual void GetPosition( int &x
, int &y
) const = 0;
223 virtual void GetSize( int &width
, int &height
) const = 0;
225 virtual bool SetShape(const wxRegion
& WXUNUSED(region
))
230 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) = 0;
232 virtual bool IsMaximized() const = 0;
234 virtual bool IsIconized() const= 0;
236 virtual void Iconize( bool iconize
)= 0;
238 virtual void Maximize(bool maximize
) = 0;
240 virtual bool IsFullScreen() const= 0;
242 virtual bool ShowFullScreen(bool show
, long style
)= 0;
244 virtual void RequestUserAttention(int flags
) = 0;
246 virtual void ScreenToWindow( int *x
, int *y
) = 0;
248 virtual void WindowToScreen( int *x
, int *y
) = 0;
250 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
252 wxNonOwnedWindow
* m_wxPeer
;
253 DECLARE_ABSTRACT_CLASS(wxNonOwnedWindowImpl
)
258 //---------------------------------------------------------------------------
259 // cocoa bridging utilities
260 //---------------------------------------------------------------------------
262 bool wxMacInitCocoa();
264 class WXDLLIMPEXP_CORE wxMacAutoreleasePool
267 wxMacAutoreleasePool();
268 ~wxMacAutoreleasePool();
275 void wxMacCocoaRelease( void* obj
);
276 void wxMacCocoaAutorelease( void* obj
);
277 void wxMacCocoaRetain( void* obj
);
281 // _WX_PRIVATE_CORE_H_