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