]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/core/private.h
wxColour is implemented using CoreGraphics
[wxWidgets.git] / include / wx / osx / core / private.h
CommitLineData
5c6eb3a8 1/////////////////////////////////////////////////////////////////////////////
eefe52da 2// Name: wx/osx/core/private.h
5c6eb3a8
SC
3// Purpose: Private declarations: as this header is only included by
4// wxWidgets itself, it may contain identifiers which don't start
5// with "wx".
6// Author: Stefan Csomor
7// Modified by:
8// Created: 1998-01-01
9// RCS-ID: $Id: private.h 53819 2008-05-29 14:11:45Z SC $
10// Copyright: (c) Stefan Csomor
11// Licence: wxWindows licence
12/////////////////////////////////////////////////////////////////////////////
13
eefe52da
SC
14#ifndef _WX_PRIVATE_CORE_H_
15#define _WX_PRIVATE_CORE_H_
5c6eb3a8
SC
16
17#include "wx/defs.h"
18
19#include <CoreFoundation/CoreFoundation.h>
20
ef0e9220
SC
21#include "wx/osx/core/cfstring.h"
22#include "wx/osx/core/cfdataref.h"
5c6eb3a8
SC
23
24#if wxUSE_GUI
25
eefe52da 26#if wxOSX_USE_IPHONE
5c6eb3a8 27#include <CoreGraphics/CoreGraphics.h>
eefe52da 28#else
09f0f2cf 29#include <ApplicationServices/ApplicationServices.h>
eefe52da
SC
30#endif
31
32#include "wx/bitmap.h"
33#include "wx/window.h"
5c6eb3a8
SC
34
35class WXDLLIMPEXP_CORE wxMacCGContextStateSaver
36{
37 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver)
38
39public:
40 wxMacCGContextStateSaver( CGContextRef cg )
41 {
42 m_cg = cg;
43 CGContextSaveGState( cg );
44 }
45 ~wxMacCGContextStateSaver()
46 {
47 CGContextRestoreGState( m_cg );
48 }
49private:
50 CGContextRef m_cg;
51};
52
eefe52da
SC
53class WXDLLIMPEXP_CORE wxDeferredObjectDeleter : public wxObject
54{
55public :
56 wxDeferredObjectDeleter( wxObject* obj ) : m_obj(obj)
57 {
58 }
59 virtual ~wxDeferredObjectDeleter()
60 {
61 delete m_obj;
62 }
63protected :
64 wxObject* m_obj ;
65} ;
5c6eb3a8
SC
66
67// Quartz
68
69WXDLLIMPEXP_CORE CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap );
70
71WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithCFData( CFDataRef data );
72WXDLLIMPEXP_CORE CGDataConsumerRef wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data );
73WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf );
74
75CGColorSpaceRef WXDLLIMPEXP_CORE wxMacGetGenericRGBColorSpace(void);
76
eefe52da
SC
77class wxWindowMac;
78// to
79extern wxWindow* g_MacLastWindow;
80class wxNonOwnedWindow;
81
82class WXDLLIMPEXP_CORE wxWidgetImpl : public wxObject
83{
84public :
85 wxWidgetImpl( wxWindowMac* peer , bool isRootControl = false );
86 wxWidgetImpl();
87 virtual ~wxWidgetImpl();
88
89 void Init();
90
91 virtual void Destroy();
92
93 bool IsRootControl() const { return m_isRootControl; }
94
95 wxWindowMac* GetWXPeer() const { return m_wxPeer; }
96
97 bool IsOk() const { return GetWXWidget() != NULL; }
98
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;
104
105 virtual void Raise() = 0;
106
107 virtual void Lower() = 0;
108
109 virtual void ScrollRect( const wxRect *rect, int dx, int dy ) = 0;
110
111 virtual WXWidget GetWXWidget() const = 0;
112
113 virtual void SetBackgroundColour( const wxColour& col ) = 0;
114
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;
120
121 virtual void SetNeedsDisplay( const wxRect* where = NULL ) = 0;
122 virtual bool GetNeedsDisplay() const = 0;
123
124 virtual bool NeedsFocusRect() const;
125 virtual void SetNeedsFocusRect( bool needs );
126
127 virtual bool CanFocus() const = 0;
128 // return true if successful
129 virtual bool SetFocus() = 0;
130 virtual bool HasFocus() const = 0;
131
132 virtual void RemoveFromParent() = 0;
133 virtual void Embed( wxWidgetImpl *parent ) = 0;
134
135 // static creation methods, must be implemented by all toolkits
136
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 ) ;
140
141 // converts from Toplevel-Content relative to local
142 static void Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to );
143protected :
144 bool m_isRootControl;
145 wxWindowMac* m_wxPeer;
146 bool m_needsFocusRect;
147
148 DECLARE_ABSTRACT_CLASS(wxWidgetImpl)
149};
150
151class wxNonOwnedWindowImpl : public wxObject
152{
153public :
154 wxNonOwnedWindowImpl( wxNonOwnedWindow* nonownedwnd) : m_wxPeer(nonownedwnd)
155 {
156 }
157 wxNonOwnedWindowImpl()
158 {
159 }
160 virtual ~wxNonOwnedWindowImpl()
161 {
162 }
163
164 virtual void Destroy()
165 {
166 }
167
168 virtual void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
169 long style, long extraStyle, const wxString& name ) = 0;
170
171
172 virtual WXWindow GetWXWindow() const = 0;
173
174 virtual void Raise()
175 {
176 }
177
178 virtual void Lower()
179 {
180 }
181
1aec1f8b 182 virtual bool Show(bool WXUNUSED(show))
eefe52da
SC
183 {
184 return false;
185 }
186
1aec1f8b 187 virtual bool ShowWithEffect(bool show, wxShowEffect WXUNUSED(effect), unsigned WXUNUSED(timeout))
eefe52da
SC
188 {
189 return Show(show);
190 }
191
192 virtual void Update()
193 {
194 }
195
1aec1f8b 196 virtual bool SetTransparent(wxByte WXUNUSED(alpha))
eefe52da
SC
197 {
198 return false;
199 }
200
1aec1f8b 201 virtual bool SetBackgroundColour(const wxColour& WXUNUSED(col) )
eefe52da
SC
202 {
203 return false;
204 }
205
1aec1f8b 206 virtual void SetExtraStyle( long WXUNUSED(exStyle) )
eefe52da
SC
207 {
208 }
209
1aec1f8b 210 virtual bool SetBackgroundStyle(wxBackgroundStyle WXUNUSED(style))
eefe52da
SC
211 {
212 return false ;
213 }
214
215 bool CanSetTransparent()
216 {
217 return false;
218 }
219
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;
224
1aec1f8b 225 virtual bool SetShape(const wxRegion& WXUNUSED(region))
eefe52da
SC
226 {
227 return false;
228 }
229
230 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) = 0;
231
232 virtual bool IsMaximized() const = 0;
233
234 virtual bool IsIconized() const= 0;
235
236 virtual void Iconize( bool iconize )= 0;
237
238 virtual void Maximize(bool maximize) = 0;
239
240 virtual bool IsFullScreen() const= 0;
241
242 virtual bool ShowFullScreen(bool show, long style)= 0;
243
244 virtual void RequestUserAttention(int flags) = 0;
245
246 virtual void ScreenToWindow( int *x, int *y ) = 0;
247
248 virtual void WindowToScreen( int *x, int *y ) = 0;
249
250 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
251protected :
252 wxNonOwnedWindow* m_wxPeer;
253 DECLARE_ABSTRACT_CLASS(wxNonOwnedWindowImpl)
254};
255
5c6eb3a8
SC
256#endif // wxUSE_GUI
257
258//---------------------------------------------------------------------------
259// cocoa bridging utilities
260//---------------------------------------------------------------------------
261
262bool wxMacInitCocoa();
263
264class WXDLLIMPEXP_CORE wxMacAutoreleasePool
265{
266public :
267 wxMacAutoreleasePool();
268 ~wxMacAutoreleasePool();
269private :
270 void* m_pool;
271};
272
273// NSObject
274
275void wxMacCocoaRelease( void* obj );
276void wxMacCocoaAutorelease( void* obj );
277void wxMacCocoaRetain( void* obj );
278
279
280#endif
eefe52da 281 // _WX_PRIVATE_CORE_H_