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_
20 # include <Carbon/Carbon.h>
22 # include <Debugging.h>
23 # include <Quickdraw.h>
24 # include <Appearance.h>
26 # include <Controls.h>
27 # include <ControlDefinitions.h>
31 # include <CoreServices.h>
34 #if UNIVERSAL_INTERFACES_VERSION < 0x0342
35 #error "please update to Apple's latest universal headers from http://developer.apple.com/sdk/"
38 #ifndef MAC_OS_X_VERSION_10_3
39 #define MAC_OS_X_VERSION_10_3 1030
42 #ifndef MAC_OS_X_VERSION_10_4
43 #define MAC_OS_X_VERSION_10_4 1040
46 #ifdef __WXMAC_CARBON__
47 #include "wx/mac/corefoundation/cfstring.h"
51 // as macro in FixMath.h for 10.3
52 inline Fixed
IntToFixed( int inInt
)
54 return (((SInt32
) inInt
) << 16);
57 inline int FixedToInt( Fixed inFixed
)
59 return (((SInt32
) inFixed
) >> 16);
65 #include "wx/listbox.h"
69 class wxMacPortStateHelper
71 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper
)
74 wxMacPortStateHelper( GrafPtr newport
);
75 wxMacPortStateHelper();
76 ~wxMacPortStateHelper();
78 void Setup( GrafPtr newport
);
80 bool IsCleared() { return m_clip
== NULL
; }
81 GrafPtr
GetCurrentPort() { return m_currentPort
; }
84 GrafPtr m_currentPort
;
87 ThemeDrawingState m_drawingState
;
94 class WXDLLEXPORT wxMacPortSaver
96 DECLARE_NO_COPY_CLASS(wxMacPortSaver
)
99 wxMacPortSaver( GrafPtr port
);
105 class WXDLLEXPORT wxMacPortSetter
107 DECLARE_NO_COPY_CLASS(wxMacPortSetter
)
110 wxMacPortSetter( const wxDC
* dc
);
113 wxMacPortStateHelper m_ph
;
118 Clips to the visible region of a control within the current port
121 class WXDLLEXPORT wxMacWindowClipper
: public wxMacPortSaver
123 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
126 wxMacWindowClipper( const wxWindow
* win
);
127 ~wxMacWindowClipper();
130 RgnHandle m_formerClip
;
134 class WXDLLEXPORT wxMacWindowStateSaver
: public wxMacWindowClipper
136 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver
)
139 wxMacWindowStateSaver( const wxWindow
* win
);
140 ~wxMacWindowStateSaver();
143 ThemeDrawingState m_themeDrawingState
;
147 #if wxMAC_USE_CORE_GRAPHICS
148 class WXDLLEXPORT wxMacCGContextStateSaver
150 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
153 wxMacCGContextStateSaver( CGContextRef cg
)
156 CGContextSaveGState( cg
);
158 ~wxMacCGContextStateSaver()
160 CGContextRestoreGState( m_cg
);
168 class wxMacDrawingHelper
170 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
173 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false );
174 ~wxMacDrawingHelper();
175 bool Ok() const { return IsOk(); }
176 bool IsOk() { return m_ok; }
177 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); }
178 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); }
179 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); }
180 const Point& GetOrigin() { return m_origin; }
183 GrafPtr m_formerPort;
184 GrafPtr m_currentPort;
185 PenState m_savedPenState;
191 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
196 WXDLLEXPORT wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
197 WXDLLEXPORT
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
200 WXDLLEXPORT wxString
wxMacFindFolderNoSeparator(short vRefNum
,
202 Boolean createFolder
);
203 WXDLLEXPORT wxString
wxMacFindFolder(short vRefNum
,
205 Boolean createFolder
);
207 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
208 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
209 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
210 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
211 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
212 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
213 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
214 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
215 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
216 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
217 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
218 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
219 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
220 #if TARGET_API_MAC_OSX
221 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
222 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
223 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
224 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
225 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
227 #if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 )
228 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
230 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
231 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
234 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
235 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
236 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
237 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
240 class wxMacCarbonEvent
250 wxMacCarbonEvent( EventRef event
, bool release
= false )
256 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
259 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
266 ReleaseEvent( m_eventRef
);
269 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
271 verify( (m_eventRef
== NULL
) || m_release
);
272 if ( m_eventRef
&& m_release
)
274 ReleaseEvent( m_eventRef
);
278 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
284 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
286 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
288 return GetParameter( inName
, type
, sizeof( T
) , data
);
290 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
292 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
295 template <typename T
> T
GetParameter( EventParamName inName
)
298 verify_noerr( GetParameter
<T
>( inName
, &value
) );
301 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
304 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
308 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
309 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
311 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
313 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
315 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
317 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
319 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
321 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
323 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
327 return ::GetEventClass( m_eventRef
);
331 return ::GetEventKind( m_eventRef
);
335 return ::GetEventTime( m_eventRef
);
339 return EventTimeToTicks( GetTime() );
341 OSStatus
SetCurrentTime( )
343 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
345 OSStatus
SetTime( EventTime when
)
347 return ::SetEventTime( m_eventRef
, when
);
349 operator EventRef () { return m_eventRef
; }
351 bool IsValid() { return m_eventRef
!= 0; }
358 // helper class for allocating and deallocating Universal Proc Ptrs
361 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
364 wxMacUPP( procType proc
)
367 m_upp
= (*newUPP
)( NULL
);
374 operator uppType() { return m_upp
; }
379 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
381 template <typename refType
> class wxMacCFRefHolder
385 : m_ref(NULL
) , m_release(false)
389 wxMacCFRefHolder( refType ref
, bool release
= true )
390 : m_ref(ref
) , m_release(release
)
401 if ( m_release
&& m_ref
!= NULL
)
414 void Set( refType ref
, bool release
= true )
421 operator refType () const { return m_ref
; }
427 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
433 GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
434 void wxMacDestroyGWorld( GWorldPtr gw );
435 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL );
436 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize );
437 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue );
438 CTabHandle wxMacCreateColorTable( int numColors );
440 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
441 void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
443 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
444 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
445 #define MAC_WXHMETAFILE(a) (PicHandle(a))
446 #define MAC_WXHICON(a) (IconRef(a))
447 #define MAC_WXHCURSOR(a) (CursHandle(a))
448 #define MAC_WXHRGN(a) (RgnHandle(a))
449 #define MAC_WXHWND(a) (WindowPtr(a))
450 #define MAC_WXRECPTR(a) ((Rect*)a)
451 #define MAC_WXPOINTPTR(a) ((Point*)a)
452 #define MAC_WXHMENU(a) ((MenuHandle)a)
454 struct wxOpaqueWindowRef
456 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
457 operator WindowRef() { return m_data
; }
462 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
463 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
464 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
465 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
467 wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
468 wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
469 wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
471 int wxMacCommandToId( UInt32 macCommandId
);
472 UInt32
wxIdToMacCommand( int wxId
);
473 wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
475 extern wxWindow
* g_MacLastWindow
;
476 pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
477 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
479 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
484 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
485 wxMacControl( wxWindow
* peer
, ControlRef control
);
486 wxMacControl( wxWindow
* peer
, WXWidget control
);
487 virtual ~wxMacControl();
491 virtual void Dispose();
493 bool Ok() const { return IsOk(); }
494 bool IsOk() const { return GetControlRef() != NULL
; }
496 void SetReferenceInNativeControl();
497 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
499 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
500 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
502 virtual void SetReference( URefCon data
);
504 void operator= (ControlRef c) { m_controlRef = c; }
505 operator ControlRef () { return m_controlRef; }
506 operator ControlRef * () { return &m_controlRef; }
508 // accessing data and values
510 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
511 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
512 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
513 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
514 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
516 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
518 virtual SInt32
GetValue() const;
519 virtual SInt32
GetMaximum() const;
520 virtual SInt32
GetMinimum() const;
522 virtual void SetValue( SInt32 v
);
523 virtual void SetMinimum( SInt32 v
);
524 virtual void SetMaximum( SInt32 v
);
526 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
527 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
529 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
530 virtual bool HasFocus() const;
531 virtual bool NeedsFocusRect() const;
532 virtual void SetNeedsFocusRect( bool needs
);
536 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
539 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
542 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
544 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
546 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
548 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
550 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
552 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
554 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
556 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
558 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
561 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
563 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
566 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
568 wxASSERT_MSG( err
== noErr
,
569 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
570 inPartCode
, (int)inTag
) );
573 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
576 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
578 template <typename T
> T
GetData( ResType inTag
) const
580 return GetData
<T
>( kControlEntireControl
, inTag
);
583 // Flash the control for the specified amount of time
584 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
586 virtual void VisibilityChanged( bool shown
);
587 virtual void SuperChangedPosition();
590 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
591 virtual void SetBackground( const wxBrush
&brush
);
592 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
593 void SetActionProc( ControlActionUPP actionProc
);
594 void SetViewSize( SInt32 viewSize
);
595 SInt32
GetViewSize() const;
597 virtual bool IsVisible() const;
598 virtual void SetVisibility( bool visible
, bool redraw
);
599 virtual bool IsEnabled() const;
600 virtual bool IsActive() const;
601 virtual void Enable( bool enable
);
603 // invalidates this control and all children
604 virtual void InvalidateWithChildren();
605 virtual void SetDrawingEnabled( bool enable
);
607 virtual bool GetNeedsDisplay() const;
609 // where is in native window relative coordinates
610 virtual void SetNeedsDisplay( RgnHandle where
);
611 // where is in native window relative coordinates
612 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
614 // if rect = NULL, entire view
615 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
617 // in native parent window relative coordinates
618 virtual void GetRect( Rect
*r
);
620 // in native parent window relative coordinates
621 virtual void SetRect( Rect
*r
);
623 virtual void GetRectInWindowCoords( Rect
*r
);
624 virtual void GetBestRect( Rect
*r
);
625 virtual void SetLabel( const wxString
&title
);
626 // converts from Toplevel-Content relative to local
627 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
629 virtual void GetFeatures( UInt32
*features
);
630 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
631 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
633 bool IsRootControl() { return m_isRootControl
; }
635 wxWindow
* GetPeer() const
640 // to be moved into a tab control class
642 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
644 ControlRef m_controlRef
;
648 bool m_needsFocusRect
;
649 bool m_isRootControl
;
652 // ============================================================================
653 // DataBrowser Wrapper
654 // ============================================================================
656 // basing on DataBrowserItemIDs
659 class wxMacDataBrowserControl
: public wxMacControl
662 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
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;
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 wxString
& item
, int column
= -1 ) = 0;
815 virtual void MacInsert( unsigned int n
, const wxArrayString
& 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
);
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 wxString
& item
, int column
= -1 );
966 virtual void MacInsert( unsigned int n
, const wxArrayString
& items
, int column
= -1 );
967 virtual int MacAppend( const wxString
& item
);
968 virtual void MacClear();
972 virtual void MacDeselectAll();
973 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
974 virtual int MacGetSelection() const;
975 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
976 virtual bool MacIsSelected( unsigned int n
) const;
980 virtual void MacScrollTo( unsigned int n
);
984 virtual void MacSetString( unsigned int n
, const wxString
& item
);
985 virtual void MacSetClientData( unsigned int n
, void * data
);
986 virtual wxString
MacGetString( unsigned int n
) const;
987 virtual void * MacGetClientData( unsigned int) const;
988 virtual unsigned int MacGetCount() const;
992 virtual wxClientDataType
GetClientDataType() const;
993 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
994 //virtual ListSortOrder GetSortOrder() const;
995 //virtual void SetSortOrder(const ListSortOrder sort);
1001 ListSortOrder m_sortOrder
;
1002 wxClientDataType m_clientDataItemsType
;
1004 // ID aware base methods, should be 'final' ie not changed in subclasses
1006 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
1007 DataBrowserItemID itemTwoID
,
1008 DataBrowserPropertyID sortProperty
);
1010 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
1011 DataBrowserPropertyID property
,
1012 DataBrowserItemDataRef itemData
,
1013 Boolean changeValue
);
1015 virtual void ItemNotification(
1016 DataBrowserItemID itemID
,
1017 DataBrowserItemNotification message
,
1018 DataBrowserItemDataRef itemData
);
1023 bool m_suppressSelection
;
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 virtual ~wxMacDataBrowserListControl();
1062 virtual wxMacDataItem
* CreateItem();
1066 wxWindow
* GetPeer() const;
1070 // ============================================================================
1071 // graphics implementation
1072 // ============================================================================
1074 #if wxMAC_USE_CORE_GRAPHICS
1076 class WXDLLEXPORT wxMacCGPath
: public wxGraphicPath
1078 DECLARE_NO_COPY_CLASS(wxMacCGPath
)
1083 // Starts a new subpath at
1084 void MoveToPoint( wxCoord x1
, wxCoord y1
);
1085 void AddLineToPoint( wxCoord x1
, wxCoord y1
);
1086 void AddQuadCurveToPoint( wxCoord cx1
, wxCoord cy1
, wxCoord x1
, wxCoord y1
);
1087 void AddRectangle( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1088 void AddCircle( wxCoord x
, wxCoord y
, wxCoord r
);
1090 // draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2)
1091 virtual void AddArcToPoint( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord r
) ;
1092 virtual void AddArc( wxCoord x
, wxCoord y
, wxCoord r
, double startAngle
, double endAngle
, bool clockwise
) ;
1094 // closes the current subpath
1095 void CloseSubpath();
1097 CGPathRef
GetPath() const;
1099 CGMutablePathRef m_path
;
1102 class WXDLLEXPORT wxMacCGContext
: public wxGraphicContext
1104 DECLARE_NO_COPY_CLASS(wxMacCGContext
)
1107 wxMacCGContext( CGrafPtr port
);
1108 wxMacCGContext( CGContextRef cgcontext
);
1110 virtual ~wxMacCGContext();
1112 virtual void Clip( const wxRegion
®ion
);
1113 virtual void StrokePath( const wxGraphicPath
*p
);
1114 virtual void DrawPath( const wxGraphicPath
*p
, int fillStyle
= wxWINDING_RULE
);
1115 virtual void FillPath( const wxGraphicPath
*p
, const wxColor
&fillColor
, int fillStyle
= wxWINDING_RULE
);
1117 virtual wxGraphicPath
* CreatePath();
1118 virtual void SetPen( const wxPen
&pen
) ;
1119 virtual void SetBrush( const wxBrush
&brush
);
1120 CGContextRef
GetNativeContext();
1121 void SetNativeContext( CGContextRef cg
);
1122 CGPathDrawingMode
GetDrawingMode() const { return m_mode
; }
1124 virtual void Translate( wxCoord dx
, wxCoord dy
);
1125 virtual void Scale( wxCoord xScale
, wxCoord yScale
);
1126 virtual void DrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1127 virtual void DrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1128 virtual void PushState();
1129 virtual void PopState();
1131 virtual void DrawText( const wxString
&str
, wxCoord x
, wxCoord y
, double angle
) ;
1133 virtual void GetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
1134 wxCoord
*descent
, wxCoord
*externalLeading
) const ;
1136 virtual void GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const ;
1138 virtual void SetFont( const wxFont
&font
) ;
1140 virtual void SetTextColor( const wxColour
&col
) ;
1142 CGContextRef m_cgContext
;
1144 CGPathDrawingMode m_mode
;
1145 ATSUStyle m_macATSUIStyle
;
1148 wxColor m_textForegroundColor
;
1151 #endif // wxMAC_USE_CORE_GRAPHICS
1153 #ifdef __WXMAC_OSX__
1155 CGColorSpaceRef
wxMacGetGenericRGBColorSpace(void);
1156 void wxMacMemoryBufferReleaseProc(void *info
, const void *data
, size_t size
);
1160 class WXDLLEXPORT wxBitmapRefData
: public wxGDIRefData
1162 DECLARE_NO_COPY_CLASS(wxBitmapRefData
)
1164 friend class WXDLLEXPORT wxIcon
;
1165 friend class WXDLLEXPORT wxCursor
;
1167 wxBitmapRefData(int width
, int height
, int depth
);
1169 virtual ~wxBitmapRefData();
1172 bool Ok() const { return IsOk(); }
1173 bool IsOk() const { return m_ok
; }
1174 void SetOk( bool isOk
) { m_ok
= isOk
; }
1176 void SetWidth( int width
) { m_width
= width
; }
1177 void SetHeight( int height
) { m_height
= height
; }
1178 void SetDepth( int depth
) { m_depth
= depth
; }
1180 int GetWidth() const { return m_width
; }
1181 int GetHeight() const { return m_height
; }
1182 int GetDepth() const { return m_depth
; }
1184 void *GetRawAccess() const;
1185 void *BeginRawAccess();
1186 void EndRawAccess();
1188 bool HasAlpha() const { return m_hasAlpha
; }
1189 void UseAlpha( bool useAlpha
);
1193 wxPalette m_bitmapPalette
;
1194 #endif // wxUSE_PALETTE
1196 wxMask
* m_bitmapMask
; // Optional mask
1197 #ifdef __WXMAC_OSX__
1198 CGImageRef
CGImageCreate() const;
1201 // returns true if the bitmap has a size that
1202 // can be natively transferred into a true icon
1203 // if no is returned GetIconRef will still produce
1204 // an icon but it will be generated via a PICT and
1205 // rescaled to 16 x 16
1206 bool HasNativeSize();
1208 // caller should increase ref count if needed longer
1209 // than the bitmap exists
1210 IconRef
GetIconRef();
1212 // returns a Pict from the bitmap content
1213 PicHandle
GetPictHandle();
1214 GWorldPtr
GetHBITMAP(GWorldPtr
* mask
= NULL
) const;
1215 void UpdateAlphaMask() const;
1218 bool Create(int width
, int height
, int depth
);
1226 wxMemoryBuffer m_memBuf
;
1227 int m_rawAccessCount
;
1229 #ifdef __WXMAC_OSX__
1230 mutable CGImageRef m_cgImageRef
;
1233 PicHandle m_pictHandle
;
1234 GWorldPtr m_hBitmap
;
1235 GWorldPtr m_hMaskBitmap
;
1236 wxMemoryBuffer m_maskMemBuf
;
1237 int m_maskBytesPerRow
;
1240 class WXDLLEXPORT wxIconRefData
: public wxGDIRefData
1244 wxIconRefData( WXHICON
);
1245 virtual ~wxIconRefData() { Free(); }
1248 virtual void Free();
1250 void SetWidth( int width
) { m_width
= width
; }
1251 void SetHeight( int height
) { m_height
= height
; }
1253 int GetWidth() const { return m_width
; }
1254 int GetHeight() const { return m_height
; }
1256 WXHICON
GetHICON() const { return (WXHICON
) m_iconRef
; }
1265 ControlRef
wxMacFindControlUnderMouse( wxTopLevelWindowMac
* toplevelWindow
, const Point
& location
, WindowRef window
, ControlPartCode
*outPart
);
1269 #ifdef WORDS_BIGENDIAN
1270 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1272 *rect
= (**pict
).picFrame
;
1276 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1278 return QDGetPictureBounds( pict
, rect
);
1286 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1289 static UPP sHandler = NULL; \
1290 if ( sHandler == NULL ) \
1291 sHandler = New##UPP( x ); \
1295 //---------------------------------------------------------------------------
1296 // wxMac string conversions
1297 //---------------------------------------------------------------------------
1299 void wxMacSetupConverters();
1300 void wxMacCleanupConverters();
1302 void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1303 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1307 wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1308 OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1309 wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
1315 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
);
1316 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
);