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"
67 class wxMacPortStateHelper
69 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper
)
72 wxMacPortStateHelper( GrafPtr newport
);
73 wxMacPortStateHelper();
74 ~wxMacPortStateHelper();
76 void Setup( GrafPtr newport
);
78 bool IsCleared() { return m_clip
== NULL
; }
79 GrafPtr
GetCurrentPort() { return m_currentPort
; }
82 GrafPtr m_currentPort
;
85 ThemeDrawingState m_drawingState
;
92 class WXDLLEXPORT wxMacPortSaver
94 DECLARE_NO_COPY_CLASS(wxMacPortSaver
)
97 wxMacPortSaver( GrafPtr port
);
103 class WXDLLEXPORT wxMacPortSetter
105 DECLARE_NO_COPY_CLASS(wxMacPortSetter
)
108 wxMacPortSetter( const wxDC
* dc
);
111 wxMacPortStateHelper m_ph
;
116 Clips to the visible region of a control within the current port
119 class WXDLLEXPORT wxMacWindowClipper
: public wxMacPortSaver
121 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
124 wxMacWindowClipper( const wxWindow
* win
);
125 ~wxMacWindowClipper();
128 RgnHandle m_formerClip
;
132 class WXDLLEXPORT wxMacWindowStateSaver
: public wxMacWindowClipper
134 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver
)
137 wxMacWindowStateSaver( const wxWindow
* win
);
138 ~wxMacWindowStateSaver();
141 ThemeDrawingState m_themeDrawingState
;
144 #if wxMAC_USE_CORE_GRAPHICS
145 class WXDLLEXPORT wxMacCGContextStateSaver
147 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
150 wxMacCGContextStateSaver( CGContextRef cg
)
153 CGContextSaveGState( cg
);
155 ~wxMacCGContextStateSaver()
157 CGContextRestoreGState( m_cg
);
165 class wxMacDrawingHelper
167 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
170 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false );
171 ~wxMacDrawingHelper();
172 bool Ok() const { return IsOk(); }
173 bool IsOk() { return m_ok; }
174 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); }
175 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); }
176 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); }
177 const Point& GetOrigin() { return m_origin; }
180 GrafPtr m_formerPort;
181 GrafPtr m_currentPort;
182 PenState m_savedPenState;
188 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
193 WXDLLEXPORT wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
194 WXDLLEXPORT
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
197 WXDLLEXPORT wxString
wxMacFindFolderNoSeparator(short vRefNum
,
199 Boolean createFolder
);
200 WXDLLEXPORT wxString
wxMacFindFolder(short vRefNum
,
202 Boolean createFolder
);
204 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
205 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
206 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
207 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
208 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
209 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
210 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
211 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
212 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
213 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
214 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
215 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
216 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
217 #if TARGET_API_MAC_OSX
218 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
219 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
220 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
221 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
222 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
224 #if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 )
225 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
227 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
228 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
231 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
232 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
233 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
234 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
237 class wxMacCarbonEvent
247 wxMacCarbonEvent( EventRef event
, bool release
= false )
253 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
256 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
263 ReleaseEvent( m_eventRef
);
266 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
268 verify( (m_eventRef
== NULL
) || m_release
);
269 if ( m_eventRef
&& m_release
)
271 ReleaseEvent( m_eventRef
);
275 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
281 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
283 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
285 return GetParameter( inName
, type
, sizeof( T
) , data
);
287 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
289 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
292 template <typename T
> T
GetParameter( EventParamName inName
)
295 verify_noerr( GetParameter
<T
>( inName
, &value
) );
298 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
301 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
305 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
306 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
308 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
310 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
312 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
314 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
316 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
318 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
320 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
324 return ::GetEventClass( m_eventRef
);
328 return ::GetEventKind( m_eventRef
);
332 return ::GetEventTime( m_eventRef
);
336 return EventTimeToTicks( GetTime() );
338 OSStatus
SetCurrentTime( )
340 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
342 OSStatus
SetTime( EventTime when
)
344 return ::SetEventTime( m_eventRef
, when
);
346 operator EventRef () { return m_eventRef
; }
348 bool IsValid() { return m_eventRef
!= 0; }
355 // helper class for allocating and deallocating Universal Proc Ptrs
358 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
361 wxMacUPP( procType proc
)
364 m_upp
= (*newUPP
)( NULL
);
371 operator uppType() { return m_upp
; }
376 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
378 template <typename refType
> class wxMacCFRefHolder
382 : m_ref(NULL
) , m_release(false)
386 wxMacCFRefHolder( refType ref
, bool release
= true )
387 : m_ref(ref
) , m_release(release
)
398 if ( m_release
&& m_ref
!= NULL
)
411 void Set( refType ref
, bool release
= true )
418 operator refType () const { return m_ref
; }
424 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
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
);
440 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
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 wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
465 wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
466 wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
468 int wxMacCommandToId( UInt32 macCommandId
);
469 UInt32
wxIdToMacCommand( int wxId
);
470 wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
472 extern wxWindow
* g_MacLastWindow
;
473 pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
474 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
476 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
481 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
482 wxMacControl( wxWindow
* peer
, ControlRef control
);
483 wxMacControl( wxWindow
* peer
, WXWidget control
);
484 virtual ~wxMacControl();
488 virtual void Dispose();
490 bool Ok() const { return IsOk(); }
491 bool IsOk() const { return GetControlRef() != NULL
; }
493 void SetReferenceInNativeControl();
494 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
496 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
497 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
499 virtual void SetReference( SInt32 data
);
501 void operator= (ControlRef c) { m_controlRef = c; }
502 operator ControlRef () { return m_controlRef; }
503 operator ControlRef * () { return &m_controlRef; }
505 // accessing data and values
507 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
508 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
509 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
510 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
511 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
513 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
515 virtual SInt32
GetValue() const;
516 virtual SInt32
GetMaximum() const;
517 virtual SInt32
GetMinimum() const;
519 virtual void SetValue( SInt32 v
);
520 virtual void SetMinimum( SInt32 v
);
521 virtual void SetMaximum( SInt32 v
);
523 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
524 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
526 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
527 virtual bool HasFocus() const;
528 virtual bool NeedsFocusRect() const;
529 virtual void SetNeedsFocusRect( bool needs
);
533 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
536 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
539 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
541 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
543 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
545 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
547 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
549 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
551 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
553 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
555 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
558 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
560 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
563 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
565 wxASSERT_MSG( err
== noErr
,
566 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
567 inPartCode
, (int)inTag
) );
570 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
573 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
575 template <typename T
> T
GetData( ResType inTag
) const
577 return GetData
<T
>( kControlEntireControl
, inTag
);
580 // Flash the control for the specified amount of time
581 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
583 virtual void VisibilityChanged( bool shown
);
584 virtual void SuperChangedPosition();
587 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
588 virtual void SetBackground( const wxBrush
&brush
);
589 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
590 void SetActionProc( ControlActionUPP actionProc
);
591 void SetViewSize( SInt32 viewSize
);
592 SInt32
GetViewSize() const;
594 virtual bool IsVisible() const;
595 virtual void SetVisibility( bool visible
, bool redraw
);
596 virtual bool IsEnabled() const;
597 virtual bool IsActive() const;
598 virtual void Enable( bool enable
);
600 // invalidates this control and all children
601 virtual void InvalidateWithChildren();
602 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
;
649 // ============================================================================
650 // DataBrowser Wrapper
651 // ============================================================================
653 // basing on DataBrowserItemIDs
656 class wxMacDataBrowserControl
: public wxMacControl
659 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
661 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
663 OSStatus
GetItemCount( DataBrowserItemID container
,
665 DataBrowserItemState state
,
666 UInt32
*numItems
) const;
668 OSStatus
GetItems( DataBrowserItemID container
,
670 DataBrowserItemState state
,
674 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
675 DataBrowserTableViewColumnIndex position
);
677 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
679 OSStatus
AutoSizeColumns();
681 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
682 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
684 OSStatus
SetHeaderButtonHeight( UInt16 height
);
685 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
687 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
688 const DataBrowserItemID
*items
,
689 DataBrowserPropertyID preSortProperty
,
690 DataBrowserPropertyID propertyID
) const;
692 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
693 const DataBrowserItemID
*items
,
694 DataBrowserPropertyID preSortProperty
);
695 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
696 const DataBrowserItemID
*items
,
697 DataBrowserPropertyID preSortProperty
);
698 OSStatus
RevealItem( DataBrowserItemID item
,
699 DataBrowserPropertyID propertyID
,
700 DataBrowserRevealOptions options
) const;
702 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
703 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
704 bool IsItemSelected( DataBrowserItemID item
) const;
705 OSStatus
SetSelectedItems( UInt32 numItems
,
706 const DataBrowserItemID
*items
,
707 DataBrowserSetOption operation
);
709 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
710 DataBrowserItemID
* item
) const;
711 OSStatus
GetItemRow( DataBrowserItemID item
,
712 DataBrowserTableViewRowIndex
* row
) const;
714 OSStatus
SetDefaultRowHeight( UInt16 height
);
715 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
717 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
718 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
720 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
721 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
723 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
724 OSStatus
SetDefaultColumnWidth( UInt16 width
);
726 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
728 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
730 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, UInt32
*position
) const;
731 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, UInt32 position
);
733 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
734 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
736 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
737 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
739 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
740 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
742 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
743 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
745 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
746 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
748 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
751 static pascal void DataBrowserItemNotificationProc(
753 DataBrowserItemID itemID
,
754 DataBrowserItemNotification message
,
755 DataBrowserItemDataRef itemData
);
757 virtual void ItemNotification(
758 DataBrowserItemID itemID
,
759 DataBrowserItemNotification message
,
760 DataBrowserItemDataRef itemData
) = 0;
762 static pascal OSStatus
DataBrowserGetSetItemDataProc(
764 DataBrowserItemID itemID
,
765 DataBrowserPropertyID property
,
766 DataBrowserItemDataRef itemData
,
767 Boolean changeValue
);
769 virtual OSStatus
GetSetItemData(
770 DataBrowserItemID itemID
,
771 DataBrowserPropertyID property
,
772 DataBrowserItemDataRef itemData
,
773 Boolean changeValue
) = 0;
775 static pascal Boolean
DataBrowserCompareProc(
777 DataBrowserItemID itemOneID
,
778 DataBrowserItemID itemTwoID
,
779 DataBrowserPropertyID sortProperty
);
781 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
782 DataBrowserItemID itemTwoID
,
783 DataBrowserPropertyID sortProperty
) = 0;
786 // ============================================================================
787 // Higher-level Databrowser
788 // ============================================================================
790 // basing on data item objects
795 class wxMacDataItemBrowserControl
;
796 class wxMacListBoxItem
;
798 const DataBrowserPropertyID kTextColumnId
= 1024;
799 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
801 // for multi-column controls, we will use this + the column ID to identify the
802 // column. We don't use kTextColumnId there, and ideally the two should merge.
803 const DataBrowserPropertyID kMinColumnId
= 1050;
805 // base API for high-level databrowser operations
807 class wxMacListControl
810 virtual void MacDelete( unsigned int n
) = 0;
811 virtual void MacInsert( unsigned int n
, const wxString
& item
, int column
= -1 ) = 0;
812 virtual void MacInsert( unsigned int n
, const wxArrayString
& items
, int column
= -1 ) = 0;
813 // returns index of newly created line
814 virtual int MacAppend( const wxString
& item
) = 0;
815 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
816 virtual void MacClear() = 0;
817 virtual void MacDeselectAll() = 0;
818 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
819 virtual int MacGetSelection() const = 0;
820 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
821 virtual bool MacIsSelected( unsigned int n
) const = 0;
822 virtual void MacScrollTo( unsigned int n
) = 0;
823 virtual wxString
MacGetString( unsigned int n
) const = 0;
824 virtual unsigned int MacGetCount() const = 0;
826 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
827 virtual void * MacGetClientData( unsigned int) const = 0;
829 virtual ~wxMacListControl() { }
832 // base class for databrowser items
842 virtual ~wxMacDataItem();
844 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
845 const wxMacDataItem
*,
846 DataBrowserPropertyID property
) const;
848 // returns true if access was successful, otherwise false
849 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
850 DataBrowserPropertyID property
,
851 DataBrowserItemDataRef itemData
,
854 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
855 DataBrowserItemNotification message
,
856 DataBrowserItemDataRef itemData
) const;
858 void SetLabel( const wxString
& str
);
859 const wxString
& GetLabel() const;
861 void SetOrder( SInt32 order
);
862 SInt32
GetOrder() const;
864 void SetData( void* data
);
865 void* GetData() const;
867 void SetColumn( short col
);
872 wxMacCFStringHolder m_cfLabel
;
875 DataBrowserPropertyID m_colId
;
881 SortOrder_Text_Ascending
,
882 SortOrder_Text_Descending
885 typedef wxMacDataItem
* wxMacDataItemPtr
;
886 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
888 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
890 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
893 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
895 // create a list item (can be a subclass of wxMacListBoxItem)
897 virtual wxMacDataItem
* CreateItem();
899 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
900 void GetItems(const wxMacDataItem
* container
, bool recurse
,
901 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
903 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
905 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
906 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
908 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
909 DataBrowserPropertyID property
) const;
910 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
911 DataBrowserPropertyID property
) const;
913 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
914 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
916 int GetColumnWidth(int colId
);
917 void SetColumnWidth(int colId
, int width
);
919 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
920 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
922 void RemoveAllItems(wxMacDataItem
*container
);
923 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
924 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
926 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
927 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
928 void SetSelectedAllItems( DataBrowserSetOption option
);
929 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
931 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
933 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
935 // item aware methods, to be used in subclasses
937 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
938 const wxMacDataItem
* itemTwoID
,
939 DataBrowserPropertyID sortProperty
);
941 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
942 DataBrowserPropertyID property
,
943 DataBrowserItemDataRef itemData
,
944 Boolean changeValue
);
946 virtual void ItemNotification(
947 const wxMacDataItem
* itemID
,
948 DataBrowserItemNotification message
,
949 DataBrowserItemDataRef itemData
);
951 // as we are getting the same events for human and API selection we have to suppress
952 // events in the latter case, since this will be used from many subclasses we keep it here
954 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
955 bool SuppressSelection( bool suppress
);
958 // wxMacListControl Methods
961 virtual void MacDelete( unsigned int n
);
962 virtual void MacInsert( unsigned int n
, const wxString
& item
, int column
= -1 );
963 virtual void MacInsert( unsigned int n
, const wxArrayString
& items
, int column
= -1 );
964 virtual int MacAppend( const wxString
& item
);
965 virtual void MacClear();
969 virtual void MacDeselectAll();
970 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
971 virtual int MacGetSelection() const;
972 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
973 virtual bool MacIsSelected( unsigned int n
) const;
977 virtual void MacScrollTo( unsigned int n
);
981 virtual void MacSetString( unsigned int n
, const wxString
& item
);
982 virtual void MacSetClientData( unsigned int n
, void * data
);
983 virtual wxString
MacGetString( unsigned int n
) const;
984 virtual void * MacGetClientData( unsigned int) const;
985 virtual unsigned int MacGetCount() const;
989 virtual wxClientDataType
GetClientDataType() const;
990 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
991 //virtual ListSortOrder GetSortOrder() const;
992 //virtual void SetSortOrder(const ListSortOrder sort);
998 ListSortOrder m_sortOrder
;
999 wxClientDataType m_clientDataItemsType
;
1001 // ID aware base methods, should be 'final' ie not changed in subclasses
1003 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
1004 DataBrowserItemID itemTwoID
,
1005 DataBrowserPropertyID sortProperty
);
1007 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
1008 DataBrowserPropertyID property
,
1009 DataBrowserItemDataRef itemData
,
1010 Boolean changeValue
);
1012 virtual void ItemNotification(
1013 DataBrowserItemID itemID
,
1014 DataBrowserItemNotification message
,
1015 DataBrowserItemDataRef itemData
);
1020 bool m_suppressSelection
;
1023 class wxMacDataItemBrowserSelectionSuppressor
1026 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
1027 ~wxMacDataItemBrowserSelectionSuppressor();
1032 wxMacDataItemBrowserControl
* m_browser
;
1035 // ============================================================================
1036 // platform listbox implementation
1037 // ============================================================================
1039 // exposed for reuse in wxCheckListBox
1041 class wxMacListBoxItem
: public wxMacDataItem
1046 virtual ~wxMacListBoxItem();
1048 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
1049 DataBrowserItemNotification message
,
1050 DataBrowserItemDataRef itemData
) const;
1053 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
1056 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
1057 virtual ~wxMacDataBrowserListControl();
1059 virtual wxMacDataItem
* CreateItem();
1063 wxWindow
* GetPeer() const;
1067 // ============================================================================
1068 // graphics implementation
1069 // ============================================================================
1071 #if wxMAC_USE_CORE_GRAPHICS
1073 class WXDLLEXPORT wxMacCGPath
: public wxGraphicPath
1075 DECLARE_NO_COPY_CLASS(wxMacCGPath
)
1080 // Starts a new subpath at
1081 void MoveToPoint( wxCoord x1
, wxCoord y1
);
1082 void AddLineToPoint( wxCoord x1
, wxCoord y1
);
1083 void AddQuadCurveToPoint( wxCoord cx1
, wxCoord cy1
, wxCoord x1
, wxCoord y1
);
1084 void AddRectangle( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1085 void AddCircle( wxCoord x
, wxCoord y
, wxCoord r
);
1087 // draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2)
1088 virtual void AddArcToPoint( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord r
) ;
1089 virtual void AddArc( wxCoord x
, wxCoord y
, wxCoord r
, double startAngle
, double endAngle
, bool clockwise
) ;
1091 // closes the current subpath
1092 void CloseSubpath();
1094 CGPathRef
GetPath() const;
1096 CGMutablePathRef m_path
;
1099 class WXDLLEXPORT wxMacCGContext
: public wxGraphicContext
1101 DECLARE_NO_COPY_CLASS(wxMacCGContext
)
1104 wxMacCGContext( CGrafPtr port
);
1105 wxMacCGContext( CGContextRef cgcontext
);
1107 virtual ~wxMacCGContext();
1109 virtual void Clip( const wxRegion
®ion
);
1110 virtual void StrokePath( const wxGraphicPath
*p
);
1111 virtual void DrawPath( const wxGraphicPath
*p
, int fillStyle
= wxWINDING_RULE
);
1112 virtual void FillPath( const wxGraphicPath
*p
, const wxColor
&fillColor
, int fillStyle
= wxWINDING_RULE
);
1114 virtual wxGraphicPath
* CreatePath();
1115 virtual void SetPen( const wxPen
&pen
) ;
1116 virtual void SetBrush( const wxBrush
&brush
);
1117 CGContextRef
GetNativeContext();
1118 void SetNativeContext( CGContextRef cg
);
1119 CGPathDrawingMode
GetDrawingMode() const { return m_mode
; }
1121 virtual void Translate( wxCoord dx
, wxCoord dy
);
1122 virtual void Scale( wxCoord xScale
, wxCoord yScale
);
1123 virtual void DrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1124 virtual void DrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1125 virtual void PushState();
1126 virtual void PopState();
1128 virtual void DrawText( const wxString
&str
, wxCoord x
, wxCoord y
, double angle
) ;
1130 virtual void GetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
1131 wxCoord
*descent
, wxCoord
*externalLeading
) const ;
1133 virtual void GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const ;
1135 virtual void SetFont( const wxFont
&font
) ;
1137 virtual void SetTextColor( const wxColour
&col
) ;
1139 CGContextRef m_cgContext
;
1141 CGPathDrawingMode m_mode
;
1142 ATSUStyle m_macATSUIStyle
;
1145 wxColor m_textForegroundColor
;
1148 #endif // wxMAC_USE_CORE_GRAPHICS
1150 #ifdef __WXMAC_OSX__
1152 CGColorSpaceRef
wxMacGetGenericRGBColorSpace(void);
1153 void wxMacMemoryBufferReleaseProc(void *info
, const void *data
, size_t size
);
1157 class WXDLLEXPORT wxBitmapRefData
: public wxGDIRefData
1159 DECLARE_NO_COPY_CLASS(wxBitmapRefData
)
1161 friend class WXDLLEXPORT wxIcon
;
1162 friend class WXDLLEXPORT wxCursor
;
1164 wxBitmapRefData(int width
, int height
, int depth
);
1166 virtual ~wxBitmapRefData();
1169 bool Ok() const { return IsOk(); }
1170 bool IsOk() const { return m_ok
; }
1171 void SetOk( bool isOk
) { m_ok
= isOk
; }
1173 void SetWidth( int width
) { m_width
= width
; }
1174 void SetHeight( int height
) { m_height
= height
; }
1175 void SetDepth( int depth
) { m_depth
= depth
; }
1177 int GetWidth() const { return m_width
; }
1178 int GetHeight() const { return m_height
; }
1179 int GetDepth() const { return m_depth
; }
1181 void *GetRawAccess() const;
1182 void *BeginRawAccess();
1183 void EndRawAccess();
1185 bool HasAlpha() const { return m_hasAlpha
; }
1186 void UseAlpha( bool useAlpha
);
1190 wxPalette m_bitmapPalette
;
1191 #endif // wxUSE_PALETTE
1193 wxMask
* m_bitmapMask
; // Optional mask
1194 #ifdef __WXMAC_OSX__
1195 CGImageRef
CGImageCreate() const;
1198 // returns true if the bitmap has a size that
1199 // can be natively transferred into a true icon
1200 // if no is returned GetIconRef will still produce
1201 // an icon but it will be generated via a PICT and
1202 // rescaled to 16 x 16
1203 bool HasNativeSize();
1205 // caller should increase ref count if needed longer
1206 // than the bitmap exists
1207 IconRef
GetIconRef();
1209 // returns a Pict from the bitmap content
1210 PicHandle
GetPictHandle();
1211 GWorldPtr
GetHBITMAP(GWorldPtr
* mask
= NULL
) const;
1212 void UpdateAlphaMask() const;
1215 bool Create(int width
, int height
, int depth
);
1223 wxMemoryBuffer m_memBuf
;
1224 int m_rawAccessCount
;
1226 #ifdef __WXMAC_OSX__
1227 mutable CGImageRef m_cgImageRef
;
1230 PicHandle m_pictHandle
;
1231 GWorldPtr m_hBitmap
;
1232 GWorldPtr m_hMaskBitmap
;
1233 wxMemoryBuffer m_maskMemBuf
;
1234 int m_maskBytesPerRow
;
1237 class WXDLLEXPORT wxIconRefData
: public wxGDIRefData
1241 wxIconRefData( WXHICON
);
1242 virtual ~wxIconRefData() { Free(); }
1245 virtual void Free();
1247 void SetWidth( int width
) { m_width
= width
; }
1248 void SetHeight( int height
) { m_height
= height
; }
1250 int GetWidth() const { return m_width
; }
1251 int GetHeight() const { return m_height
; }
1253 WXHICON
GetHICON() const { return (WXHICON
) m_iconRef
; }
1262 ControlRef
wxMacFindControlUnderMouse( wxTopLevelWindowMac
* toplevelWindow
, const Point
& location
, WindowRef window
, ControlPartCode
*outPart
);
1264 #ifdef WORDS_BIGENDIAN
1265 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1267 *rect
= (**pict
).picFrame
;
1271 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1273 return QDGetPictureBounds( pict
, rect
);
1279 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1282 static UPP sHandler = NULL; \
1283 if ( sHandler == NULL ) \
1284 sHandler = New##UPP( x ); \
1288 //---------------------------------------------------------------------------
1289 // wxMac string conversions
1290 //---------------------------------------------------------------------------
1292 void wxMacSetupConverters();
1293 void wxMacCleanupConverters();
1295 void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1296 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1300 wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1301 OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1302 wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);