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