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