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