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