]>
Commit | Line | Data |
---|---|---|
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 | 23 | |
030495ec VZ |
24 | // Define helper macros allowing to insert small snippets of code to be |
25 | // compiled for high enough OS X version only: this shouldn't be abused for | |
26 | // anything big but it's handy for e.g. specifying OS X 10.6-only protocols in | |
27 | // the Objective C classes declarations when they're not supported under the | |
28 | // previous versions | |
29 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 | |
30 | #define wxOSX_10_6_AND_LATER(x) x | |
31 | #else | |
32 | #define wxOSX_10_6_AND_LATER(x) | |
33 | #endif | |
34 | ||
524c47aa | 35 | #if wxOSX_USE_COCOA_OR_CARBON |
1e181c7a | 36 | |
524c47aa | 37 | WXDLLIMPEXP_BASE long UMAGetSystemVersion() ; |
1e181c7a SC |
38 | |
39 | void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , unsigned char * to ); | |
40 | wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( const unsigned char * from ); | |
41 | ||
524c47aa SC |
42 | #endif |
43 | ||
5c6eb3a8 SC |
44 | #if wxUSE_GUI |
45 | ||
eefe52da | 46 | #if wxOSX_USE_IPHONE |
5c6eb3a8 | 47 | #include <CoreGraphics/CoreGraphics.h> |
eefe52da | 48 | #else |
09f0f2cf | 49 | #include <ApplicationServices/ApplicationServices.h> |
eefe52da SC |
50 | #endif |
51 | ||
52 | #include "wx/bitmap.h" | |
53 | #include "wx/window.h" | |
5c6eb3a8 SC |
54 | |
55 | class WXDLLIMPEXP_CORE wxMacCGContextStateSaver | |
56 | { | |
c0c133e1 | 57 | wxDECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver); |
5c6eb3a8 SC |
58 | |
59 | public: | |
60 | wxMacCGContextStateSaver( CGContextRef cg ) | |
61 | { | |
62 | m_cg = cg; | |
63 | CGContextSaveGState( cg ); | |
64 | } | |
65 | ~wxMacCGContextStateSaver() | |
66 | { | |
67 | CGContextRestoreGState( m_cg ); | |
68 | } | |
69 | private: | |
70 | CGContextRef m_cg; | |
71 | }; | |
72 | ||
eefe52da SC |
73 | class WXDLLIMPEXP_CORE wxDeferredObjectDeleter : public wxObject |
74 | { | |
75 | public : | |
03647350 | 76 | wxDeferredObjectDeleter( wxObject* obj ) : m_obj(obj) |
eefe52da SC |
77 | { |
78 | } | |
79 | virtual ~wxDeferredObjectDeleter() | |
80 | { | |
81 | delete m_obj; | |
82 | } | |
83 | protected : | |
84 | wxObject* m_obj ; | |
85 | } ; | |
5c6eb3a8 SC |
86 | |
87 | // Quartz | |
88 | ||
89 | WXDLLIMPEXP_CORE CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap ); | |
90 | ||
91 | WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithCFData( CFDataRef data ); | |
92 | WXDLLIMPEXP_CORE CGDataConsumerRef wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data ); | |
93 | WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf ); | |
94 | ||
95 | CGColorSpaceRef WXDLLIMPEXP_CORE wxMacGetGenericRGBColorSpace(void); | |
96 | ||
eefe52da SC |
97 | class wxWindowMac; |
98 | // to | |
99 | extern wxWindow* g_MacLastWindow; | |
100 | class wxNonOwnedWindow; | |
101 | ||
524c47aa SC |
102 | // temporary typedef so that no additional casts are necessary within carbon code at the moment |
103 | ||
104 | class wxMacControl; | |
105 | class wxWidgetImpl; | |
106 | class wxNotebook; | |
de24bdf2 | 107 | class wxTextCtrl; |
524c47aa | 108 | |
8fa9ac5e SC |
109 | WXDLLIMPEXP_CORE wxWindowMac * wxFindWindowFromWXWidget(WXWidget inControl ); |
110 | ||
524c47aa SC |
111 | #if wxOSX_USE_CARBON |
112 | typedef wxMacControl wxWidgetImplType; | |
113 | #else | |
114 | typedef wxWidgetImpl wxWidgetImplType; | |
115 | #endif | |
116 | ||
6c1f25cc | 117 | #if wxUSE_MENUS |
03647350 | 118 | class wxMenuItemImpl : public wxObject |
524c47aa SC |
119 | { |
120 | public : | |
121 | wxMenuItemImpl( wxMenuItem* peer ) : m_peer(peer) | |
122 | { | |
123 | } | |
03647350 | 124 | |
524c47aa SC |
125 | virtual ~wxMenuItemImpl() ; |
126 | virtual void SetBitmap( const wxBitmap& bitmap ) = 0; | |
127 | virtual void Enable( bool enable ) = 0; | |
128 | virtual void Check( bool check ) = 0; | |
129 | virtual void SetLabel( const wxString& text, wxAcceleratorEntry *entry ) = 0; | |
130 | virtual void Hide( bool hide = true ) = 0; | |
03647350 | 131 | |
524c47aa SC |
132 | virtual void * GetHMenuItem() = 0; |
133 | ||
134 | wxMenuItem* GetWXPeer() { return m_peer ; } | |
135 | ||
136 | static wxMenuItemImpl* Create( wxMenuItem* peer, wxMenu *pParentMenu, | |
137 | int id, | |
138 | const wxString& text, | |
139 | wxAcceleratorEntry *entry, | |
140 | const wxString& strHelp, | |
141 | wxItemKind kind, | |
142 | wxMenu *pSubMenu ); | |
143 | ||
144 | protected : | |
145 | wxMenuItem* m_peer; | |
03647350 | 146 | |
69cc4323 | 147 | DECLARE_ABSTRACT_CLASS(wxMenuItemImpl) |
524c47aa SC |
148 | } ; |
149 | ||
03647350 | 150 | class wxMenuImpl : public wxObject |
524c47aa SC |
151 | { |
152 | public : | |
153 | wxMenuImpl( wxMenu* peer ) : m_peer(peer) | |
154 | { | |
155 | } | |
03647350 VZ |
156 | |
157 | virtual ~wxMenuImpl() ; | |
158 | virtual void InsertOrAppend(wxMenuItem *pItem, size_t pos) = 0; | |
524c47aa | 159 | virtual void Remove( wxMenuItem *pItem ) = 0; |
03647350 | 160 | |
524c47aa SC |
161 | virtual void MakeRoot() = 0; |
162 | ||
163 | virtual void SetTitle( const wxString& text ) = 0; | |
164 | ||
165 | virtual WXHMENU GetHMenu() = 0; | |
03647350 | 166 | |
524c47aa SC |
167 | wxMenu* GetWXPeer() { return m_peer ; } |
168 | ||
2cb5d2d2 SC |
169 | virtual void PopUp( wxWindow *win, int x, int y ) = 0; |
170 | ||
524c47aa SC |
171 | static wxMenuImpl* Create( wxMenu* peer, const wxString& title ); |
172 | static wxMenuImpl* CreateRootMenu( wxMenu* peer ); | |
173 | protected : | |
174 | wxMenu* m_peer; | |
03647350 | 175 | |
69cc4323 | 176 | DECLARE_ABSTRACT_CLASS(wxMenuItemImpl) |
524c47aa | 177 | } ; |
6c1f25cc | 178 | #endif |
524c47aa SC |
179 | |
180 | ||
eefe52da SC |
181 | class WXDLLIMPEXP_CORE wxWidgetImpl : public wxObject |
182 | { | |
183 | public : | |
184 | wxWidgetImpl( wxWindowMac* peer , bool isRootControl = false ); | |
185 | wxWidgetImpl(); | |
186 | virtual ~wxWidgetImpl(); | |
187 | ||
188 | void Init(); | |
189 | ||
eefe52da SC |
190 | bool IsRootControl() const { return m_isRootControl; } |
191 | ||
192 | wxWindowMac* GetWXPeer() const { return m_wxPeer; } | |
03647350 | 193 | |
eefe52da SC |
194 | bool IsOk() const { return GetWXWidget() != NULL; } |
195 | ||
196 | // not only the control itself, but also all its parents must be visible | |
197 | // in order for this function to return true | |
198 | virtual bool IsVisible() const = 0; | |
199 | // set the visibility of this widget (maybe latent) | |
200 | virtual void SetVisibility( bool visible ) = 0; | |
201 | ||
ab9a0b84 VZ |
202 | virtual bool ShowWithEffect(bool WXUNUSED(show), |
203 | wxShowEffect WXUNUSED(effect), | |
204 | unsigned WXUNUSED(timeout)) | |
205 | { | |
206 | return false; | |
207 | } | |
208 | ||
eefe52da | 209 | virtual void Raise() = 0; |
03647350 | 210 | |
eefe52da SC |
211 | virtual void Lower() = 0; |
212 | ||
213 | virtual void ScrollRect( const wxRect *rect, int dx, int dy ) = 0; | |
214 | ||
215 | virtual WXWidget GetWXWidget() const = 0; | |
03647350 | 216 | |
eefe52da | 217 | virtual void SetBackgroundColour( const wxColour& col ) = 0; |
bc5c09a3 | 218 | virtual bool SetBackgroundStyle(wxBackgroundStyle style) = 0; |
eefe52da SC |
219 | |
220 | // all coordinates in native parent widget relative coordinates | |
221 | virtual void GetContentArea( int &left , int &top , int &width , int &height ) const = 0; | |
222 | virtual void Move(int x, int y, int width, int height) = 0; | |
223 | virtual void GetPosition( int &x, int &y ) const = 0; | |
224 | virtual void GetSize( int &width, int &height ) const = 0; | |
524c47aa | 225 | virtual void SetControlSize( wxWindowVariant variant ) = 0; |
eefe52da | 226 | |
ee032c59 SC |
227 | // native view coordinates are topleft to bottom right (flipped regarding CoreGraphics origin) |
228 | virtual bool IsFlipped() const { return true; } | |
229 | ||
eefe52da SC |
230 | virtual void SetNeedsDisplay( const wxRect* where = NULL ) = 0; |
231 | virtual bool GetNeedsDisplay() const = 0; | |
232 | ||
233 | virtual bool NeedsFocusRect() const; | |
234 | virtual void SetNeedsFocusRect( bool needs ); | |
235 | ||
f2f6030e SC |
236 | virtual bool NeedsFrame() const; |
237 | virtual void SetNeedsFrame( bool needs ); | |
238 | ||
eefe52da SC |
239 | virtual bool CanFocus() const = 0; |
240 | // return true if successful | |
241 | virtual bool SetFocus() = 0; | |
242 | virtual bool HasFocus() const = 0; | |
03647350 | 243 | |
eefe52da SC |
244 | virtual void RemoveFromParent() = 0; |
245 | virtual void Embed( wxWidgetImpl *parent ) = 0; | |
03647350 | 246 | |
524c47aa SC |
247 | virtual void SetDefaultButton( bool isDefault ) = 0; |
248 | virtual void PerformClick() = 0; | |
249 | virtual void SetLabel( const wxString& title, wxFontEncoding encoding ) = 0; | |
250 | ||
54f11060 SC |
251 | virtual void SetCursor( const wxCursor & cursor ) = 0; |
252 | virtual void CaptureMouse() = 0; | |
253 | virtual void ReleaseMouse() = 0; | |
254 | ||
524c47aa SC |
255 | virtual wxInt32 GetValue() const = 0; |
256 | virtual void SetValue( wxInt32 v ) = 0; | |
e5d05b90 | 257 | virtual wxBitmap GetBitmap() const = 0; |
524c47aa | 258 | virtual void SetBitmap( const wxBitmap& bitmap ) = 0; |
e5d05b90 | 259 | virtual void SetBitmapPosition( wxDirection dir ) = 0; |
524c47aa SC |
260 | virtual void SetupTabs( const wxNotebook ¬ebook ) =0; |
261 | virtual void GetBestRect( wxRect *r ) const = 0; | |
262 | virtual bool IsEnabled() const = 0; | |
263 | virtual void Enable( bool enable ) = 0; | |
264 | virtual void SetMinimum( wxInt32 v ) = 0; | |
265 | virtual void SetMaximum( wxInt32 v ) = 0; | |
19c7ac3d SC |
266 | virtual wxInt32 GetMinimum() const = 0; |
267 | virtual wxInt32 GetMaximum() const = 0; | |
524c47aa SC |
268 | virtual void PulseGauge() = 0; |
269 | virtual void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ) = 0; | |
270 | ||
1e181c7a | 271 | virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ) = 0; |
a7b9865d KO |
272 | |
273 | virtual void SetToolTip(wxToolTip* WXUNUSED(tooltip)) { } | |
1e181c7a | 274 | |
524c47aa SC |
275 | // is the clicked event sent AFTER the state already changed, so no additional |
276 | // state changing logic is required from the outside | |
277 | virtual bool ButtonClickDidStateChange() = 0; | |
03647350 | 278 | |
c4825ef7 | 279 | virtual void InstallEventHandler( WXWidget control = NULL ) = 0; |
809020fc KO |
280 | |
281 | // Mechanism used to keep track of whether a change should send an event | |
282 | // Do SendEvents(false) when starting actions that would trigger programmatic events | |
283 | // and SendEvents(true) at the end of the block. | |
284 | virtual void SendEvents(bool shouldSendEvents) { m_shouldSendEvents = shouldSendEvents; } | |
285 | virtual bool ShouldSendEvents() { return m_shouldSendEvents; } | |
eefe52da | 286 | |
f55d9f74 SC |
287 | // static methods for associating native controls and their implementations |
288 | ||
03647350 | 289 | static wxWidgetImpl* |
f55d9f74 | 290 | FindFromWXWidget(WXWidget control); |
03647350 | 291 | |
f55d9f74 | 292 | static void RemoveAssociations( wxWidgetImpl* impl); |
03647350 | 293 | |
f55d9f74 | 294 | static void Associate( WXWidget control, wxWidgetImpl *impl ); |
03647350 | 295 | |
f06e0fea | 296 | static WXWidget FindFocus(); |
03647350 | 297 | |
eefe52da | 298 | // static creation methods, must be implemented by all toolkits |
03647350 VZ |
299 | |
300 | static wxWidgetImplType* CreateUserPane( wxWindowMac* wxpeer, | |
301 | wxWindowMac* parent, | |
302 | wxWindowID id, | |
303 | const wxPoint& pos, | |
524c47aa | 304 | const wxSize& size, |
03647350 | 305 | long style, |
524c47aa SC |
306 | long extraStyle) ; |
307 | static wxWidgetImplType* CreateContentView( wxNonOwnedWindow* now ) ; | |
308 | ||
03647350 VZ |
309 | static wxWidgetImplType* CreateButton( wxWindowMac* wxpeer, |
310 | wxWindowMac* parent, | |
311 | wxWindowID id, | |
524c47aa | 312 | const wxString& label, |
03647350 | 313 | const wxPoint& pos, |
524c47aa | 314 | const wxSize& size, |
03647350 | 315 | long style, |
524c47aa SC |
316 | long extraStyle) ; |
317 | ||
03647350 VZ |
318 | static wxWidgetImplType* CreateDisclosureTriangle( wxWindowMac* wxpeer, |
319 | wxWindowMac* parent, | |
320 | wxWindowID id, | |
524c47aa | 321 | const wxString& label, |
03647350 | 322 | const wxPoint& pos, |
524c47aa | 323 | const wxSize& size, |
03647350 | 324 | long style, |
524c47aa | 325 | long extraStyle) ; |
03647350 VZ |
326 | |
327 | static wxWidgetImplType* CreateStaticLine( wxWindowMac* wxpeer, | |
328 | wxWindowMac* parent, | |
329 | wxWindowID id, | |
330 | const wxPoint& pos, | |
524c47aa | 331 | const wxSize& size, |
03647350 | 332 | long style, |
524c47aa SC |
333 | long extraStyle) ; |
334 | ||
03647350 VZ |
335 | static wxWidgetImplType* CreateGroupBox( wxWindowMac* wxpeer, |
336 | wxWindowMac* parent, | |
337 | wxWindowID id, | |
524c47aa | 338 | const wxString& label, |
03647350 | 339 | const wxPoint& pos, |
524c47aa | 340 | const wxSize& size, |
03647350 | 341 | long style, |
524c47aa SC |
342 | long extraStyle) ; |
343 | ||
03647350 VZ |
344 | static wxWidgetImplType* CreateStaticText( wxWindowMac* wxpeer, |
345 | wxWindowMac* parent, | |
346 | wxWindowID id, | |
524c47aa | 347 | const wxString& label, |
03647350 | 348 | const wxPoint& pos, |
524c47aa | 349 | const wxSize& size, |
03647350 | 350 | long style, |
524c47aa SC |
351 | long extraStyle) ; |
352 | ||
03647350 VZ |
353 | static wxWidgetImplType* CreateTextControl( wxTextCtrl* wxpeer, |
354 | wxWindowMac* parent, | |
355 | wxWindowID id, | |
524c47aa | 356 | const wxString& content, |
03647350 | 357 | const wxPoint& pos, |
524c47aa | 358 | const wxSize& size, |
03647350 | 359 | long style, |
524c47aa SC |
360 | long extraStyle) ; |
361 | ||
03647350 VZ |
362 | static wxWidgetImplType* CreateSearchControl( wxTextCtrl* wxpeer, |
363 | wxWindowMac* parent, | |
364 | wxWindowID id, | |
1e181c7a | 365 | const wxString& content, |
03647350 | 366 | const wxPoint& pos, |
1e181c7a | 367 | const wxSize& size, |
03647350 | 368 | long style, |
1e181c7a SC |
369 | long extraStyle) ; |
370 | ||
03647350 VZ |
371 | static wxWidgetImplType* CreateCheckBox( wxWindowMac* wxpeer, |
372 | wxWindowMac* parent, | |
373 | wxWindowID id, | |
524c47aa | 374 | const wxString& label, |
03647350 | 375 | const wxPoint& pos, |
524c47aa | 376 | const wxSize& size, |
03647350 | 377 | long style, |
524c47aa | 378 | long extraStyle); |
03647350 VZ |
379 | |
380 | static wxWidgetImplType* CreateRadioButton( wxWindowMac* wxpeer, | |
381 | wxWindowMac* parent, | |
382 | wxWindowID id, | |
524c47aa | 383 | const wxString& label, |
03647350 | 384 | const wxPoint& pos, |
524c47aa | 385 | const wxSize& size, |
03647350 | 386 | long style, |
524c47aa SC |
387 | long extraStyle); |
388 | ||
03647350 VZ |
389 | static wxWidgetImplType* CreateToggleButton( wxWindowMac* wxpeer, |
390 | wxWindowMac* parent, | |
391 | wxWindowID id, | |
524c47aa | 392 | const wxString& label, |
03647350 | 393 | const wxPoint& pos, |
524c47aa | 394 | const wxSize& size, |
03647350 | 395 | long style, |
524c47aa SC |
396 | long extraStyle); |
397 | ||
03647350 VZ |
398 | static wxWidgetImplType* CreateBitmapToggleButton( wxWindowMac* wxpeer, |
399 | wxWindowMac* parent, | |
400 | wxWindowID id, | |
524c47aa | 401 | const wxBitmap& bitmap, |
03647350 | 402 | const wxPoint& pos, |
524c47aa | 403 | const wxSize& size, |
03647350 | 404 | long style, |
524c47aa SC |
405 | long extraStyle); |
406 | ||
03647350 VZ |
407 | static wxWidgetImplType* CreateBitmapButton( wxWindowMac* wxpeer, |
408 | wxWindowMac* parent, | |
409 | wxWindowID id, | |
524c47aa | 410 | const wxBitmap& bitmap, |
03647350 | 411 | const wxPoint& pos, |
524c47aa | 412 | const wxSize& size, |
03647350 | 413 | long style, |
524c47aa SC |
414 | long extraStyle); |
415 | ||
03647350 VZ |
416 | static wxWidgetImplType* CreateTabView( wxWindowMac* wxpeer, |
417 | wxWindowMac* parent, | |
418 | wxWindowID id, | |
419 | const wxPoint& pos, | |
524c47aa | 420 | const wxSize& size, |
03647350 | 421 | long style, |
524c47aa SC |
422 | long extraStyle); |
423 | ||
03647350 VZ |
424 | static wxWidgetImplType* CreateGauge( wxWindowMac* wxpeer, |
425 | wxWindowMac* parent, | |
426 | wxWindowID id, | |
524c47aa SC |
427 | wxInt32 value, |
428 | wxInt32 minimum, | |
429 | wxInt32 maximum, | |
03647350 | 430 | const wxPoint& pos, |
524c47aa | 431 | const wxSize& size, |
03647350 | 432 | long style, |
524c47aa SC |
433 | long extraStyle); |
434 | ||
03647350 VZ |
435 | static wxWidgetImplType* CreateSlider( wxWindowMac* wxpeer, |
436 | wxWindowMac* parent, | |
437 | wxWindowID id, | |
524c47aa SC |
438 | wxInt32 value, |
439 | wxInt32 minimum, | |
440 | wxInt32 maximum, | |
03647350 | 441 | const wxPoint& pos, |
524c47aa | 442 | const wxSize& size, |
03647350 | 443 | long style, |
524c47aa SC |
444 | long extraStyle); |
445 | ||
03647350 VZ |
446 | static wxWidgetImplType* CreateSpinButton( wxWindowMac* wxpeer, |
447 | wxWindowMac* parent, | |
448 | wxWindowID id, | |
524c47aa SC |
449 | wxInt32 value, |
450 | wxInt32 minimum, | |
451 | wxInt32 maximum, | |
03647350 | 452 | const wxPoint& pos, |
524c47aa | 453 | const wxSize& size, |
03647350 | 454 | long style, |
524c47aa SC |
455 | long extraStyle); |
456 | ||
03647350 VZ |
457 | static wxWidgetImplType* CreateScrollBar( wxWindowMac* wxpeer, |
458 | wxWindowMac* parent, | |
459 | wxWindowID id, | |
460 | const wxPoint& pos, | |
524c47aa | 461 | const wxSize& size, |
03647350 | 462 | long style, |
524c47aa SC |
463 | long extraStyle); |
464 | ||
03647350 VZ |
465 | static wxWidgetImplType* CreateChoice( wxWindowMac* wxpeer, |
466 | wxWindowMac* parent, | |
467 | wxWindowID id, | |
524c47aa | 468 | wxMenu* menu, |
03647350 | 469 | const wxPoint& pos, |
524c47aa | 470 | const wxSize& size, |
03647350 | 471 | long style, |
524c47aa SC |
472 | long extraStyle); |
473 | ||
03647350 VZ |
474 | static wxWidgetImplType* CreateListBox( wxWindowMac* wxpeer, |
475 | wxWindowMac* parent, | |
476 | wxWindowID id, | |
477 | const wxPoint& pos, | |
524c47aa | 478 | const wxSize& size, |
03647350 | 479 | long style, |
524c47aa | 480 | long extraStyle); |
eefe52da | 481 | |
c84030e0 | 482 | #if wxOSX_USE_COCOA |
f941a30b KO |
483 | static wxWidgetImplType* CreateComboBox( wxWindowMac* wxpeer, |
484 | wxWindowMac* parent, | |
485 | wxWindowID id, | |
486 | wxMenu* menu, | |
487 | const wxPoint& pos, | |
488 | const wxSize& size, | |
489 | long style, | |
490 | long extraStyle); | |
491 | #endif | |
492 | ||
eefe52da SC |
493 | // converts from Toplevel-Content relative to local |
494 | static void Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to ); | |
495 | protected : | |
496 | bool m_isRootControl; | |
497 | wxWindowMac* m_wxPeer; | |
498 | bool m_needsFocusRect; | |
f2f6030e | 499 | bool m_needsFrame; |
809020fc | 500 | bool m_shouldSendEvents; |
eefe52da SC |
501 | |
502 | DECLARE_ABSTRACT_CLASS(wxWidgetImpl) | |
503 | }; | |
504 | ||
524c47aa SC |
505 | // |
506 | // the interface to be implemented eg by a listbox | |
507 | // | |
508 | ||
03647350 | 509 | class WXDLLIMPEXP_CORE wxListWidgetColumn |
524c47aa SC |
510 | { |
511 | public : | |
512 | virtual ~wxListWidgetColumn() {} | |
513 | } ; | |
514 | ||
515 | class WXDLLIMPEXP_CORE wxListWidgetCellValue | |
516 | { | |
517 | public : | |
518 | wxListWidgetCellValue() {} | |
519 | virtual ~wxListWidgetCellValue() {} | |
03647350 | 520 | |
524c47aa SC |
521 | virtual void Set( CFStringRef value ) = 0; |
522 | virtual void Set( const wxString& value ) = 0; | |
523 | virtual void Set( int value ) = 0; | |
60ebcb8a | 524 | virtual void Check( bool check ); |
03647350 | 525 | |
60ebcb8a | 526 | virtual bool IsChecked() const; |
524c47aa SC |
527 | virtual int GetIntValue() const = 0; |
528 | virtual wxString GetStringValue() const = 0; | |
529 | } ; | |
530 | ||
531 | class WXDLLIMPEXP_CORE wxListWidgetImpl | |
532 | { | |
533 | public: | |
534 | wxListWidgetImpl() {} | |
535 | virtual ~wxListWidgetImpl() { } | |
03647350 VZ |
536 | |
537 | virtual wxListWidgetColumn* InsertTextColumn( unsigned pos, const wxString& title, bool editable = false, | |
524c47aa | 538 | wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) = 0 ; |
03647350 | 539 | virtual wxListWidgetColumn* InsertCheckColumn( unsigned pos , const wxString& title, bool editable = false, |
524c47aa | 540 | wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) = 0 ; |
03647350 | 541 | |
524c47aa SC |
542 | // add and remove |
543 | ||
544 | // TODO will be replaced | |
545 | virtual void ListDelete( unsigned int n ) = 0; | |
546 | virtual void ListInsert( unsigned int n ) = 0; | |
547 | virtual void ListClear() = 0; | |
548 | ||
549 | // selecting | |
550 | ||
551 | virtual void ListDeselectAll() = 0; | |
552 | virtual void ListSetSelection( unsigned int n, bool select, bool multi ) = 0; | |
553 | virtual int ListGetSelection() const = 0; | |
554 | virtual int ListGetSelections( wxArrayInt& aSelections ) const = 0; | |
555 | virtual bool ListIsSelected( unsigned int n ) const = 0; | |
03647350 | 556 | |
524c47aa SC |
557 | // display |
558 | ||
559 | virtual void ListScrollTo( unsigned int n ) = 0; | |
560 | virtual void UpdateLine( unsigned int n, wxListWidgetColumn* col = NULL ) = 0; | |
561 | virtual void UpdateLineToEnd( unsigned int n) = 0; | |
562 | ||
563 | // accessing content | |
564 | ||
565 | virtual unsigned int ListGetCount() const = 0; | |
566 | }; | |
567 | ||
1e181c7a SC |
568 | // |
569 | // interface to be implemented by a textcontrol | |
570 | // | |
571 | ||
21a9d326 SC |
572 | class WXDLLIMPEXP_FWD_CORE wxTextAttr; |
573 | ||
1e181c7a SC |
574 | // common interface for all implementations |
575 | class WXDLLIMPEXP_CORE wxTextWidgetImpl | |
576 | ||
577 | { | |
578 | public : | |
579 | wxTextWidgetImpl() {} | |
580 | ||
581 | virtual ~wxTextWidgetImpl() {} | |
582 | ||
583 | virtual bool CanFocus() const { return true; } | |
584 | ||
585 | virtual wxString GetStringValue() const = 0 ; | |
586 | virtual void SetStringValue( const wxString &val ) = 0 ; | |
587 | virtual void SetSelection( long from, long to ) = 0 ; | |
588 | virtual void GetSelection( long* from, long* to ) const = 0 ; | |
589 | virtual void WriteText( const wxString& str ) = 0 ; | |
590 | ||
16671f22 | 591 | virtual bool GetStyle( long position, wxTextAttr& style); |
1e181c7a SC |
592 | virtual void SetStyle( long start, long end, const wxTextAttr& style ) ; |
593 | virtual void Copy() ; | |
594 | virtual void Cut() ; | |
595 | virtual void Paste() ; | |
596 | virtual bool CanPaste() const ; | |
597 | virtual void SetEditable( bool editable ) ; | |
0b6a49c2 | 598 | virtual long GetLastPosition() const ; |
1e181c7a SC |
599 | virtual void Replace( long from, long to, const wxString &str ) ; |
600 | virtual void Remove( long from, long to ) ; | |
601 | ||
602 | ||
603 | virtual bool HasOwnContextMenu() const | |
604 | { return false ; } | |
605 | ||
606 | virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) ) | |
607 | { return false ; } | |
608 | ||
609 | virtual void Clear() ; | |
610 | virtual bool CanUndo() const; | |
611 | virtual void Undo() ; | |
612 | virtual bool CanRedo() const; | |
613 | virtual void Redo() ; | |
614 | virtual int GetNumberOfLines() const ; | |
615 | virtual long XYToPosition(long x, long y) const; | |
616 | virtual bool PositionToXY(long pos, long *x, long *y) const ; | |
617 | virtual void ShowPosition(long WXUNUSED(pos)) ; | |
618 | virtual int GetLineLength(long lineNo) const ; | |
619 | virtual wxString GetLineText(long lineNo) const ; | |
620 | virtual void CheckSpelling(bool WXUNUSED(check)) { } | |
9ab7ff53 KO |
621 | |
622 | virtual wxSize GetBestSize() const { return wxDefaultSize; } | |
1e181c7a SC |
623 | }; |
624 | ||
c84030e0 KO |
625 | // common interface for all implementations |
626 | class WXDLLIMPEXP_CORE wxComboWidgetImpl | |
627 | ||
628 | { | |
629 | public : | |
630 | wxComboWidgetImpl() {} | |
631 | ||
632 | virtual ~wxComboWidgetImpl() {} | |
633 | ||
634 | virtual int GetSelectedItem() const { return -1; }; | |
635 | virtual void SetSelectedItem(int WXUNUSED(item)) {}; | |
636 | ||
637 | virtual int GetNumberOfItems() const { return -1; }; | |
638 | ||
639 | virtual void InsertItem(int WXUNUSED(pos), const wxString& WXUNUSED(item)) {} | |
640 | ||
641 | virtual void RemoveItem(int WXUNUSED(pos)) {} | |
642 | ||
643 | virtual void Clear() {} | |
644 | ||
645 | virtual wxString GetStringAtIndex(int WXUNUSED(pos)) const { return wxEmptyString; } | |
646 | ||
647 | virtual int FindString(const wxString& WXUNUSED(text)) const { return -1; } | |
648 | }; | |
649 | ||
411a1c35 | 650 | // |
b38dc31f | 651 | // common interface for buttons |
411a1c35 SC |
652 | // |
653 | ||
b38dc31f | 654 | class wxButtonImpl |
411a1c35 SC |
655 | { |
656 | public : | |
b38dc31f SC |
657 | wxButtonImpl(){} |
658 | virtual ~wxButtonImpl(){} | |
411a1c35 SC |
659 | |
660 | virtual void SetPressedBitmap( const wxBitmap& bitmap ) = 0; | |
661 | } ; | |
662 | ||
1e181c7a SC |
663 | // |
664 | // common interface for search controls | |
665 | // | |
666 | ||
667 | class wxSearchWidgetImpl | |
668 | { | |
669 | public : | |
670 | wxSearchWidgetImpl(){} | |
671 | virtual ~wxSearchWidgetImpl(){} | |
672 | ||
673 | // search field options | |
674 | virtual void ShowSearchButton( bool show ) = 0; | |
675 | virtual bool IsSearchButtonVisible() const = 0; | |
676 | ||
677 | virtual void ShowCancelButton( bool show ) = 0; | |
678 | virtual bool IsCancelButtonVisible() const = 0; | |
679 | ||
680 | virtual void SetSearchMenu( wxMenu* menu ) = 0; | |
681 | ||
682 | virtual void SetDescriptiveText(const wxString& text) = 0; | |
683 | } ; | |
684 | ||
524c47aa SC |
685 | // |
686 | // toplevel window implementation class | |
687 | // | |
688 | ||
eefe52da SC |
689 | class wxNonOwnedWindowImpl : public wxObject |
690 | { | |
691 | public : | |
692 | wxNonOwnedWindowImpl( wxNonOwnedWindow* nonownedwnd) : m_wxPeer(nonownedwnd) | |
693 | { | |
694 | } | |
695 | wxNonOwnedWindowImpl() | |
696 | { | |
697 | } | |
698 | virtual ~wxNonOwnedWindowImpl() | |
699 | { | |
700 | } | |
03647350 | 701 | |
0aaa6ace | 702 | virtual void WillBeDestroyed() |
eefe52da SC |
703 | { |
704 | } | |
705 | ||
706 | virtual void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size, | |
707 | long style, long extraStyle, const wxString& name ) = 0; | |
03647350 VZ |
708 | |
709 | ||
eefe52da | 710 | virtual WXWindow GetWXWindow() const = 0; |
03647350 | 711 | |
eefe52da SC |
712 | virtual void Raise() |
713 | { | |
714 | } | |
03647350 | 715 | |
eefe52da SC |
716 | virtual void Lower() |
717 | { | |
718 | } | |
719 | ||
1aec1f8b | 720 | virtual bool Show(bool WXUNUSED(show)) |
eefe52da SC |
721 | { |
722 | return false; | |
723 | } | |
03647350 | 724 | |
1aec1f8b | 725 | virtual bool ShowWithEffect(bool show, wxShowEffect WXUNUSED(effect), unsigned WXUNUSED(timeout)) |
eefe52da SC |
726 | { |
727 | return Show(show); | |
728 | } | |
03647350 | 729 | |
eefe52da SC |
730 | virtual void Update() |
731 | { | |
732 | } | |
733 | ||
1aec1f8b | 734 | virtual bool SetTransparent(wxByte WXUNUSED(alpha)) |
eefe52da SC |
735 | { |
736 | return false; | |
737 | } | |
738 | ||
1aec1f8b | 739 | virtual bool SetBackgroundColour(const wxColour& WXUNUSED(col) ) |
eefe52da SC |
740 | { |
741 | return false; | |
742 | } | |
743 | ||
1aec1f8b | 744 | virtual void SetExtraStyle( long WXUNUSED(exStyle) ) |
eefe52da SC |
745 | { |
746 | } | |
b6dc21e7 KO |
747 | |
748 | virtual void SetWindowStyleFlag( long WXUNUSED(style) ) | |
749 | { | |
750 | } | |
751 | ||
1aec1f8b | 752 | virtual bool SetBackgroundStyle(wxBackgroundStyle WXUNUSED(style)) |
03647350 | 753 | { |
eefe52da SC |
754 | return false ; |
755 | } | |
03647350 | 756 | |
eefe52da SC |
757 | bool CanSetTransparent() |
758 | { | |
759 | return false; | |
760 | } | |
761 | ||
03647350 | 762 | virtual void GetContentArea( int &left , int &top , int &width , int &height ) const = 0; |
eefe52da SC |
763 | virtual void MoveWindow(int x, int y, int width, int height) = 0; |
764 | virtual void GetPosition( int &x, int &y ) const = 0; | |
765 | virtual void GetSize( int &width, int &height ) const = 0; | |
766 | ||
1aec1f8b | 767 | virtual bool SetShape(const wxRegion& WXUNUSED(region)) |
eefe52da SC |
768 | { |
769 | return false; | |
770 | } | |
03647350 | 771 | |
eefe52da | 772 | virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) = 0; |
03647350 | 773 | |
eefe52da | 774 | virtual bool IsMaximized() const = 0; |
03647350 | 775 | |
eefe52da | 776 | virtual bool IsIconized() const= 0; |
03647350 | 777 | |
eefe52da | 778 | virtual void Iconize( bool iconize )= 0; |
03647350 | 779 | |
eefe52da | 780 | virtual void Maximize(bool maximize) = 0; |
03647350 | 781 | |
eefe52da | 782 | virtual bool IsFullScreen() const= 0; |
03647350 | 783 | |
dbc7ceb9 KO |
784 | virtual void ShowWithoutActivating() { Show(true); } |
785 | ||
eefe52da SC |
786 | virtual bool ShowFullScreen(bool show, long style)= 0; |
787 | ||
788 | virtual void RequestUserAttention(int flags) = 0; | |
03647350 VZ |
789 | |
790 | virtual void ScreenToWindow( int *x, int *y ) = 0; | |
791 | ||
eefe52da | 792 | virtual void WindowToScreen( int *x, int *y ) = 0; |
03647350 | 793 | |
dbc7ceb9 KO |
794 | virtual bool IsActive() = 0; |
795 | ||
eefe52da | 796 | wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; } |
03647350 | 797 | |
075e3553 SC |
798 | static wxNonOwnedWindowImpl* |
799 | FindFromWXWindow(WXWindow window); | |
800 | ||
801 | static void RemoveAssociations( wxNonOwnedWindowImpl* impl); | |
802 | ||
803 | static void Associate( WXWindow window, wxNonOwnedWindowImpl *impl ); | |
804 | ||
524c47aa | 805 | // static creation methods, must be implemented by all toolkits |
03647350 | 806 | |
17e2694c SC |
807 | static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow native) ; |
808 | ||
524c47aa SC |
809 | static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size, |
810 | long style, long extraStyle, const wxString& name ) ; | |
efb2fa41 KO |
811 | |
812 | virtual void SetModified(bool WXUNUSED(modified)) { } | |
ebf7d5c4 | 813 | virtual bool IsModified() const { return false; } |
524c47aa | 814 | |
eefe52da SC |
815 | protected : |
816 | wxNonOwnedWindow* m_wxPeer; | |
817 | DECLARE_ABSTRACT_CLASS(wxNonOwnedWindowImpl) | |
818 | }; | |
819 | ||
5c6eb3a8 SC |
820 | #endif // wxUSE_GUI |
821 | ||
822 | //--------------------------------------------------------------------------- | |
823 | // cocoa bridging utilities | |
824 | //--------------------------------------------------------------------------- | |
825 | ||
826 | bool wxMacInitCocoa(); | |
827 | ||
828 | class WXDLLIMPEXP_CORE wxMacAutoreleasePool | |
829 | { | |
830 | public : | |
831 | wxMacAutoreleasePool(); | |
832 | ~wxMacAutoreleasePool(); | |
833 | private : | |
834 | void* m_pool; | |
835 | }; | |
836 | ||
837 | // NSObject | |
838 | ||
839 | void wxMacCocoaRelease( void* obj ); | |
840 | void wxMacCocoaAutorelease( void* obj ); | |
f1c40652 | 841 | void* wxMacCocoaRetain( void* obj ); |
5c6eb3a8 SC |
842 | |
843 | ||
844 | #endif | |
eefe52da | 845 | // _WX_PRIVATE_CORE_H_ |