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_
19 #include <Carbon/Carbon.h>
21 #include "wx/mac/corefoundation/cfstring.h"
22 #include "wx/mac/corefoundation/cfdataref.h"
24 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
25 typedef UInt32 URefCon
;
26 typedef SInt32 SRefCon
;
31 #include "wx/listbox.h"
35 class wxMacPortStateHelper
37 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper
)
40 wxMacPortStateHelper( GrafPtr newport
);
41 wxMacPortStateHelper();
42 ~wxMacPortStateHelper();
44 void Setup( GrafPtr newport
);
46 bool IsCleared() { return m_clip
== NULL
; }
47 GrafPtr
GetCurrentPort() { return m_currentPort
; }
50 GrafPtr m_currentPort
;
53 ThemeDrawingState m_drawingState
;
60 class WXDLLEXPORT wxMacPortSaver
62 DECLARE_NO_COPY_CLASS(wxMacPortSaver
)
65 wxMacPortSaver( GrafPtr port
);
71 class WXDLLEXPORT wxMacPortSetter
73 DECLARE_NO_COPY_CLASS(wxMacPortSetter
)
76 wxMacPortSetter( const wxDC
* dc
);
79 wxMacPortStateHelper m_ph
;
84 Clips to the visible region of a control within the current port
87 class WXDLLEXPORT wxMacWindowClipper
: public wxMacPortSaver
89 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
92 wxMacWindowClipper( const wxWindow
* win
);
93 ~wxMacWindowClipper();
96 RgnHandle m_formerClip
;
100 class WXDLLEXPORT wxMacWindowStateSaver
: public wxMacWindowClipper
102 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver
)
105 wxMacWindowStateSaver( const wxWindow
* win
);
106 ~wxMacWindowStateSaver();
109 ThemeDrawingState m_themeDrawingState
;
113 class WXDLLEXPORT wxMacCGContextStateSaver
115 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
118 wxMacCGContextStateSaver( CGContextRef cg
)
121 CGContextSaveGState( cg
);
123 ~wxMacCGContextStateSaver()
125 CGContextRestoreGState( m_cg
);
132 class wxMacDrawingHelper
134 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
137 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false );
138 ~wxMacDrawingHelper();
139 bool Ok() const { return IsOk(); }
140 bool IsOk() { return m_ok; }
141 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); }
142 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); }
143 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); }
144 const Point& GetOrigin() { return m_origin; }
147 GrafPtr m_formerPort;
148 GrafPtr m_currentPort;
149 PenState m_savedPenState;
156 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
157 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
163 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
164 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
167 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
169 Boolean createFolder
);
170 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
172 Boolean createFolder
);
174 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
175 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
176 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
177 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
178 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
179 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
180 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
181 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
182 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
183 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
184 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
185 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
186 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
187 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
188 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
189 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
190 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
191 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
192 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
193 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
194 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
197 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
198 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
199 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
200 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
203 class wxMacCarbonEvent
213 wxMacCarbonEvent( EventRef event
, bool release
= false )
219 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
222 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
229 ReleaseEvent( m_eventRef
);
232 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
234 verify( (m_eventRef
== NULL
) || m_release
);
235 if ( m_eventRef
&& m_release
)
237 ReleaseEvent( m_eventRef
);
241 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
247 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
249 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
251 return GetParameter( inName
, type
, sizeof( T
) , data
);
253 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
255 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
258 template <typename T
> T
GetParameter( EventParamName inName
)
261 verify_noerr( GetParameter
<T
>( inName
, &value
) );
264 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
267 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
271 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
272 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
274 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
276 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
278 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
280 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
282 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
284 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
286 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
290 return ::GetEventClass( m_eventRef
);
294 return ::GetEventKind( m_eventRef
);
298 return ::GetEventTime( m_eventRef
);
302 return EventTimeToTicks( GetTime() );
304 OSStatus
SetCurrentTime( )
306 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
308 OSStatus
SetTime( EventTime when
)
310 return ::SetEventTime( m_eventRef
, when
);
312 operator EventRef () { return m_eventRef
; }
314 bool IsValid() { return m_eventRef
!= 0; }
321 // helper class for allocating and deallocating Universal Proc Ptrs
324 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
327 wxMacUPP( procType
WXUNUSED(proc
) )
330 m_upp
= (*newUPP
)( NULL
);
337 operator uppType() { return m_upp
; }
342 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
344 template <typename refType
> class wxMacCFRefHolder
348 : m_ref(NULL
) , m_release(false)
352 wxMacCFRefHolder( refType ref
, bool release
= true )
353 : m_ref(ref
) , m_release(release
)
364 if ( m_release
&& m_ref
!= NULL
)
377 void Set( refType ref
, bool release
= true )
384 operator refType () const { return m_ref
; }
386 wxMacCFRefHolder
& operator=(refType r
)
395 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
400 class wxMacToolTipTimer
;
408 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
423 PicHandle m_backpict
;
427 wxMacToolTipTimer
* m_timer
;
429 wxMacCFStringHolder m_helpTextRef
;
433 GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
434 void wxMacDestroyGWorld( GWorldPtr gw );
435 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL );
436 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize );
437 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue );
438 CTabHandle wxMacCreateColorTable( int numColors );
440 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
441 void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
442 CGImageRef
wxMacCreateCGImageFromBitmap( const wxBitmap
& bitmap
);
444 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
445 #define MAC_WXHMETAFILE(a) (PicHandle(a))
446 #define MAC_WXHICON(a) (IconRef(a))
447 #define MAC_WXHCURSOR(a) (CursHandle(a))
448 #define MAC_WXHRGN(a) (RgnHandle(a))
449 #define MAC_WXHWND(a) (WindowPtr(a))
450 #define MAC_WXRECPTR(a) ((Rect*)a)
451 #define MAC_WXPOINTPTR(a) ((Point*)a)
452 #define MAC_WXHMENU(a) ((MenuHandle)a)
454 struct wxOpaqueWindowRef
456 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
457 operator WindowRef() { return m_data
; }
462 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
463 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
464 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
465 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
467 WXDLLIMPEXP_CORE wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
468 WXDLLIMPEXP_CORE wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
469 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
471 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
472 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
473 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
475 extern wxWindow
* g_MacLastWindow
;
476 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
477 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
479 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
481 class wxMacControl
: public wxObject
484 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
485 wxMacControl( wxWindow
* peer
, ControlRef control
);
486 wxMacControl( wxWindow
* peer
, WXWidget control
);
488 virtual ~wxMacControl();
492 virtual void Dispose();
494 bool Ok() const { return IsOk(); }
495 bool IsOk() const { return GetControlRef() != NULL
; }
497 void SetReferenceInNativeControl();
498 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
500 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
501 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
503 virtual void SetReference( URefCon data
);
505 void operator= (ControlRef c) { m_controlRef = c; }
506 operator ControlRef () { return m_controlRef; }
507 operator ControlRef * () { return &m_controlRef; }
509 // accessing data and values
511 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
512 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
513 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
514 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
515 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
517 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
519 virtual SInt32
GetValue() const;
520 virtual SInt32
GetMaximum() const;
521 virtual SInt32
GetMinimum() const;
523 virtual void SetValue( SInt32 v
);
524 virtual void SetMinimum( SInt32 v
);
525 virtual void SetMaximum( SInt32 v
);
527 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
528 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
530 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
531 virtual bool HasFocus() const;
532 virtual bool NeedsFocusRect() const;
533 virtual void SetNeedsFocusRect( bool needs
);
537 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
540 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
543 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
545 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
547 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
549 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
551 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
553 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
555 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
557 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
559 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
562 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
564 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
567 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
569 wxASSERT_MSG( err
== noErr
,
570 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
571 inPartCode
, (int)inTag
) );
574 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
577 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
579 template <typename T
> T
GetData( ResType inTag
) const
581 return GetData
<T
>( kControlEntireControl
, inTag
);
584 // Flash the control for the specified amount of time
585 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
587 virtual void VisibilityChanged( bool shown
);
588 virtual void SuperChangedPosition();
591 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
592 virtual void SetBackgroundColour( const wxColour
& col
);
593 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
594 void SetActionProc( ControlActionUPP actionProc
);
595 void SetViewSize( SInt32 viewSize
);
596 SInt32
GetViewSize() const;
598 virtual bool IsVisible() const;
599 virtual void SetVisibility( bool visible
, bool redraw
);
600 virtual bool IsEnabled() const;
601 virtual bool IsActive() const;
602 virtual void Enable( bool enable
);
604 // invalidates this control and all children
605 virtual void InvalidateWithChildren();
606 virtual void SetDrawingEnabled( bool enable
);
607 virtual bool GetNeedsDisplay() const;
609 // where is in native window relative coordinates
610 virtual void SetNeedsDisplay( RgnHandle where
);
611 // where is in native window relative coordinates
612 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
614 // if rect = NULL, entire view
615 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
617 // in native parent window relative coordinates
618 virtual void GetRect( Rect
*r
);
620 // in native parent window relative coordinates
621 virtual void SetRect( Rect
*r
);
623 virtual void GetRectInWindowCoords( Rect
*r
);
624 virtual void GetBestRect( Rect
*r
);
625 virtual void SetLabel( const wxString
&title
);
626 // converts from Toplevel-Content relative to local
627 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
629 virtual void GetFeatures( UInt32
*features
);
630 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
631 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
633 bool IsRootControl() { return m_isRootControl
; }
635 wxWindow
* GetPeer() const
640 // to be moved into a tab control class
642 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
644 ControlRef m_controlRef
;
648 bool m_needsFocusRect
;
649 bool m_isRootControl
;
650 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
653 // ============================================================================
654 // DataBrowser Wrapper
655 // ============================================================================
657 // basing on DataBrowserItemIDs
660 class wxMacDataBrowserControl
: public wxMacControl
663 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
664 wxMacDataBrowserControl() {}
666 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
668 OSStatus
GetItemCount( DataBrowserItemID container
,
670 DataBrowserItemState state
,
671 ItemCount
*numItems
) const;
673 OSStatus
GetItems( DataBrowserItemID container
,
675 DataBrowserItemState state
,
679 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
680 DataBrowserTableViewColumnIndex position
);
682 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
684 OSStatus
AutoSizeColumns();
686 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
687 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
689 OSStatus
SetHeaderButtonHeight( UInt16 height
);
690 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
692 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
693 const DataBrowserItemID
*items
,
694 DataBrowserPropertyID preSortProperty
,
695 DataBrowserPropertyID propertyID
) const;
697 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
698 const DataBrowserItemID
*items
,
699 DataBrowserPropertyID preSortProperty
);
700 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
701 const DataBrowserItemID
*items
,
702 DataBrowserPropertyID preSortProperty
);
703 OSStatus
RevealItem( DataBrowserItemID item
,
704 DataBrowserPropertyID propertyID
,
705 DataBrowserRevealOptions options
) const;
707 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
708 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
709 bool IsItemSelected( DataBrowserItemID item
) const;
710 OSStatus
SetSelectedItems( UInt32 numItems
,
711 const DataBrowserItemID
*items
,
712 DataBrowserSetOption operation
);
714 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
715 DataBrowserItemID
* item
) const;
716 OSStatus
GetItemRow( DataBrowserItemID item
,
717 DataBrowserTableViewRowIndex
* row
) const;
719 OSStatus
SetDefaultRowHeight( UInt16 height
);
720 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
722 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
723 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
725 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
726 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
728 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
729 OSStatus
SetDefaultColumnWidth( UInt16 width
);
731 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
733 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
735 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
736 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
738 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
739 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
741 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
742 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
744 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
745 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
747 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
748 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
750 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
751 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
753 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
756 static pascal void DataBrowserItemNotificationProc(
758 DataBrowserItemID itemID
,
759 DataBrowserItemNotification message
,
760 DataBrowserItemDataRef itemData
);
762 virtual void ItemNotification(
763 DataBrowserItemID itemID
,
764 DataBrowserItemNotification message
,
765 DataBrowserItemDataRef itemData
) = 0;
767 static pascal OSStatus
DataBrowserGetSetItemDataProc(
769 DataBrowserItemID itemID
,
770 DataBrowserPropertyID property
,
771 DataBrowserItemDataRef itemData
,
772 Boolean changeValue
);
774 virtual OSStatus
GetSetItemData(
775 DataBrowserItemID itemID
,
776 DataBrowserPropertyID property
,
777 DataBrowserItemDataRef itemData
,
778 Boolean changeValue
) = 0;
780 static pascal Boolean
DataBrowserCompareProc(
782 DataBrowserItemID itemOneID
,
783 DataBrowserItemID itemTwoID
,
784 DataBrowserPropertyID sortProperty
);
786 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
787 DataBrowserItemID itemTwoID
,
788 DataBrowserPropertyID sortProperty
) = 0;
789 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
792 // ============================================================================
793 // Higher-level Databrowser
794 // ============================================================================
796 // basing on data item objects
801 class wxMacDataItemBrowserControl
;
802 class wxMacListBoxItem
;
804 const DataBrowserPropertyID kTextColumnId
= 1024;
805 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
807 // for multi-column controls, we will use this + the column ID to identify the
808 // column. We don't use kTextColumnId there, and ideally the two should merge.
809 const DataBrowserPropertyID kMinColumnId
= 1050;
811 // base API for high-level databrowser operations
813 class wxMacListControl
816 virtual void MacDelete( unsigned int n
) = 0;
817 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 ) = 0;
818 // returns index of newly created line
819 virtual int MacAppend( const wxString
& item
) = 0;
820 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
821 virtual void MacClear() = 0;
822 virtual void MacDeselectAll() = 0;
823 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
824 virtual int MacGetSelection() const = 0;
825 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
826 virtual bool MacIsSelected( unsigned int n
) const = 0;
827 virtual void MacScrollTo( unsigned int n
) = 0;
828 virtual wxString
MacGetString( unsigned int n
) const = 0;
829 virtual unsigned int MacGetCount() const = 0;
831 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
832 virtual void * MacGetClientData( unsigned int) const = 0;
834 virtual ~wxMacListControl() { }
837 // base class for databrowser items
847 virtual ~wxMacDataItem();
849 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
850 const wxMacDataItem
*,
851 DataBrowserPropertyID property
) const;
853 // returns true if access was successful, otherwise false
854 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
855 DataBrowserPropertyID property
,
856 DataBrowserItemDataRef itemData
,
859 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
860 DataBrowserItemNotification message
,
861 DataBrowserItemDataRef itemData
) const;
863 void SetLabel( const wxString
& str
);
864 const wxString
& GetLabel() const;
866 void SetOrder( SInt32 order
);
867 SInt32
GetOrder() const;
869 void SetData( void* data
);
870 void* GetData() const;
872 void SetColumn( short col
);
877 wxMacCFStringHolder m_cfLabel
;
880 DataBrowserPropertyID m_colId
;
886 SortOrder_Text_Ascending
,
887 SortOrder_Text_Descending
890 typedef wxMacDataItem
* wxMacDataItemPtr
;
891 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
893 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
895 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
898 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
899 wxMacDataItemBrowserControl() {}
900 // create a list item (can be a subclass of wxMacListBoxItem)
902 virtual wxMacDataItem
* CreateItem();
904 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
905 void GetItems(const wxMacDataItem
* container
, bool recurse
,
906 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
908 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
910 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
911 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
913 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
914 DataBrowserPropertyID property
) const;
915 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
916 DataBrowserPropertyID property
) const;
918 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
919 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
921 int GetColumnWidth(int colId
);
922 void SetColumnWidth(int colId
, int width
);
924 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
925 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
927 void RemoveAllItems(wxMacDataItem
*container
);
928 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
929 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
931 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
932 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
933 void SetSelectedAllItems( DataBrowserSetOption option
);
934 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
936 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
938 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
940 // item aware methods, to be used in subclasses
942 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
943 const wxMacDataItem
* itemTwoID
,
944 DataBrowserPropertyID sortProperty
);
946 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
947 DataBrowserPropertyID property
,
948 DataBrowserItemDataRef itemData
,
949 Boolean changeValue
);
951 virtual void ItemNotification(
952 const wxMacDataItem
* itemID
,
953 DataBrowserItemNotification message
,
954 DataBrowserItemDataRef itemData
);
956 // as we are getting the same events for human and API selection we have to suppress
957 // events in the latter case, since this will be used from many subclasses we keep it here
959 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
960 bool SuppressSelection( bool suppress
);
963 // wxMacListControl Methods
966 virtual void MacDelete( unsigned int n
);
967 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 );
968 virtual int MacAppend( const wxString
& item
);
969 virtual void MacClear();
973 virtual void MacDeselectAll();
974 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
975 virtual int MacGetSelection() const;
976 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
977 virtual bool MacIsSelected( unsigned int n
) const;
981 virtual void MacScrollTo( unsigned int n
);
985 virtual void MacSetString( unsigned int n
, const wxString
& item
);
986 virtual void MacSetClientData( unsigned int n
, void * data
);
987 virtual wxString
MacGetString( unsigned int n
) const;
988 virtual void * MacGetClientData( unsigned int) const;
989 virtual unsigned int MacGetCount() const;
993 virtual wxClientDataType
GetClientDataType() const;
994 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
995 //virtual ListSortOrder GetSortOrder() const;
996 //virtual void SetSortOrder(const ListSortOrder sort);
1002 ListSortOrder m_sortOrder
;
1003 wxClientDataType m_clientDataItemsType
;
1005 // ID aware base methods, should be 'final' ie not changed in subclasses
1007 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
1008 DataBrowserItemID itemTwoID
,
1009 DataBrowserPropertyID sortProperty
);
1011 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
1012 DataBrowserPropertyID property
,
1013 DataBrowserItemDataRef itemData
,
1014 Boolean changeValue
);
1016 virtual void ItemNotification(
1017 DataBrowserItemID itemID
,
1018 DataBrowserItemNotification message
,
1019 DataBrowserItemDataRef itemData
);
1024 bool m_suppressSelection
;
1025 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
1028 class wxMacDataItemBrowserSelectionSuppressor
1031 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
1032 ~wxMacDataItemBrowserSelectionSuppressor();
1037 wxMacDataItemBrowserControl
* m_browser
;
1040 // ============================================================================
1041 // platform listbox implementation
1042 // ============================================================================
1044 // exposed for reuse in wxCheckListBox
1046 class wxMacListBoxItem
: public wxMacDataItem
1051 virtual ~wxMacListBoxItem();
1053 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
1054 DataBrowserItemNotification message
,
1055 DataBrowserItemDataRef itemData
) const;
1058 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
1061 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
1062 wxMacDataBrowserListControl() {}
1063 virtual ~wxMacDataBrowserListControl();
1065 virtual wxMacDataItem
* CreateItem();
1069 wxWindow
* GetPeer() const;
1071 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
1074 // ============================================================================
1075 // graphics implementation
1076 // ============================================================================
1078 // draw the image 'upside down' corrected as HIViewDrawCGImage does
1080 OSStatus WXDLLEXPORT
wxMacDrawCGImage(
1081 CGContextRef inContext
,
1082 const HIRect
* inBounds
,
1083 CGImageRef inImage
) ;
1085 CGColorRef
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
1087 CGColorSpaceRef
wxMacGetGenericRGBColorSpace(void);
1089 void wxMacMemoryBufferReleaseProc(void *info
, const void *data
, size_t size
);
1093 class wxMacDeferredWindowDeleter
: public wxObject
1096 wxMacDeferredWindowDeleter( WindowRef windowRef
);
1097 virtual ~wxMacDeferredWindowDeleter();
1100 WindowRef m_macWindow
;
1105 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1108 static UPP sHandler = NULL; \
1109 if ( sHandler == NULL ) \
1110 sHandler = New##UPP( x ); \
1114 //---------------------------------------------------------------------------
1115 // wxMac string conversions
1116 //---------------------------------------------------------------------------
1118 void wxMacSetupConverters();
1119 void wxMacCleanupConverters();
1121 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1122 WXDLLIMPEXP_BASE wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1126 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1127 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1128 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
1134 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
);
1135 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
);
1139 //---------------------------------------------------------------------------
1140 // cocoa bridging utilities
1141 //---------------------------------------------------------------------------
1143 bool wxMacInitCocoa();
1145 class wxMacAutoreleasePool
1148 wxMacAutoreleasePool();
1149 ~wxMacAutoreleasePool();
1156 void wxMacCocoaRelease( void* obj
);
1157 void wxMacCocoaAutorelease( void* obj
);
1158 void wxMacCocoaRetain( void* obj
);
1164 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
1165 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
1166 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
1167 void wxMacCocoaHideCursor();
1168 void wxMacCocoaShowCursor();
1170 typedef struct tagClassicCursor
1177 #else // !wxMAC_USE_COCOA
1181 typedef Cursor ClassicCursor
;
1183 #endif // wxMAC_USE_COCOA
1191 const short kwxCursorBullseye
= 0;
1192 const short kwxCursorBlank
= 1;
1193 const short kwxCursorPencil
= 2;
1194 const short kwxCursorMagnifier
= 3;
1195 const short kwxCursorNoEntry
= 4;
1196 const short kwxCursorPaintBrush
= 5;
1197 const short kwxCursorPointRight
= 6;
1198 const short kwxCursorPointLeft
= 7;
1199 const short kwxCursorQuestionArrow
= 8;
1200 const short kwxCursorRightArrow
= 9;
1201 const short kwxCursorSizeNS
= 10;
1202 const short kwxCursorSize
= 11;
1203 const short kwxCursorSizeNESW
= 12;
1204 const short kwxCursorSizeNWSE
= 13;
1205 const short kwxCursorRoller
= 14;
1206 const short kwxCursorLast
= kwxCursorRoller
;
1208 // exposing our fallback cursor map
1210 extern ClassicCursor gMacCursors
[];