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_WXCOLORREF(a) (*((RGBColor*)&(a)))
442 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
443 #define MAC_WXHMETAFILE(a) (PicHandle(a))
444 #define MAC_WXHICON(a) (IconRef(a))
445 #define MAC_WXHCURSOR(a) (CursHandle(a))
446 #define MAC_WXHRGN(a) (RgnHandle(a))
447 #define MAC_WXHWND(a) (WindowPtr(a))
448 #define MAC_WXRECPTR(a) ((Rect*)a)
449 #define MAC_WXPOINTPTR(a) ((Point*)a)
450 #define MAC_WXHMENU(a) ((MenuHandle)a)
452 struct wxOpaqueWindowRef
454 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
455 operator WindowRef() { return m_data
; }
460 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
461 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
462 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
463 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
465 WXDLLIMPEXP_CORE wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
466 WXDLLIMPEXP_CORE wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
467 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
469 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
470 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
471 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
473 extern wxWindow
* g_MacLastWindow
;
474 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
475 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
477 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
479 class wxMacControl
: public wxObject
482 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
483 wxMacControl( wxWindow
* peer
, ControlRef control
);
484 wxMacControl( wxWindow
* peer
, WXWidget control
);
486 virtual ~wxMacControl();
490 virtual void Dispose();
492 bool Ok() const { return IsOk(); }
493 bool IsOk() const { return GetControlRef() != NULL
; }
495 void SetReferenceInNativeControl();
496 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
498 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
499 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
501 virtual void SetReference( URefCon data
);
503 void operator= (ControlRef c) { m_controlRef = c; }
504 operator ControlRef () { return m_controlRef; }
505 operator ControlRef * () { return &m_controlRef; }
507 // accessing data and values
509 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
510 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
511 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
512 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
513 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
515 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
517 virtual SInt32
GetValue() const;
518 virtual SInt32
GetMaximum() const;
519 virtual SInt32
GetMinimum() const;
521 virtual void SetValue( SInt32 v
);
522 virtual void SetMinimum( SInt32 v
);
523 virtual void SetMaximum( SInt32 v
);
525 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
526 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
528 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
529 virtual bool HasFocus() const;
530 virtual bool NeedsFocusRect() const;
531 virtual void SetNeedsFocusRect( bool needs
);
535 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
538 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
541 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
543 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
545 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
547 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
549 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
551 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
553 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
555 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
557 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
560 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
562 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
565 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
567 wxASSERT_MSG( err
== noErr
,
568 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
569 inPartCode
, (int)inTag
) );
572 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
575 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
577 template <typename T
> T
GetData( ResType inTag
) const
579 return GetData
<T
>( kControlEntireControl
, inTag
);
582 // Flash the control for the specified amount of time
583 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
585 virtual void VisibilityChanged( bool shown
);
586 virtual void SuperChangedPosition();
589 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
590 virtual void SetBackground( const wxBrush
&brush
);
591 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
592 void SetActionProc( ControlActionUPP actionProc
);
593 void SetViewSize( SInt32 viewSize
);
594 SInt32
GetViewSize() const;
596 virtual bool IsVisible() const;
597 virtual void SetVisibility( bool visible
, bool redraw
);
598 virtual bool IsEnabled() const;
599 virtual bool IsActive() const;
600 virtual void Enable( bool enable
);
602 // invalidates this control and all children
603 virtual void InvalidateWithChildren();
604 virtual void SetDrawingEnabled( bool enable
);
605 virtual bool GetNeedsDisplay() const;
607 // where is in native window relative coordinates
608 virtual void SetNeedsDisplay( RgnHandle where
);
609 // where is in native window relative coordinates
610 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
612 // if rect = NULL, entire view
613 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
615 // in native parent window relative coordinates
616 virtual void GetRect( Rect
*r
);
618 // in native parent window relative coordinates
619 virtual void SetRect( Rect
*r
);
621 virtual void GetRectInWindowCoords( Rect
*r
);
622 virtual void GetBestRect( Rect
*r
);
623 virtual void SetLabel( const wxString
&title
);
624 // converts from Toplevel-Content relative to local
625 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
627 virtual void GetFeatures( UInt32
*features
);
628 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
629 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
631 bool IsRootControl() { return m_isRootControl
; }
633 wxWindow
* GetPeer() const
638 // to be moved into a tab control class
640 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
642 ControlRef m_controlRef
;
646 bool m_needsFocusRect
;
647 bool m_isRootControl
;
648 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
651 // ============================================================================
652 // DataBrowser Wrapper
653 // ============================================================================
655 // basing on DataBrowserItemIDs
658 class wxMacDataBrowserControl
: public wxMacControl
661 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
662 wxMacDataBrowserControl() {}
664 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
666 OSStatus
GetItemCount( DataBrowserItemID container
,
668 DataBrowserItemState state
,
669 ItemCount
*numItems
) const;
671 OSStatus
GetItems( DataBrowserItemID container
,
673 DataBrowserItemState state
,
677 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
678 DataBrowserTableViewColumnIndex position
);
680 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
682 OSStatus
AutoSizeColumns();
684 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
685 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
687 OSStatus
SetHeaderButtonHeight( UInt16 height
);
688 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
690 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
691 const DataBrowserItemID
*items
,
692 DataBrowserPropertyID preSortProperty
,
693 DataBrowserPropertyID propertyID
) const;
695 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
696 const DataBrowserItemID
*items
,
697 DataBrowserPropertyID preSortProperty
);
698 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
699 const DataBrowserItemID
*items
,
700 DataBrowserPropertyID preSortProperty
);
701 OSStatus
RevealItem( DataBrowserItemID item
,
702 DataBrowserPropertyID propertyID
,
703 DataBrowserRevealOptions options
) const;
705 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
706 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
707 bool IsItemSelected( DataBrowserItemID item
) const;
708 OSStatus
SetSelectedItems( UInt32 numItems
,
709 const DataBrowserItemID
*items
,
710 DataBrowserSetOption operation
);
712 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
713 DataBrowserItemID
* item
) const;
714 OSStatus
GetItemRow( DataBrowserItemID item
,
715 DataBrowserTableViewRowIndex
* row
) const;
717 OSStatus
SetDefaultRowHeight( UInt16 height
);
718 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
720 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
721 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
723 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
724 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
726 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
727 OSStatus
SetDefaultColumnWidth( UInt16 width
);
729 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
731 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
733 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
734 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
736 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
737 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
739 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
740 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
742 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
743 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
745 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
746 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
748 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
749 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
751 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
754 static pascal void DataBrowserItemNotificationProc(
756 DataBrowserItemID itemID
,
757 DataBrowserItemNotification message
,
758 DataBrowserItemDataRef itemData
);
760 virtual void ItemNotification(
761 DataBrowserItemID itemID
,
762 DataBrowserItemNotification message
,
763 DataBrowserItemDataRef itemData
) = 0;
765 static pascal OSStatus
DataBrowserGetSetItemDataProc(
767 DataBrowserItemID itemID
,
768 DataBrowserPropertyID property
,
769 DataBrowserItemDataRef itemData
,
770 Boolean changeValue
);
772 virtual OSStatus
GetSetItemData(
773 DataBrowserItemID itemID
,
774 DataBrowserPropertyID property
,
775 DataBrowserItemDataRef itemData
,
776 Boolean changeValue
) = 0;
778 static pascal Boolean
DataBrowserCompareProc(
780 DataBrowserItemID itemOneID
,
781 DataBrowserItemID itemTwoID
,
782 DataBrowserPropertyID sortProperty
);
784 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
785 DataBrowserItemID itemTwoID
,
786 DataBrowserPropertyID sortProperty
) = 0;
787 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
790 // ============================================================================
791 // Higher-level Databrowser
792 // ============================================================================
794 // basing on data item objects
799 class wxMacDataItemBrowserControl
;
800 class wxMacListBoxItem
;
802 const DataBrowserPropertyID kTextColumnId
= 1024;
803 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
805 // for multi-column controls, we will use this + the column ID to identify the
806 // column. We don't use kTextColumnId there, and ideally the two should merge.
807 const DataBrowserPropertyID kMinColumnId
= 1050;
809 // base API for high-level databrowser operations
811 class wxMacListControl
814 virtual void MacDelete( unsigned int n
) = 0;
815 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 ) = 0;
816 // returns index of newly created line
817 virtual int MacAppend( const wxString
& item
) = 0;
818 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
819 virtual void MacClear() = 0;
820 virtual void MacDeselectAll() = 0;
821 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
822 virtual int MacGetSelection() const = 0;
823 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
824 virtual bool MacIsSelected( unsigned int n
) const = 0;
825 virtual void MacScrollTo( unsigned int n
) = 0;
826 virtual wxString
MacGetString( unsigned int n
) const = 0;
827 virtual unsigned int MacGetCount() const = 0;
829 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
830 virtual void * MacGetClientData( unsigned int) const = 0;
832 virtual ~wxMacListControl() { }
835 // base class for databrowser items
845 virtual ~wxMacDataItem();
847 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
848 const wxMacDataItem
*,
849 DataBrowserPropertyID property
) const;
851 // returns true if access was successful, otherwise false
852 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
853 DataBrowserPropertyID property
,
854 DataBrowserItemDataRef itemData
,
857 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
858 DataBrowserItemNotification message
,
859 DataBrowserItemDataRef itemData
) const;
861 void SetLabel( const wxString
& str
);
862 const wxString
& GetLabel() const;
864 void SetOrder( SInt32 order
);
865 SInt32
GetOrder() const;
867 void SetData( void* data
);
868 void* GetData() const;
870 void SetColumn( short col
);
875 wxMacCFStringHolder m_cfLabel
;
878 DataBrowserPropertyID m_colId
;
884 SortOrder_Text_Ascending
,
885 SortOrder_Text_Descending
888 typedef wxMacDataItem
* wxMacDataItemPtr
;
889 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
891 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
893 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
896 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
897 wxMacDataItemBrowserControl() {}
898 // create a list item (can be a subclass of wxMacListBoxItem)
900 virtual wxMacDataItem
* CreateItem();
902 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
903 void GetItems(const wxMacDataItem
* container
, bool recurse
,
904 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
906 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
908 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
909 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
911 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
912 DataBrowserPropertyID property
) const;
913 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
914 DataBrowserPropertyID property
) const;
916 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
917 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
919 int GetColumnWidth(int colId
);
920 void SetColumnWidth(int colId
, int width
);
922 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
923 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
925 void RemoveAllItems(wxMacDataItem
*container
);
926 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
927 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
929 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
930 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
931 void SetSelectedAllItems( DataBrowserSetOption option
);
932 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
934 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
936 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
938 // item aware methods, to be used in subclasses
940 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
941 const wxMacDataItem
* itemTwoID
,
942 DataBrowserPropertyID sortProperty
);
944 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
945 DataBrowserPropertyID property
,
946 DataBrowserItemDataRef itemData
,
947 Boolean changeValue
);
949 virtual void ItemNotification(
950 const wxMacDataItem
* itemID
,
951 DataBrowserItemNotification message
,
952 DataBrowserItemDataRef itemData
);
954 // as we are getting the same events for human and API selection we have to suppress
955 // events in the latter case, since this will be used from many subclasses we keep it here
957 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
958 bool SuppressSelection( bool suppress
);
961 // wxMacListControl Methods
964 virtual void MacDelete( unsigned int n
);
965 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 );
966 virtual int MacAppend( const wxString
& item
);
967 virtual void MacClear();
971 virtual void MacDeselectAll();
972 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
973 virtual int MacGetSelection() const;
974 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
975 virtual bool MacIsSelected( unsigned int n
) const;
979 virtual void MacScrollTo( unsigned int n
);
983 virtual void MacSetString( unsigned int n
, const wxString
& item
);
984 virtual void MacSetClientData( unsigned int n
, void * data
);
985 virtual wxString
MacGetString( unsigned int n
) const;
986 virtual void * MacGetClientData( unsigned int) const;
987 virtual unsigned int MacGetCount() const;
991 virtual wxClientDataType
GetClientDataType() const;
992 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
993 //virtual ListSortOrder GetSortOrder() const;
994 //virtual void SetSortOrder(const ListSortOrder sort);
1000 ListSortOrder m_sortOrder
;
1001 wxClientDataType m_clientDataItemsType
;
1003 // ID aware base methods, should be 'final' ie not changed in subclasses
1005 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
1006 DataBrowserItemID itemTwoID
,
1007 DataBrowserPropertyID sortProperty
);
1009 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
1010 DataBrowserPropertyID property
,
1011 DataBrowserItemDataRef itemData
,
1012 Boolean changeValue
);
1014 virtual void ItemNotification(
1015 DataBrowserItemID itemID
,
1016 DataBrowserItemNotification message
,
1017 DataBrowserItemDataRef itemData
);
1022 bool m_suppressSelection
;
1023 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
1026 class wxMacDataItemBrowserSelectionSuppressor
1029 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
1030 ~wxMacDataItemBrowserSelectionSuppressor();
1035 wxMacDataItemBrowserControl
* m_browser
;
1038 // ============================================================================
1039 // platform listbox implementation
1040 // ============================================================================
1042 // exposed for reuse in wxCheckListBox
1044 class wxMacListBoxItem
: public wxMacDataItem
1049 virtual ~wxMacListBoxItem();
1051 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
1052 DataBrowserItemNotification message
,
1053 DataBrowserItemDataRef itemData
) const;
1056 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
1059 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
1060 wxMacDataBrowserListControl() {}
1061 virtual ~wxMacDataBrowserListControl();
1063 virtual wxMacDataItem
* CreateItem();
1067 wxWindow
* GetPeer() const;
1069 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
1072 // ============================================================================
1073 // graphics implementation
1074 // ============================================================================
1076 // make sure we all use one class for all conversions from wx to native colour
1078 class wxMacCoreGraphicsColour
1081 wxMacCoreGraphicsColour();
1082 wxMacCoreGraphicsColour(const wxBrush
&brush
);
1083 ~wxMacCoreGraphicsColour();
1085 void Apply( CGContextRef cgContext
);
1088 wxMacCFRefHolder
<CGColorRef
> m_color
;
1089 wxMacCFRefHolder
<CGColorSpaceRef
> m_colorSpace
;
1092 wxMacCFRefHolder
<CGPatternRef
> m_pattern
;
1093 CGFloat
* m_patternColorComponents
;
1096 CGColorSpaceRef
wxMacGetGenericRGBColorSpace(void);
1097 void wxMacMemoryBufferReleaseProc(void *info
, const void *data
, size_t size
);
1099 class WXDLLEXPORT wxBitmapRefData
: public wxGDIRefData
1101 friend class WXDLLIMPEXP_FWD_CORE wxIcon
;
1102 friend class WXDLLIMPEXP_FWD_CORE wxCursor
;
1104 wxBitmapRefData(int width
, int height
, int depth
);
1106 wxBitmapRefData(const wxBitmapRefData
&tocopy
);
1108 virtual ~wxBitmapRefData();
1111 bool Ok() const { return IsOk(); }
1112 bool IsOk() const { return m_ok
; }
1113 void SetOk( bool isOk
) { m_ok
= isOk
; }
1115 void SetWidth( int width
) { m_width
= width
; }
1116 void SetHeight( int height
) { m_height
= height
; }
1117 void SetDepth( int depth
) { m_depth
= depth
; }
1119 int GetWidth() const { return m_width
; }
1120 int GetHeight() const { return m_height
; }
1121 int GetDepth() const { return m_depth
; }
1123 void *GetRawAccess() const;
1124 void *BeginRawAccess();
1125 void EndRawAccess();
1127 bool HasAlpha() const { return m_hasAlpha
; }
1128 void UseAlpha( bool useAlpha
);
1132 wxPalette m_bitmapPalette
;
1133 #endif // wxUSE_PALETTE
1135 wxMask
* m_bitmapMask
; // Optional mask
1136 CGImageRef
CGImageCreate() const;
1138 // returns true if the bitmap has a size that
1139 // can be natively transferred into a true icon
1140 // if no is returned GetIconRef will still produce
1141 // an icon but it will be generated via a PICT and
1142 // rescaled to 16 x 16
1143 bool HasNativeSize();
1145 // caller should increase ref count if needed longer
1146 // than the bitmap exists
1147 IconRef
GetIconRef();
1149 // returns a Pict from the bitmap content
1150 PicHandle
GetPictHandle();
1152 CGContextRef
GetBitmapContext() const;
1154 int GetBytesPerRow() const { return m_bytesPerRow
; }
1156 bool Create(int width
, int height
, int depth
);
1164 wxMemoryBuffer m_memBuf
;
1165 int m_rawAccessCount
;
1167 mutable CGImageRef m_cgImageRef
;
1170 PicHandle m_pictHandle
;
1172 CGContextRef m_hBitmap
;
1175 class WXDLLEXPORT wxIconRefData
: public wxGDIRefData
1179 wxIconRefData( WXHICON
);
1180 virtual ~wxIconRefData() { Free(); }
1183 virtual void Free();
1185 void SetWidth( int width
) { m_width
= width
; }
1186 void SetHeight( int height
) { m_height
= height
; }
1188 int GetWidth() const { return m_width
; }
1189 int GetHeight() const { return m_height
; }
1191 WXHICON
GetHICON() const { return (WXHICON
) m_iconRef
; }
1200 class wxMacDeferredWindowDeleter
: public wxObject
1203 wxMacDeferredWindowDeleter( WindowRef windowRef
);
1204 virtual ~wxMacDeferredWindowDeleter();
1207 WindowRef m_macWindow
;
1212 #ifdef WORDS_BIGENDIAN
1213 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1215 *rect
= (**pict
).picFrame
;
1219 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1221 return QDGetPictureBounds( pict
, rect
);
1229 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1232 static UPP sHandler = NULL; \
1233 if ( sHandler == NULL ) \
1234 sHandler = New##UPP( x ); \
1238 //---------------------------------------------------------------------------
1239 // wxMac string conversions
1240 //---------------------------------------------------------------------------
1242 void wxMacSetupConverters();
1243 void wxMacCleanupConverters();
1245 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1246 WXDLLIMPEXP_BASE wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1250 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1251 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1252 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
1258 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
);
1259 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
);
1263 //---------------------------------------------------------------------------
1264 // cocoa bridging utilities
1265 //---------------------------------------------------------------------------
1267 bool wxMacInitCocoa();
1269 class wxMacAutoreleasePool
1272 wxMacAutoreleasePool();
1273 ~wxMacAutoreleasePool();
1280 void wxMacCocoaRelease( void* obj
);
1281 void wxMacCocoaAutorelease( void* obj
);
1282 void wxMacCocoaRetain( void* obj
);
1288 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
1289 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
1290 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
1291 void wxMacCocoaHideCursor();
1292 void wxMacCocoaShowCursor();
1294 typedef struct tagClassicCursor
1301 #else // !wxMAC_USE_COCOA
1305 typedef Cursor ClassicCursor
;
1307 #endif // wxMAC_USE_COCOA
1315 const short kwxCursorBullseye
= 0;
1316 const short kwxCursorBlank
= 1;
1317 const short kwxCursorPencil
= 2;
1318 const short kwxCursorMagnifier
= 3;
1319 const short kwxCursorNoEntry
= 4;
1320 const short kwxCursorPaintBrush
= 5;
1321 const short kwxCursorPointRight
= 6;
1322 const short kwxCursorPointLeft
= 7;
1323 const short kwxCursorQuestionArrow
= 8;
1324 const short kwxCursorRightArrow
= 9;
1325 const short kwxCursorSizeNS
= 10;
1326 const short kwxCursorSize
= 11;
1327 const short kwxCursorSizeNESW
= 12;
1328 const short kwxCursorSizeNWSE
= 13;
1329 const short kwxCursorRoller
= 14;
1330 const short kwxCursorLast
= kwxCursorRoller
;
1332 // exposing our fallback cursor map
1334 extern ClassicCursor gMacCursors
[];