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