]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/core/private.h
update project files
[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
09ffaca3 344 // finds the impl associated with this native control
03647350 345 static wxWidgetImpl*
f55d9f74 346 FindFromWXWidget(WXWidget control);
03647350 347
09ffaca3
SC
348 // finds the impl associated with this native control, if the native control itself is not known
349 // also checks whether its parent is eg a registered scrollview, ie whether the control is a native subpart
350 // of a known control
351 static wxWidgetImpl*
352 FindBestFromWXWidget(WXWidget control);
353
f55d9f74 354 static void RemoveAssociations( wxWidgetImpl* impl);
03647350 355
f55d9f74 356 static void Associate( WXWidget control, wxWidgetImpl *impl );
03647350 357
f06e0fea 358 static WXWidget FindFocus();
03647350 359
eefe52da 360 // static creation methods, must be implemented by all toolkits
03647350
VZ
361
362 static wxWidgetImplType* CreateUserPane( wxWindowMac* wxpeer,
363 wxWindowMac* parent,
364 wxWindowID id,
365 const wxPoint& pos,
524c47aa 366 const wxSize& size,
03647350 367 long style,
524c47aa
SC
368 long extraStyle) ;
369 static wxWidgetImplType* CreateContentView( wxNonOwnedWindow* now ) ;
370
03647350
VZ
371 static wxWidgetImplType* CreateButton( 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
SC
378 long extraStyle) ;
379
03647350
VZ
380 static wxWidgetImplType* CreateDisclosureTriangle( 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 387 long extraStyle) ;
03647350
VZ
388
389 static wxWidgetImplType* CreateStaticLine( wxWindowMac* wxpeer,
390 wxWindowMac* parent,
391 wxWindowID id,
392 const wxPoint& pos,
524c47aa 393 const wxSize& size,
03647350 394 long style,
524c47aa
SC
395 long extraStyle) ;
396
03647350
VZ
397 static wxWidgetImplType* CreateGroupBox( wxWindowMac* wxpeer,
398 wxWindowMac* parent,
399 wxWindowID id,
524c47aa 400 const wxString& label,
03647350 401 const wxPoint& pos,
524c47aa 402 const wxSize& size,
03647350 403 long style,
524c47aa
SC
404 long extraStyle) ;
405
03647350
VZ
406 static wxWidgetImplType* CreateStaticText( wxWindowMac* wxpeer,
407 wxWindowMac* parent,
408 wxWindowID id,
524c47aa 409 const wxString& label,
03647350 410 const wxPoint& pos,
524c47aa 411 const wxSize& size,
03647350 412 long style,
524c47aa
SC
413 long extraStyle) ;
414
03647350
VZ
415 static wxWidgetImplType* CreateTextControl( wxTextCtrl* wxpeer,
416 wxWindowMac* parent,
417 wxWindowID id,
524c47aa 418 const wxString& content,
03647350 419 const wxPoint& pos,
524c47aa 420 const wxSize& size,
03647350 421 long style,
524c47aa
SC
422 long extraStyle) ;
423
11f87a38 424 static wxWidgetImplType* CreateSearchControl( wxSearchCtrl* wxpeer,
03647350
VZ
425 wxWindowMac* parent,
426 wxWindowID id,
1e181c7a 427 const wxString& content,
03647350 428 const wxPoint& pos,
1e181c7a 429 const wxSize& size,
03647350 430 long style,
1e181c7a
SC
431 long extraStyle) ;
432
03647350
VZ
433 static wxWidgetImplType* CreateCheckBox( wxWindowMac* wxpeer,
434 wxWindowMac* parent,
435 wxWindowID id,
524c47aa 436 const wxString& label,
03647350 437 const wxPoint& pos,
524c47aa 438 const wxSize& size,
03647350 439 long style,
524c47aa 440 long extraStyle);
03647350
VZ
441
442 static wxWidgetImplType* CreateRadioButton( wxWindowMac* wxpeer,
443 wxWindowMac* parent,
444 wxWindowID id,
524c47aa 445 const wxString& label,
03647350 446 const wxPoint& pos,
524c47aa 447 const wxSize& size,
03647350 448 long style,
524c47aa
SC
449 long extraStyle);
450
03647350
VZ
451 static wxWidgetImplType* CreateToggleButton( wxWindowMac* wxpeer,
452 wxWindowMac* parent,
453 wxWindowID id,
524c47aa 454 const wxString& label,
03647350 455 const wxPoint& pos,
524c47aa 456 const wxSize& size,
03647350 457 long style,
524c47aa
SC
458 long extraStyle);
459
03647350
VZ
460 static wxWidgetImplType* CreateBitmapToggleButton( wxWindowMac* wxpeer,
461 wxWindowMac* parent,
462 wxWindowID id,
524c47aa 463 const wxBitmap& bitmap,
03647350 464 const wxPoint& pos,
524c47aa 465 const wxSize& size,
03647350 466 long style,
524c47aa
SC
467 long extraStyle);
468
03647350
VZ
469 static wxWidgetImplType* CreateBitmapButton( wxWindowMac* wxpeer,
470 wxWindowMac* parent,
471 wxWindowID id,
524c47aa 472 const wxBitmap& bitmap,
03647350 473 const wxPoint& pos,
524c47aa 474 const wxSize& size,
03647350 475 long style,
524c47aa
SC
476 long extraStyle);
477
03647350
VZ
478 static wxWidgetImplType* CreateTabView( wxWindowMac* wxpeer,
479 wxWindowMac* parent,
480 wxWindowID id,
481 const wxPoint& pos,
524c47aa 482 const wxSize& size,
03647350 483 long style,
524c47aa
SC
484 long extraStyle);
485
03647350
VZ
486 static wxWidgetImplType* CreateGauge( wxWindowMac* wxpeer,
487 wxWindowMac* parent,
488 wxWindowID id,
524c47aa
SC
489 wxInt32 value,
490 wxInt32 minimum,
491 wxInt32 maximum,
03647350 492 const wxPoint& pos,
524c47aa 493 const wxSize& size,
03647350 494 long style,
524c47aa
SC
495 long extraStyle);
496
03647350
VZ
497 static wxWidgetImplType* CreateSlider( wxWindowMac* wxpeer,
498 wxWindowMac* parent,
499 wxWindowID id,
524c47aa
SC
500 wxInt32 value,
501 wxInt32 minimum,
502 wxInt32 maximum,
03647350 503 const wxPoint& pos,
524c47aa 504 const wxSize& size,
03647350 505 long style,
524c47aa
SC
506 long extraStyle);
507
03647350
VZ
508 static wxWidgetImplType* CreateSpinButton( wxWindowMac* wxpeer,
509 wxWindowMac* parent,
510 wxWindowID id,
524c47aa
SC
511 wxInt32 value,
512 wxInt32 minimum,
513 wxInt32 maximum,
03647350 514 const wxPoint& pos,
524c47aa 515 const wxSize& size,
03647350 516 long style,
524c47aa
SC
517 long extraStyle);
518
03647350
VZ
519 static wxWidgetImplType* CreateScrollBar( wxWindowMac* wxpeer,
520 wxWindowMac* parent,
521 wxWindowID id,
522 const wxPoint& pos,
524c47aa 523 const wxSize& size,
03647350 524 long style,
524c47aa
SC
525 long extraStyle);
526
03647350
VZ
527 static wxWidgetImplType* CreateChoice( wxWindowMac* wxpeer,
528 wxWindowMac* parent,
529 wxWindowID id,
524c47aa 530 wxMenu* menu,
03647350 531 const wxPoint& pos,
524c47aa 532 const wxSize& size,
03647350 533 long style,
524c47aa
SC
534 long extraStyle);
535
03647350
VZ
536 static wxWidgetImplType* CreateListBox( wxWindowMac* wxpeer,
537 wxWindowMac* parent,
538 wxWindowID id,
539 const wxPoint& pos,
524c47aa 540 const wxSize& size,
03647350 541 long style,
524c47aa 542 long extraStyle);
eefe52da 543
c84030e0 544#if wxOSX_USE_COCOA
ce00f59b
VZ
545 static wxWidgetImplType* CreateComboBox( wxComboBox* wxpeer,
546 wxWindowMac* parent,
547 wxWindowID id,
f941a30b 548 wxMenu* menu,
ce00f59b 549 const wxPoint& pos,
f941a30b 550 const wxSize& size,
ce00f59b 551 long style,
f941a30b
KO
552 long extraStyle);
553#endif
554
eefe52da
SC
555 // converts from Toplevel-Content relative to local
556 static void Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to );
557protected :
558 bool m_isRootControl;
415f4a01 559 bool m_isUserPane;
eefe52da
SC
560 wxWindowMac* m_wxPeer;
561 bool m_needsFocusRect;
f2f6030e 562 bool m_needsFrame;
809020fc 563 bool m_shouldSendEvents;
eefe52da
SC
564
565 DECLARE_ABSTRACT_CLASS(wxWidgetImpl)
566};
567
524c47aa
SC
568//
569// the interface to be implemented eg by a listbox
570//
571
03647350 572class WXDLLIMPEXP_CORE wxListWidgetColumn
524c47aa
SC
573{
574public :
575 virtual ~wxListWidgetColumn() {}
576} ;
577
578class WXDLLIMPEXP_CORE wxListWidgetCellValue
579{
580public :
581 wxListWidgetCellValue() {}
582 virtual ~wxListWidgetCellValue() {}
03647350 583
524c47aa
SC
584 virtual void Set( CFStringRef value ) = 0;
585 virtual void Set( const wxString& value ) = 0;
586 virtual void Set( int value ) = 0;
60ebcb8a 587 virtual void Check( bool check );
03647350 588
60ebcb8a 589 virtual bool IsChecked() const;
524c47aa
SC
590 virtual int GetIntValue() const = 0;
591 virtual wxString GetStringValue() const = 0;
592} ;
593
594class WXDLLIMPEXP_CORE wxListWidgetImpl
595{
596public:
597 wxListWidgetImpl() {}
598 virtual ~wxListWidgetImpl() { }
03647350
VZ
599
600 virtual wxListWidgetColumn* InsertTextColumn( unsigned pos, const wxString& title, bool editable = false,
524c47aa 601 wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) = 0 ;
03647350 602 virtual wxListWidgetColumn* InsertCheckColumn( unsigned pos , const wxString& title, bool editable = false,
524c47aa 603 wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) = 0 ;
03647350 604
524c47aa
SC
605 // add and remove
606
607 // TODO will be replaced
608 virtual void ListDelete( unsigned int n ) = 0;
609 virtual void ListInsert( unsigned int n ) = 0;
610 virtual void ListClear() = 0;
611
612 // selecting
613
614 virtual void ListDeselectAll() = 0;
615 virtual void ListSetSelection( unsigned int n, bool select, bool multi ) = 0;
616 virtual int ListGetSelection() const = 0;
617 virtual int ListGetSelections( wxArrayInt& aSelections ) const = 0;
618 virtual bool ListIsSelected( unsigned int n ) const = 0;
03647350 619
524c47aa
SC
620 // display
621
622 virtual void ListScrollTo( unsigned int n ) = 0;
623 virtual void UpdateLine( unsigned int n, wxListWidgetColumn* col = NULL ) = 0;
624 virtual void UpdateLineToEnd( unsigned int n) = 0;
625
626 // accessing content
627
628 virtual unsigned int ListGetCount() const = 0;
ce00f59b 629
20196e15 630 virtual int DoListHitTest( const wxPoint& inpoint ) const = 0;
524c47aa
SC
631};
632
1e181c7a
SC
633//
634// interface to be implemented by a textcontrol
635//
636
21a9d326 637class WXDLLIMPEXP_FWD_CORE wxTextAttr;
c072b9ec 638class WXDLLIMPEXP_FWD_CORE wxTextEntry;
21a9d326 639
1e181c7a
SC
640// common interface for all implementations
641class WXDLLIMPEXP_CORE wxTextWidgetImpl
642
643{
644public :
c072b9ec
VZ
645 // Any widgets implementing this interface must be associated with a
646 // wxTextEntry so instead of requiring the derived classes to implement
647 // another (pure) virtual function, just take the pointer to this entry in
648 // our ctor and implement GetTextEntry() ourselves.
649 wxTextWidgetImpl(wxTextEntry *entry) : m_entry(entry) {}
1e181c7a
SC
650
651 virtual ~wxTextWidgetImpl() {}
652
c072b9ec
VZ
653 wxTextEntry *GetTextEntry() const { return m_entry; }
654
1e181c7a
SC
655 virtual bool CanFocus() const { return true; }
656
657 virtual wxString GetStringValue() const = 0 ;
658 virtual void SetStringValue( const wxString &val ) = 0 ;
659 virtual void SetSelection( long from, long to ) = 0 ;
660 virtual void GetSelection( long* from, long* to ) const = 0 ;
661 virtual void WriteText( const wxString& str ) = 0 ;
662
4386db06
SC
663 virtual bool CanClipMaxLength() const { return false; }
664 virtual void SetMaxLength(unsigned long WXUNUSED(len)) {}
665
16671f22 666 virtual bool GetStyle( long position, wxTextAttr& style);
1e181c7a
SC
667 virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
668 virtual void Copy() ;
669 virtual void Cut() ;
670 virtual void Paste() ;
671 virtual bool CanPaste() const ;
672 virtual void SetEditable( bool editable ) ;
0b6a49c2 673 virtual long GetLastPosition() const ;
1e181c7a
SC
674 virtual void Replace( long from, long to, const wxString &str ) ;
675 virtual void Remove( long from, long to ) ;
676
677
678 virtual bool HasOwnContextMenu() const
679 { return false ; }
680
681 virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) )
682 { return false ; }
683
684 virtual void Clear() ;
685 virtual bool CanUndo() const;
686 virtual void Undo() ;
687 virtual bool CanRedo() const;
688 virtual void Redo() ;
689 virtual int GetNumberOfLines() const ;
690 virtual long XYToPosition(long x, long y) const;
691 virtual bool PositionToXY(long pos, long *x, long *y) const ;
692 virtual void ShowPosition(long WXUNUSED(pos)) ;
693 virtual int GetLineLength(long lineNo) const ;
694 virtual wxString GetLineText(long lineNo) const ;
695 virtual void CheckSpelling(bool WXUNUSED(check)) { }
ce00f59b 696
9ab7ff53 697 virtual wxSize GetBestSize() const { return wxDefaultSize; }
c072b9ec 698
99eb484a 699 virtual bool SetHint(const wxString& WXUNUSED(hint)) { return false; }
c072b9ec
VZ
700private:
701 wxTextEntry * const m_entry;
702
703 wxDECLARE_NO_COPY_CLASS(wxTextWidgetImpl);
1e181c7a
SC
704};
705
c84030e0
KO
706// common interface for all implementations
707class WXDLLIMPEXP_CORE wxComboWidgetImpl
708
709{
710public :
711 wxComboWidgetImpl() {}
712
713 virtual ~wxComboWidgetImpl() {}
ce00f59b 714
6dd0883d
SN
715 virtual int GetSelectedItem() const { return -1; }
716 virtual void SetSelectedItem(int WXUNUSED(item)) {}
ce00f59b 717
6dd0883d 718 virtual int GetNumberOfItems() const { return -1; }
ce00f59b 719
c84030e0 720 virtual void InsertItem(int WXUNUSED(pos), const wxString& WXUNUSED(item)) {}
ce00f59b 721
c84030e0 722 virtual void RemoveItem(int WXUNUSED(pos)) {}
ce00f59b 723
c84030e0 724 virtual void Clear() {}
ff8cb900
VZ
725 virtual void Popup() {}
726 virtual void Dismiss() {}
ce00f59b 727
c84030e0 728 virtual wxString GetStringAtIndex(int WXUNUSED(pos)) const { return wxEmptyString; }
ce00f59b 729
c84030e0
KO
730 virtual int FindString(const wxString& WXUNUSED(text)) const { return -1; }
731};
732
411a1c35 733//
b38dc31f 734// common interface for buttons
411a1c35
SC
735//
736
b38dc31f 737class wxButtonImpl
411a1c35
SC
738{
739 public :
b38dc31f
SC
740 wxButtonImpl(){}
741 virtual ~wxButtonImpl(){}
ce00f59b 742
411a1c35
SC
743 virtual void SetPressedBitmap( const wxBitmap& bitmap ) = 0;
744} ;
745
1e181c7a
SC
746//
747// common interface for search controls
748//
749
750class wxSearchWidgetImpl
751{
752public :
753 wxSearchWidgetImpl(){}
754 virtual ~wxSearchWidgetImpl(){}
755
756 // search field options
757 virtual void ShowSearchButton( bool show ) = 0;
758 virtual bool IsSearchButtonVisible() const = 0;
759
760 virtual void ShowCancelButton( bool show ) = 0;
761 virtual bool IsCancelButtonVisible() const = 0;
762
763 virtual void SetSearchMenu( wxMenu* menu ) = 0;
764
765 virtual void SetDescriptiveText(const wxString& text) = 0;
766} ;
767
524c47aa
SC
768//
769// toplevel window implementation class
770//
771
eefe52da
SC
772class wxNonOwnedWindowImpl : public wxObject
773{
774public :
775 wxNonOwnedWindowImpl( wxNonOwnedWindow* nonownedwnd) : m_wxPeer(nonownedwnd)
776 {
777 }
778 wxNonOwnedWindowImpl()
779 {
780 }
781 virtual ~wxNonOwnedWindowImpl()
782 {
783 }
03647350 784
0aaa6ace 785 virtual void WillBeDestroyed()
eefe52da
SC
786 {
787 }
788
789 virtual void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
790 long style, long extraStyle, const wxString& name ) = 0;
03647350
VZ
791
792
eefe52da 793 virtual WXWindow GetWXWindow() const = 0;
03647350 794
eefe52da
SC
795 virtual void Raise()
796 {
797 }
03647350 798
eefe52da
SC
799 virtual void Lower()
800 {
801 }
802
1aec1f8b 803 virtual bool Show(bool WXUNUSED(show))
eefe52da
SC
804 {
805 return false;
806 }
03647350 807
1aec1f8b 808 virtual bool ShowWithEffect(bool show, wxShowEffect WXUNUSED(effect), unsigned WXUNUSED(timeout))
eefe52da
SC
809 {
810 return Show(show);
811 }
03647350 812
eefe52da
SC
813 virtual void Update()
814 {
815 }
816
1aec1f8b 817 virtual bool SetTransparent(wxByte WXUNUSED(alpha))
eefe52da
SC
818 {
819 return false;
820 }
821
1aec1f8b 822 virtual bool SetBackgroundColour(const wxColour& WXUNUSED(col) )
eefe52da
SC
823 {
824 return false;
825 }
826
1aec1f8b 827 virtual void SetExtraStyle( long WXUNUSED(exStyle) )
eefe52da
SC
828 {
829 }
ce00f59b 830
b6dc21e7
KO
831 virtual void SetWindowStyleFlag( long WXUNUSED(style) )
832 {
833 }
ce00f59b 834
1aec1f8b 835 virtual bool SetBackgroundStyle(wxBackgroundStyle WXUNUSED(style))
03647350 836 {
eefe52da
SC
837 return false ;
838 }
03647350 839
6f5778a6 840 virtual bool CanSetTransparent()
eefe52da
SC
841 {
842 return false;
843 }
844
03647350 845 virtual void GetContentArea( int &left , int &top , int &width , int &height ) const = 0;
eefe52da
SC
846 virtual void MoveWindow(int x, int y, int width, int height) = 0;
847 virtual void GetPosition( int &x, int &y ) const = 0;
848 virtual void GetSize( int &width, int &height ) const = 0;
849
1aec1f8b 850 virtual bool SetShape(const wxRegion& WXUNUSED(region))
eefe52da
SC
851 {
852 return false;
853 }
03647350 854
eefe52da 855 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) = 0;
03647350 856
eefe52da 857 virtual bool IsMaximized() const = 0;
03647350 858
eefe52da 859 virtual bool IsIconized() const= 0;
03647350 860
eefe52da 861 virtual void Iconize( bool iconize )= 0;
03647350 862
eefe52da 863 virtual void Maximize(bool maximize) = 0;
03647350 864
eefe52da 865 virtual bool IsFullScreen() const= 0;
03647350 866
dbc7ceb9 867 virtual void ShowWithoutActivating() { Show(true); }
ce00f59b 868
eefe52da
SC
869 virtual bool ShowFullScreen(bool show, long style)= 0;
870
871 virtual void RequestUserAttention(int flags) = 0;
03647350
VZ
872
873 virtual void ScreenToWindow( int *x, int *y ) = 0;
874
eefe52da 875 virtual void WindowToScreen( int *x, int *y ) = 0;
f8619070
SC
876
877 virtual double GetMagnificationFactor() const { return 1.0; }
03647350 878
dbc7ceb9 879 virtual bool IsActive() = 0;
ce00f59b 880
eefe52da 881 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
03647350 882
075e3553
SC
883 static wxNonOwnedWindowImpl*
884 FindFromWXWindow(WXWindow window);
ce00f59b 885
075e3553 886 static void RemoveAssociations( wxNonOwnedWindowImpl* impl);
ce00f59b 887
075e3553 888 static void Associate( WXWindow window, wxNonOwnedWindowImpl *impl );
ce00f59b 889
524c47aa 890 // static creation methods, must be implemented by all toolkits
03647350 891
17e2694c 892 static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow native) ;
ce00f59b 893
524c47aa
SC
894 static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
895 long style, long extraStyle, const wxString& name ) ;
ce00f59b 896
efb2fa41 897 virtual void SetModified(bool WXUNUSED(modified)) { }
ebf7d5c4 898 virtual bool IsModified() const { return false; }
524c47aa 899
6a0e4ead
VZ
900 virtual void SetRepresentedFilename(const wxString& WXUNUSED(filename)) { }
901
31c659e8
SC
902#if wxOSX_USE_IPHONE
903 virtual CGFloat GetWindowLevel() const { return 0.0; }
904#else
9d243a47 905 virtual CGWindowLevel GetWindowLevel() const { return kCGNormalWindowLevel; }
31c659e8 906#endif
9d243a47 907 virtual void RestoreWindowLevel() {}
eefe52da
SC
908protected :
909 wxNonOwnedWindow* m_wxPeer;
910 DECLARE_ABSTRACT_CLASS(wxNonOwnedWindowImpl)
911};
912
5c6eb3a8
SC
913#endif // wxUSE_GUI
914
915//---------------------------------------------------------------------------
916// cocoa bridging utilities
917//---------------------------------------------------------------------------
918
919bool wxMacInitCocoa();
920
921class WXDLLIMPEXP_CORE wxMacAutoreleasePool
922{
923public :
924 wxMacAutoreleasePool();
925 ~wxMacAutoreleasePool();
926private :
927 void* m_pool;
928};
929
930// NSObject
931
932void wxMacCocoaRelease( void* obj );
933void wxMacCocoaAutorelease( void* obj );
f1c40652 934void* wxMacCocoaRetain( void* obj );
5c6eb3a8
SC
935
936
937#endif
eefe52da 938 // _WX_PRIVATE_CORE_H_