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_
20 # include <Carbon/Carbon.h>
22 # include <Debugging.h>
23 # include <Quickdraw.h>
24 # include <Appearance.h>
26 # include <Controls.h>
27 # include <ControlDefinitions.h>
31 # include <CoreServices.h>
34 #if UNIVERSAL_INTERFACES_VERSION < 0x0342
35 #error "please update to Apple's latest universal headers from http://developer.apple.com/sdk/"
38 #ifndef MAC_OS_X_VERSION_10_3
39 #define MAC_OS_X_VERSION_10_3 1030
42 #ifndef MAC_OS_X_VERSION_10_4
43 #define MAC_OS_X_VERSION_10_4 1040
46 #ifdef __WXMAC_CARBON__
47 #include "wx/mac/corefoundation/cfstring.h"
51 // as macro in FixMath.h for 10.3
52 inline Fixed
IntToFixed( int inInt
)
54 return (((SInt32
) inInt
) << 16);
57 inline int FixedToInt( Fixed inFixed
)
59 return (((SInt32
) inFixed
) >> 16);
65 #include "wx/listbox.h"
67 class wxMacPortStateHelper
69 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper
)
72 wxMacPortStateHelper( GrafPtr newport
);
73 wxMacPortStateHelper();
74 ~wxMacPortStateHelper();
76 void Setup( GrafPtr newport
);
78 bool IsCleared() { return m_clip
== NULL
; }
79 GrafPtr
GetCurrentPort() { return m_currentPort
; }
82 GrafPtr m_currentPort
;
85 ThemeDrawingState m_drawingState
;
92 class WXDLLEXPORT wxMacPortSaver
94 DECLARE_NO_COPY_CLASS(wxMacPortSaver
)
97 wxMacPortSaver( GrafPtr port
);
103 class WXDLLEXPORT wxMacPortSetter
105 DECLARE_NO_COPY_CLASS(wxMacPortSetter
)
108 wxMacPortSetter( const wxDC
* dc
);
111 wxMacPortStateHelper m_ph
;
116 Clips to the visible region of a control within the current port
119 class WXDLLEXPORT wxMacWindowClipper
: public wxMacPortSaver
121 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
124 wxMacWindowClipper( const wxWindow
* win
);
125 ~wxMacWindowClipper();
128 RgnHandle m_formerClip
;
132 class WXDLLEXPORT wxMacWindowStateSaver
: public wxMacWindowClipper
134 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver
)
137 wxMacWindowStateSaver( const wxWindow
* win
);
138 ~wxMacWindowStateSaver();
141 ThemeDrawingState m_themeDrawingState
;
144 #if wxMAC_USE_CORE_GRAPHICS
145 class WXDLLEXPORT wxMacCGContextStateSaver
147 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
150 wxMacCGContextStateSaver( CGContextRef cg
)
153 CGContextSaveGState( cg
);
155 ~wxMacCGContextStateSaver()
157 CGContextRestoreGState( m_cg
);
165 class wxMacDrawingHelper
167 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
170 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false );
171 ~wxMacDrawingHelper();
172 bool Ok() { return m_ok; }
173 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); }
174 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); }
175 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); }
176 const Point& GetOrigin() { return m_origin; }
179 GrafPtr m_formerPort;
180 GrafPtr m_currentPort;
181 PenState m_savedPenState;
187 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
192 WXDLLEXPORT wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
193 WXDLLEXPORT
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
196 WXDLLEXPORT wxString
wxMacFindFolderNoSeparator(short vRefNum
,
198 Boolean createFolder
);
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 #if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 )
224 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
226 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
227 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
230 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
231 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
232 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
233 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
236 class wxMacCarbonEvent
246 wxMacCarbonEvent( EventRef event
, bool release
= false )
252 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
255 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
262 ReleaseEvent( m_eventRef
);
265 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
267 verify( (m_eventRef
== NULL
) || m_release
);
268 if ( m_eventRef
&& m_release
)
270 ReleaseEvent( m_eventRef
);
274 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
280 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
282 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
284 return GetParameter( inName
, type
, sizeof( T
) , data
);
286 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
288 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
291 template <typename T
> T
GetParameter( EventParamName inName
)
294 verify_noerr( GetParameter
<T
>( inName
, &value
) );
297 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
300 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
304 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
305 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
307 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
309 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
311 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
313 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
315 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
317 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
319 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
323 return ::GetEventClass( m_eventRef
);
327 return ::GetEventKind( m_eventRef
);
331 return ::GetEventTime( m_eventRef
);
335 return EventTimeToTicks( GetTime() );
337 OSStatus
SetCurrentTime( )
339 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
341 OSStatus
SetTime( EventTime when
)
343 return ::SetEventTime( m_eventRef
, when
);
345 operator EventRef () { return m_eventRef
; }
347 bool IsValid() { return m_eventRef
!= 0; }
354 // helper class for allocating and deallocating Universal Proc Ptrs
357 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
360 wxMacUPP( procType proc
)
363 m_upp
= (*newUPP
)( NULL
);
370 operator uppType() { return m_upp
; }
375 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
377 template <typename refType
> class wxMacCFRefHolder
381 : m_ref(NULL
) , m_release(false)
385 wxMacCFRefHolder( refType ref
, bool release
= true )
386 : m_ref(ref
) , m_release(release
)
397 if ( m_release
&& m_ref
!= NULL
)
410 void Set( refType ref
, bool release
= true )
417 operator refType () const { return m_ref
; }
423 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
429 GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
430 void wxMacDestroyGWorld( GWorldPtr gw );
431 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL );
432 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize );
433 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue );
434 CTabHandle wxMacCreateColorTable( int numColors );
436 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
437 void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
439 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
440 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
441 #define MAC_WXHMETAFILE(a) (PicHandle(a))
442 #define MAC_WXHICON(a) (IconRef(a))
443 #define MAC_WXHCURSOR(a) (CursHandle(a))
444 #define MAC_WXHRGN(a) (RgnHandle(a))
445 #define MAC_WXHWND(a) (WindowPtr(a))
446 #define MAC_WXRECPTR(a) ((Rect*)a)
447 #define MAC_WXPOINTPTR(a) ((Point*)a)
448 #define MAC_WXHMENU(a) ((MenuHandle)a)
450 struct wxOpaqueWindowRef
452 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
453 operator WindowRef() { return m_data
; }
458 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
459 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
460 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
461 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
463 wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
464 wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
465 wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
467 int wxMacCommandToId( UInt32 macCommandId
);
468 UInt32
wxIdToMacCommand( int wxId
);
469 wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
471 extern wxWindow
* g_MacLastWindow
;
472 pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
473 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
475 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
480 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
481 wxMacControl( wxWindow
* peer
, ControlRef control
);
482 wxMacControl( wxWindow
* peer
, WXWidget control
);
483 virtual ~wxMacControl();
487 virtual void Dispose();
489 bool Ok() const { return GetControlRef() != NULL
; }
491 void SetReferenceInNativeControl();
492 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
494 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
495 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
497 virtual void SetReference( SInt32 data
);
499 void operator= (ControlRef c) { m_controlRef = c; }
500 operator ControlRef () { return m_controlRef; }
501 operator ControlRef * () { return &m_controlRef; }
503 // accessing data and values
505 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
506 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
507 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
508 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
509 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
511 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
513 virtual SInt32
GetValue() const;
514 virtual SInt32
GetMaximum() const;
515 virtual SInt32
GetMinimum() const;
517 virtual void SetValue( SInt32 v
);
518 virtual void SetMinimum( SInt32 v
);
519 virtual void SetMaximum( SInt32 v
);
521 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
522 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
524 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
525 virtual bool HasFocus() const;
526 virtual bool NeedsFocusRect() const;
527 virtual void SetNeedsFocusRect( bool needs
);
531 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
534 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
537 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
539 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
541 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
543 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
545 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
547 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
549 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
551 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
553 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
556 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
558 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
561 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
563 wxASSERT_MSG( err
== noErr
,
564 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
565 inPartCode
, (int)inTag
) );
568 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
571 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
573 template <typename T
> T
GetData( ResType inTag
) const
575 return GetData
<T
>( kControlEntireControl
, inTag
);
578 // Flash the control for the specified amount of time
579 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
581 virtual void VisibilityChanged( bool shown
);
582 virtual void SuperChangedPosition();
585 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
586 virtual void SetBackground( const wxBrush
&brush
);
587 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
588 void SetActionProc( ControlActionUPP actionProc
);
589 void SetViewSize( SInt32 viewSize
);
590 SInt32
GetViewSize() const;
592 virtual bool IsVisible() const;
593 virtual void SetVisibility( bool visible
, bool redraw
);
594 virtual bool IsEnabled() const;
595 virtual bool IsActive() const;
596 virtual void Enable( bool enable
);
598 // invalidates this control and all children
599 virtual void InvalidateWithChildren();
600 virtual void SetDrawingEnabled( bool enable
);
602 virtual bool GetNeedsDisplay() const;
604 // where is in native window relative coordinates
605 virtual void SetNeedsDisplay( RgnHandle where
);
606 // where is in native window relative coordinates
607 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
609 // if rect = NULL, entire view
610 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
612 // in native parent window relative coordinates
613 virtual void GetRect( Rect
*r
);
615 // in native parent window relative coordinates
616 virtual void SetRect( Rect
*r
);
618 virtual void GetRectInWindowCoords( Rect
*r
);
619 virtual void GetBestRect( Rect
*r
);
620 virtual void SetLabel( const wxString
&title
);
621 // converts from Toplevel-Content relative to local
622 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
624 virtual void GetFeatures( UInt32
*features
);
625 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
626 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
628 bool IsCompositing() { return m_isCompositing
; }
629 bool IsRootControl() { return m_isRootControl
; }
631 wxWindow
* GetPeer() const
636 // to be moved into a tab control class
638 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
640 ControlRef m_controlRef
;
644 bool m_needsFocusRect
;
645 bool m_isCompositing
;
646 bool m_isRootControl
;
649 // ============================================================================
650 // DataBrowser Wrapper
651 // ============================================================================
653 // basing on DataBrowserItemIDs
656 class wxMacDataBrowserControl
: public wxMacControl
659 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
661 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
663 OSStatus
GetItemCount( DataBrowserItemID container
,
665 DataBrowserItemState state
,
666 UInt32
*numItems
) const;
668 OSStatus
GetItems( DataBrowserItemID container
,
670 DataBrowserItemState state
,
674 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
675 DataBrowserTableViewColumnIndex position
);
677 OSStatus
AutoSizeColumns();
679 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
680 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
682 OSStatus
SetHeaderButtonHeight( UInt16 height
);
683 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
685 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
686 const DataBrowserItemID
*items
,
687 DataBrowserPropertyID preSortProperty
,
688 DataBrowserPropertyID propertyID
) const;
690 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
691 const DataBrowserItemID
*items
,
692 DataBrowserPropertyID preSortProperty
);
693 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
694 const DataBrowserItemID
*items
,
695 DataBrowserPropertyID preSortProperty
);
696 OSStatus
RevealItem( DataBrowserItemID item
,
697 DataBrowserPropertyID propertyID
,
698 DataBrowserRevealOptions options
) const;
700 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
701 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
702 bool IsItemSelected( DataBrowserItemID item
) const;
703 OSStatus
SetSelectedItems( UInt32 numItems
,
704 const DataBrowserItemID
*items
,
705 DataBrowserSetOption operation
);
707 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
708 DataBrowserItemID
* item
) const;
709 OSStatus
GetItemRow( DataBrowserItemID item
,
710 DataBrowserTableViewRowIndex
* row
) const;
712 OSStatus
SetDefaultRowHeight( UInt16 height
);
713 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
715 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
716 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
718 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
719 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
721 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
722 OSStatus
SetDefaultColumnWidth( UInt16 width
);
724 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
726 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, UInt32
*position
) const;
727 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, UInt32 position
);
729 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
730 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
732 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
733 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
735 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
736 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
738 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
739 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
741 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
742 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
744 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
747 static pascal void DataBrowserItemNotificationProc(
749 DataBrowserItemID itemID
,
750 DataBrowserItemNotification message
,
751 DataBrowserItemDataRef itemData
);
753 virtual void ItemNotification(
754 DataBrowserItemID itemID
,
755 DataBrowserItemNotification message
,
756 DataBrowserItemDataRef itemData
) = 0;
758 static pascal OSStatus
DataBrowserGetSetItemDataProc(
760 DataBrowserItemID itemID
,
761 DataBrowserPropertyID property
,
762 DataBrowserItemDataRef itemData
,
763 Boolean changeValue
);
765 virtual OSStatus
GetSetItemData(
766 DataBrowserItemID itemID
,
767 DataBrowserPropertyID property
,
768 DataBrowserItemDataRef itemData
,
769 Boolean changeValue
) = 0;
771 static pascal Boolean
DataBrowserCompareProc(
773 DataBrowserItemID itemOneID
,
774 DataBrowserItemID itemTwoID
,
775 DataBrowserPropertyID sortProperty
);
777 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
778 DataBrowserItemID itemTwoID
,
779 DataBrowserPropertyID sortProperty
) = 0;
782 // ============================================================================
783 // Higher-level Databrowser
784 // ============================================================================
786 // basing on data item objects
791 class wxMacDataItemBrowserControl
;
793 // base class for databrowser items
799 virtual ~wxMacDataItem();
801 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
802 const wxMacDataItem
*,
803 DataBrowserPropertyID property
) const;
805 // returns true if access was successful, otherwise false
806 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
807 DataBrowserPropertyID property
,
808 DataBrowserItemDataRef itemData
,
811 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
812 DataBrowserItemNotification message
,
813 DataBrowserItemDataRef itemData
) const;
816 typedef wxMacDataItem
* wxMacDataItemPtr
;
817 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
819 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
821 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
824 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
826 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
827 void GetItems(const wxMacDataItem
* container
, bool recurse
,
828 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
830 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
831 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
833 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
834 DataBrowserPropertyID property
) const;
835 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
836 DataBrowserPropertyID property
) const;
838 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
839 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
841 void RemoveAllItems(wxMacDataItem
*container
);
842 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
843 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
845 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
846 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
847 void SetSelectedAllItems( DataBrowserSetOption option
);
848 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
850 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
852 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
854 // item aware methods, to be used in subclasses
856 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
857 const wxMacDataItem
* itemTwoID
,
858 DataBrowserPropertyID sortProperty
);
860 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
861 DataBrowserPropertyID property
,
862 DataBrowserItemDataRef itemData
,
863 Boolean changeValue
);
865 virtual void ItemNotification(
866 const wxMacDataItem
* itemID
,
867 DataBrowserItemNotification message
,
868 DataBrowserItemDataRef itemData
);
870 // as we are getting the same events for human and API selection we have to suppress
871 // events in the latter case, since this will be used from many subclasses we keep it here
873 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
874 bool SuppressSelection( bool suppress
);
877 // ID aware base methods, should be 'final' ie not changed in subclasses
879 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
880 DataBrowserItemID itemTwoID
,
881 DataBrowserPropertyID sortProperty
);
883 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
884 DataBrowserPropertyID property
,
885 DataBrowserItemDataRef itemData
,
886 Boolean changeValue
);
888 virtual void ItemNotification(
889 DataBrowserItemID itemID
,
890 DataBrowserItemNotification message
,
891 DataBrowserItemDataRef itemData
);
895 bool m_suppressSelection
;
898 class wxMacDataItemBrowserSelectionSuppressor
901 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
902 ~wxMacDataItemBrowserSelectionSuppressor();
907 wxMacDataItemBrowserControl
* m_browser
;
910 // ============================================================================
911 // platform listbox implementation
912 // ============================================================================
914 // exposed for reuse in wxCheckListBox
916 class wxMacListBoxItem
: public wxMacDataItem
921 virtual ~wxMacListBoxItem();
923 void SetLabel( const wxString
& str
);
924 const wxString
& GetLabel() const;
926 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
927 const wxMacDataItem
* rhs
,
928 DataBrowserPropertyID sortProperty
) const;
930 virtual OSStatus
GetSetData( wxMacDataItemBrowserControl
*owner
,
931 DataBrowserPropertyID property
,
932 DataBrowserItemDataRef itemData
,
935 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
936 DataBrowserItemNotification message
,
937 DataBrowserItemDataRef itemData
) const;
939 void SetOrder( SInt32 order
);
940 SInt32
GetOrder() const;
942 void SetData( void* data
);
943 void* GetData() const;
947 wxMacCFStringHolder m_cfLabel
;
952 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
, public wxMacListControl
955 wxMacDataBrowserListControl( wxListBox
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
956 ~wxMacDataBrowserListControl();
958 // create a list item (can be a subclass of wxMacListBoxItem)
960 virtual wxMacListBoxItem
* CreateItem();
964 void MacDelete( unsigned int n
);
965 void MacInsert( unsigned int n
, const wxString
& item
);
966 void MacInsert( unsigned int n
, const wxArrayString
& items
);
967 int MacAppend( const wxString
& item
);
972 void MacDeselectAll();
973 void MacSetSelection( unsigned int n
, bool select
);
974 int MacGetSelection() const;
975 int MacGetSelections( wxArrayInt
& aSelections
) const;
976 bool MacIsSelected( unsigned int n
) const;
980 void MacScrollTo( unsigned int n
);
984 void MacSetString( unsigned int n
, const wxString
& item
);
985 void MacSetClientData( unsigned int n
, void * data
);
986 wxString
MacGetString( unsigned int n
) const;
987 void * MacGetClientData( unsigned int) const;
988 unsigned int MacGetCount() const;
992 wxClientDataType
GetClientDataType() const;
993 void SetClientDataType(wxClientDataType clientDataItemsType
);
997 wxListBox
* GetPeer() const;
1000 wxClientDataType m_clientDataItemsType
;
1003 // ============================================================================
1004 // graphics implementation
1005 // ============================================================================
1007 #if wxMAC_USE_CORE_GRAPHICS
1009 class WXDLLEXPORT wxMacCGPath
: public wxGraphicPath
1011 DECLARE_NO_COPY_CLASS(wxMacCGPath
)
1016 // Starts a new subpath at
1017 void MoveToPoint( wxCoord x1
, wxCoord y1
);
1018 void AddLineToPoint( wxCoord x1
, wxCoord y1
);
1019 void AddQuadCurveToPoint( wxCoord cx1
, wxCoord cy1
, wxCoord x1
, wxCoord y1
);
1020 void AddRectangle( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1021 void AddCircle( wxCoord x
, wxCoord y
, wxCoord r
);
1023 // closes the current subpath
1024 void CloseSubpath();
1026 CGPathRef
GetPath() const;
1028 CGMutablePathRef m_path
;
1031 class WXDLLEXPORT wxMacCGContext
: public wxGraphicContext
1033 DECLARE_NO_COPY_CLASS(wxMacCGContext
)
1036 wxMacCGContext( CGrafPtr port
);
1037 wxMacCGContext( CGContextRef cgcontext
);
1041 virtual void Clip( const wxRegion
®ion
);
1042 virtual void StrokePath( const wxGraphicPath
*p
);
1043 virtual void DrawPath( const wxGraphicPath
*p
, int fillStyle
= wxWINDING_RULE
);
1044 virtual void FillPath( const wxGraphicPath
*p
, const wxColor
&fillColor
, int fillStyle
= wxWINDING_RULE
);
1046 virtual wxGraphicPath
* CreatePath();
1047 virtual void SetPen( const wxPen
&pen
) ;
1048 virtual void SetBrush( const wxBrush
&brush
);
1049 CGContextRef
GetNativeContext();
1050 void SetNativeContext( CGContextRef cg
);
1051 CGPathDrawingMode
GetDrawingMode() const { return m_mode
; }
1053 CGContextRef m_cgContext
;
1055 CGPathDrawingMode m_mode
;
1060 #endif // wxMAC_USE_CORE_GRAPHICS
1062 #ifdef __WXMAC_OSX__
1064 CGColorSpaceRef
wxMacGetGenericRGBColorSpace(void);
1065 void wxMacMemoryBufferReleaseProc(void *info
, const void *data
, size_t size
);
1069 class WXDLLEXPORT wxBitmapRefData
: public wxGDIRefData
1071 DECLARE_NO_COPY_CLASS(wxBitmapRefData
)
1073 friend class WXDLLEXPORT wxIcon
;
1074 friend class WXDLLEXPORT wxCursor
;
1076 wxBitmapRefData(int width
, int height
, int depth
);
1081 bool Ok() const { return m_ok
; }
1082 void SetOk( bool isOk
) { m_ok
= isOk
; }
1084 void SetWidth( int width
) { m_width
= width
; }
1085 void SetHeight( int height
) { m_height
= height
; }
1086 void SetDepth( int depth
) { m_depth
= depth
; }
1088 int GetWidth() const { return m_width
; }
1089 int GetHeight() const { return m_height
; }
1090 int GetDepth() const { return m_depth
; }
1092 void *GetRawAccess() const;
1093 void *BeginRawAccess();
1094 void EndRawAccess();
1096 bool HasAlpha() const { return m_hasAlpha
; }
1097 void UseAlpha( bool useAlpha
);
1101 wxPalette m_bitmapPalette
;
1102 #endif // wxUSE_PALETTE
1104 wxMask
* m_bitmapMask
; // Optional mask
1105 #ifdef __WXMAC_OSX__
1106 CGImageRef
CGImageCreate() const;
1109 // returns true if the bitmap has a size that
1110 // can be natively transferred into a true icon
1111 // if no is returned GetIconRef will still produce
1112 // an icon but it will be generated via a PICT and
1113 // rescaled to 16 x 16
1114 bool HasNativeSize();
1116 // caller should increase ref count if needed longer
1117 // than the bitmap exists
1118 IconRef
GetIconRef();
1120 // returns a Pict from the bitmap content
1121 PicHandle
GetPictHandle();
1122 GWorldPtr
GetHBITMAP(GWorldPtr
* mask
= NULL
) const;
1123 void UpdateAlphaMask() const;
1126 bool Create(int width
, int height
, int depth
);
1134 wxMemoryBuffer m_memBuf
;
1135 int m_rawAccessCount
;
1137 #ifdef __WXMAC_OSX__
1138 mutable CGImageRef m_cgImageRef
;
1141 PicHandle m_pictHandle
;
1142 GWorldPtr m_hBitmap
;
1143 GWorldPtr m_hMaskBitmap
;
1144 wxMemoryBuffer m_maskMemBuf
;
1145 int m_maskBytesPerRow
;
1148 class WXDLLEXPORT wxIconRefData
: public wxGDIRefData
1152 wxIconRefData( WXHICON
);
1153 virtual ~wxIconRefData() { Free(); }
1156 virtual void Free();
1158 void SetWidth( int width
) { m_width
= width
; }
1159 void SetHeight( int height
) { m_height
= height
; }
1161 int GetWidth() const { return m_width
; }
1162 int GetHeight() const { return m_height
; }
1164 WXHICON
GetHICON() const { return (WXHICON
) m_iconRef
; }
1173 ControlRef
wxMacFindControlUnderMouse( wxTopLevelWindowMac
* toplevelWindow
, const Point
& location
, WindowRef window
, ControlPartCode
*outPart
);
1175 #ifdef WORDS_BIGENDIAN
1176 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1178 *rect
= (**pict
).picFrame
;
1182 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1184 return QDGetPictureBounds( pict
, rect
);
1190 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1193 static UPP sHandler = NULL; \
1194 if ( sHandler == NULL ) \
1195 sHandler = New##UPP( x ); \
1199 //---------------------------------------------------------------------------
1200 // wxMac string conversions
1201 //---------------------------------------------------------------------------
1203 void wxMacSetupConverters();
1204 void wxMacCleanupConverters();
1206 void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1207 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1211 wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1212 OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1213 wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);