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"
32 #include "wx/mac/carbon/dc.h"
33 #include "wx/mac/carbon/dcclient.h"
34 #include "wx/mac/carbon/dcmemory.h"
36 class WXDLLEXPORT wxMacCGContextStateSaver
38 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
41 wxMacCGContextStateSaver( CGContextRef cg
)
44 CGContextSaveGState( cg
);
46 ~wxMacCGContextStateSaver()
48 CGContextRestoreGState( m_cg
);
56 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
57 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
63 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
64 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
67 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
69 Boolean createFolder
);
70 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
72 Boolean createFolder
);
74 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
75 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
76 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
77 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
78 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
79 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
80 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
81 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
82 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
83 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
84 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
85 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
86 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
87 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
88 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
89 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
90 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
91 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
92 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
93 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
94 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
97 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
98 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
99 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
100 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
103 class wxMacCarbonEvent
113 wxMacCarbonEvent( EventRef event
, bool release
= false )
119 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
122 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
129 ReleaseEvent( m_eventRef
);
132 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
134 verify( (m_eventRef
== NULL
) || m_release
);
135 if ( m_eventRef
&& m_release
)
137 ReleaseEvent( m_eventRef
);
141 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
147 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
149 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
151 return GetParameter( inName
, type
, sizeof( T
) , data
);
153 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
155 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
158 template <typename T
> T
GetParameter( EventParamName inName
)
161 verify_noerr( GetParameter
<T
>( inName
, &value
) );
164 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
167 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
171 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
172 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
174 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
176 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
178 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
180 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
182 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
184 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
186 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
190 return ::GetEventClass( m_eventRef
);
194 return ::GetEventKind( m_eventRef
);
198 return ::GetEventTime( m_eventRef
);
202 return EventTimeToTicks( GetTime() );
204 OSStatus
SetCurrentTime( )
206 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
208 OSStatus
SetTime( EventTime when
)
210 return ::SetEventTime( m_eventRef
, when
);
212 operator EventRef () { return m_eventRef
; }
214 bool IsValid() { return m_eventRef
!= 0; }
221 // helper class for allocating and deallocating Universal Proc Ptrs
224 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
227 wxMacUPP( procType
WXUNUSED(proc
) )
230 m_upp
= (*newUPP
)( NULL
);
237 operator uppType() { return m_upp
; }
242 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
244 template <typename refType
> class wxMacCFRefHolder
248 : m_ref(NULL
) , m_release(false)
252 wxMacCFRefHolder( refType ref
, bool release
= true )
253 : m_ref(ref
) , m_release(release
)
264 if ( m_release
&& m_ref
!= NULL
)
277 void Set( refType ref
, bool release
= true )
284 operator refType () const { return m_ref
; }
286 wxMacCFRefHolder
& operator=(refType r
)
295 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
300 class wxMacToolTipTimer
;
308 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
323 PicHandle m_backpict
;
327 wxMacToolTipTimer
* m_timer
;
329 wxMacCFStringHolder m_helpTextRef
;
334 WXDLLIMPEXP_CORE
void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
335 WXDLLIMPEXP_CORE
void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
336 WXDLLIMPEXP_CORE CGImageRef
wxMacCreateCGImageFromBitmap( const wxBitmap
& bitmap
);
338 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithCFData( CFDataRef data
);
339 WXDLLIMPEXP_CORE CGDataConsumerRef
wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data
);
340 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer
& buf
);
343 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
344 #define MAC_WXHMETAFILE(a) (PicHandle(a))
345 #define MAC_WXHICON(a) (IconRef(a))
346 #define MAC_WXHCURSOR(a) (CursHandle(a))
347 #define MAC_WXHRGN(a) (RgnHandle(a))
348 #define MAC_WXHWND(a) (WindowPtr(a))
349 #define MAC_WXRECPTR(a) ((Rect*)a)
350 #define MAC_WXPOINTPTR(a) ((Point*)a)
351 #define MAC_WXHMENU(a) ((MenuHandle)a)
353 struct wxOpaqueWindowRef
355 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
356 operator WindowRef() { return m_data
; }
361 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
362 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
363 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
364 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
366 WXDLLIMPEXP_CORE wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
367 WXDLLIMPEXP_CORE wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
368 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
370 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
371 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
372 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
374 extern wxWindow
* g_MacLastWindow
;
375 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
376 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
378 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
380 // additional optional event defines
382 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
384 kEventControlFocusPartChanged
= 164
388 class wxMacControl
: public wxObject
391 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
392 wxMacControl( wxWindow
* peer
, ControlRef control
);
393 wxMacControl( wxWindow
* peer
, WXWidget control
);
395 virtual ~wxMacControl();
399 virtual void Dispose();
401 bool Ok() const { return IsOk(); }
402 bool IsOk() const { return GetControlRef() != NULL
; }
404 void SetReferenceInNativeControl();
405 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
407 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
408 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
410 virtual void SetReference( URefCon data
);
412 void operator= (ControlRef c) { m_controlRef = c; }
413 operator ControlRef () { return m_controlRef; }
414 operator ControlRef * () { return &m_controlRef; }
416 // accessing data and values
418 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
419 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
420 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
421 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
422 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
424 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
426 virtual SInt32
GetValue() const;
427 virtual SInt32
GetMaximum() const;
428 virtual SInt32
GetMinimum() const;
430 virtual void SetValue( SInt32 v
);
431 virtual void SetMinimum( SInt32 v
);
432 virtual void SetMaximum( SInt32 v
);
434 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
435 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
437 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
438 virtual bool HasFocus() const;
439 virtual bool NeedsFocusRect() const;
440 virtual void SetNeedsFocusRect( bool needs
);
444 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
447 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
450 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
452 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
454 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
456 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
458 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
460 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
462 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
464 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
466 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
469 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
471 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
474 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
476 wxASSERT_MSG( err
== noErr
,
477 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
478 inPartCode
, (int)inTag
) );
481 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
484 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
486 template <typename T
> T
GetData( ResType inTag
) const
488 return GetData
<T
>( kControlEntireControl
, inTag
);
491 // Flash the control for the specified amount of time
492 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
494 virtual void VisibilityChanged( bool shown
);
495 virtual void SuperChangedPosition();
498 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
499 virtual void SetBackgroundColour( const wxColour
& col
);
500 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
501 void SetActionProc( ControlActionUPP actionProc
);
502 void SetViewSize( SInt32 viewSize
);
503 SInt32
GetViewSize() const;
505 virtual bool IsVisible() const;
506 virtual void SetVisibility( bool visible
, bool redraw
);
507 virtual bool IsEnabled() const;
508 virtual bool IsActive() const;
509 virtual void Enable( bool enable
);
511 // invalidates this control and all children
512 virtual void InvalidateWithChildren();
513 virtual void SetDrawingEnabled( bool enable
);
514 virtual bool GetNeedsDisplay() const;
516 // where is in native window relative coordinates
517 virtual void SetNeedsDisplay( RgnHandle where
);
518 // where is in native window relative coordinates
519 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
521 // if rect = NULL, entire view
522 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
524 // in native parent window relative coordinates
525 virtual void GetRect( Rect
*r
);
527 // in native parent window relative coordinates
528 virtual void SetRect( Rect
*r
);
530 virtual void GetRectInWindowCoords( Rect
*r
);
531 virtual void GetBestRect( Rect
*r
);
532 virtual void SetLabel( const wxString
&title
);
533 // converts from Toplevel-Content relative to local
534 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
536 virtual void GetFeatures( UInt32
*features
);
537 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
538 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
540 bool IsRootControl() { return m_isRootControl
; }
542 wxWindow
* GetPeer() const
547 // to be moved into a tab control class
549 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
551 ControlRef m_controlRef
;
555 bool m_needsFocusRect
;
556 bool m_isRootControl
;
557 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
560 // ============================================================================
561 // DataBrowser Wrapper
562 // ============================================================================
564 // basing on DataBrowserItemIDs
567 class wxMacDataBrowserControl
: public wxMacControl
570 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
571 wxMacDataBrowserControl() {}
573 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
575 OSStatus
GetItemCount( DataBrowserItemID container
,
577 DataBrowserItemState state
,
578 ItemCount
*numItems
) const;
580 OSStatus
GetItems( DataBrowserItemID container
,
582 DataBrowserItemState state
,
586 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
587 DataBrowserTableViewColumnIndex position
);
589 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
591 OSStatus
AutoSizeColumns();
593 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
594 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
596 OSStatus
SetHeaderButtonHeight( UInt16 height
);
597 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
599 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
600 const DataBrowserItemID
*items
,
601 DataBrowserPropertyID preSortProperty
,
602 DataBrowserPropertyID propertyID
) const;
604 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
605 const DataBrowserItemID
*items
,
606 DataBrowserPropertyID preSortProperty
);
607 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
608 const DataBrowserItemID
*items
,
609 DataBrowserPropertyID preSortProperty
);
610 OSStatus
RevealItem( DataBrowserItemID item
,
611 DataBrowserPropertyID propertyID
,
612 DataBrowserRevealOptions options
) const;
614 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
615 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
616 bool IsItemSelected( DataBrowserItemID item
) const;
617 OSStatus
SetSelectedItems( UInt32 numItems
,
618 const DataBrowserItemID
*items
,
619 DataBrowserSetOption operation
);
621 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
622 DataBrowserItemID
* item
) const;
623 OSStatus
GetItemRow( DataBrowserItemID item
,
624 DataBrowserTableViewRowIndex
* row
) const;
626 OSStatus
SetDefaultRowHeight( UInt16 height
);
627 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
629 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
630 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
632 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
633 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
635 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
636 OSStatus
SetDefaultColumnWidth( UInt16 width
);
638 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
640 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
642 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
643 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
645 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
646 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
648 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
649 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
651 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
652 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
654 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
655 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
657 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
658 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
660 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
663 static pascal void DataBrowserItemNotificationProc(
665 DataBrowserItemID itemID
,
666 DataBrowserItemNotification message
,
667 DataBrowserItemDataRef itemData
);
669 virtual void ItemNotification(
670 DataBrowserItemID itemID
,
671 DataBrowserItemNotification message
,
672 DataBrowserItemDataRef itemData
) = 0;
674 static pascal OSStatus
DataBrowserGetSetItemDataProc(
676 DataBrowserItemID itemID
,
677 DataBrowserPropertyID property
,
678 DataBrowserItemDataRef itemData
,
679 Boolean changeValue
);
681 virtual OSStatus
GetSetItemData(
682 DataBrowserItemID itemID
,
683 DataBrowserPropertyID property
,
684 DataBrowserItemDataRef itemData
,
685 Boolean changeValue
) = 0;
687 static pascal Boolean
DataBrowserCompareProc(
689 DataBrowserItemID itemOneID
,
690 DataBrowserItemID itemTwoID
,
691 DataBrowserPropertyID sortProperty
);
693 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
694 DataBrowserItemID itemTwoID
,
695 DataBrowserPropertyID sortProperty
) = 0;
696 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
699 // ============================================================================
700 // Higher-level Databrowser
701 // ============================================================================
703 // basing on data item objects
708 class wxMacDataItemBrowserControl
;
709 class wxMacListBoxItem
;
711 const DataBrowserPropertyID kTextColumnId
= 1024;
712 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
714 // for multi-column controls, we will use this + the column ID to identify the
715 // column. We don't use kTextColumnId there, and ideally the two should merge.
716 const DataBrowserPropertyID kMinColumnId
= 1050;
718 // base API for high-level databrowser operations
720 class wxMacListControl
723 virtual void MacDelete( unsigned int n
) = 0;
724 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 ) = 0;
725 // returns index of newly created line
726 virtual int MacAppend( const wxString
& item
) = 0;
727 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
728 virtual void MacClear() = 0;
729 virtual void MacDeselectAll() = 0;
730 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
731 virtual int MacGetSelection() const = 0;
732 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
733 virtual bool MacIsSelected( unsigned int n
) const = 0;
734 virtual void MacScrollTo( unsigned int n
) = 0;
735 virtual wxString
MacGetString( unsigned int n
) const = 0;
736 virtual unsigned int MacGetCount() const = 0;
738 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
739 virtual void * MacGetClientData( unsigned int) const = 0;
741 virtual ~wxMacListControl() { }
744 // base class for databrowser items
754 virtual ~wxMacDataItem();
756 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
757 const wxMacDataItem
*,
758 DataBrowserPropertyID property
) const;
760 // returns true if access was successful, otherwise false
761 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
762 DataBrowserPropertyID property
,
763 DataBrowserItemDataRef itemData
,
766 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
767 DataBrowserItemNotification message
,
768 DataBrowserItemDataRef itemData
) const;
770 void SetLabel( const wxString
& str
);
771 const wxString
& GetLabel() const;
773 void SetOrder( SInt32 order
);
774 SInt32
GetOrder() const;
776 void SetData( void* data
);
777 void* GetData() const;
779 void SetColumn( short col
);
784 wxMacCFStringHolder m_cfLabel
;
787 DataBrowserPropertyID m_colId
;
793 SortOrder_Text_Ascending
,
794 SortOrder_Text_Descending
797 typedef wxMacDataItem
* wxMacDataItemPtr
;
798 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
800 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
802 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
805 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
806 wxMacDataItemBrowserControl() {}
807 // create a list item (can be a subclass of wxMacListBoxItem)
809 virtual wxMacDataItem
* CreateItem();
811 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
812 void GetItems(const wxMacDataItem
* container
, bool recurse
,
813 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
815 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
817 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
818 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
820 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
821 DataBrowserPropertyID property
) const;
822 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
823 DataBrowserPropertyID property
) const;
825 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
826 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
828 int GetColumnWidth(int colId
);
829 void SetColumnWidth(int colId
, int width
);
831 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
832 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
834 void RemoveAllItems(wxMacDataItem
*container
);
835 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
836 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
838 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
839 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
840 void SetSelectedAllItems( DataBrowserSetOption option
);
841 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
843 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
845 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
847 // item aware methods, to be used in subclasses
849 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
850 const wxMacDataItem
* itemTwoID
,
851 DataBrowserPropertyID sortProperty
);
853 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
854 DataBrowserPropertyID property
,
855 DataBrowserItemDataRef itemData
,
856 Boolean changeValue
);
858 virtual void ItemNotification(
859 const wxMacDataItem
* itemID
,
860 DataBrowserItemNotification message
,
861 DataBrowserItemDataRef itemData
);
863 // as we are getting the same events for human and API selection we have to suppress
864 // events in the latter case, since this will be used from many subclasses we keep it here
866 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
867 bool SuppressSelection( bool suppress
);
870 // wxMacListControl Methods
873 virtual void MacDelete( unsigned int n
);
874 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 );
875 virtual int MacAppend( const wxString
& item
);
876 virtual void MacClear();
880 virtual void MacDeselectAll();
881 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
882 virtual int MacGetSelection() const;
883 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
884 virtual bool MacIsSelected( unsigned int n
) const;
888 virtual void MacScrollTo( unsigned int n
);
892 virtual void MacSetString( unsigned int n
, const wxString
& item
);
893 virtual void MacSetClientData( unsigned int n
, void * data
);
894 virtual wxString
MacGetString( unsigned int n
) const;
895 virtual void * MacGetClientData( unsigned int) const;
896 virtual unsigned int MacGetCount() const;
900 virtual wxClientDataType
GetClientDataType() const;
901 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
902 //virtual ListSortOrder GetSortOrder() const;
903 //virtual void SetSortOrder(const ListSortOrder sort);
909 ListSortOrder m_sortOrder
;
910 wxClientDataType m_clientDataItemsType
;
912 // ID aware base methods, should be 'final' ie not changed in subclasses
914 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
915 DataBrowserItemID itemTwoID
,
916 DataBrowserPropertyID sortProperty
);
918 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
919 DataBrowserPropertyID property
,
920 DataBrowserItemDataRef itemData
,
921 Boolean changeValue
);
923 virtual void ItemNotification(
924 DataBrowserItemID itemID
,
925 DataBrowserItemNotification message
,
926 DataBrowserItemDataRef itemData
);
931 bool m_suppressSelection
;
932 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
935 class wxMacDataItemBrowserSelectionSuppressor
938 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
939 ~wxMacDataItemBrowserSelectionSuppressor();
944 wxMacDataItemBrowserControl
* m_browser
;
947 // ============================================================================
948 // platform listbox implementation
949 // ============================================================================
951 // exposed for reuse in wxCheckListBox
953 class wxMacListBoxItem
: public wxMacDataItem
958 virtual ~wxMacListBoxItem();
960 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
961 DataBrowserItemNotification message
,
962 DataBrowserItemDataRef itemData
) const;
965 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
968 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
969 wxMacDataBrowserListControl() {}
970 virtual ~wxMacDataBrowserListControl();
972 virtual wxMacDataItem
* CreateItem();
976 wxWindow
* GetPeer() const;
978 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
981 // ============================================================================
982 // graphics implementation
983 // ============================================================================
985 // draw the image 'upside down' corrected as HIViewDrawCGImage does
987 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
988 CGContextRef inContext
,
989 const HIRect
* inBounds
,
990 CGImageRef inImage
) ;
992 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
994 CGColorSpaceRef WXDLLIMPEXP_CORE
wxMacGetGenericRGBColorSpace(void);
998 class wxMacDeferredWindowDeleter
: public wxObject
1001 wxMacDeferredWindowDeleter( WindowRef windowRef
);
1002 virtual ~wxMacDeferredWindowDeleter();
1005 WindowRef m_macWindow
;
1010 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1013 static UPP sHandler = NULL; \
1014 if ( sHandler == NULL ) \
1015 sHandler = New##UPP( x ); \
1019 //---------------------------------------------------------------------------
1020 // wxMac string conversions
1021 //---------------------------------------------------------------------------
1023 void wxMacSetupConverters();
1024 void wxMacCleanupConverters();
1026 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1027 WXDLLIMPEXP_BASE wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1031 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1032 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1033 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
1039 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
);
1040 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
);
1044 //---------------------------------------------------------------------------
1045 // cocoa bridging utilities
1046 //---------------------------------------------------------------------------
1048 bool wxMacInitCocoa();
1050 class wxMacAutoreleasePool
1053 wxMacAutoreleasePool();
1054 ~wxMacAutoreleasePool();
1061 void wxMacCocoaRelease( void* obj
);
1062 void wxMacCocoaAutorelease( void* obj
);
1063 void wxMacCocoaRetain( void* obj
);
1069 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
1070 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
1071 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
1072 void wxMacCocoaHideCursor();
1073 void wxMacCocoaShowCursor();
1075 typedef struct tagClassicCursor
1082 #else // !wxMAC_USE_COCOA
1086 typedef Cursor ClassicCursor
;
1088 #endif // wxMAC_USE_COCOA
1096 const short kwxCursorBullseye
= 0;
1097 const short kwxCursorBlank
= 1;
1098 const short kwxCursorPencil
= 2;
1099 const short kwxCursorMagnifier
= 3;
1100 const short kwxCursorNoEntry
= 4;
1101 const short kwxCursorPaintBrush
= 5;
1102 const short kwxCursorPointRight
= 6;
1103 const short kwxCursorPointLeft
= 7;
1104 const short kwxCursorQuestionArrow
= 8;
1105 const short kwxCursorRightArrow
= 9;
1106 const short kwxCursorSizeNS
= 10;
1107 const short kwxCursorSize
= 11;
1108 const short kwxCursorSizeNESW
= 12;
1109 const short kwxCursorSizeNWSE
= 13;
1110 const short kwxCursorRoller
= 14;
1111 const short kwxCursorLast
= kwxCursorRoller
;
1113 // exposing our fallback cursor map
1115 extern ClassicCursor gMacCursors
[];