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