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_
21 # include <Carbon/Carbon.h>
23 # include <Debugging.h>
24 # include <Quickdraw.h>
25 # include <Appearance.h>
27 # include <Controls.h>
28 # include <ControlDefinitions.h>
32 # include <CoreServices.h>
35 #if UNIVERSAL_INTERFACES_VERSION < 0x0342
36 #error "please update to Apple's lastest universal headers from http://developer.apple.com/sdk/"
39 #ifndef MAC_OS_X_VERSION_10_3
40 #define MAC_OS_X_VERSION_10_3 1030
43 #ifndef MAC_OS_X_VERSION_10_4
44 #define MAC_OS_X_VERSION_10_4 1040
47 #ifdef __WXMAC_CARBON__
48 #include "wx/mac/corefoundation/cfstring.h"
52 // as macro in FixMath.h for 10.3
53 inline Fixed
IntToFixed( int inInt
)
55 return (((SInt32
) inInt
) << 16);
58 inline int FixedToInt( Fixed inFixed
)
60 return (((SInt32
) inFixed
) >> 16);
67 #include "wx/window.h"
68 #include "wx/toplevel.h"
70 class wxMacPortStateHelper
72 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper
)
75 wxMacPortStateHelper( GrafPtr newport
);
76 wxMacPortStateHelper();
77 ~wxMacPortStateHelper();
79 void Setup( GrafPtr newport
);
81 bool IsCleared() { return m_clip
== NULL
; }
82 GrafPtr
GetCurrentPort() { return m_currentPort
; }
85 GrafPtr m_currentPort
;
88 ThemeDrawingState m_drawingState
;
95 class WXDLLEXPORT wxMacPortSaver
97 DECLARE_NO_COPY_CLASS(wxMacPortSaver
)
100 wxMacPortSaver( GrafPtr port
);
106 class WXDLLEXPORT wxMacPortSetter
108 DECLARE_NO_COPY_CLASS(wxMacPortSetter
)
111 wxMacPortSetter( const wxDC
* dc
);
114 wxMacPortStateHelper m_ph
;
119 Clips to the visible region of a control within the current port
122 class WXDLLEXPORT wxMacWindowClipper
: public wxMacPortSaver
124 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
127 wxMacWindowClipper( const wxWindow
* win
);
128 ~wxMacWindowClipper();
131 RgnHandle m_formerClip
;
135 class WXDLLEXPORT wxMacWindowStateSaver
: public wxMacWindowClipper
137 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver
)
140 wxMacWindowStateSaver( const wxWindow
* win
);
141 ~wxMacWindowStateSaver();
144 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() { return m_ok; }
176 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); }
177 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); }
178 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); }
179 const Point& GetOrigin() { return m_origin; }
182 GrafPtr m_formerPort;
183 GrafPtr m_currentPort;
184 PenState m_savedPenState;
190 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
195 WXDLLEXPORT wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
196 WXDLLEXPORT
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
199 WXDLLEXPORT wxString
wxMacFindFolderNoSeparator(short vRefNum
,
201 Boolean createFolder
);
202 WXDLLEXPORT wxString
wxMacFindFolder(short vRefNum
,
204 Boolean createFolder
);
206 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
207 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
208 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
209 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
210 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
211 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
212 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
213 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
214 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
215 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
216 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
217 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
218 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
219 #if TARGET_API_MAC_OSX
220 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
221 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
222 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
223 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
224 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
226 #if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 )
227 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
229 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
230 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
233 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
234 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
235 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
236 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
239 class wxMacCarbonEvent
249 wxMacCarbonEvent( EventRef event
, bool release
= false )
255 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
258 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
265 ReleaseEvent( m_eventRef
);
268 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
270 verify( (m_eventRef
== NULL
) || m_release
);
271 if ( m_eventRef
&& m_release
)
273 ReleaseEvent( m_eventRef
);
277 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
283 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
285 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
287 return GetParameter( inName
, type
, sizeof( T
) , data
);
289 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
291 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
294 template <typename T
> T
GetParameter( EventParamName inName
)
297 verify_noerr( GetParameter
<T
>( inName
, &value
) );
300 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
303 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
307 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
308 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
310 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
312 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
314 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
316 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
318 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
320 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
322 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
326 return ::GetEventClass( m_eventRef
);
330 return ::GetEventKind( m_eventRef
);
334 return ::GetEventTime( m_eventRef
);
338 return EventTimeToTicks( GetTime() );
340 OSStatus
SetCurrentTime( )
342 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
344 OSStatus
SetTime( EventTime when
)
346 return ::SetEventTime( m_eventRef
, when
);
348 operator EventRef () { return m_eventRef
; }
350 bool IsValid() { return m_eventRef
!= 0; }
357 // helper class for allocating and deallocating Universal Proc Ptrs
360 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
363 wxMacUPP( procType proc
)
366 m_upp
= (*newUPP
)( NULL
);
373 operator uppType() { return m_upp
; }
378 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
380 template <typename refType
> class wxMacCFRefHolder
384 : m_ref(NULL
) , m_release(false)
388 wxMacCFRefHolder( refType ref
, bool release
= true )
389 : m_ref(ref
) , m_release(release
)
400 if ( m_release
&& m_ref
!= NULL
)
413 void Set( refType ref
, bool release
= true )
420 operator refType () const { return m_ref
; }
426 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
431 #include "wx/listbox.h"
434 GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
435 void wxMacDestroyGWorld( GWorldPtr gw );
436 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL );
437 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize );
438 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue );
439 CTabHandle wxMacCreateColorTable( int numColors );
441 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
442 void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
444 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
445 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
446 #define MAC_WXHMETAFILE(a) (PicHandle(a))
447 #define MAC_WXHICON(a) (IconRef(a))
448 #define MAC_WXHCURSOR(a) (CursHandle(a))
449 #define MAC_WXHRGN(a) (RgnHandle(a))
450 #define MAC_WXHWND(a) (WindowPtr(a))
451 #define MAC_WXRECPTR(a) ((Rect*)a)
452 #define MAC_WXPOINTPTR(a) ((Point*)a)
453 #define MAC_WXHMENU(a) ((MenuHandle)a)
455 struct wxOpaqueWindowRef
457 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
458 operator WindowRef() { return m_data
; }
463 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
464 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
465 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
466 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
468 wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
469 wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
470 wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
472 int wxMacCommandToId( UInt32 macCommandId
);
473 UInt32
wxIdToMacCommand( int wxId
);
474 wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
476 extern wxWindow
* g_MacLastWindow
;
477 pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
478 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
480 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
485 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
486 wxMacControl( wxWindow
* peer
, ControlRef control
);
487 wxMacControl( wxWindow
* peer
, WXWidget control
);
488 virtual ~wxMacControl();
492 virtual void Dispose();
494 bool Ok() 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( SInt32 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
, wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
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
);
606 virtual bool GetNeedsDisplay() const;
608 // where is in native window relative coordinates
609 virtual void SetNeedsDisplay( RgnHandle where
);
610 // where is in native window relative coordinates
611 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
613 // if rect = NULL, entire view
614 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
616 // in native parent window relative coordinates
617 virtual void GetRect( Rect
*r
);
619 // in native parent window relative coordinates
620 virtual void SetRect( Rect
*r
);
622 virtual void GetRectInWindowCoords( Rect
*r
);
623 virtual void GetBestRect( Rect
*r
);
624 virtual void SetLabel( const wxString
&title
);
625 // converts from Toplevel-Content relative to local
626 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
628 virtual void GetFeatures( UInt32
*features
);
629 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
630 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
632 bool IsCompositing() { return m_isCompositing
; }
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_isCompositing
;
650 bool m_isRootControl
;
653 // ============================================================================
654 // DataBrowser Wrapper
655 // ============================================================================
657 // basing on DataBrowserItemIDs
660 class wxMacDataBrowserControl
: public wxMacControl
663 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
665 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
667 OSStatus
GetItemCount( DataBrowserItemID container
,
669 DataBrowserItemState state
,
670 UInt32
*numItems
) const;
672 OSStatus
GetItems( DataBrowserItemID container
,
674 DataBrowserItemState state
,
678 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
679 DataBrowserTableViewColumnIndex position
);
681 OSStatus
AutoSizeColumns();
683 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
684 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
686 OSStatus
SetHeaderButtonHeight( UInt16 height
);
687 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
689 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
690 const DataBrowserItemID
*items
,
691 DataBrowserPropertyID preSortProperty
,
692 DataBrowserPropertyID propertyID
) const;
694 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
695 const DataBrowserItemID
*items
,
696 DataBrowserPropertyID preSortProperty
);
697 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
698 const DataBrowserItemID
*items
,
699 DataBrowserPropertyID preSortProperty
);
700 OSStatus
RevealItem( DataBrowserItemID item
,
701 DataBrowserPropertyID propertyID
,
702 DataBrowserRevealOptions options
) const;
704 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
705 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
706 bool IsItemSelected( DataBrowserItemID item
) const;
707 OSStatus
SetSelectedItems( UInt32 numItems
,
708 const DataBrowserItemID
*items
,
709 DataBrowserSetOption operation
);
711 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
712 DataBrowserItemID
* item
) const;
713 OSStatus
GetItemRow( DataBrowserItemID item
,
714 DataBrowserTableViewRowIndex
* row
) const;
716 OSStatus
SetDefaultRowHeight( UInt16 height
);
717 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
719 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
720 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
722 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
723 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
725 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
726 OSStatus
SetDefaultColumnWidth( UInt16 width
);
728 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
730 OSStatus
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
;
797 // base class for databrowser items
803 virtual ~wxMacDataItem();
805 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
806 const wxMacDataItem
*,
807 DataBrowserPropertyID property
) const;
809 // returns true if access was successful, otherwise false
810 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
811 DataBrowserPropertyID property
,
812 DataBrowserItemDataRef itemData
,
815 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
816 DataBrowserItemNotification message
,
817 DataBrowserItemDataRef itemData
) const;
820 typedef wxMacDataItem
* wxMacDataItemPtr
;
821 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
823 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
825 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
828 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
830 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
831 void GetItems(const wxMacDataItem
* container
, bool recurse
,
832 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
834 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
835 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
837 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
838 DataBrowserPropertyID property
) const;
839 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
840 DataBrowserPropertyID property
) const;
842 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
843 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
845 void RemoveAllItems(wxMacDataItem
*container
);
846 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
847 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
849 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
850 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
851 void SetSelectedAllItems( DataBrowserSetOption option
);
852 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
854 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
856 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
858 // item aware methods, to be used in subclasses
860 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
861 const wxMacDataItem
* itemTwoID
,
862 DataBrowserPropertyID sortProperty
);
864 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
865 DataBrowserPropertyID property
,
866 DataBrowserItemDataRef itemData
,
867 Boolean changeValue
);
869 virtual void ItemNotification(
870 const wxMacDataItem
* itemID
,
871 DataBrowserItemNotification message
,
872 DataBrowserItemDataRef itemData
);
874 // as we are getting the same events for human and API selection we have to suppress
875 // events in the latter case, since this will be used from many subclasses we keep it here
877 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
878 bool SuppressSelection( bool suppress
);
881 // ID aware base methods, should be 'final' ie not changed in subclasses
883 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
884 DataBrowserItemID itemTwoID
,
885 DataBrowserPropertyID sortProperty
);
887 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
888 DataBrowserPropertyID property
,
889 DataBrowserItemDataRef itemData
,
890 Boolean changeValue
);
892 virtual void ItemNotification(
893 DataBrowserItemID itemID
,
894 DataBrowserItemNotification message
,
895 DataBrowserItemDataRef itemData
);
899 bool m_suppressSelection
;
902 class wxMacDataItemBrowserSelectionSuppressor
905 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
906 ~wxMacDataItemBrowserSelectionSuppressor();
911 wxMacDataItemBrowserControl
* m_browser
;
914 // ============================================================================
915 // platform listbox implementation
916 // ============================================================================
918 // exposed for reuse in wxCheckListBox
920 class wxMacListBoxItem
: public wxMacDataItem
925 virtual ~wxMacListBoxItem();
927 void SetLabel( const wxString
& str
);
928 const wxString
& GetLabel() const;
930 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
931 const wxMacDataItem
* rhs
,
932 DataBrowserPropertyID sortProperty
) const;
934 virtual OSStatus
GetSetData( wxMacDataItemBrowserControl
*owner
,
935 DataBrowserPropertyID property
,
936 DataBrowserItemDataRef itemData
,
939 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
940 DataBrowserItemNotification message
,
941 DataBrowserItemDataRef itemData
) const;
943 void SetOrder( SInt32 order
);
944 SInt32
GetOrder() const;
946 void SetData( void* data
);
947 void* GetData() const;
951 wxMacCFStringHolder m_cfLabel
;
956 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
, public wxMacListControl
959 wxMacDataBrowserListControl( wxListBox
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
960 ~wxMacDataBrowserListControl();
962 // create a list item (can be a subclass of wxMacListBoxItem)
964 virtual wxMacListBoxItem
* CreateItem();
968 void MacDelete( unsigned int n
);
969 void MacInsert( unsigned int n
, const wxString
& item
);
970 void MacInsert( unsigned int n
, const wxArrayString
& items
);
971 int MacAppend( const wxString
& item
);
976 void MacDeselectAll();
977 void MacSetSelection( unsigned int n
, bool select
);
978 int MacGetSelection() const;
979 int MacGetSelections( wxArrayInt
& aSelections
) const;
980 bool MacIsSelected( unsigned int n
) const;
984 void MacScrollTo( unsigned int n
);
988 void MacSetString( unsigned int n
, const wxString
& item
);
989 void MacSetClientData( unsigned int n
, void * data
);
990 wxString
MacGetString( unsigned int n
) const;
991 void * MacGetClientData( unsigned int) const;
992 unsigned int MacGetCount() const;
996 wxClientDataType
GetClientDataType() const;
997 void SetClientDataType(wxClientDataType clientDataItemsType
);
1001 wxListBox
* GetPeer() const;
1003 bool m_stringSorted
;
1004 wxClientDataType m_clientDataItemsType
;
1007 // ============================================================================
1008 // graphics implementation
1009 // ============================================================================
1011 #if wxMAC_USE_CORE_GRAPHICS
1013 class WXDLLEXPORT wxMacCGPath
: public wxGraphicPath
1015 DECLARE_NO_COPY_CLASS(wxMacCGPath
)
1020 // Starts a new subpath at
1021 void MoveToPoint( wxCoord x1
, wxCoord y1
);
1022 void AddLineToPoint( wxCoord x1
, wxCoord y1
);
1023 void AddQuadCurveToPoint( wxCoord cx1
, wxCoord cy1
, wxCoord x1
, wxCoord y1
);
1024 void AddRectangle( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1025 void AddCircle( wxCoord x
, wxCoord y
, wxCoord r
);
1027 // closes the current subpath
1028 void CloseSubpath();
1030 CGPathRef
GetPath() const;
1032 CGMutablePathRef m_path
;
1035 class WXDLLEXPORT wxMacCGContext
: public wxGraphicContext
1037 DECLARE_NO_COPY_CLASS(wxMacCGContext
)
1040 wxMacCGContext( CGrafPtr port
);
1041 wxMacCGContext( CGContextRef cgcontext
);
1045 virtual void Clip( const wxRegion
®ion
);
1046 virtual void StrokePath( const wxGraphicPath
*p
);
1047 virtual void DrawPath( const wxGraphicPath
*p
, int fillStyle
= wxWINDING_RULE
);
1048 virtual void FillPath( const wxGraphicPath
*p
, const wxColor
&fillColor
, int fillStyle
= wxWINDING_RULE
);
1050 virtual wxGraphicPath
* CreatePath();
1051 virtual void SetPen( const wxPen
&pen
) ;
1052 virtual void SetBrush( const wxBrush
&brush
);
1053 CGContextRef
GetNativeContext();
1054 void SetNativeContext( CGContextRef cg
);
1055 CGPathDrawingMode
GetDrawingMode() const { return m_mode
; }
1057 CGContextRef m_cgContext
;
1059 CGPathDrawingMode m_mode
;
1064 #endif // wxMAC_USE_CORE_GRAPHICS
1066 #ifdef __WXMAC_OSX__
1068 CGColorSpaceRef
wxMacGetGenericRGBColorSpace(void);
1069 void wxMacMemoryBufferReleaseProc(void *info
, const void *data
, size_t size
);
1073 class WXDLLEXPORT wxBitmapRefData
: public wxGDIRefData
1075 DECLARE_NO_COPY_CLASS(wxBitmapRefData
)
1077 friend class WXDLLEXPORT wxIcon
;
1078 friend class WXDLLEXPORT wxCursor
;
1080 wxBitmapRefData(int width
, int height
, int depth
);
1085 bool Ok() const { return m_ok
; }
1086 void SetOk( bool isOk
) { m_ok
= isOk
; }
1088 void SetWidth( int width
) { m_width
= width
; }
1089 void SetHeight( int height
) { m_height
= height
; }
1090 void SetDepth( int depth
) { m_depth
= depth
; }
1092 int GetWidth() const { return m_width
; }
1093 int GetHeight() const { return m_height
; }
1094 int GetDepth() const { return m_depth
; }
1096 void *GetRawAccess() const;
1097 void *BeginRawAccess();
1098 void EndRawAccess();
1100 bool HasAlpha() const { return m_hasAlpha
; }
1101 void UseAlpha( bool useAlpha
);
1105 wxPalette m_bitmapPalette
;
1106 #endif // wxUSE_PALETTE
1108 wxMask
* m_bitmapMask
; // Optional mask
1109 #ifdef __WXMAC_OSX__
1110 CGImageRef
CGImageCreate() const;
1113 // returns true if the bitmap has a size that
1114 // can be natively transferred into a true icon
1115 // if no is returned GetIconRef will still produce
1116 // an icon but it will be generated via a PICT and
1117 // rescaled to 16 x 16
1118 bool HasNativeSize();
1120 // caller should increase ref count if needed longer
1121 // than the bitmap exists
1122 IconRef
GetIconRef();
1124 // returns a Pict from the bitmap content
1125 PicHandle
GetPictHandle();
1126 GWorldPtr
GetHBITMAP(GWorldPtr
* mask
= NULL
) const;
1127 void UpdateAlphaMask() const;
1130 bool Create(int width
, int height
, int depth
);
1138 wxMemoryBuffer m_memBuf
;
1139 int m_rawAccessCount
;
1141 #ifdef __WXMAC_OSX__
1142 mutable CGImageRef m_cgImageRef
;
1145 PicHandle m_pictHandle
;
1146 GWorldPtr m_hBitmap
;
1147 GWorldPtr m_hMaskBitmap
;
1148 wxMemoryBuffer m_maskMemBuf
;
1149 int m_maskBytesPerRow
;
1152 class WXDLLEXPORT wxIconRefData
: public wxGDIRefData
1156 wxIconRefData( WXHICON
);
1157 virtual ~wxIconRefData() { Free(); }
1160 virtual void Free();
1162 void SetWidth( int width
) { m_width
= width
; }
1163 void SetHeight( int height
) { m_height
= height
; }
1165 int GetWidth() const { return m_width
; }
1166 int GetHeight() const { return m_height
; }
1168 WXHICON
GetHICON() const { return (WXHICON
) m_iconRef
; }
1177 ControlRef
wxMacFindControlUnderMouse( wxTopLevelWindowMac
* toplevelWindow
, const Point
& location
, WindowRef window
, ControlPartCode
*outPart
);
1179 #ifdef WORDS_BIGENDIAN
1180 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1182 *rect
= (**pict
).picFrame
;
1186 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1188 return QDGetPictureBounds( pict
, rect
);
1194 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1197 static UPP sHandler = NULL; \
1198 if ( sHandler == NULL ) \
1199 sHandler = New##UPP( x ); \
1203 //---------------------------------------------------------------------------
1204 // wxMac string conversions
1205 //---------------------------------------------------------------------------
1207 void wxMacSetupConverters();
1208 void wxMacCleanupConverters();
1210 void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1211 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1215 wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1216 OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1217 wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);