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