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