1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/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
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_PRIVATE_H_
15 #define _WX_PRIVATE_H_
21 # include <Carbon/Carbon.h>
23 # include <Debugging.h>
24 # include <Quickdraw.h>
25 # include <Appearance.h>
27 # include <Controls.h>
28 # include <ControlDefinitions.h>
32 # include <CoreServices.h>
35 #if UNIVERSAL_INTERFACES_VERSION < 0x0342
36 #error "please update to Apple's lastest universal headers from http://developer.apple.com/sdk/"
39 #ifndef MAC_OS_X_VERSION_10_3
40 #define MAC_OS_X_VERSION_10_3 1030
43 #ifndef MAC_OS_X_VERSION_10_4
44 #define MAC_OS_X_VERSION_10_4 1040
47 #ifdef __WXMAC_CARBON__
48 #include "wx/mac/corefoundation/cfstring.h"
52 // as macro in FixMath.h for 10.3
53 inline Fixed
IntToFixed( int inInt
)
55 return (((SInt32
) inInt
) << 16);
58 inline int FixedToInt( Fixed inFixed
)
60 return (((SInt32
) inFixed
) >> 16);
67 #include "wx/window.h"
68 #include "wx/toplevel.h"
70 class wxMacPortStateHelper
72 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper
)
75 wxMacPortStateHelper( GrafPtr newport
) ;
76 wxMacPortStateHelper() ;
77 ~wxMacPortStateHelper() ;
79 void Setup( GrafPtr newport
) ;
81 bool IsCleared() { return m_clip
== NULL
; }
82 GrafPtr
GetCurrentPort() { return m_currentPort
; }
85 GrafPtr m_currentPort
;
88 ThemeDrawingState m_drawingState
;
95 class WXDLLEXPORT wxMacPortSaver
97 DECLARE_NO_COPY_CLASS(wxMacPortSaver
)
100 wxMacPortSaver( GrafPtr port
);
106 class WXDLLEXPORT wxMacPortSetter
108 DECLARE_NO_COPY_CLASS(wxMacPortSetter
)
111 wxMacPortSetter( const wxDC
* dc
) ;
114 wxMacPortStateHelper m_ph
;
119 Clips to the visible region of a control within the current port
122 class WXDLLEXPORT wxMacWindowClipper
: public wxMacPortSaver
124 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
127 wxMacWindowClipper( const wxWindow
* win
) ;
128 ~wxMacWindowClipper() ;
131 RgnHandle m_formerClip
;
132 RgnHandle m_newClip
;
135 class WXDLLEXPORT wxMacWindowStateSaver
: public wxMacWindowClipper
137 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver
)
140 wxMacWindowStateSaver( const wxWindow
* win
) ;
141 ~wxMacWindowStateSaver() ;
144 ThemeDrawingState m_themeDrawingState
;
147 #if wxMAC_USE_CORE_GRAPHICS
148 class WXDLLEXPORT wxMacCGContextStateSaver
150 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
153 wxMacCGContextStateSaver( CGContextRef cg
)
156 CGContextSaveGState( cg
) ;
158 ~wxMacCGContextStateSaver()
160 CGContextRestoreGState( m_cg
) ;
168 class wxMacDrawingHelper
170 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
173 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ) ;
174 ~wxMacDrawingHelper() ;
175 bool Ok() { return m_ok ; }
176 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ) ; }
177 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ) ; }
178 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ) ; }
179 const Point& GetOrigin() { return m_origin ; }
182 GrafPtr m_formerPort ;
183 GrafPtr m_currentPort ;
184 PenState m_savedPenState ;
190 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
) ;
195 WXDLLEXPORT wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
) ;
196 WXDLLEXPORT
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
) ;
199 WXDLLEXPORT wxString
wxMacFindFolder(short vRefNum
,
201 Boolean createFolder
);
203 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ) ; return 0 ; }
204 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
205 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
206 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
207 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
208 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
209 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
210 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
211 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
212 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
213 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
214 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
215 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
216 #if TARGET_API_MAC_OSX
217 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
218 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
219 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
220 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
221 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
223 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
224 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
225 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
228 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr ; }
229 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus ; }
230 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex ; }
231 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr ; }
234 class wxMacCarbonEvent
244 wxMacCarbonEvent( EventRef event
, bool release
= false )
247 m_release
= release
;
250 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
253 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) ) ;
260 ReleaseEvent( m_eventRef
) ;
263 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
265 verify( (m_eventRef
== NULL
) || m_release
) ;
266 if ( m_eventRef
&& m_release
)
268 ReleaseEvent( m_eventRef
) ;
272 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) ;
278 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
) ;
280 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
282 return GetParameter( inName
, type
, sizeof( T
) , data
) ;
284 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
286 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
) ;
289 template <typename T
> T
GetParameter( EventParamName inName
)
292 verify_noerr( GetParameter
<T
>( inName
, &value
) ) ;
295 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
298 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) ) ;
302 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
) ;
303 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
305 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
) ;
307 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
309 return SetParameter
<T
>( inName
, inDesiredType
, &data
) ;
311 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
313 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
) ;
315 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
317 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
) ;
321 return ::GetEventClass( m_eventRef
) ;
325 return ::GetEventKind( m_eventRef
) ;
329 return ::GetEventTime( m_eventRef
) ;
333 return EventTimeToTicks( GetTime() ) ;
335 OSStatus
SetCurrentTime( )
337 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() ) ;
339 OSStatus
SetTime( EventTime when
)
341 return ::SetEventTime( m_eventRef
, when
) ;
343 operator EventRef () { return m_eventRef
; }
345 bool IsValid() { return m_eventRef
!= 0 ; }
347 EventRef m_eventRef
;
352 // helper class for allocating and deallocating Universal Proc Ptrs
355 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
358 wxMacUPP( procType proc
)
361 m_upp
= (*newUPP
)( NULL
) ;
366 disposeUPP( m_upp
) ;
368 operator uppType() { return m_upp
; }
373 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
375 template <typename refType
> class wxMacCFRefHolder
379 : m_ref(NULL
) , m_release(false)
383 wxMacCFRefHolder( refType ref
, bool release
= true )
384 : m_ref(ref
) , m_release(release
)
395 if ( m_release
&& m_ref
!= NULL
)
402 refType val
= m_ref
;
408 void Set( refType ref
, bool release
= true )
411 m_release
= release
;
415 operator refType () const { return m_ref
; }
421 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
426 GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
427 void wxMacDestroyGWorld( GWorldPtr gw ) ;
428 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
429 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
430 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
431 CTabHandle wxMacCreateColorTable( int numColors ) ;
433 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 ) ;
434 void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
) ;
436 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
437 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
438 #define MAC_WXHMETAFILE(a) (PicHandle(a))
439 #define MAC_WXHICON(a) (IconRef(a))
440 #define MAC_WXHCURSOR(a) (CursHandle(a))
441 #define MAC_WXHRGN(a) (RgnHandle(a))
442 #define MAC_WXHWND(a) (WindowPtr(a))
443 #define MAC_WXRECPTR(a) ((Rect*)a)
444 #define MAC_WXPOINTPTR(a) ((Point*)a)
445 #define MAC_WXHMENU(a) ((MenuHandle)a)
447 struct wxOpaqueWindowRef
449 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
450 operator WindowRef() { return m_data
; }
455 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
) ;
456 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
) ;
457 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
) ;
458 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
) ;
460 wxWindow
* wxFindControlFromMacControl(ControlRef inControl
) ;
461 wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
) ;
462 wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
) ;
464 int wxMacCommandToId( UInt32 macCommandId
) ;
465 UInt32
wxIdToMacCommand( int wxId
) ;
466 wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
) ;
468 extern wxWindow
* g_MacLastWindow
;
469 pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
) ;
470 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true ) ;
472 ControlActionUPP
GetwxMacLiveScrollbarActionProc() ;
477 wxMacControl( wxWindow
* peer
, bool isRootControl
= false ) ;
478 wxMacControl( wxWindow
* peer
, ControlRef control
) ;
479 wxMacControl( wxWindow
* peer
, WXWidget control
) ;
480 virtual ~wxMacControl() ;
484 virtual void Dispose() ;
486 bool Ok() const { return GetControlRef() != NULL
; }
488 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
489 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
491 virtual void SetReference( SInt32 data
) ;
493 void operator= (ControlRef c) { m_controlRef = c ; }
494 operator ControlRef () { return m_controlRef; }
495 operator ControlRef * () { return &m_controlRef; }
497 // accessing data and values
499 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
) ;
500 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const ;
501 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const ;
502 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 ) ;
503 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 ) ;
505 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 ) ;
507 virtual SInt32
GetValue() const ;
508 virtual SInt32
GetMaximum() const ;
509 virtual SInt32
GetMinimum() const ;
511 virtual void SetValue( SInt32 v
) ;
512 virtual void SetMinimum( SInt32 v
) ;
513 virtual void SetMaximum( SInt32 v
) ;
515 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
) ;
516 virtual void SetRange( SInt32 minimum
, SInt32 maximum
) ;
518 virtual OSStatus
SetFocus( ControlFocusPart focusPart
) ;
519 virtual bool HasFocus() const ;
520 virtual bool NeedsFocusRect() const ;
521 virtual void SetNeedsFocusRect( bool needs
) ;
525 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
528 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) ) ;
531 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
533 return SetData( inPartCode
, inTag
, sizeof( T
) , data
) ;
535 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
537 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
) ;
539 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
541 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
) ;
543 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
545 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
) ;
547 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
550 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
) ;
552 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
555 verify_noerr( GetData
<T
>( inPartCode
, inTag
, &value
) ) ;
558 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
561 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
) ;
563 template <typename T
> T
GetData( ResType inTag
) const
566 verify_noerr( GetData
<T
>( kControlEntireControl
, inTag
, &value
) ) ;
570 // Flash the control for the specified amount of time
571 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 ) ;
573 virtual void VisibilityChanged( bool shown
) ;
574 virtual void SuperChangedPosition() ;
577 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
) ;
578 virtual void SetBackground( const wxBrush
&brush
) ;
579 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
) ;
580 void SetActionProc( ControlActionUPP actionProc
) ;
581 void SetViewSize( SInt32 viewSize
) ;
582 SInt32
GetViewSize() const ;
584 virtual bool IsVisible() const ;
585 virtual void SetVisibility( bool visible
, bool redraw
) ;
586 virtual bool IsEnabled() const ;
587 virtual bool IsActive() const ;
588 virtual void Enable( bool enable
) ;
590 // invalidates this control and all children
591 virtual void InvalidateWithChildren() ;
592 virtual void SetDrawingEnabled( bool enable
) ;
594 virtual bool GetNeedsDisplay() const ;
596 // where is in native window relative coordinates
597 virtual void SetNeedsDisplay( RgnHandle where
) ;
598 // where is in native window relative coordinates
599 virtual void SetNeedsDisplay( Rect
* where
= NULL
) ;
601 // if rect = NULL, entire view
602 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
) ;
604 // in native parent window relative coordinates
605 virtual void GetRect( Rect
*r
) ;
607 // in native parent window relative coordinates
608 virtual void SetRect( Rect
*r
) ;
610 virtual void GetRectInWindowCoords( Rect
*r
) ;
611 virtual void GetBestRect( Rect
*r
) ;
612 virtual void SetLabel( const wxString
&title
) ;
613 // converts from Toplevel-Content relative to local
614 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
) ;
616 virtual void GetFeatures( UInt32
*features
) ;
617 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
) ;
618 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
) ;
619 // to be moved into a databrowser subclass
621 virtual OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
) ;
622 virtual OSStatus
AddListViewColumn( DataBrowserListViewColumnDesc
*columnDesc
,
623 DataBrowserTableViewColumnIndex position
) ;
624 virtual OSStatus
AutoSizeListViewColumns() ;
625 virtual OSStatus
SetHasScrollBars( bool horiz
, bool vert
) ;
626 virtual OSStatus
SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
) ;
627 virtual OSStatus
SetListViewHeaderBtnHeight(UInt16 height
) ;
628 virtual OSStatus
SetCallbacks(const DataBrowserCallbacks
* callbacks
) ;
629 virtual OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
630 const DataBrowserItemID
* items
,
631 DataBrowserPropertyID preSortProperty
,
632 DataBrowserPropertyID propertyID
) ;
633 virtual OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
634 const DataBrowserItemID
* items
,
635 DataBrowserPropertyID preSortProperty
) ;
636 virtual OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
637 const DataBrowserItemID
* items
,
638 DataBrowserPropertyID preSortProperty
) ;
639 virtual OSStatus
RevealItem( DataBrowserItemID item
,
640 DataBrowserPropertyID propertyID
,
641 DataBrowserRevealOptions options
) ;
642 virtual OSStatus
GetSelectionAnchor( DataBrowserItemID
* first
, DataBrowserItemID
* last
) ;
643 virtual bool IsItemSelected( DataBrowserItemID item
) ;
644 virtual OSStatus
SetSelectedItems(UInt32 numItems
,
645 const DataBrowserItemID
* items
,
646 DataBrowserSetOption operation
) ;
648 // to be moved into a tab control class
650 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
) ;
651 bool IsCompositing() { return m_isCompositing
; }
652 bool IsRootControl() { return m_isRootControl
; }
654 ControlRef m_controlRef
;
658 bool m_needsFocusRect
;
659 bool m_isCompositing
;
660 bool m_isRootControl
;
663 #if wxMAC_USE_CORE_GRAPHICS
665 class WXDLLEXPORT wxMacCGPath
: public wxGraphicPath
667 DECLARE_NO_COPY_CLASS(wxMacCGPath
)
672 // Starts a new subpath at
673 void MoveToPoint( wxCoord x1
, wxCoord y1
) ;
674 void AddLineToPoint( wxCoord x1
, wxCoord y1
) ;
675 void AddQuadCurveToPoint( wxCoord cx1
, wxCoord cy1
, wxCoord x1
, wxCoord y1
) ;
676 void AddRectangle( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) ;
677 void AddCircle( wxCoord x
, wxCoord y
, wxCoord r
) ;
679 // closes the current subpath
680 void CloseSubpath() ;
682 CGPathRef
GetPath() const ;
684 CGMutablePathRef m_path
;
687 class WXDLLEXPORT wxMacCGContext
: public wxGraphicContext
689 DECLARE_NO_COPY_CLASS(wxMacCGContext
)
692 wxMacCGContext( CGrafPtr port
) ;
693 wxMacCGContext( CGContextRef cgcontext
) ;
697 virtual void Clip( const wxRegion
®ion
) ;
698 virtual void StrokePath( const wxGraphicPath
*p
) ;
699 virtual void DrawPath( const wxGraphicPath
*p
, int fillStyle
= wxWINDING_RULE
) ;
700 virtual void FillPath( const wxGraphicPath
*p
, const wxColor
&fillColor
, int fillStyle
= wxWINDING_RULE
) ;
702 virtual wxGraphicPath
* CreatePath() ;
703 virtual void SetPen( const wxPen
&pen
) ;
704 virtual void SetBrush( const wxBrush
&brush
) ;
705 CGContextRef
GetNativeContext() ;
706 void SetNativeContext( CGContextRef cg
) ;
707 CGPathDrawingMode
GetDrawingMode() const { return m_mode
; }
709 CGContextRef m_cgContext
;
711 CGPathDrawingMode m_mode
;
716 #endif // wxMAC_USE_CORE_GRAPHICS
720 CGColorSpaceRef
wxMacGetGenericRGBColorSpace(void) ;
721 void wxMacMemoryBufferReleaseProc(void *info
, const void *data
, size_t size
) ;
725 class WXDLLEXPORT wxBitmapRefData
: public wxGDIRefData
727 DECLARE_NO_COPY_CLASS(wxBitmapRefData
)
729 friend class WXDLLEXPORT wxIcon
;
730 friend class WXDLLEXPORT wxCursor
;
732 wxBitmapRefData(int width
, int height
, int depth
);
737 bool Ok() const { return m_ok
; }
738 void SetOk( bool isOk
) { m_ok
= isOk
; }
740 void SetWidth( int width
) { m_width
= width
; }
741 void SetHeight( int height
) { m_height
= height
; }
742 void SetDepth( int depth
) { m_depth
= depth
; }
744 int GetWidth() const { return m_width
; }
745 int GetHeight() const { return m_height
; }
746 int GetDepth() const { return m_depth
; }
748 void *GetRawAccess() const ;
749 void *BeginRawAccess() ;
750 void EndRawAccess() ;
752 bool HasAlpha() const { return m_hasAlpha
; }
753 void UseAlpha( bool useAlpha
) ;
757 wxPalette m_bitmapPalette
;
758 #endif // wxUSE_PALETTE
760 wxMask
* m_bitmapMask
; // Optional mask
762 CGImageRef
CGImageCreate() const ;
765 // returns true if the bitmap has a size that
766 // can be natively transferred into a true icon
767 // if no is returned GetIconRef will still produce
768 // an icon but it will be generated via a PICT and
769 // rescaled to 16 x 16
770 bool HasNativeSize() ;
772 // caller should increase ref count if needed longer
773 // than the bitmap exists
774 IconRef
GetIconRef() ;
776 // returns a Pict from the bitmap content
777 PicHandle
GetPictHandle() ;
778 GWorldPtr
GetHBITMAP(GWorldPtr
* mask
= NULL
) const ;
779 void UpdateAlphaMask() const ;
782 bool Create(int width
, int height
, int depth
) ;
790 wxMemoryBuffer m_memBuf
;
791 int m_rawAccessCount
;
794 mutable CGImageRef m_cgImageRef
;
797 PicHandle m_pictHandle
;
799 GWorldPtr m_hMaskBitmap
;
800 wxMemoryBuffer m_maskMemBuf
;
801 int m_maskBytesPerRow
;
804 class WXDLLEXPORT wxIconRefData
: public wxGDIRefData
808 wxIconRefData( WXHICON
) ;
809 virtual ~wxIconRefData() { Free(); }
814 void SetWidth( int width
) { m_width
= width
; }
815 void SetHeight( int height
) { m_height
= height
; }
817 int GetWidth() const { return m_width
; }
818 int GetHeight() const { return m_height
; }
820 WXHICON
GetHICON() const { return (WXHICON
) m_iconRef
; }
829 ControlRef
wxMacFindControlUnderMouse( wxTopLevelWindowMac
* toplevelWindow
, const Point
& location
, WindowRef window
, ControlPartCode
*outPart
) ;
832 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
834 *rect
= (**pict
).picFrame
;
838 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
840 return QDGetPictureBounds( pict
, rect
) ;
846 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
849 static UPP sHandler = NULL; \
850 if ( sHandler == NULL ) \
851 sHandler = New##UPP( x ); \
855 //---------------------------------------------------------------------------
856 // wxMac string conversions
857 //---------------------------------------------------------------------------
859 void wxMacSetupConverters() ;
860 void wxMacCleanupConverters() ;
862 void wxMacStringToPascal( const wxString
&from
, StringPtr to
) ;
863 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
) ;
867 wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
) ;
868 OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
) ;
869 wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
) ;