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