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