1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/private.h
3 // Purpose: Private declarations: as this header is only included by
4 // wxWidgets itself, it may contain identifiers which don't start
6 // Author: Stefan Csomor
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_PRIVATE_H_
15 #define _WX_PRIVATE_H_
19 #include <Carbon/Carbon.h>
21 #include "wx/mac/corefoundation/cfstring.h"
22 #include "wx/mac/corefoundation/cfdataref.h"
24 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
25 typedef UInt32 URefCon
;
26 typedef SInt32 SRefCon
;
31 #include "wx/listbox.h"
35 class wxMacPortStateHelper
37 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper
)
40 wxMacPortStateHelper( GrafPtr newport
);
41 wxMacPortStateHelper();
42 ~wxMacPortStateHelper();
44 void Setup( GrafPtr newport
);
46 bool IsCleared() { return m_clip
== NULL
; }
47 GrafPtr
GetCurrentPort() { return m_currentPort
; }
50 GrafPtr m_currentPort
;
53 ThemeDrawingState m_drawingState
;
60 class WXDLLEXPORT wxMacPortSaver
62 DECLARE_NO_COPY_CLASS(wxMacPortSaver
)
65 wxMacPortSaver( GrafPtr port
);
71 class WXDLLEXPORT wxMacPortSetter
73 DECLARE_NO_COPY_CLASS(wxMacPortSetter
)
76 wxMacPortSetter( const wxDC
* dc
);
79 wxMacPortStateHelper m_ph
;
84 Clips to the visible region of a control within the current port
87 class WXDLLEXPORT wxMacWindowClipper
: public wxMacPortSaver
89 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
92 wxMacWindowClipper( const wxWindow
* win
);
93 ~wxMacWindowClipper();
96 RgnHandle m_formerClip
;
100 class WXDLLEXPORT wxMacWindowStateSaver
: public wxMacWindowClipper
102 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver
)
105 wxMacWindowStateSaver( const wxWindow
* win
);
106 ~wxMacWindowStateSaver();
109 ThemeDrawingState m_themeDrawingState
;
113 class WXDLLEXPORT wxMacCGContextStateSaver
115 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
118 wxMacCGContextStateSaver( CGContextRef cg
)
121 CGContextSaveGState( cg
);
123 ~wxMacCGContextStateSaver()
125 CGContextRestoreGState( m_cg
);
132 class wxMacDrawingHelper
134 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
137 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false );
138 ~wxMacDrawingHelper();
139 bool Ok() const { return IsOk(); }
140 bool IsOk() { return m_ok; }
141 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); }
142 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); }
143 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); }
144 const Point& GetOrigin() { return m_origin; }
147 GrafPtr m_formerPort;
148 GrafPtr m_currentPort;
149 PenState m_savedPenState;
155 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
160 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
161 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
164 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
166 Boolean createFolder
);
167 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
169 Boolean createFolder
);
171 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
172 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
173 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
174 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
175 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
176 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
177 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
178 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
179 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
180 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
181 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
182 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
183 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
184 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
185 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
186 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
187 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
188 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
189 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
190 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
191 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
194 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
195 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
196 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
197 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
200 class wxMacCarbonEvent
210 wxMacCarbonEvent( EventRef event
, bool release
= false )
216 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
219 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
226 ReleaseEvent( m_eventRef
);
229 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
231 verify( (m_eventRef
== NULL
) || m_release
);
232 if ( m_eventRef
&& m_release
)
234 ReleaseEvent( m_eventRef
);
238 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
244 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
246 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
248 return GetParameter( inName
, type
, sizeof( T
) , data
);
250 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
252 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
255 template <typename T
> T
GetParameter( EventParamName inName
)
258 verify_noerr( GetParameter
<T
>( inName
, &value
) );
261 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
264 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
268 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
269 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
271 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
273 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
275 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
277 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
279 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
281 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
283 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
287 return ::GetEventClass( m_eventRef
);
291 return ::GetEventKind( m_eventRef
);
295 return ::GetEventTime( m_eventRef
);
299 return EventTimeToTicks( GetTime() );
301 OSStatus
SetCurrentTime( )
303 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
305 OSStatus
SetTime( EventTime when
)
307 return ::SetEventTime( m_eventRef
, when
);
309 operator EventRef () { return m_eventRef
; }
311 bool IsValid() { return m_eventRef
!= 0; }
318 // helper class for allocating and deallocating Universal Proc Ptrs
321 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
324 wxMacUPP( procType
WXUNUSED(proc
) )
327 m_upp
= (*newUPP
)( NULL
);
334 operator uppType() { return m_upp
; }
339 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
341 template <typename refType
> class wxMacCFRefHolder
345 : m_ref(NULL
) , m_release(false)
349 wxMacCFRefHolder( refType ref
, bool release
= true )
350 : m_ref(ref
) , m_release(release
)
361 if ( m_release
&& m_ref
!= NULL
)
374 void Set( refType ref
, bool release
= true )
381 operator refType () const { return m_ref
; }
383 wxMacCFRefHolder
& operator=(refType r
)
392 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
397 class wxMacToolTipTimer
;
405 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
420 PicHandle m_backpict
;
424 wxMacToolTipTimer
* m_timer
;
426 wxMacCFStringHolder m_helpTextRef
;
430 GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
431 void wxMacDestroyGWorld( GWorldPtr gw );
432 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL );
433 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize );
434 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue );
435 CTabHandle wxMacCreateColorTable( int numColors );
437 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
438 void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
439 CGImageRef
wxMacCreateCGImageFromBitmap( const wxBitmap
& bitmap
);
441 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
442 #define MAC_WXHMETAFILE(a) (PicHandle(a))
443 #define MAC_WXHICON(a) (IconRef(a))
444 #define MAC_WXHCURSOR(a) (CursHandle(a))
445 #define MAC_WXHRGN(a) (RgnHandle(a))
446 #define MAC_WXHWND(a) (WindowPtr(a))
447 #define MAC_WXRECPTR(a) ((Rect*)a)
448 #define MAC_WXPOINTPTR(a) ((Point*)a)
449 #define MAC_WXHMENU(a) ((MenuHandle)a)
451 struct wxOpaqueWindowRef
453 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
454 operator WindowRef() { return m_data
; }
459 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
460 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
461 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
462 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
464 WXDLLIMPEXP_CORE wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
465 WXDLLIMPEXP_CORE wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
466 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
468 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
469 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
470 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
472 extern wxWindow
* g_MacLastWindow
;
473 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
474 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
476 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
478 class wxMacControl
: public wxObject
481 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
482 wxMacControl( wxWindow
* peer
, ControlRef control
);
483 wxMacControl( wxWindow
* peer
, WXWidget control
);
485 virtual ~wxMacControl();
489 virtual void Dispose();
491 bool Ok() const { return IsOk(); }
492 bool IsOk() const { return GetControlRef() != NULL
; }
494 void SetReferenceInNativeControl();
495 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
497 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
498 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
500 virtual void SetReference( URefCon data
);
502 void operator= (ControlRef c) { m_controlRef = c; }
503 operator ControlRef () { return m_controlRef; }
504 operator ControlRef * () { return &m_controlRef; }
506 // accessing data and values
508 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
509 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
510 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
511 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
512 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
514 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
516 virtual SInt32
GetValue() const;
517 virtual SInt32
GetMaximum() const;
518 virtual SInt32
GetMinimum() const;
520 virtual void SetValue( SInt32 v
);
521 virtual void SetMinimum( SInt32 v
);
522 virtual void SetMaximum( SInt32 v
);
524 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
525 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
527 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
528 virtual bool HasFocus() const;
529 virtual bool NeedsFocusRect() const;
530 virtual void SetNeedsFocusRect( bool needs
);
534 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
537 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
540 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
542 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
544 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
546 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
548 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
550 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
552 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
554 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
556 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
559 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
561 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
564 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
566 wxASSERT_MSG( err
== noErr
,
567 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
568 inPartCode
, (int)inTag
) );
571 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
574 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
576 template <typename T
> T
GetData( ResType inTag
) const
578 return GetData
<T
>( kControlEntireControl
, inTag
);
581 // Flash the control for the specified amount of time
582 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
584 virtual void VisibilityChanged( bool shown
);
585 virtual void SuperChangedPosition();
588 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
589 virtual void SetBackgroundColour( const wxColour
& col
);
590 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
591 void SetActionProc( ControlActionUPP actionProc
);
592 void SetViewSize( SInt32 viewSize
);
593 SInt32
GetViewSize() const;
595 virtual bool IsVisible() const;
596 virtual void SetVisibility( bool visible
, bool redraw
);
597 virtual bool IsEnabled() const;
598 virtual bool IsActive() const;
599 virtual void Enable( bool enable
);
601 // invalidates this control and all children
602 virtual void InvalidateWithChildren();
603 virtual void SetDrawingEnabled( bool enable
);
604 virtual bool GetNeedsDisplay() const;
606 // where is in native window relative coordinates
607 virtual void SetNeedsDisplay( RgnHandle where
);
608 // where is in native window relative coordinates
609 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
611 // if rect = NULL, entire view
612 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
614 // in native parent window relative coordinates
615 virtual void GetRect( Rect
*r
);
617 // in native parent window relative coordinates
618 virtual void SetRect( Rect
*r
);
620 virtual void GetRectInWindowCoords( Rect
*r
);
621 virtual void GetBestRect( Rect
*r
);
622 virtual void SetLabel( const wxString
&title
);
623 // converts from Toplevel-Content relative to local
624 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
626 virtual void GetFeatures( UInt32
*features
);
627 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
628 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
630 bool IsRootControl() { return m_isRootControl
; }
632 wxWindow
* GetPeer() const
637 // to be moved into a tab control class
639 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
641 ControlRef m_controlRef
;
645 bool m_needsFocusRect
;
646 bool m_isRootControl
;
647 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
650 // ============================================================================
651 // DataBrowser Wrapper
652 // ============================================================================
654 // basing on DataBrowserItemIDs
657 class wxMacDataBrowserControl
: public wxMacControl
660 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
661 wxMacDataBrowserControl() {}
663 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
665 OSStatus
GetItemCount( DataBrowserItemID container
,
667 DataBrowserItemState state
,
668 ItemCount
*numItems
) const;
670 OSStatus
GetItems( DataBrowserItemID container
,
672 DataBrowserItemState state
,
676 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
677 DataBrowserTableViewColumnIndex position
);
679 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
681 OSStatus
AutoSizeColumns();
683 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
684 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
686 OSStatus
SetHeaderButtonHeight( UInt16 height
);
687 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
689 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
690 const DataBrowserItemID
*items
,
691 DataBrowserPropertyID preSortProperty
,
692 DataBrowserPropertyID propertyID
) const;
694 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
695 const DataBrowserItemID
*items
,
696 DataBrowserPropertyID preSortProperty
);
697 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
698 const DataBrowserItemID
*items
,
699 DataBrowserPropertyID preSortProperty
);
700 OSStatus
RevealItem( DataBrowserItemID item
,
701 DataBrowserPropertyID propertyID
,
702 DataBrowserRevealOptions options
) const;
704 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
705 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
706 bool IsItemSelected( DataBrowserItemID item
) const;
707 OSStatus
SetSelectedItems( UInt32 numItems
,
708 const DataBrowserItemID
*items
,
709 DataBrowserSetOption operation
);
711 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
712 DataBrowserItemID
* item
) const;
713 OSStatus
GetItemRow( DataBrowserItemID item
,
714 DataBrowserTableViewRowIndex
* row
) const;
716 OSStatus
SetDefaultRowHeight( UInt16 height
);
717 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
719 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
720 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
722 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
723 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
725 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
726 OSStatus
SetDefaultColumnWidth( UInt16 width
);
728 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
730 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
732 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
733 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
735 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
736 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
738 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
739 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
741 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
742 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
744 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
745 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
747 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
748 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
750 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
753 static pascal void DataBrowserItemNotificationProc(
755 DataBrowserItemID itemID
,
756 DataBrowserItemNotification message
,
757 DataBrowserItemDataRef itemData
);
759 virtual void ItemNotification(
760 DataBrowserItemID itemID
,
761 DataBrowserItemNotification message
,
762 DataBrowserItemDataRef itemData
) = 0;
764 static pascal OSStatus
DataBrowserGetSetItemDataProc(
766 DataBrowserItemID itemID
,
767 DataBrowserPropertyID property
,
768 DataBrowserItemDataRef itemData
,
769 Boolean changeValue
);
771 virtual OSStatus
GetSetItemData(
772 DataBrowserItemID itemID
,
773 DataBrowserPropertyID property
,
774 DataBrowserItemDataRef itemData
,
775 Boolean changeValue
) = 0;
777 static pascal Boolean
DataBrowserCompareProc(
779 DataBrowserItemID itemOneID
,
780 DataBrowserItemID itemTwoID
,
781 DataBrowserPropertyID sortProperty
);
783 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
784 DataBrowserItemID itemTwoID
,
785 DataBrowserPropertyID sortProperty
) = 0;
786 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
789 // ============================================================================
790 // Higher-level Databrowser
791 // ============================================================================
793 // basing on data item objects
798 class wxMacDataItemBrowserControl
;
799 class wxMacListBoxItem
;
801 const DataBrowserPropertyID kTextColumnId
= 1024;
802 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
804 // for multi-column controls, we will use this + the column ID to identify the
805 // column. We don't use kTextColumnId there, and ideally the two should merge.
806 const DataBrowserPropertyID kMinColumnId
= 1050;
808 // base API for high-level databrowser operations
810 class wxMacListControl
813 virtual void MacDelete( unsigned int n
) = 0;
814 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 ) = 0;
815 // returns index of newly created line
816 virtual int MacAppend( const wxString
& item
) = 0;
817 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
818 virtual void MacClear() = 0;
819 virtual void MacDeselectAll() = 0;
820 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
821 virtual int MacGetSelection() const = 0;
822 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
823 virtual bool MacIsSelected( unsigned int n
) const = 0;
824 virtual void MacScrollTo( unsigned int n
) = 0;
825 virtual wxString
MacGetString( unsigned int n
) const = 0;
826 virtual unsigned int MacGetCount() const = 0;
828 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
829 virtual void * MacGetClientData( unsigned int) const = 0;
831 virtual ~wxMacListControl() { }
834 // base class for databrowser items
844 virtual ~wxMacDataItem();
846 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
847 const wxMacDataItem
*,
848 DataBrowserPropertyID property
) const;
850 // returns true if access was successful, otherwise false
851 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
852 DataBrowserPropertyID property
,
853 DataBrowserItemDataRef itemData
,
856 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
857 DataBrowserItemNotification message
,
858 DataBrowserItemDataRef itemData
) const;
860 void SetLabel( const wxString
& str
);
861 const wxString
& GetLabel() const;
863 void SetOrder( SInt32 order
);
864 SInt32
GetOrder() const;
866 void SetData( void* data
);
867 void* GetData() const;
869 void SetColumn( short col
);
874 wxMacCFStringHolder m_cfLabel
;
877 DataBrowserPropertyID m_colId
;
883 SortOrder_Text_Ascending
,
884 SortOrder_Text_Descending
887 typedef wxMacDataItem
* wxMacDataItemPtr
;
888 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
890 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
892 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
895 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
896 wxMacDataItemBrowserControl() {}
897 // create a list item (can be a subclass of wxMacListBoxItem)
899 virtual wxMacDataItem
* CreateItem();
901 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
902 void GetItems(const wxMacDataItem
* container
, bool recurse
,
903 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
905 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
907 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
908 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
910 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
911 DataBrowserPropertyID property
) const;
912 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
913 DataBrowserPropertyID property
) const;
915 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
916 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
918 int GetColumnWidth(int colId
);
919 void SetColumnWidth(int colId
, int width
);
921 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
922 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
924 void RemoveAllItems(wxMacDataItem
*container
);
925 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
926 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
928 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
929 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
930 void SetSelectedAllItems( DataBrowserSetOption option
);
931 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
933 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
935 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
937 // item aware methods, to be used in subclasses
939 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
940 const wxMacDataItem
* itemTwoID
,
941 DataBrowserPropertyID sortProperty
);
943 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
944 DataBrowserPropertyID property
,
945 DataBrowserItemDataRef itemData
,
946 Boolean changeValue
);
948 virtual void ItemNotification(
949 const wxMacDataItem
* itemID
,
950 DataBrowserItemNotification message
,
951 DataBrowserItemDataRef itemData
);
953 // as we are getting the same events for human and API selection we have to suppress
954 // events in the latter case, since this will be used from many subclasses we keep it here
956 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
957 bool SuppressSelection( bool suppress
);
960 // wxMacListControl Methods
963 virtual void MacDelete( unsigned int n
);
964 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 );
965 virtual int MacAppend( const wxString
& item
);
966 virtual void MacClear();
970 virtual void MacDeselectAll();
971 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
972 virtual int MacGetSelection() const;
973 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
974 virtual bool MacIsSelected( unsigned int n
) const;
978 virtual void MacScrollTo( unsigned int n
);
982 virtual void MacSetString( unsigned int n
, const wxString
& item
);
983 virtual void MacSetClientData( unsigned int n
, void * data
);
984 virtual wxString
MacGetString( unsigned int n
) const;
985 virtual void * MacGetClientData( unsigned int) const;
986 virtual unsigned int MacGetCount() const;
990 virtual wxClientDataType
GetClientDataType() const;
991 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
992 //virtual ListSortOrder GetSortOrder() const;
993 //virtual void SetSortOrder(const ListSortOrder sort);
999 ListSortOrder m_sortOrder
;
1000 wxClientDataType m_clientDataItemsType
;
1002 // ID aware base methods, should be 'final' ie not changed in subclasses
1004 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
1005 DataBrowserItemID itemTwoID
,
1006 DataBrowserPropertyID sortProperty
);
1008 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
1009 DataBrowserPropertyID property
,
1010 DataBrowserItemDataRef itemData
,
1011 Boolean changeValue
);
1013 virtual void ItemNotification(
1014 DataBrowserItemID itemID
,
1015 DataBrowserItemNotification message
,
1016 DataBrowserItemDataRef itemData
);
1021 bool m_suppressSelection
;
1022 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
1025 class wxMacDataItemBrowserSelectionSuppressor
1028 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
1029 ~wxMacDataItemBrowserSelectionSuppressor();
1034 wxMacDataItemBrowserControl
* m_browser
;
1037 // ============================================================================
1038 // platform listbox implementation
1039 // ============================================================================
1041 // exposed for reuse in wxCheckListBox
1043 class wxMacListBoxItem
: public wxMacDataItem
1048 virtual ~wxMacListBoxItem();
1050 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
1051 DataBrowserItemNotification message
,
1052 DataBrowserItemDataRef itemData
) const;
1055 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
1058 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
1059 wxMacDataBrowserListControl() {}
1060 virtual ~wxMacDataBrowserListControl();
1062 virtual wxMacDataItem
* CreateItem();
1066 wxWindow
* GetPeer() const;
1068 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
1071 // ============================================================================
1072 // graphics implementation
1073 // ============================================================================
1075 // draw the image 'upside down' corrected as HIViewDrawCGImage does
1077 OSStatus WXDLLEXPORT
wxMacDrawCGImage(
1078 CGContextRef inContext
,
1079 const HIRect
* inBounds
,
1080 CGImageRef inImage
) ;
1082 CGColorRef
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
1084 CGColorSpaceRef
wxMacGetGenericRGBColorSpace(void);
1086 void wxMacMemoryBufferReleaseProc(void *info
, const void *data
, size_t size
);
1088 class WXDLLEXPORT wxBitmapRefData
: public wxGDIRefData
1090 friend class WXDLLIMPEXP_FWD_CORE wxIcon
;
1091 friend class WXDLLIMPEXP_FWD_CORE wxCursor
;
1093 wxBitmapRefData(int width
, int height
, int depth
);
1095 wxBitmapRefData(const wxBitmapRefData
&tocopy
);
1097 virtual ~wxBitmapRefData();
1100 bool Ok() const { return IsOk(); }
1101 bool IsOk() const { return m_ok
; }
1102 void SetOk( bool isOk
) { m_ok
= isOk
; }
1104 void SetWidth( int width
) { m_width
= width
; }
1105 void SetHeight( int height
) { m_height
= height
; }
1106 void SetDepth( int depth
) { m_depth
= depth
; }
1108 int GetWidth() const { return m_width
; }
1109 int GetHeight() const { return m_height
; }
1110 int GetDepth() const { return m_depth
; }
1112 void *GetRawAccess() const;
1113 void *BeginRawAccess();
1114 void EndRawAccess();
1116 bool HasAlpha() const { return m_hasAlpha
; }
1117 void UseAlpha( bool useAlpha
);
1121 wxPalette m_bitmapPalette
;
1122 #endif // wxUSE_PALETTE
1124 wxMask
* m_bitmapMask
; // Optional mask
1125 CGImageRef
CGImageCreate() const;
1127 // returns true if the bitmap has a size that
1128 // can be natively transferred into a true icon
1129 // if no is returned GetIconRef will still produce
1130 // an icon but it will be generated via a PICT and
1131 // rescaled to 16 x 16
1132 bool HasNativeSize();
1134 // caller should increase ref count if needed longer
1135 // than the bitmap exists
1136 IconRef
GetIconRef();
1138 // returns a Pict from the bitmap content
1139 PicHandle
GetPictHandle();
1141 CGContextRef
GetBitmapContext() const;
1143 int GetBytesPerRow() const { return m_bytesPerRow
; }
1145 bool Create(int width
, int height
, int depth
);
1153 wxMemoryBuffer m_memBuf
;
1154 int m_rawAccessCount
;
1156 mutable CGImageRef m_cgImageRef
;
1159 PicHandle m_pictHandle
;
1161 CGContextRef m_hBitmap
;
1164 class WXDLLEXPORT wxIconRefData
: public wxGDIRefData
1168 wxIconRefData( WXHICON
);
1169 virtual ~wxIconRefData() { Free(); }
1172 virtual void Free();
1174 void SetWidth( int width
) { m_width
= width
; }
1175 void SetHeight( int height
) { m_height
= height
; }
1177 int GetWidth() const { return m_width
; }
1178 int GetHeight() const { return m_height
; }
1180 WXHICON
GetHICON() const { return (WXHICON
) m_iconRef
; }
1189 class wxMacDeferredWindowDeleter
: public wxObject
1192 wxMacDeferredWindowDeleter( WindowRef windowRef
);
1193 virtual ~wxMacDeferredWindowDeleter();
1196 WindowRef m_macWindow
;
1201 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1204 static UPP sHandler = NULL; \
1205 if ( sHandler == NULL ) \
1206 sHandler = New##UPP( x ); \
1210 //---------------------------------------------------------------------------
1211 // wxMac string conversions
1212 //---------------------------------------------------------------------------
1214 void wxMacSetupConverters();
1215 void wxMacCleanupConverters();
1217 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1218 WXDLLIMPEXP_BASE wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1222 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1223 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1224 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
1230 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
);
1231 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
);
1235 //---------------------------------------------------------------------------
1236 // cocoa bridging utilities
1237 //---------------------------------------------------------------------------
1239 bool wxMacInitCocoa();
1241 class wxMacAutoreleasePool
1244 wxMacAutoreleasePool();
1245 ~wxMacAutoreleasePool();
1252 void wxMacCocoaRelease( void* obj
);
1253 void wxMacCocoaAutorelease( void* obj
);
1254 void wxMacCocoaRetain( void* obj
);
1260 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
1261 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
1262 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
1263 void wxMacCocoaHideCursor();
1264 void wxMacCocoaShowCursor();
1266 typedef struct tagClassicCursor
1273 #else // !wxMAC_USE_COCOA
1277 typedef Cursor ClassicCursor
;
1279 #endif // wxMAC_USE_COCOA
1287 const short kwxCursorBullseye
= 0;
1288 const short kwxCursorBlank
= 1;
1289 const short kwxCursorPencil
= 2;
1290 const short kwxCursorMagnifier
= 3;
1291 const short kwxCursorNoEntry
= 4;
1292 const short kwxCursorPaintBrush
= 5;
1293 const short kwxCursorPointRight
= 6;
1294 const short kwxCursorPointLeft
= 7;
1295 const short kwxCursorQuestionArrow
= 8;
1296 const short kwxCursorRightArrow
= 9;
1297 const short kwxCursorSizeNS
= 10;
1298 const short kwxCursorSize
= 11;
1299 const short kwxCursorSizeNESW
= 12;
1300 const short kwxCursorSizeNWSE
= 13;
1301 const short kwxCursorRoller
= 14;
1302 const short kwxCursorLast
= kwxCursorRoller
;
1304 // exposing our fallback cursor map
1306 extern ClassicCursor gMacCursors
[];