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
94 typedef wxMacControl wxWidgetImplType
;
96 typedef wxWidgetImpl wxWidgetImplType
;
99 class wxMenuItemImpl
: public wxObject
102 wxMenuItemImpl( wxMenuItem
* peer
) : m_peer(peer
)
106 virtual ~wxMenuItemImpl() ;
107 virtual void SetBitmap( const wxBitmap
& bitmap
) = 0;
108 virtual void Enable( bool enable
) = 0;
109 virtual void Check( bool check
) = 0;
110 virtual void SetLabel( const wxString
& text
, wxAcceleratorEntry
*entry
) = 0;
111 virtual void Hide( bool hide
= true ) = 0;
113 virtual void * GetHMenuItem() = 0;
115 wxMenuItem
* GetWXPeer() { return m_peer
; }
117 static wxMenuItemImpl
* Create( wxMenuItem
* peer
, wxMenu
*pParentMenu
,
119 const wxString
& text
,
120 wxAcceleratorEntry
*entry
,
121 const wxString
& strHelp
,
128 DECLARE_ABSTRACT_CLASS(wxMenuItemImpl
);
131 class wxMenuImpl
: public wxObject
134 wxMenuImpl( wxMenu
* peer
) : m_peer(peer
)
138 virtual ~wxMenuImpl() ;
139 virtual void InsertOrAppend(wxMenuItem
*pItem
, size_t pos
) = 0;
140 virtual void Remove( wxMenuItem
*pItem
) = 0;
142 virtual void MakeRoot() = 0;
144 virtual void SetTitle( const wxString
& text
) = 0;
146 virtual WXHMENU
GetHMenu() = 0;
148 wxMenu
* GetWXPeer() { return m_peer
; }
150 static wxMenuImpl
* Create( wxMenu
* peer
, const wxString
& title
);
151 static wxMenuImpl
* CreateRootMenu( wxMenu
* peer
);
155 DECLARE_ABSTRACT_CLASS(wxMenuItemImpl
);
160 class WXDLLIMPEXP_CORE wxWidgetImpl
: public wxObject
163 wxWidgetImpl( wxWindowMac
* peer
, bool isRootControl
= false );
165 virtual ~wxWidgetImpl();
169 bool IsRootControl() const { return m_isRootControl
; }
171 wxWindowMac
* GetWXPeer() const { return m_wxPeer
; }
173 bool IsOk() const { return GetWXWidget() != NULL
; }
175 // not only the control itself, but also all its parents must be visible
176 // in order for this function to return true
177 virtual bool IsVisible() const = 0;
178 // set the visibility of this widget (maybe latent)
179 virtual void SetVisibility( bool visible
) = 0;
181 virtual void Raise() = 0;
183 virtual void Lower() = 0;
185 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
) = 0;
187 virtual WXWidget
GetWXWidget() const = 0;
189 virtual void SetBackgroundColour( const wxColour
& col
) = 0;
191 // all coordinates in native parent widget relative coordinates
192 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const = 0;
193 virtual void Move(int x
, int y
, int width
, int height
) = 0;
194 virtual void GetPosition( int &x
, int &y
) const = 0;
195 virtual void GetSize( int &width
, int &height
) const = 0;
196 virtual void SetControlSize( wxWindowVariant variant
) = 0;
198 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
) = 0;
199 virtual bool GetNeedsDisplay() const = 0;
201 virtual bool NeedsFocusRect() const;
202 virtual void SetNeedsFocusRect( bool needs
);
204 virtual bool CanFocus() const = 0;
205 // return true if successful
206 virtual bool SetFocus() = 0;
207 virtual bool HasFocus() const = 0;
209 virtual void RemoveFromParent() = 0;
210 virtual void Embed( wxWidgetImpl
*parent
) = 0;
212 virtual void SetDefaultButton( bool isDefault
) = 0;
213 virtual void PerformClick() = 0;
214 virtual void SetLabel( const wxString
& title
, wxFontEncoding encoding
) = 0;
216 virtual wxInt32
GetValue() const = 0;
217 virtual void SetValue( wxInt32 v
) = 0;
218 virtual void SetBitmap( const wxBitmap
& bitmap
) = 0;
219 virtual void SetupTabs( const wxNotebook
¬ebook
) =0;
220 virtual void GetBestRect( wxRect
*r
) const = 0;
221 virtual bool IsEnabled() const = 0;
222 virtual void Enable( bool enable
) = 0;
223 virtual void SetMinimum( wxInt32 v
) = 0;
224 virtual void SetMaximum( wxInt32 v
) = 0;
225 virtual void PulseGauge() = 0;
226 virtual void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
) = 0;
228 // is the clicked event sent AFTER the state already changed, so no additional
229 // state changing logic is required from the outside
230 virtual bool ButtonClickDidStateChange() = 0;
232 // static creation methods, must be implemented by all toolkits
234 static wxWidgetImplType
* CreateUserPane( wxWindowMac
* wxpeer
,
241 static wxWidgetImplType
* CreateContentView( wxNonOwnedWindow
* now
) ;
243 static wxWidgetImplType
* CreateButton( wxWindowMac
* wxpeer
,
246 const wxString
& label
,
252 static wxWidgetImplType
* CreateDisclosureTriangle( wxWindowMac
* wxpeer
,
255 const wxString
& label
,
261 static wxWidgetImplType
* CreateStaticLine( wxWindowMac
* wxpeer
,
269 static wxWidgetImplType
* CreateGroupBox( wxWindowMac
* wxpeer
,
272 const wxString
& label
,
278 static wxWidgetImplType
* CreateStaticText( wxWindowMac
* wxpeer
,
281 const wxString
& label
,
287 static wxWidgetImplType
* CreateTextControl( wxTextCtrl
* wxpeer
,
290 const wxString
& content
,
296 static wxWidgetImplType
* CreateCheckBox( wxWindowMac
* wxpeer
,
299 const wxString
& label
,
305 static wxWidgetImplType
* CreateRadioButton( wxWindowMac
* wxpeer
,
308 const wxString
& label
,
314 static wxWidgetImplType
* CreateToggleButton( wxWindowMac
* wxpeer
,
317 const wxString
& label
,
323 static wxWidgetImplType
* CreateBitmapToggleButton( wxWindowMac
* wxpeer
,
326 const wxBitmap
& bitmap
,
332 static wxWidgetImplType
* CreateBitmapButton( wxWindowMac
* wxpeer
,
335 const wxBitmap
& bitmap
,
341 static wxWidgetImplType
* CreateTabView( wxWindowMac
* wxpeer
,
349 static wxWidgetImplType
* CreateGauge( wxWindowMac
* wxpeer
,
360 static wxWidgetImplType
* CreateSlider( wxWindowMac
* wxpeer
,
371 static wxWidgetImplType
* CreateSpinButton( wxWindowMac
* wxpeer
,
382 static wxWidgetImplType
* CreateScrollBar( wxWindowMac
* wxpeer
,
390 static wxWidgetImplType
* CreateChoice( wxWindowMac
* wxpeer
,
399 static wxWidgetImplType
* CreateListBox( wxWindowMac
* wxpeer
,
407 // converts from Toplevel-Content relative to local
408 static void Convert( wxPoint
*pt
, wxWidgetImpl
*from
, wxWidgetImpl
*to
);
410 bool m_isRootControl
;
411 wxWindowMac
* m_wxPeer
;
412 bool m_needsFocusRect
;
414 DECLARE_ABSTRACT_CLASS(wxWidgetImpl
)
418 // the interface to be implemented eg by a listbox
421 class WXDLLIMPEXP_CORE wxListWidgetColumn
424 virtual ~wxListWidgetColumn() {}
427 class WXDLLIMPEXP_CORE wxListWidgetCellValue
430 wxListWidgetCellValue() {}
431 virtual ~wxListWidgetCellValue() {}
433 virtual void Set( CFStringRef value
) = 0;
434 virtual void Set( const wxString
& value
) = 0;
435 virtual void Set( int value
) = 0;
437 virtual int GetIntValue() const = 0;
438 virtual wxString
GetStringValue() const = 0;
441 class WXDLLIMPEXP_CORE wxListWidgetImpl
444 wxListWidgetImpl() {}
445 virtual ~wxListWidgetImpl() { }
447 virtual wxListWidgetColumn
* InsertTextColumn( unsigned pos
, const wxString
& title
, bool editable
= false,
448 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) = 0 ;
449 virtual wxListWidgetColumn
* InsertCheckColumn( unsigned pos
, const wxString
& title
, bool editable
= false,
450 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) = 0 ;
454 // TODO will be replaced
455 virtual void ListDelete( unsigned int n
) = 0;
456 virtual void ListInsert( unsigned int n
) = 0;
457 virtual void ListClear() = 0;
461 virtual void ListDeselectAll() = 0;
462 virtual void ListSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
463 virtual int ListGetSelection() const = 0;
464 virtual int ListGetSelections( wxArrayInt
& aSelections
) const = 0;
465 virtual bool ListIsSelected( unsigned int n
) const = 0;
469 virtual void ListScrollTo( unsigned int n
) = 0;
470 virtual void UpdateLine( unsigned int n
, wxListWidgetColumn
* col
= NULL
) = 0;
471 virtual void UpdateLineToEnd( unsigned int n
) = 0;
475 virtual unsigned int ListGetCount() const = 0;
479 // toplevel window implementation class
482 class wxNonOwnedWindowImpl
: public wxObject
485 wxNonOwnedWindowImpl( wxNonOwnedWindow
* nonownedwnd
) : m_wxPeer(nonownedwnd
)
488 wxNonOwnedWindowImpl()
491 virtual ~wxNonOwnedWindowImpl()
495 virtual void Destroy()
499 virtual void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
500 long style
, long extraStyle
, const wxString
& name
) = 0;
503 virtual WXWindow
GetWXWindow() const = 0;
513 virtual bool Show(bool WXUNUSED(show
))
518 virtual bool ShowWithEffect(bool show
, wxShowEffect
WXUNUSED(effect
), unsigned WXUNUSED(timeout
))
523 virtual void Update()
527 virtual bool SetTransparent(wxByte
WXUNUSED(alpha
))
532 virtual bool SetBackgroundColour(const wxColour
& WXUNUSED(col
) )
537 virtual void SetExtraStyle( long WXUNUSED(exStyle
) )
541 virtual bool SetBackgroundStyle(wxBackgroundStyle
WXUNUSED(style
))
546 bool CanSetTransparent()
551 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const = 0;
552 virtual void MoveWindow(int x
, int y
, int width
, int height
) = 0;
553 virtual void GetPosition( int &x
, int &y
) const = 0;
554 virtual void GetSize( int &width
, int &height
) const = 0;
556 virtual bool SetShape(const wxRegion
& WXUNUSED(region
))
561 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) = 0;
563 virtual bool IsMaximized() const = 0;
565 virtual bool IsIconized() const= 0;
567 virtual void Iconize( bool iconize
)= 0;
569 virtual void Maximize(bool maximize
) = 0;
571 virtual bool IsFullScreen() const= 0;
573 virtual bool ShowFullScreen(bool show
, long style
)= 0;
575 virtual void RequestUserAttention(int flags
) = 0;
577 virtual void ScreenToWindow( int *x
, int *y
) = 0;
579 virtual void WindowToScreen( int *x
, int *y
) = 0;
581 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
583 // static creation methods, must be implemented by all toolkits
585 static wxNonOwnedWindowImpl
* CreateNonOwnedWindow( wxNonOwnedWindow
* wxpeer
, wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
586 long style
, long extraStyle
, const wxString
& name
) ;
589 wxNonOwnedWindow
* m_wxPeer
;
590 DECLARE_ABSTRACT_CLASS(wxNonOwnedWindowImpl
)
595 //---------------------------------------------------------------------------
596 // cocoa bridging utilities
597 //---------------------------------------------------------------------------
599 bool wxMacInitCocoa();
601 class WXDLLIMPEXP_CORE wxMacAutoreleasePool
604 wxMacAutoreleasePool();
605 ~wxMacAutoreleasePool();
612 void wxMacCocoaRelease( void* obj
);
613 void wxMacCocoaAutorelease( void* obj
);
614 void wxMacCocoaRetain( void* obj
);
618 // _WX_PRIVATE_CORE_H_