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