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