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"
33 class WXDLLEXPORT wxMacCGContextStateSaver
35 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
38 wxMacCGContextStateSaver( CGContextRef cg
)
41 CGContextSaveGState( cg
);
43 ~wxMacCGContextStateSaver()
45 CGContextRestoreGState( m_cg
);
53 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
54 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
60 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
61 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
64 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
66 Boolean createFolder
);
67 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
69 Boolean createFolder
);
71 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
72 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
73 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
74 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
75 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
76 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
77 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
78 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
79 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
80 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
81 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
82 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
83 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
84 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
85 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
86 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
87 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
88 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
89 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
90 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
91 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
94 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
95 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
96 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
97 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
100 class wxMacCarbonEvent
110 wxMacCarbonEvent( EventRef event
, bool release
= false )
116 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
119 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
126 ReleaseEvent( m_eventRef
);
129 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
131 verify( (m_eventRef
== NULL
) || m_release
);
132 if ( m_eventRef
&& m_release
)
134 ReleaseEvent( m_eventRef
);
138 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
144 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
146 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
148 return GetParameter( inName
, type
, sizeof( T
) , data
);
150 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
152 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
155 template <typename T
> T
GetParameter( EventParamName inName
)
158 verify_noerr( GetParameter
<T
>( inName
, &value
) );
161 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
164 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
168 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
169 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
171 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
173 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
175 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
177 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
179 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
181 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
183 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
187 return ::GetEventClass( m_eventRef
);
191 return ::GetEventKind( m_eventRef
);
195 return ::GetEventTime( m_eventRef
);
199 return EventTimeToTicks( GetTime() );
201 OSStatus
SetCurrentTime( )
203 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
205 OSStatus
SetTime( EventTime when
)
207 return ::SetEventTime( m_eventRef
, when
);
209 operator EventRef () { return m_eventRef
; }
211 bool IsValid() { return m_eventRef
!= 0; }
218 // helper class for allocating and deallocating Universal Proc Ptrs
221 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
224 wxMacUPP( procType
WXUNUSED(proc
) )
227 m_upp
= (*newUPP
)( NULL
);
234 operator uppType() { return m_upp
; }
239 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
241 template <typename refType
> class wxMacCFRefHolder
245 : m_ref(NULL
) , m_release(false)
249 wxMacCFRefHolder( refType ref
, bool release
= true )
250 : m_ref(ref
) , m_release(release
)
261 if ( m_release
&& m_ref
!= NULL
)
274 void Set( refType ref
, bool release
= true )
281 operator refType () const { return m_ref
; }
283 wxMacCFRefHolder
& operator=(refType r
)
292 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
297 class wxMacToolTipTimer
;
305 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
320 PicHandle m_backpict
;
324 wxMacToolTipTimer
* m_timer
;
326 wxMacCFStringHolder m_helpTextRef
;
331 WXDLLIMPEXP_CORE
void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
332 WXDLLIMPEXP_CORE
void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
333 WXDLLIMPEXP_CORE CGImageRef
wxMacCreateCGImageFromBitmap( const wxBitmap
& bitmap
);
335 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithCFData( CFDataRef data
);
336 WXDLLIMPEXP_CORE CGDataConsumerRef
wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data
);
337 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer
& buf
);
340 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
341 #define MAC_WXHMETAFILE(a) (PicHandle(a))
342 #define MAC_WXHICON(a) (IconRef(a))
343 #define MAC_WXHCURSOR(a) (CursHandle(a))
344 #define MAC_WXHRGN(a) (RgnHandle(a))
345 #define MAC_WXHWND(a) (WindowPtr(a))
346 #define MAC_WXRECPTR(a) ((Rect*)a)
347 #define MAC_WXPOINTPTR(a) ((Point*)a)
348 #define MAC_WXHMENU(a) ((MenuHandle)a)
350 struct wxOpaqueWindowRef
352 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
353 operator WindowRef() { return m_data
; }
358 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
359 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
360 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
361 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
363 WXDLLIMPEXP_CORE wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
364 WXDLLIMPEXP_CORE wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
365 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
367 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
368 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
369 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
371 extern wxWindow
* g_MacLastWindow
;
372 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
373 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
375 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
377 // additional optional event defines
379 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
381 kEventControlFocusPartChanged
= 164
385 class wxMacControl
: public wxObject
388 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
389 wxMacControl( wxWindow
* peer
, ControlRef control
);
390 wxMacControl( wxWindow
* peer
, WXWidget control
);
392 virtual ~wxMacControl();
396 virtual void Dispose();
398 bool Ok() const { return IsOk(); }
399 bool IsOk() const { return GetControlRef() != NULL
; }
401 void SetReferenceInNativeControl();
402 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
404 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
405 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
407 virtual void SetReference( URefCon data
);
409 void operator= (ControlRef c) { m_controlRef = c; }
410 operator ControlRef () { return m_controlRef; }
411 operator ControlRef * () { return &m_controlRef; }
413 // accessing data and values
415 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
416 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
417 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
418 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
419 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
421 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
423 virtual SInt32
GetValue() const;
424 virtual SInt32
GetMaximum() const;
425 virtual SInt32
GetMinimum() const;
427 virtual void SetValue( SInt32 v
);
428 virtual void SetMinimum( SInt32 v
);
429 virtual void SetMaximum( SInt32 v
);
431 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
432 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
434 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
435 virtual bool HasFocus() const;
436 virtual bool NeedsFocusRect() const;
437 virtual void SetNeedsFocusRect( bool needs
);
441 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
444 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
447 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
449 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
451 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
453 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
455 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
457 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
459 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
461 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
463 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
466 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
468 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
471 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
473 wxASSERT_MSG( err
== noErr
,
474 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
475 inPartCode
, (int)inTag
) );
478 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
481 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
483 template <typename T
> T
GetData( ResType inTag
) const
485 return GetData
<T
>( kControlEntireControl
, inTag
);
488 // Flash the control for the specified amount of time
489 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
491 virtual void VisibilityChanged( bool shown
);
492 virtual void SuperChangedPosition();
495 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
496 virtual void SetBackgroundColour( const wxColour
& col
);
497 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
498 void SetActionProc( ControlActionUPP actionProc
);
499 void SetViewSize( SInt32 viewSize
);
500 SInt32
GetViewSize() const;
502 virtual bool IsVisible() const;
503 virtual void SetVisibility( bool visible
, bool redraw
);
504 virtual bool IsEnabled() const;
505 virtual bool IsActive() const;
506 virtual void Enable( bool enable
);
508 // invalidates this control and all children
509 virtual void InvalidateWithChildren();
510 virtual void SetDrawingEnabled( bool enable
);
511 virtual bool GetNeedsDisplay() const;
513 // where is in native window relative coordinates
514 virtual void SetNeedsDisplay( RgnHandle where
);
515 // where is in native window relative coordinates
516 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
518 // if rect = NULL, entire view
519 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
521 // in native parent window relative coordinates
522 virtual void GetRect( Rect
*r
);
524 // in native parent window relative coordinates
525 virtual void SetRect( Rect
*r
);
527 virtual void GetRectInWindowCoords( Rect
*r
);
528 virtual void GetBestRect( Rect
*r
);
529 virtual void SetLabel( const wxString
&title
);
530 // converts from Toplevel-Content relative to local
531 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
533 virtual void GetFeatures( UInt32
*features
);
534 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
535 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
537 bool IsRootControl() { return m_isRootControl
; }
539 wxWindow
* GetPeer() const
544 // to be moved into a tab control class
546 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
548 ControlRef m_controlRef
;
552 bool m_needsFocusRect
;
553 bool m_isRootControl
;
554 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
557 // ============================================================================
558 // DataBrowser Wrapper
559 // ============================================================================
561 // basing on DataBrowserItemIDs
564 class wxMacDataBrowserControl
: public wxMacControl
567 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
568 wxMacDataBrowserControl() {}
570 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
572 OSStatus
GetItemCount( DataBrowserItemID container
,
574 DataBrowserItemState state
,
575 ItemCount
*numItems
) const;
577 OSStatus
GetItems( DataBrowserItemID container
,
579 DataBrowserItemState state
,
583 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
584 DataBrowserTableViewColumnIndex position
);
586 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
588 OSStatus
AutoSizeColumns();
590 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
591 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
593 OSStatus
SetHeaderButtonHeight( UInt16 height
);
594 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
596 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
597 const DataBrowserItemID
*items
,
598 DataBrowserPropertyID preSortProperty
,
599 DataBrowserPropertyID propertyID
) const;
601 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
602 const DataBrowserItemID
*items
,
603 DataBrowserPropertyID preSortProperty
);
604 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
605 const DataBrowserItemID
*items
,
606 DataBrowserPropertyID preSortProperty
);
607 OSStatus
RevealItem( DataBrowserItemID item
,
608 DataBrowserPropertyID propertyID
,
609 DataBrowserRevealOptions options
) const;
611 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
612 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
613 bool IsItemSelected( DataBrowserItemID item
) const;
614 OSStatus
SetSelectedItems( UInt32 numItems
,
615 const DataBrowserItemID
*items
,
616 DataBrowserSetOption operation
);
618 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
619 DataBrowserItemID
* item
) const;
620 OSStatus
GetItemRow( DataBrowserItemID item
,
621 DataBrowserTableViewRowIndex
* row
) const;
623 OSStatus
SetDefaultRowHeight( UInt16 height
);
624 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
626 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
627 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
629 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
630 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
632 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
633 OSStatus
SetDefaultColumnWidth( UInt16 width
);
635 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
637 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
639 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
640 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
642 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
643 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
645 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
646 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
648 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
649 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
651 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
652 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
654 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
655 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
657 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
660 static pascal void DataBrowserItemNotificationProc(
662 DataBrowserItemID itemID
,
663 DataBrowserItemNotification message
,
664 DataBrowserItemDataRef itemData
);
666 virtual void ItemNotification(
667 DataBrowserItemID itemID
,
668 DataBrowserItemNotification message
,
669 DataBrowserItemDataRef itemData
) = 0;
671 static pascal OSStatus
DataBrowserGetSetItemDataProc(
673 DataBrowserItemID itemID
,
674 DataBrowserPropertyID property
,
675 DataBrowserItemDataRef itemData
,
676 Boolean changeValue
);
678 virtual OSStatus
GetSetItemData(
679 DataBrowserItemID itemID
,
680 DataBrowserPropertyID property
,
681 DataBrowserItemDataRef itemData
,
682 Boolean changeValue
) = 0;
684 static pascal Boolean
DataBrowserCompareProc(
686 DataBrowserItemID itemOneID
,
687 DataBrowserItemID itemTwoID
,
688 DataBrowserPropertyID sortProperty
);
690 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
691 DataBrowserItemID itemTwoID
,
692 DataBrowserPropertyID sortProperty
) = 0;
693 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
696 // ============================================================================
697 // Higher-level Databrowser
698 // ============================================================================
700 // basing on data item objects
705 class wxMacDataItemBrowserControl
;
706 class wxMacListBoxItem
;
708 const DataBrowserPropertyID kTextColumnId
= 1024;
709 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
711 // for multi-column controls, we will use this + the column ID to identify the
712 // column. We don't use kTextColumnId there, and ideally the two should merge.
713 const DataBrowserPropertyID kMinColumnId
= 1050;
715 // base API for high-level databrowser operations
717 class wxMacListControl
720 virtual void MacDelete( unsigned int n
) = 0;
721 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 ) = 0;
722 // returns index of newly created line
723 virtual int MacAppend( const wxString
& item
) = 0;
724 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
725 virtual void MacClear() = 0;
726 virtual void MacDeselectAll() = 0;
727 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
728 virtual int MacGetSelection() const = 0;
729 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
730 virtual bool MacIsSelected( unsigned int n
) const = 0;
731 virtual void MacScrollTo( unsigned int n
) = 0;
732 virtual wxString
MacGetString( unsigned int n
) const = 0;
733 virtual unsigned int MacGetCount() const = 0;
735 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
736 virtual void * MacGetClientData( unsigned int) const = 0;
738 virtual ~wxMacListControl() { }
741 // base class for databrowser items
751 virtual ~wxMacDataItem();
753 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
754 const wxMacDataItem
*,
755 DataBrowserPropertyID property
) const;
757 // returns true if access was successful, otherwise false
758 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
759 DataBrowserPropertyID property
,
760 DataBrowserItemDataRef itemData
,
763 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
764 DataBrowserItemNotification message
,
765 DataBrowserItemDataRef itemData
) const;
767 void SetLabel( const wxString
& str
);
768 const wxString
& GetLabel() const;
770 void SetOrder( SInt32 order
);
771 SInt32
GetOrder() const;
773 void SetData( void* data
);
774 void* GetData() const;
776 void SetColumn( short col
);
781 wxMacCFStringHolder m_cfLabel
;
784 DataBrowserPropertyID m_colId
;
790 SortOrder_Text_Ascending
,
791 SortOrder_Text_Descending
794 typedef wxMacDataItem
* wxMacDataItemPtr
;
795 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
797 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
799 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
802 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
803 wxMacDataItemBrowserControl() {}
804 // create a list item (can be a subclass of wxMacListBoxItem)
806 virtual wxMacDataItem
* CreateItem();
808 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
809 void GetItems(const wxMacDataItem
* container
, bool recurse
,
810 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
812 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
814 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
815 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
817 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
818 DataBrowserPropertyID property
) const;
819 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
820 DataBrowserPropertyID property
) const;
822 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
823 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
825 int GetColumnWidth(int colId
);
826 void SetColumnWidth(int colId
, int width
);
828 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
829 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
831 void RemoveAllItems(wxMacDataItem
*container
);
832 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
833 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
835 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
836 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
837 void SetSelectedAllItems( DataBrowserSetOption option
);
838 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
840 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
842 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
844 // item aware methods, to be used in subclasses
846 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
847 const wxMacDataItem
* itemTwoID
,
848 DataBrowserPropertyID sortProperty
);
850 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
851 DataBrowserPropertyID property
,
852 DataBrowserItemDataRef itemData
,
853 Boolean changeValue
);
855 virtual void ItemNotification(
856 const wxMacDataItem
* itemID
,
857 DataBrowserItemNotification message
,
858 DataBrowserItemDataRef itemData
);
860 // as we are getting the same events for human and API selection we have to suppress
861 // events in the latter case, since this will be used from many subclasses we keep it here
863 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
864 bool SuppressSelection( bool suppress
);
867 // wxMacListControl Methods
870 virtual void MacDelete( unsigned int n
);
871 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 );
872 virtual int MacAppend( const wxString
& item
);
873 virtual void MacClear();
877 virtual void MacDeselectAll();
878 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
879 virtual int MacGetSelection() const;
880 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
881 virtual bool MacIsSelected( unsigned int n
) const;
885 virtual void MacScrollTo( unsigned int n
);
889 virtual void MacSetString( unsigned int n
, const wxString
& item
);
890 virtual void MacSetClientData( unsigned int n
, void * data
);
891 virtual wxString
MacGetString( unsigned int n
) const;
892 virtual void * MacGetClientData( unsigned int) const;
893 virtual unsigned int MacGetCount() const;
897 virtual wxClientDataType
GetClientDataType() const;
898 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
899 //virtual ListSortOrder GetSortOrder() const;
900 //virtual void SetSortOrder(const ListSortOrder sort);
906 ListSortOrder m_sortOrder
;
907 wxClientDataType m_clientDataItemsType
;
909 // ID aware base methods, should be 'final' ie not changed in subclasses
911 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
912 DataBrowserItemID itemTwoID
,
913 DataBrowserPropertyID sortProperty
);
915 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
916 DataBrowserPropertyID property
,
917 DataBrowserItemDataRef itemData
,
918 Boolean changeValue
);
920 virtual void ItemNotification(
921 DataBrowserItemID itemID
,
922 DataBrowserItemNotification message
,
923 DataBrowserItemDataRef itemData
);
928 bool m_suppressSelection
;
929 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
932 class wxMacDataItemBrowserSelectionSuppressor
935 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
936 ~wxMacDataItemBrowserSelectionSuppressor();
941 wxMacDataItemBrowserControl
* m_browser
;
944 // ============================================================================
945 // platform listbox implementation
946 // ============================================================================
948 // exposed for reuse in wxCheckListBox
950 class wxMacListBoxItem
: public wxMacDataItem
955 virtual ~wxMacListBoxItem();
957 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
958 DataBrowserItemNotification message
,
959 DataBrowserItemDataRef itemData
) const;
962 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
965 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
966 wxMacDataBrowserListControl() {}
967 virtual ~wxMacDataBrowserListControl();
969 virtual wxMacDataItem
* CreateItem();
973 wxWindow
* GetPeer() const;
975 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
978 // ============================================================================
979 // graphics implementation
980 // ============================================================================
982 // draw the image 'upside down' corrected as HIViewDrawCGImage does
984 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
985 CGContextRef inContext
,
986 const HIRect
* inBounds
,
987 CGImageRef inImage
) ;
989 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
991 CGColorSpaceRef WXDLLIMPEXP_CORE
wxMacGetGenericRGBColorSpace(void);
995 class wxMacDeferredWindowDeleter
: public wxObject
998 wxMacDeferredWindowDeleter( WindowRef windowRef
);
999 virtual ~wxMacDeferredWindowDeleter();
1002 WindowRef m_macWindow
;
1007 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1010 static UPP sHandler = NULL; \
1011 if ( sHandler == NULL ) \
1012 sHandler = New##UPP( x ); \
1016 //---------------------------------------------------------------------------
1017 // wxMac string conversions
1018 //---------------------------------------------------------------------------
1020 void wxMacSetupConverters();
1021 void wxMacCleanupConverters();
1023 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1024 WXDLLIMPEXP_BASE wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1028 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1029 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1030 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
1036 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
);
1037 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
);
1041 //---------------------------------------------------------------------------
1042 // cocoa bridging utilities
1043 //---------------------------------------------------------------------------
1045 bool wxMacInitCocoa();
1047 class wxMacAutoreleasePool
1050 wxMacAutoreleasePool();
1051 ~wxMacAutoreleasePool();
1058 void wxMacCocoaRelease( void* obj
);
1059 void wxMacCocoaAutorelease( void* obj
);
1060 void wxMacCocoaRetain( void* obj
);
1066 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
1067 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
1068 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
1069 void wxMacCocoaHideCursor();
1070 void wxMacCocoaShowCursor();
1072 typedef struct tagClassicCursor
1079 #else // !wxMAC_USE_COCOA
1083 typedef Cursor ClassicCursor
;
1085 #endif // wxMAC_USE_COCOA
1093 const short kwxCursorBullseye
= 0;
1094 const short kwxCursorBlank
= 1;
1095 const short kwxCursorPencil
= 2;
1096 const short kwxCursorMagnifier
= 3;
1097 const short kwxCursorNoEntry
= 4;
1098 const short kwxCursorPaintBrush
= 5;
1099 const short kwxCursorPointRight
= 6;
1100 const short kwxCursorPointLeft
= 7;
1101 const short kwxCursorQuestionArrow
= 8;
1102 const short kwxCursorRightArrow
= 9;
1103 const short kwxCursorSizeNS
= 10;
1104 const short kwxCursorSize
= 11;
1105 const short kwxCursorSizeNESW
= 12;
1106 const short kwxCursorSizeNWSE
= 13;
1107 const short kwxCursorRoller
= 14;
1108 const short kwxCursorLast
= kwxCursorRoller
;
1110 // exposing our fallback cursor map
1112 extern ClassicCursor gMacCursors
[];