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