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 WXDLLEXPORT wxMacPortSaver
37 DECLARE_NO_COPY_CLASS(wxMacPortSaver
)
40 wxMacPortSaver( GrafPtr port
);
48 Clips to the visible region of a control within the current port
51 class WXDLLEXPORT wxMacWindowClipper
: public wxMacPortSaver
53 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
56 wxMacWindowClipper( const wxWindow
* win
);
57 ~wxMacWindowClipper();
60 RgnHandle m_formerClip
;
64 class WXDLLEXPORT wxMacWindowStateSaver
: public wxMacWindowClipper
66 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver
)
69 wxMacWindowStateSaver( const wxWindow
* win
);
70 ~wxMacWindowStateSaver();
73 ThemeDrawingState m_themeDrawingState
;
77 class WXDLLEXPORT wxMacCGContextStateSaver
79 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
82 wxMacCGContextStateSaver( CGContextRef cg
)
85 CGContextSaveGState( cg
);
87 ~wxMacCGContextStateSaver()
89 CGContextRestoreGState( m_cg
);
96 class wxMacDrawingHelper
98 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
101 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false );
102 ~wxMacDrawingHelper();
103 bool Ok() const { return IsOk(); }
104 bool IsOk() { return m_ok; }
105 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); }
106 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); }
107 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); }
108 const Point& GetOrigin() { return m_origin; }
111 GrafPtr m_formerPort;
112 GrafPtr m_currentPort;
113 PenState m_savedPenState;
120 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
121 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
127 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
128 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
131 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
133 Boolean createFolder
);
134 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
136 Boolean createFolder
);
138 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
139 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
140 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
141 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
142 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
143 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
144 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
145 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
146 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
147 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
148 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
149 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
150 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
151 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
152 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
153 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
154 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
155 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
156 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
157 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
158 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
161 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
162 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
163 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
164 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
167 class wxMacCarbonEvent
177 wxMacCarbonEvent( EventRef event
, bool release
= false )
183 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
186 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
193 ReleaseEvent( m_eventRef
);
196 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
198 verify( (m_eventRef
== NULL
) || m_release
);
199 if ( m_eventRef
&& m_release
)
201 ReleaseEvent( m_eventRef
);
205 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
211 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
213 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
215 return GetParameter( inName
, type
, sizeof( T
) , data
);
217 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
219 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
222 template <typename T
> T
GetParameter( EventParamName inName
)
225 verify_noerr( GetParameter
<T
>( inName
, &value
) );
228 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
231 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
235 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
236 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
238 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
240 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
242 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
244 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
246 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
248 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
250 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
254 return ::GetEventClass( m_eventRef
);
258 return ::GetEventKind( m_eventRef
);
262 return ::GetEventTime( m_eventRef
);
266 return EventTimeToTicks( GetTime() );
268 OSStatus
SetCurrentTime( )
270 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
272 OSStatus
SetTime( EventTime when
)
274 return ::SetEventTime( m_eventRef
, when
);
276 operator EventRef () { return m_eventRef
; }
278 bool IsValid() { return m_eventRef
!= 0; }
285 // helper class for allocating and deallocating Universal Proc Ptrs
288 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
291 wxMacUPP( procType
WXUNUSED(proc
) )
294 m_upp
= (*newUPP
)( NULL
);
301 operator uppType() { return m_upp
; }
306 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
308 template <typename refType
> class wxMacCFRefHolder
312 : m_ref(NULL
) , m_release(false)
316 wxMacCFRefHolder( refType ref
, bool release
= true )
317 : m_ref(ref
) , m_release(release
)
328 if ( m_release
&& m_ref
!= NULL
)
341 void Set( refType ref
, bool release
= true )
348 operator refType () const { return m_ref
; }
350 wxMacCFRefHolder
& operator=(refType r
)
359 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
364 class wxMacToolTipTimer
;
372 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
387 PicHandle m_backpict
;
391 wxMacToolTipTimer
* m_timer
;
393 wxMacCFStringHolder m_helpTextRef
;
397 GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
398 void wxMacDestroyGWorld( GWorldPtr gw );
399 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL );
400 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize );
401 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue );
402 CTabHandle wxMacCreateColorTable( int numColors );
404 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
405 void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
406 CGImageRef
wxMacCreateCGImageFromBitmap( const wxBitmap
& bitmap
);
408 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
409 #define MAC_WXHMETAFILE(a) (PicHandle(a))
410 #define MAC_WXHICON(a) (IconRef(a))
411 #define MAC_WXHCURSOR(a) (CursHandle(a))
412 #define MAC_WXHRGN(a) (RgnHandle(a))
413 #define MAC_WXHWND(a) (WindowPtr(a))
414 #define MAC_WXRECPTR(a) ((Rect*)a)
415 #define MAC_WXPOINTPTR(a) ((Point*)a)
416 #define MAC_WXHMENU(a) ((MenuHandle)a)
418 struct wxOpaqueWindowRef
420 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
421 operator WindowRef() { return m_data
; }
426 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
427 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
428 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
429 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
431 WXDLLIMPEXP_CORE wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
432 WXDLLIMPEXP_CORE wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
433 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
435 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
436 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
437 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
439 extern wxWindow
* g_MacLastWindow
;
440 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
441 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
443 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
445 class wxMacControl
: public wxObject
448 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
449 wxMacControl( wxWindow
* peer
, ControlRef control
);
450 wxMacControl( wxWindow
* peer
, WXWidget control
);
452 virtual ~wxMacControl();
456 virtual void Dispose();
458 bool Ok() const { return IsOk(); }
459 bool IsOk() const { return GetControlRef() != NULL
; }
461 void SetReferenceInNativeControl();
462 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
464 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
465 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
467 virtual void SetReference( URefCon data
);
469 void operator= (ControlRef c) { m_controlRef = c; }
470 operator ControlRef () { return m_controlRef; }
471 operator ControlRef * () { return &m_controlRef; }
473 // accessing data and values
475 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
476 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
477 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
478 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
479 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
481 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
483 virtual SInt32
GetValue() const;
484 virtual SInt32
GetMaximum() const;
485 virtual SInt32
GetMinimum() const;
487 virtual void SetValue( SInt32 v
);
488 virtual void SetMinimum( SInt32 v
);
489 virtual void SetMaximum( SInt32 v
);
491 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
492 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
494 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
495 virtual bool HasFocus() const;
496 virtual bool NeedsFocusRect() const;
497 virtual void SetNeedsFocusRect( bool needs
);
501 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
504 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
507 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
509 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
511 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
513 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
515 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
517 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
519 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
521 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
523 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
526 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
528 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
531 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
533 wxASSERT_MSG( err
== noErr
,
534 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
535 inPartCode
, (int)inTag
) );
538 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
541 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
543 template <typename T
> T
GetData( ResType inTag
) const
545 return GetData
<T
>( kControlEntireControl
, inTag
);
548 // Flash the control for the specified amount of time
549 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
551 virtual void VisibilityChanged( bool shown
);
552 virtual void SuperChangedPosition();
555 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
556 virtual void SetBackgroundColour( const wxColour
& col
);
557 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
558 void SetActionProc( ControlActionUPP actionProc
);
559 void SetViewSize( SInt32 viewSize
);
560 SInt32
GetViewSize() const;
562 virtual bool IsVisible() const;
563 virtual void SetVisibility( bool visible
, bool redraw
);
564 virtual bool IsEnabled() const;
565 virtual bool IsActive() const;
566 virtual void Enable( bool enable
);
568 // invalidates this control and all children
569 virtual void InvalidateWithChildren();
570 virtual void SetDrawingEnabled( bool enable
);
571 virtual bool GetNeedsDisplay() const;
573 // where is in native window relative coordinates
574 virtual void SetNeedsDisplay( RgnHandle where
);
575 // where is in native window relative coordinates
576 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
578 // if rect = NULL, entire view
579 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
581 // in native parent window relative coordinates
582 virtual void GetRect( Rect
*r
);
584 // in native parent window relative coordinates
585 virtual void SetRect( Rect
*r
);
587 virtual void GetRectInWindowCoords( Rect
*r
);
588 virtual void GetBestRect( Rect
*r
);
589 virtual void SetLabel( const wxString
&title
);
590 // converts from Toplevel-Content relative to local
591 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
593 virtual void GetFeatures( UInt32
*features
);
594 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
595 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
597 bool IsRootControl() { return m_isRootControl
; }
599 wxWindow
* GetPeer() const
604 // to be moved into a tab control class
606 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
608 ControlRef m_controlRef
;
612 bool m_needsFocusRect
;
613 bool m_isRootControl
;
614 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
617 // ============================================================================
618 // DataBrowser Wrapper
619 // ============================================================================
621 // basing on DataBrowserItemIDs
624 class wxMacDataBrowserControl
: public wxMacControl
627 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
628 wxMacDataBrowserControl() {}
630 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
632 OSStatus
GetItemCount( DataBrowserItemID container
,
634 DataBrowserItemState state
,
635 ItemCount
*numItems
) const;
637 OSStatus
GetItems( DataBrowserItemID container
,
639 DataBrowserItemState state
,
643 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
644 DataBrowserTableViewColumnIndex position
);
646 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
648 OSStatus
AutoSizeColumns();
650 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
651 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
653 OSStatus
SetHeaderButtonHeight( UInt16 height
);
654 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
656 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
657 const DataBrowserItemID
*items
,
658 DataBrowserPropertyID preSortProperty
,
659 DataBrowserPropertyID propertyID
) const;
661 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
662 const DataBrowserItemID
*items
,
663 DataBrowserPropertyID preSortProperty
);
664 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
665 const DataBrowserItemID
*items
,
666 DataBrowserPropertyID preSortProperty
);
667 OSStatus
RevealItem( DataBrowserItemID item
,
668 DataBrowserPropertyID propertyID
,
669 DataBrowserRevealOptions options
) const;
671 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
672 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
673 bool IsItemSelected( DataBrowserItemID item
) const;
674 OSStatus
SetSelectedItems( UInt32 numItems
,
675 const DataBrowserItemID
*items
,
676 DataBrowserSetOption operation
);
678 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
679 DataBrowserItemID
* item
) const;
680 OSStatus
GetItemRow( DataBrowserItemID item
,
681 DataBrowserTableViewRowIndex
* row
) const;
683 OSStatus
SetDefaultRowHeight( UInt16 height
);
684 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
686 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
687 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
689 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
690 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
692 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
693 OSStatus
SetDefaultColumnWidth( UInt16 width
);
695 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
697 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
699 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
700 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
702 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
703 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
705 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
706 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
708 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
709 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
711 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
712 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
714 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
715 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
717 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
720 static pascal void DataBrowserItemNotificationProc(
722 DataBrowserItemID itemID
,
723 DataBrowserItemNotification message
,
724 DataBrowserItemDataRef itemData
);
726 virtual void ItemNotification(
727 DataBrowserItemID itemID
,
728 DataBrowserItemNotification message
,
729 DataBrowserItemDataRef itemData
) = 0;
731 static pascal OSStatus
DataBrowserGetSetItemDataProc(
733 DataBrowserItemID itemID
,
734 DataBrowserPropertyID property
,
735 DataBrowserItemDataRef itemData
,
736 Boolean changeValue
);
738 virtual OSStatus
GetSetItemData(
739 DataBrowserItemID itemID
,
740 DataBrowserPropertyID property
,
741 DataBrowserItemDataRef itemData
,
742 Boolean changeValue
) = 0;
744 static pascal Boolean
DataBrowserCompareProc(
746 DataBrowserItemID itemOneID
,
747 DataBrowserItemID itemTwoID
,
748 DataBrowserPropertyID sortProperty
);
750 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
751 DataBrowserItemID itemTwoID
,
752 DataBrowserPropertyID sortProperty
) = 0;
753 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
756 // ============================================================================
757 // Higher-level Databrowser
758 // ============================================================================
760 // basing on data item objects
765 class wxMacDataItemBrowserControl
;
766 class wxMacListBoxItem
;
768 const DataBrowserPropertyID kTextColumnId
= 1024;
769 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
771 // for multi-column controls, we will use this + the column ID to identify the
772 // column. We don't use kTextColumnId there, and ideally the two should merge.
773 const DataBrowserPropertyID kMinColumnId
= 1050;
775 // base API for high-level databrowser operations
777 class wxMacListControl
780 virtual void MacDelete( unsigned int n
) = 0;
781 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 ) = 0;
782 // returns index of newly created line
783 virtual int MacAppend( const wxString
& item
) = 0;
784 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
785 virtual void MacClear() = 0;
786 virtual void MacDeselectAll() = 0;
787 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
788 virtual int MacGetSelection() const = 0;
789 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
790 virtual bool MacIsSelected( unsigned int n
) const = 0;
791 virtual void MacScrollTo( unsigned int n
) = 0;
792 virtual wxString
MacGetString( unsigned int n
) const = 0;
793 virtual unsigned int MacGetCount() const = 0;
795 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
796 virtual void * MacGetClientData( unsigned int) const = 0;
798 virtual ~wxMacListControl() { }
801 // base class for databrowser items
811 virtual ~wxMacDataItem();
813 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
814 const wxMacDataItem
*,
815 DataBrowserPropertyID property
) const;
817 // returns true if access was successful, otherwise false
818 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
819 DataBrowserPropertyID property
,
820 DataBrowserItemDataRef itemData
,
823 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
824 DataBrowserItemNotification message
,
825 DataBrowserItemDataRef itemData
) const;
827 void SetLabel( const wxString
& str
);
828 const wxString
& GetLabel() const;
830 void SetOrder( SInt32 order
);
831 SInt32
GetOrder() const;
833 void SetData( void* data
);
834 void* GetData() const;
836 void SetColumn( short col
);
841 wxMacCFStringHolder m_cfLabel
;
844 DataBrowserPropertyID m_colId
;
850 SortOrder_Text_Ascending
,
851 SortOrder_Text_Descending
854 typedef wxMacDataItem
* wxMacDataItemPtr
;
855 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
857 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
859 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
862 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
863 wxMacDataItemBrowserControl() {}
864 // create a list item (can be a subclass of wxMacListBoxItem)
866 virtual wxMacDataItem
* CreateItem();
868 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
869 void GetItems(const wxMacDataItem
* container
, bool recurse
,
870 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
872 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
874 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
875 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
877 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
878 DataBrowserPropertyID property
) const;
879 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
880 DataBrowserPropertyID property
) const;
882 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
883 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
885 int GetColumnWidth(int colId
);
886 void SetColumnWidth(int colId
, int width
);
888 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
889 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
891 void RemoveAllItems(wxMacDataItem
*container
);
892 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
893 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
895 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
896 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
897 void SetSelectedAllItems( DataBrowserSetOption option
);
898 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
900 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
902 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
904 // item aware methods, to be used in subclasses
906 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
907 const wxMacDataItem
* itemTwoID
,
908 DataBrowserPropertyID sortProperty
);
910 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
911 DataBrowserPropertyID property
,
912 DataBrowserItemDataRef itemData
,
913 Boolean changeValue
);
915 virtual void ItemNotification(
916 const wxMacDataItem
* itemID
,
917 DataBrowserItemNotification message
,
918 DataBrowserItemDataRef itemData
);
920 // as we are getting the same events for human and API selection we have to suppress
921 // events in the latter case, since this will be used from many subclasses we keep it here
923 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
924 bool SuppressSelection( bool suppress
);
927 // wxMacListControl Methods
930 virtual void MacDelete( unsigned int n
);
931 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 );
932 virtual int MacAppend( const wxString
& item
);
933 virtual void MacClear();
937 virtual void MacDeselectAll();
938 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
939 virtual int MacGetSelection() const;
940 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
941 virtual bool MacIsSelected( unsigned int n
) const;
945 virtual void MacScrollTo( unsigned int n
);
949 virtual void MacSetString( unsigned int n
, const wxString
& item
);
950 virtual void MacSetClientData( unsigned int n
, void * data
);
951 virtual wxString
MacGetString( unsigned int n
) const;
952 virtual void * MacGetClientData( unsigned int) const;
953 virtual unsigned int MacGetCount() const;
957 virtual wxClientDataType
GetClientDataType() const;
958 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
959 //virtual ListSortOrder GetSortOrder() const;
960 //virtual void SetSortOrder(const ListSortOrder sort);
966 ListSortOrder m_sortOrder
;
967 wxClientDataType m_clientDataItemsType
;
969 // ID aware base methods, should be 'final' ie not changed in subclasses
971 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
972 DataBrowserItemID itemTwoID
,
973 DataBrowserPropertyID sortProperty
);
975 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
976 DataBrowserPropertyID property
,
977 DataBrowserItemDataRef itemData
,
978 Boolean changeValue
);
980 virtual void ItemNotification(
981 DataBrowserItemID itemID
,
982 DataBrowserItemNotification message
,
983 DataBrowserItemDataRef itemData
);
988 bool m_suppressSelection
;
989 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
992 class wxMacDataItemBrowserSelectionSuppressor
995 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
996 ~wxMacDataItemBrowserSelectionSuppressor();
1001 wxMacDataItemBrowserControl
* m_browser
;
1004 // ============================================================================
1005 // platform listbox implementation
1006 // ============================================================================
1008 // exposed for reuse in wxCheckListBox
1010 class wxMacListBoxItem
: public wxMacDataItem
1015 virtual ~wxMacListBoxItem();
1017 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
1018 DataBrowserItemNotification message
,
1019 DataBrowserItemDataRef itemData
) const;
1022 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
1025 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
1026 wxMacDataBrowserListControl() {}
1027 virtual ~wxMacDataBrowserListControl();
1029 virtual wxMacDataItem
* CreateItem();
1033 wxWindow
* GetPeer() const;
1035 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
1038 // ============================================================================
1039 // graphics implementation
1040 // ============================================================================
1042 // draw the image 'upside down' corrected as HIViewDrawCGImage does
1044 OSStatus WXDLLEXPORT
wxMacDrawCGImage(
1045 CGContextRef inContext
,
1046 const HIRect
* inBounds
,
1047 CGImageRef inImage
) ;
1049 CGColorRef WXDLLEXPORT
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
1051 CGColorSpaceRef WXDLLEXPORT
wxMacGetGenericRGBColorSpace(void);
1055 class wxMacDeferredWindowDeleter
: public wxObject
1058 wxMacDeferredWindowDeleter( WindowRef windowRef
);
1059 virtual ~wxMacDeferredWindowDeleter();
1062 WindowRef m_macWindow
;
1067 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1070 static UPP sHandler = NULL; \
1071 if ( sHandler == NULL ) \
1072 sHandler = New##UPP( x ); \
1076 //---------------------------------------------------------------------------
1077 // wxMac string conversions
1078 //---------------------------------------------------------------------------
1080 void wxMacSetupConverters();
1081 void wxMacCleanupConverters();
1083 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1084 WXDLLIMPEXP_BASE wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1088 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1089 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1090 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
1096 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
);
1097 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
);
1101 //---------------------------------------------------------------------------
1102 // cocoa bridging utilities
1103 //---------------------------------------------------------------------------
1105 bool wxMacInitCocoa();
1107 class wxMacAutoreleasePool
1110 wxMacAutoreleasePool();
1111 ~wxMacAutoreleasePool();
1118 void wxMacCocoaRelease( void* obj
);
1119 void wxMacCocoaAutorelease( void* obj
);
1120 void wxMacCocoaRetain( void* obj
);
1126 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
1127 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
1128 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
1129 void wxMacCocoaHideCursor();
1130 void wxMacCocoaShowCursor();
1132 typedef struct tagClassicCursor
1139 #else // !wxMAC_USE_COCOA
1143 typedef Cursor ClassicCursor
;
1145 #endif // wxMAC_USE_COCOA
1153 const short kwxCursorBullseye
= 0;
1154 const short kwxCursorBlank
= 1;
1155 const short kwxCursorPencil
= 2;
1156 const short kwxCursorMagnifier
= 3;
1157 const short kwxCursorNoEntry
= 4;
1158 const short kwxCursorPaintBrush
= 5;
1159 const short kwxCursorPointRight
= 6;
1160 const short kwxCursorPointLeft
= 7;
1161 const short kwxCursorQuestionArrow
= 8;
1162 const short kwxCursorRightArrow
= 9;
1163 const short kwxCursorSizeNS
= 10;
1164 const short kwxCursorSize
= 11;
1165 const short kwxCursorSizeNESW
= 12;
1166 const short kwxCursorSizeNWSE
= 13;
1167 const short kwxCursorRoller
= 14;
1168 const short kwxCursorLast
= kwxCursorRoller
;
1170 // exposing our fallback cursor map
1172 extern ClassicCursor gMacCursors
[];