]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/core/private.h
Minor corrections to make dist after reports
[wxWidgets.git] / include / wx / osx / core / private.h
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
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
14 #ifndef _WX_PRIVATE_CORE_H_
15 #define _WX_PRIVATE_CORE_H_
16
17 #include "wx/defs.h"
18
19 #include <CoreFoundation/CoreFoundation.h>
20
21 #include "wx/osx/core/cfstring.h"
22 #include "wx/osx/core/cfdataref.h"
23
24 #if wxUSE_GUI
25
26 #if wxOSX_USE_IPHONE
27 #include <CoreGraphics/CoreGraphics.h>
28 #else
29 #include <ApplicationServices/ApplicationServices.h>
30 #endif
31
32 #include "wx/bitmap.h"
33 #include "wx/window.h"
34
35 class WXDLLIMPEXP_CORE wxMacCGContextStateSaver
36 {
37 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver)
38
39 public:
40 wxMacCGContextStateSaver( CGContextRef cg )
41 {
42 m_cg = cg;
43 CGContextSaveGState( cg );
44 }
45 ~wxMacCGContextStateSaver()
46 {
47 CGContextRestoreGState( m_cg );
48 }
49 private:
50 CGContextRef m_cg;
51 };
52
53 class WXDLLIMPEXP_CORE wxDeferredObjectDeleter : public wxObject
54 {
55 public :
56 wxDeferredObjectDeleter( wxObject* obj ) : m_obj(obj)
57 {
58 }
59 virtual ~wxDeferredObjectDeleter()
60 {
61 delete m_obj;
62 }
63 protected :
64 wxObject* m_obj ;
65 } ;
66
67 // Quartz
68
69 WXDLLIMPEXP_CORE CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap );
70
71 WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithCFData( CFDataRef data );
72 WXDLLIMPEXP_CORE CGDataConsumerRef wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data );
73 WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf );
74
75 CGColorSpaceRef WXDLLIMPEXP_CORE wxMacGetGenericRGBColorSpace(void);
76
77 class wxWindowMac;
78 // to
79 extern wxWindow* g_MacLastWindow;
80 class wxNonOwnedWindow;
81
82 class WXDLLIMPEXP_CORE wxWidgetImpl : public wxObject
83 {
84 public :
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 );
143 protected :
144 bool m_isRootControl;
145 wxWindowMac* m_wxPeer;
146 bool m_needsFocusRect;
147
148 DECLARE_ABSTRACT_CLASS(wxWidgetImpl)
149 };
150
151 class wxNonOwnedWindowImpl : public wxObject
152 {
153 public :
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
182 virtual bool Show(bool WXUNUSED(show))
183 {
184 return false;
185 }
186
187 virtual bool ShowWithEffect(bool show, wxShowEffect WXUNUSED(effect), unsigned WXUNUSED(timeout))
188 {
189 return Show(show);
190 }
191
192 virtual void Update()
193 {
194 }
195
196 virtual bool SetTransparent(wxByte WXUNUSED(alpha))
197 {
198 return false;
199 }
200
201 virtual bool SetBackgroundColour(const wxColour& WXUNUSED(col) )
202 {
203 return false;
204 }
205
206 virtual void SetExtraStyle( long WXUNUSED(exStyle) )
207 {
208 }
209
210 virtual bool SetBackgroundStyle(wxBackgroundStyle WXUNUSED(style))
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
225 virtual bool SetShape(const wxRegion& WXUNUSED(region))
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; }
251 protected :
252 wxNonOwnedWindow* m_wxPeer;
253 DECLARE_ABSTRACT_CLASS(wxNonOwnedWindowImpl)
254 };
255
256 #endif // wxUSE_GUI
257
258 //---------------------------------------------------------------------------
259 // cocoa bridging utilities
260 //---------------------------------------------------------------------------
261
262 bool wxMacInitCocoa();
263
264 class WXDLLIMPEXP_CORE wxMacAutoreleasePool
265 {
266 public :
267 wxMacAutoreleasePool();
268 ~wxMacAutoreleasePool();
269 private :
270 void* m_pool;
271 };
272
273 // NSObject
274
275 void wxMacCocoaRelease( void* obj );
276 void wxMacCocoaAutorelease( void* obj );
277 void wxMacCocoaRetain( void* obj );
278
279
280 #endif
281 // _WX_PRIVATE_CORE_H_