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