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
6 // Author: Stefan Csomor
9 // RCS-ID: $Id: private.h 53819 2008-05-29 14:11:45Z SC $
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_PRIVATE_CORE_H_
15 #define _WX_PRIVATE_CORE_H_
19 #include <CoreFoundation/CoreFoundation.h>
21 #include "wx/osx/core/cfstring.h"
22 #include "wx/osx/core/cfdataref.h"
24 #if wxOSX_USE_COCOA_OR_CARBON
25 WXDLLIMPEXP_BASE
long UMAGetSystemVersion() ;
31 #include <CoreGraphics/CoreGraphics.h>
33 #include <ApplicationServices/ApplicationServices.h>
36 #include "wx/bitmap.h"
37 #include "wx/window.h"
39 class WXDLLIMPEXP_CORE wxMacCGContextStateSaver
41 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
44 wxMacCGContextStateSaver( CGContextRef cg
)
47 CGContextSaveGState( cg
);
49 ~wxMacCGContextStateSaver()
51 CGContextRestoreGState( m_cg
);
57 class WXDLLIMPEXP_CORE wxDeferredObjectDeleter
: public wxObject
60 wxDeferredObjectDeleter( wxObject
* obj
) : m_obj(obj
)
63 virtual ~wxDeferredObjectDeleter()
73 WXDLLIMPEXP_CORE CGImageRef
wxMacCreateCGImageFromBitmap( const wxBitmap
& bitmap
);
75 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithCFData( CFDataRef data
);
76 WXDLLIMPEXP_CORE CGDataConsumerRef
wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data
);
77 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer
& buf
);
79 CGColorSpaceRef WXDLLIMPEXP_CORE
wxMacGetGenericRGBColorSpace(void);
83 extern wxWindow
* g_MacLastWindow
;
84 class wxNonOwnedWindow
;
86 // temporary typedef so that no additional casts are necessary within carbon code at the moment
93 typedef wxMacControl wxWidgetImplType
;
95 typedef wxWidgetImpl wxWidgetImplType
;
98 class wxMenuItemImpl
: public wxObject
101 wxMenuItemImpl( wxMenuItem
* peer
) : m_peer(peer
)
105 virtual ~wxMenuItemImpl() ;
106 virtual void SetBitmap( const wxBitmap
& bitmap
) = 0;
107 virtual void Enable( bool enable
) = 0;
108 virtual void Check( bool check
) = 0;
109 virtual void SetLabel( const wxString
& text
, wxAcceleratorEntry
*entry
) = 0;
110 virtual void Hide( bool hide
= true ) = 0;
112 virtual void * GetHMenuItem() = 0;
114 wxMenuItem
* GetWXPeer() { return m_peer
; }
116 static wxMenuItemImpl
* Create( wxMenuItem
* peer
, wxMenu
*pParentMenu
,
118 const wxString
& text
,
119 wxAcceleratorEntry
*entry
,
120 const wxString
& strHelp
,
127 DECLARE_ABSTRACT_CLASS(wxMenuItemImpl
);
130 class wxMenuImpl
: public wxObject
133 wxMenuImpl( wxMenu
* peer
) : m_peer(peer
)
137 virtual ~wxMenuImpl() ;
138 virtual void InsertOrAppend(wxMenuItem
*pItem
, size_t pos
) = 0;
139 virtual void Remove( wxMenuItem
*pItem
) = 0;
141 virtual void MakeRoot() = 0;
143 virtual void SetTitle( const wxString
& text
) = 0;
145 virtual WXHMENU
GetHMenu() = 0;
147 wxMenu
* GetWXPeer() { return m_peer
; }
149 static wxMenuImpl
* Create( wxMenu
* peer
, const wxString
& title
);
150 static wxMenuImpl
* CreateRootMenu( wxMenu
* peer
);
154 DECLARE_ABSTRACT_CLASS(wxMenuItemImpl
);
159 class WXDLLIMPEXP_CORE wxWidgetImpl
: public wxObject
162 wxWidgetImpl( wxWindowMac
* peer
, bool isRootControl
= false );
164 virtual ~wxWidgetImpl();
168 bool IsRootControl() const { return m_isRootControl
; }
170 wxWindowMac
* GetWXPeer() const { return m_wxPeer
; }
172 bool IsOk() const { return GetWXWidget() != NULL
; }
174 // not only the control itself, but also all its parents must be visible
175 // in order for this function to return true
176 virtual bool IsVisible() const = 0;
177 // set the visibility of this widget (maybe latent)
178 virtual void SetVisibility( bool visible
) = 0;
180 virtual void Raise() = 0;
182 virtual void Lower() = 0;
184 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
) = 0;
186 virtual WXWidget
GetWXWidget() const = 0;
188 virtual void SetBackgroundColour( const wxColour
& col
) = 0;
190 // all coordinates in native parent widget relative coordinates
191 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const = 0;
192 virtual void Move(int x
, int y
, int width
, int height
) = 0;
193 virtual void GetPosition( int &x
, int &y
) const = 0;
194 virtual void GetSize( int &width
, int &height
) const = 0;
195 virtual void SetControlSize( wxWindowVariant variant
) = 0;
197 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
) = 0;
198 virtual bool GetNeedsDisplay() const = 0;
200 virtual bool NeedsFocusRect() const;
201 virtual void SetNeedsFocusRect( bool needs
);
203 virtual bool CanFocus() const = 0;
204 // return true if successful
205 virtual bool SetFocus() = 0;
206 virtual bool HasFocus() const = 0;
208 virtual void RemoveFromParent() = 0;
209 virtual void Embed( wxWidgetImpl
*parent
) = 0;
211 virtual void SetDefaultButton( bool isDefault
) = 0;
212 virtual void PerformClick() = 0;
213 virtual void SetLabel( const wxString
& title
, wxFontEncoding encoding
) = 0;
215 virtual wxInt32
GetValue() const = 0;
216 virtual void SetValue( wxInt32 v
) = 0;
217 virtual void SetBitmap( const wxBitmap
& bitmap
) = 0;
218 virtual void SetupTabs( const wxNotebook
¬ebook
) =0;
219 virtual void GetBestRect( wxRect
*r
) const = 0;
220 virtual bool IsEnabled() const = 0;
221 virtual void Enable( bool enable
) = 0;
222 virtual void SetMinimum( wxInt32 v
) = 0;
223 virtual void SetMaximum( wxInt32 v
) = 0;
224 virtual void PulseGauge() = 0;
225 virtual void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
) = 0;
227 // is the clicked event sent AFTER the state already changed, so no additional
228 // state changing logic is required from the outside
229 virtual bool ButtonClickDidStateChange() = 0;
231 // static creation methods, must be implemented by all toolkits
233 static wxWidgetImplType
* CreateUserPane( wxWindowMac
* wxpeer
,
240 static wxWidgetImplType
* CreateContentView( wxNonOwnedWindow
* now
) ;
242 static wxWidgetImplType
* CreateButton( wxWindowMac
* wxpeer
,
245 const wxString
& label
,
251 static wxWidgetImplType
* CreateDisclosureTriangle( wxWindowMac
* wxpeer
,
254 const wxString
& label
,
260 static wxWidgetImplType
* CreateStaticLine( wxWindowMac
* wxpeer
,
268 static wxWidgetImplType
* CreateGroupBox( wxWindowMac
* wxpeer
,
271 const wxString
& label
,
277 static wxWidgetImplType
* CreateStaticText( wxWindowMac
* wxpeer
,
280 const wxString
& label
,
286 static wxWidgetImplType
* CreateTextControl( wxTextCtrl
* wxpeer
,
289 const wxString
& content
,
295 static wxWidgetImplType
* CreateCheckBox( wxWindowMac
* wxpeer
,
298 const wxString
& label
,
304 static wxWidgetImplType
* CreateRadioButton( wxWindowMac
* wxpeer
,
307 const wxString
& label
,
313 static wxWidgetImplType
* CreateToggleButton( wxWindowMac
* wxpeer
,
316 const wxString
& label
,
322 static wxWidgetImplType
* CreateBitmapToggleButton( wxWindowMac
* wxpeer
,
325 const wxBitmap
& bitmap
,
331 static wxWidgetImplType
* CreateBitmapButton( wxWindowMac
* wxpeer
,
334 const wxBitmap
& bitmap
,
340 static wxWidgetImplType
* CreateTabView( wxWindowMac
* wxpeer
,
348 static wxWidgetImplType
* CreateGauge( wxWindowMac
* wxpeer
,
359 static wxWidgetImplType
* CreateSlider( wxWindowMac
* wxpeer
,
370 static wxWidgetImplType
* CreateSpinButton( wxWindowMac
* wxpeer
,
381 static wxWidgetImplType
* CreateScrollBar( wxWindowMac
* wxpeer
,
389 static wxWidgetImplType
* CreateChoice( wxWindowMac
* wxpeer
,
398 static wxWidgetImplType
* CreateListBox( wxWindowMac
* wxpeer
,
406 // converts from Toplevel-Content relative to local
407 static void Convert( wxPoint
*pt
, wxWidgetImpl
*from
, wxWidgetImpl
*to
);
409 bool m_isRootControl
;
410 wxWindowMac
* m_wxPeer
;
411 bool m_needsFocusRect
;
413 DECLARE_ABSTRACT_CLASS(wxWidgetImpl
)
417 // the interface to be implemented eg by a listbox
420 class WXDLLIMPEXP_CORE wxMacDataItem
;
422 class WXDLLIMPEXP_CORE wxListWidgetColumn
425 virtual ~wxListWidgetColumn() {}
428 class WXDLLIMPEXP_CORE wxListWidgetCellValue
431 wxListWidgetCellValue() {}
432 virtual ~wxListWidgetCellValue() {}
434 virtual void Set( CFStringRef value
) = 0;
435 virtual void Set( const wxString
& value
) = 0;
436 virtual void Set( int value
) = 0;
438 virtual int GetIntValue() const = 0;
439 virtual wxString
GetStringValue() const = 0;
442 class WXDLLIMPEXP_CORE wxListWidgetImpl
445 wxListWidgetImpl() {}
446 virtual ~wxListWidgetImpl() { }
448 virtual wxListWidgetColumn
* InsertTextColumn( unsigned pos
, const wxString
& title
, bool editable
= false,
449 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) = 0 ;
450 virtual wxListWidgetColumn
* InsertCheckColumn( unsigned pos
, const wxString
& title
, bool editable
= false,
451 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) = 0 ;
455 // TODO will be replaced
456 virtual void ListDelete( unsigned int n
) = 0;
457 virtual void ListInsert( unsigned int n
) = 0;
458 virtual void ListClear() = 0;
462 virtual void ListDeselectAll() = 0;
463 virtual void ListSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
464 virtual int ListGetSelection() const = 0;
465 virtual int ListGetSelections( wxArrayInt
& aSelections
) const = 0;
466 virtual bool ListIsSelected( unsigned int n
) const = 0;
470 virtual void ListScrollTo( unsigned int n
) = 0;
471 virtual void UpdateLine( unsigned int n
, wxListWidgetColumn
* col
= NULL
) = 0;
472 virtual void UpdateLineToEnd( unsigned int n
) = 0;
476 virtual unsigned int ListGetCount() const = 0;
480 // toplevel window implementation class
483 class wxNonOwnedWindowImpl
: public wxObject
486 wxNonOwnedWindowImpl( wxNonOwnedWindow
* nonownedwnd
) : m_wxPeer(nonownedwnd
)
489 wxNonOwnedWindowImpl()
492 virtual ~wxNonOwnedWindowImpl()
496 virtual void Destroy()
500 virtual void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
501 long style
, long extraStyle
, const wxString
& name
) = 0;
504 virtual WXWindow
GetWXWindow() const = 0;
514 virtual bool Show(bool WXUNUSED(show
))
519 virtual bool ShowWithEffect(bool show
, wxShowEffect
WXUNUSED(effect
), unsigned WXUNUSED(timeout
))
524 virtual void Update()
528 virtual bool SetTransparent(wxByte
WXUNUSED(alpha
))
533 virtual bool SetBackgroundColour(const wxColour
& WXUNUSED(col
) )
538 virtual void SetExtraStyle( long WXUNUSED(exStyle
) )
542 virtual bool SetBackgroundStyle(wxBackgroundStyle
WXUNUSED(style
))
547 bool CanSetTransparent()
552 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const = 0;
553 virtual void MoveWindow(int x
, int y
, int width
, int height
) = 0;
554 virtual void GetPosition( int &x
, int &y
) const = 0;
555 virtual void GetSize( int &width
, int &height
) const = 0;
557 virtual bool SetShape(const wxRegion
& WXUNUSED(region
))
562 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) = 0;
564 virtual bool IsMaximized() const = 0;
566 virtual bool IsIconized() const= 0;
568 virtual void Iconize( bool iconize
)= 0;
570 virtual void Maximize(bool maximize
) = 0;
572 virtual bool IsFullScreen() const= 0;
574 virtual bool ShowFullScreen(bool show
, long style
)= 0;
576 virtual void RequestUserAttention(int flags
) = 0;
578 virtual void ScreenToWindow( int *x
, int *y
) = 0;
580 virtual void WindowToScreen( int *x
, int *y
) = 0;
582 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
584 // static creation methods, must be implemented by all toolkits
586 static wxNonOwnedWindowImpl
* CreateNonOwnedWindow( wxNonOwnedWindow
* wxpeer
, wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
587 long style
, long extraStyle
, const wxString
& name
) ;
590 wxNonOwnedWindow
* m_wxPeer
;
591 DECLARE_ABSTRACT_CLASS(wxNonOwnedWindowImpl
)
596 //---------------------------------------------------------------------------
597 // cocoa bridging utilities
598 //---------------------------------------------------------------------------
600 bool wxMacInitCocoa();
602 class WXDLLIMPEXP_CORE wxMacAutoreleasePool
605 wxMacAutoreleasePool();
606 ~wxMacAutoreleasePool();
613 void wxMacCocoaRelease( void* obj
);
614 void wxMacCocoaAutorelease( void* obj
);
615 void wxMacCocoaRetain( void* obj
);
619 // _WX_PRIVATE_CORE_H_