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
);
97 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
98 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
104 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
105 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
108 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
110 Boolean createFolder
);
111 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
113 Boolean createFolder
);
115 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
116 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
117 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
118 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
119 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
120 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
121 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
122 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
123 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
124 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
125 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
126 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
127 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
128 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
129 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
130 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
131 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
132 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
133 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
134 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
135 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
138 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
139 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
140 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
141 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
144 class wxMacCarbonEvent
154 wxMacCarbonEvent( EventRef event
, bool release
= false )
160 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
163 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
170 ReleaseEvent( m_eventRef
);
173 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
175 verify( (m_eventRef
== NULL
) || m_release
);
176 if ( m_eventRef
&& m_release
)
178 ReleaseEvent( m_eventRef
);
182 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
188 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
190 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
192 return GetParameter( inName
, type
, sizeof( T
) , data
);
194 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
196 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
199 template <typename T
> T
GetParameter( EventParamName inName
)
202 verify_noerr( GetParameter
<T
>( inName
, &value
) );
205 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
208 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
212 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
213 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
215 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
217 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
219 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
221 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
223 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
225 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
227 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
231 return ::GetEventClass( m_eventRef
);
235 return ::GetEventKind( m_eventRef
);
239 return ::GetEventTime( m_eventRef
);
243 return EventTimeToTicks( GetTime() );
245 OSStatus
SetCurrentTime( )
247 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
249 OSStatus
SetTime( EventTime when
)
251 return ::SetEventTime( m_eventRef
, when
);
253 operator EventRef () { return m_eventRef
; }
255 bool IsValid() { return m_eventRef
!= 0; }
262 // helper class for allocating and deallocating Universal Proc Ptrs
265 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
268 wxMacUPP( procType
WXUNUSED(proc
) )
271 m_upp
= (*newUPP
)( NULL
);
278 operator uppType() { return m_upp
; }
283 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
285 template <typename refType
> class wxMacCFRefHolder
289 : m_ref(NULL
) , m_release(false)
293 wxMacCFRefHolder( refType ref
, bool release
= true )
294 : m_ref(ref
) , m_release(release
)
305 if ( m_release
&& m_ref
!= NULL
)
318 void Set( refType ref
, bool release
= true )
325 operator refType () const { return m_ref
; }
327 wxMacCFRefHolder
& operator=(refType r
)
336 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
341 class wxMacToolTipTimer
;
349 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
364 PicHandle m_backpict
;
368 wxMacToolTipTimer
* m_timer
;
370 wxMacCFStringHolder m_helpTextRef
;
375 WXDLLIMPEXP_CORE
void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
376 WXDLLIMPEXP_CORE
void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
377 WXDLLIMPEXP_CORE CGImageRef
wxMacCreateCGImageFromBitmap( const wxBitmap
& bitmap
);
379 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithCFData( CFDataRef data
);
380 WXDLLIMPEXP_CORE CGDataConsumerRef
wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data
);
381 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer
& buf
);
384 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
385 #define MAC_WXHMETAFILE(a) (PicHandle(a))
386 #define MAC_WXHICON(a) (IconRef(a))
387 #define MAC_WXHCURSOR(a) (CursHandle(a))
388 #define MAC_WXHRGN(a) (RgnHandle(a))
389 #define MAC_WXHWND(a) (WindowPtr(a))
390 #define MAC_WXRECPTR(a) ((Rect*)a)
391 #define MAC_WXPOINTPTR(a) ((Point*)a)
392 #define MAC_WXHMENU(a) ((MenuHandle)a)
394 struct wxOpaqueWindowRef
396 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
397 operator WindowRef() { return m_data
; }
402 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
403 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
404 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
405 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
407 WXDLLIMPEXP_CORE wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
408 WXDLLIMPEXP_CORE wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
409 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
411 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
412 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
413 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
415 extern wxWindow
* g_MacLastWindow
;
416 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
417 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
419 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
421 class wxMacControl
: public wxObject
424 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
425 wxMacControl( wxWindow
* peer
, ControlRef control
);
426 wxMacControl( wxWindow
* peer
, WXWidget control
);
428 virtual ~wxMacControl();
432 virtual void Dispose();
434 bool Ok() const { return IsOk(); }
435 bool IsOk() const { return GetControlRef() != NULL
; }
437 void SetReferenceInNativeControl();
438 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
440 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
441 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
443 virtual void SetReference( URefCon data
);
445 void operator= (ControlRef c) { m_controlRef = c; }
446 operator ControlRef () { return m_controlRef; }
447 operator ControlRef * () { return &m_controlRef; }
449 // accessing data and values
451 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
452 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
453 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
454 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
455 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
457 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
459 virtual SInt32
GetValue() const;
460 virtual SInt32
GetMaximum() const;
461 virtual SInt32
GetMinimum() const;
463 virtual void SetValue( SInt32 v
);
464 virtual void SetMinimum( SInt32 v
);
465 virtual void SetMaximum( SInt32 v
);
467 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
468 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
470 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
471 virtual bool HasFocus() const;
472 virtual bool NeedsFocusRect() const;
473 virtual void SetNeedsFocusRect( bool needs
);
477 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
480 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
483 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
485 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
487 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
489 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
491 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
493 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
495 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
497 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
499 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
502 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
504 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
507 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
509 wxASSERT_MSG( err
== noErr
,
510 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
511 inPartCode
, (int)inTag
) );
514 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
517 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
519 template <typename T
> T
GetData( ResType inTag
) const
521 return GetData
<T
>( kControlEntireControl
, inTag
);
524 // Flash the control for the specified amount of time
525 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
527 virtual void VisibilityChanged( bool shown
);
528 virtual void SuperChangedPosition();
531 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
532 virtual void SetBackgroundColour( const wxColour
& col
);
533 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
534 void SetActionProc( ControlActionUPP actionProc
);
535 void SetViewSize( SInt32 viewSize
);
536 SInt32
GetViewSize() const;
538 virtual bool IsVisible() const;
539 virtual void SetVisibility( bool visible
, bool redraw
);
540 virtual bool IsEnabled() const;
541 virtual bool IsActive() const;
542 virtual void Enable( bool enable
);
544 // invalidates this control and all children
545 virtual void InvalidateWithChildren();
546 virtual void SetDrawingEnabled( bool enable
);
547 virtual bool GetNeedsDisplay() const;
549 // where is in native window relative coordinates
550 virtual void SetNeedsDisplay( RgnHandle where
);
551 // where is in native window relative coordinates
552 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
554 // if rect = NULL, entire view
555 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
557 // in native parent window relative coordinates
558 virtual void GetRect( Rect
*r
);
560 // in native parent window relative coordinates
561 virtual void SetRect( Rect
*r
);
563 virtual void GetRectInWindowCoords( Rect
*r
);
564 virtual void GetBestRect( Rect
*r
);
565 virtual void SetLabel( const wxString
&title
);
566 // converts from Toplevel-Content relative to local
567 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
569 virtual void GetFeatures( UInt32
*features
);
570 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
571 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
573 bool IsRootControl() { return m_isRootControl
; }
575 wxWindow
* GetPeer() const
580 // to be moved into a tab control class
582 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
584 ControlRef m_controlRef
;
588 bool m_needsFocusRect
;
589 bool m_isRootControl
;
590 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
593 // ============================================================================
594 // DataBrowser Wrapper
595 // ============================================================================
597 // basing on DataBrowserItemIDs
600 class wxMacDataBrowserControl
: public wxMacControl
603 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
604 wxMacDataBrowserControl() {}
606 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
608 OSStatus
GetItemCount( DataBrowserItemID container
,
610 DataBrowserItemState state
,
611 ItemCount
*numItems
) const;
613 OSStatus
GetItems( DataBrowserItemID container
,
615 DataBrowserItemState state
,
619 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
620 DataBrowserTableViewColumnIndex position
);
622 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
624 OSStatus
AutoSizeColumns();
626 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
627 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
629 OSStatus
SetHeaderButtonHeight( UInt16 height
);
630 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
632 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
633 const DataBrowserItemID
*items
,
634 DataBrowserPropertyID preSortProperty
,
635 DataBrowserPropertyID propertyID
) const;
637 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
638 const DataBrowserItemID
*items
,
639 DataBrowserPropertyID preSortProperty
);
640 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
641 const DataBrowserItemID
*items
,
642 DataBrowserPropertyID preSortProperty
);
643 OSStatus
RevealItem( DataBrowserItemID item
,
644 DataBrowserPropertyID propertyID
,
645 DataBrowserRevealOptions options
) const;
647 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
648 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
649 bool IsItemSelected( DataBrowserItemID item
) const;
650 OSStatus
SetSelectedItems( UInt32 numItems
,
651 const DataBrowserItemID
*items
,
652 DataBrowserSetOption operation
);
654 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
655 DataBrowserItemID
* item
) const;
656 OSStatus
GetItemRow( DataBrowserItemID item
,
657 DataBrowserTableViewRowIndex
* row
) const;
659 OSStatus
SetDefaultRowHeight( UInt16 height
);
660 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
662 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
663 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
665 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
666 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
668 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
669 OSStatus
SetDefaultColumnWidth( UInt16 width
);
671 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
673 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
675 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
676 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
678 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
679 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
681 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
682 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
684 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
685 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
687 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
688 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
690 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
691 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
693 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
696 static pascal void DataBrowserItemNotificationProc(
698 DataBrowserItemID itemID
,
699 DataBrowserItemNotification message
,
700 DataBrowserItemDataRef itemData
);
702 virtual void ItemNotification(
703 DataBrowserItemID itemID
,
704 DataBrowserItemNotification message
,
705 DataBrowserItemDataRef itemData
) = 0;
707 static pascal OSStatus
DataBrowserGetSetItemDataProc(
709 DataBrowserItemID itemID
,
710 DataBrowserPropertyID property
,
711 DataBrowserItemDataRef itemData
,
712 Boolean changeValue
);
714 virtual OSStatus
GetSetItemData(
715 DataBrowserItemID itemID
,
716 DataBrowserPropertyID property
,
717 DataBrowserItemDataRef itemData
,
718 Boolean changeValue
) = 0;
720 static pascal Boolean
DataBrowserCompareProc(
722 DataBrowserItemID itemOneID
,
723 DataBrowserItemID itemTwoID
,
724 DataBrowserPropertyID sortProperty
);
726 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
727 DataBrowserItemID itemTwoID
,
728 DataBrowserPropertyID sortProperty
) = 0;
729 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
732 // ============================================================================
733 // Higher-level Databrowser
734 // ============================================================================
736 // basing on data item objects
741 class wxMacDataItemBrowserControl
;
742 class wxMacListBoxItem
;
744 const DataBrowserPropertyID kTextColumnId
= 1024;
745 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
747 // for multi-column controls, we will use this + the column ID to identify the
748 // column. We don't use kTextColumnId there, and ideally the two should merge.
749 const DataBrowserPropertyID kMinColumnId
= 1050;
751 // base API for high-level databrowser operations
753 class wxMacListControl
756 virtual void MacDelete( unsigned int n
) = 0;
757 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 ) = 0;
758 // returns index of newly created line
759 virtual int MacAppend( const wxString
& item
) = 0;
760 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
761 virtual void MacClear() = 0;
762 virtual void MacDeselectAll() = 0;
763 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
764 virtual int MacGetSelection() const = 0;
765 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
766 virtual bool MacIsSelected( unsigned int n
) const = 0;
767 virtual void MacScrollTo( unsigned int n
) = 0;
768 virtual wxString
MacGetString( unsigned int n
) const = 0;
769 virtual unsigned int MacGetCount() const = 0;
771 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
772 virtual void * MacGetClientData( unsigned int) const = 0;
774 virtual ~wxMacListControl() { }
777 // base class for databrowser items
787 virtual ~wxMacDataItem();
789 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
790 const wxMacDataItem
*,
791 DataBrowserPropertyID property
) const;
793 // returns true if access was successful, otherwise false
794 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
795 DataBrowserPropertyID property
,
796 DataBrowserItemDataRef itemData
,
799 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
800 DataBrowserItemNotification message
,
801 DataBrowserItemDataRef itemData
) const;
803 void SetLabel( const wxString
& str
);
804 const wxString
& GetLabel() const;
806 void SetOrder( SInt32 order
);
807 SInt32
GetOrder() const;
809 void SetData( void* data
);
810 void* GetData() const;
812 void SetColumn( short col
);
817 wxMacCFStringHolder m_cfLabel
;
820 DataBrowserPropertyID m_colId
;
826 SortOrder_Text_Ascending
,
827 SortOrder_Text_Descending
830 typedef wxMacDataItem
* wxMacDataItemPtr
;
831 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
833 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
835 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
838 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
839 wxMacDataItemBrowserControl() {}
840 // create a list item (can be a subclass of wxMacListBoxItem)
842 virtual wxMacDataItem
* CreateItem();
844 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
845 void GetItems(const wxMacDataItem
* container
, bool recurse
,
846 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
848 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
850 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
851 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
853 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
854 DataBrowserPropertyID property
) const;
855 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
856 DataBrowserPropertyID property
) const;
858 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
859 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
861 int GetColumnWidth(int colId
);
862 void SetColumnWidth(int colId
, int width
);
864 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
865 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
867 void RemoveAllItems(wxMacDataItem
*container
);
868 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
869 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
871 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
872 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
873 void SetSelectedAllItems( DataBrowserSetOption option
);
874 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
876 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
878 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
880 // item aware methods, to be used in subclasses
882 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
883 const wxMacDataItem
* itemTwoID
,
884 DataBrowserPropertyID sortProperty
);
886 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
887 DataBrowserPropertyID property
,
888 DataBrowserItemDataRef itemData
,
889 Boolean changeValue
);
891 virtual void ItemNotification(
892 const wxMacDataItem
* itemID
,
893 DataBrowserItemNotification message
,
894 DataBrowserItemDataRef itemData
);
896 // as we are getting the same events for human and API selection we have to suppress
897 // events in the latter case, since this will be used from many subclasses we keep it here
899 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
900 bool SuppressSelection( bool suppress
);
903 // wxMacListControl Methods
906 virtual void MacDelete( unsigned int n
);
907 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 );
908 virtual int MacAppend( const wxString
& item
);
909 virtual void MacClear();
913 virtual void MacDeselectAll();
914 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
915 virtual int MacGetSelection() const;
916 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
917 virtual bool MacIsSelected( unsigned int n
) const;
921 virtual void MacScrollTo( unsigned int n
);
925 virtual void MacSetString( unsigned int n
, const wxString
& item
);
926 virtual void MacSetClientData( unsigned int n
, void * data
);
927 virtual wxString
MacGetString( unsigned int n
) const;
928 virtual void * MacGetClientData( unsigned int) const;
929 virtual unsigned int MacGetCount() const;
933 virtual wxClientDataType
GetClientDataType() const;
934 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
935 //virtual ListSortOrder GetSortOrder() const;
936 //virtual void SetSortOrder(const ListSortOrder sort);
942 ListSortOrder m_sortOrder
;
943 wxClientDataType m_clientDataItemsType
;
945 // ID aware base methods, should be 'final' ie not changed in subclasses
947 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
948 DataBrowserItemID itemTwoID
,
949 DataBrowserPropertyID sortProperty
);
951 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
952 DataBrowserPropertyID property
,
953 DataBrowserItemDataRef itemData
,
954 Boolean changeValue
);
956 virtual void ItemNotification(
957 DataBrowserItemID itemID
,
958 DataBrowserItemNotification message
,
959 DataBrowserItemDataRef itemData
);
964 bool m_suppressSelection
;
965 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
968 class wxMacDataItemBrowserSelectionSuppressor
971 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
972 ~wxMacDataItemBrowserSelectionSuppressor();
977 wxMacDataItemBrowserControl
* m_browser
;
980 // ============================================================================
981 // platform listbox implementation
982 // ============================================================================
984 // exposed for reuse in wxCheckListBox
986 class wxMacListBoxItem
: public wxMacDataItem
991 virtual ~wxMacListBoxItem();
993 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
994 DataBrowserItemNotification message
,
995 DataBrowserItemDataRef itemData
) const;
998 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
1001 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
1002 wxMacDataBrowserListControl() {}
1003 virtual ~wxMacDataBrowserListControl();
1005 virtual wxMacDataItem
* CreateItem();
1009 wxWindow
* GetPeer() const;
1011 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
1014 // ============================================================================
1015 // graphics implementation
1016 // ============================================================================
1018 // draw the image 'upside down' corrected as HIViewDrawCGImage does
1020 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
1021 CGContextRef inContext
,
1022 const HIRect
* inBounds
,
1023 CGImageRef inImage
) ;
1025 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
1027 CGColorSpaceRef WXDLLIMPEXP_CORE
wxMacGetGenericRGBColorSpace(void);
1031 class wxMacDeferredWindowDeleter
: public wxObject
1034 wxMacDeferredWindowDeleter( WindowRef windowRef
);
1035 virtual ~wxMacDeferredWindowDeleter();
1038 WindowRef m_macWindow
;
1043 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1046 static UPP sHandler = NULL; \
1047 if ( sHandler == NULL ) \
1048 sHandler = New##UPP( x ); \
1052 //---------------------------------------------------------------------------
1053 // wxMac string conversions
1054 //---------------------------------------------------------------------------
1056 void wxMacSetupConverters();
1057 void wxMacCleanupConverters();
1059 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1060 WXDLLIMPEXP_BASE wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1064 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1065 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1066 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
1072 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
);
1073 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
);
1077 //---------------------------------------------------------------------------
1078 // cocoa bridging utilities
1079 //---------------------------------------------------------------------------
1081 bool wxMacInitCocoa();
1083 class wxMacAutoreleasePool
1086 wxMacAutoreleasePool();
1087 ~wxMacAutoreleasePool();
1094 void wxMacCocoaRelease( void* obj
);
1095 void wxMacCocoaAutorelease( void* obj
);
1096 void wxMacCocoaRetain( void* obj
);
1102 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
1103 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
1104 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
1105 void wxMacCocoaHideCursor();
1106 void wxMacCocoaShowCursor();
1108 typedef struct tagClassicCursor
1115 #else // !wxMAC_USE_COCOA
1119 typedef Cursor ClassicCursor
;
1121 #endif // wxMAC_USE_COCOA
1129 const short kwxCursorBullseye
= 0;
1130 const short kwxCursorBlank
= 1;
1131 const short kwxCursorPencil
= 2;
1132 const short kwxCursorMagnifier
= 3;
1133 const short kwxCursorNoEntry
= 4;
1134 const short kwxCursorPaintBrush
= 5;
1135 const short kwxCursorPointRight
= 6;
1136 const short kwxCursorPointLeft
= 7;
1137 const short kwxCursorQuestionArrow
= 8;
1138 const short kwxCursorRightArrow
= 9;
1139 const short kwxCursorSizeNS
= 10;
1140 const short kwxCursorSize
= 11;
1141 const short kwxCursorSizeNESW
= 12;
1142 const short kwxCursorSizeNWSE
= 13;
1143 const short kwxCursorRoller
= 14;
1144 const short kwxCursorLast
= kwxCursorRoller
;
1146 // exposing our fallback cursor map
1148 extern ClassicCursor gMacCursors
[];