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 #ifndef MAC_OS_X_VERSION_10_5
47 #define MAC_OS_X_VERSION_10_5 1050
50 #ifdef __WXMAC_CARBON__
51 #include "wx/mac/corefoundation/cfstring.h"
55 // as macro in FixMath.h for 10.3
56 inline Fixed
IntToFixed( int inInt
)
58 return (((SInt32
) inInt
) << 16);
61 inline int FixedToInt( Fixed inFixed
)
63 return (((SInt32
) inFixed
) >> 16);
67 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
68 typedef UInt32 URefCon
;
69 typedef SInt32 SRefCon
;
74 #include "wx/listbox.h"
78 class wxMacPortStateHelper
80 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper
)
83 wxMacPortStateHelper( GrafPtr newport
);
84 wxMacPortStateHelper();
85 ~wxMacPortStateHelper();
87 void Setup( GrafPtr newport
);
89 bool IsCleared() { return m_clip
== NULL
; }
90 GrafPtr
GetCurrentPort() { return m_currentPort
; }
93 GrafPtr m_currentPort
;
96 ThemeDrawingState m_drawingState
;
103 class WXDLLEXPORT wxMacPortSaver
105 DECLARE_NO_COPY_CLASS(wxMacPortSaver
)
108 wxMacPortSaver( GrafPtr port
);
114 class WXDLLEXPORT wxMacPortSetter
116 DECLARE_NO_COPY_CLASS(wxMacPortSetter
)
119 wxMacPortSetter( const wxDC
* dc
);
122 wxMacPortStateHelper m_ph
;
127 Clips to the visible region of a control within the current port
130 class WXDLLEXPORT wxMacWindowClipper
: public wxMacPortSaver
132 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
135 wxMacWindowClipper( const wxWindow
* win
);
136 ~wxMacWindowClipper();
139 RgnHandle m_formerClip
;
143 class WXDLLEXPORT wxMacWindowStateSaver
: public wxMacWindowClipper
145 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver
)
148 wxMacWindowStateSaver( const wxWindow
* win
);
149 ~wxMacWindowStateSaver();
152 ThemeDrawingState m_themeDrawingState
;
156 #if wxMAC_USE_CORE_GRAPHICS
157 class WXDLLEXPORT wxMacCGContextStateSaver
159 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
162 wxMacCGContextStateSaver( CGContextRef cg
)
165 CGContextSaveGState( cg
);
167 ~wxMacCGContextStateSaver()
169 CGContextRestoreGState( m_cg
);
177 class wxMacDrawingHelper
179 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
182 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false );
183 ~wxMacDrawingHelper();
184 bool Ok() const { return IsOk(); }
185 bool IsOk() { return m_ok; }
186 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); }
187 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); }
188 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); }
189 const Point& GetOrigin() { return m_origin; }
192 GrafPtr m_formerPort;
193 GrafPtr m_currentPort;
194 PenState m_savedPenState;
200 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
205 WXDLLEXPORT wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
206 WXDLLEXPORT
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
209 WXDLLEXPORT wxString
wxMacFindFolderNoSeparator(short vRefNum
,
211 Boolean createFolder
);
212 WXDLLEXPORT wxString
wxMacFindFolder(short vRefNum
,
214 Boolean createFolder
);
216 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
217 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
218 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
219 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
220 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
221 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
222 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
223 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
224 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
225 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
226 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
227 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
228 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
229 #if TARGET_API_MAC_OSX
230 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
231 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
232 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
233 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
234 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
236 #if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 )
237 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
239 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
240 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
243 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
244 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
245 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
246 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
249 class wxMacCarbonEvent
259 wxMacCarbonEvent( EventRef event
, bool release
= false )
265 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
268 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
275 ReleaseEvent( m_eventRef
);
278 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
280 verify( (m_eventRef
== NULL
) || m_release
);
281 if ( m_eventRef
&& m_release
)
283 ReleaseEvent( m_eventRef
);
287 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
293 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
295 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
297 return GetParameter( inName
, type
, sizeof( T
) , data
);
299 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
301 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
304 template <typename T
> T
GetParameter( EventParamName inName
)
307 verify_noerr( GetParameter
<T
>( inName
, &value
) );
310 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
313 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
317 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
318 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
320 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
322 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
324 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
326 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
328 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
330 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
332 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
336 return ::GetEventClass( m_eventRef
);
340 return ::GetEventKind( m_eventRef
);
344 return ::GetEventTime( m_eventRef
);
348 return EventTimeToTicks( GetTime() );
350 OSStatus
SetCurrentTime( )
352 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
354 OSStatus
SetTime( EventTime when
)
356 return ::SetEventTime( m_eventRef
, when
);
358 operator EventRef () { return m_eventRef
; }
360 bool IsValid() { return m_eventRef
!= 0; }
367 // helper class for allocating and deallocating Universal Proc Ptrs
370 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
373 wxMacUPP( procType proc
)
376 m_upp
= (*newUPP
)( NULL
);
383 operator uppType() { return m_upp
; }
388 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
390 template <typename refType
> class wxMacCFRefHolder
394 : m_ref(NULL
) , m_release(false)
398 wxMacCFRefHolder( refType ref
, bool release
= true )
399 : m_ref(ref
) , m_release(release
)
410 if ( m_release
&& m_ref
!= NULL
)
423 void Set( refType ref
, bool release
= true )
430 operator refType () const { return m_ref
; }
436 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder
)
442 GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
443 void wxMacDestroyGWorld( GWorldPtr gw );
444 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL );
445 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize );
446 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue );
447 CTabHandle wxMacCreateColorTable( int numColors );
449 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
450 void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
452 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
453 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
454 #define MAC_WXHMETAFILE(a) (PicHandle(a))
455 #define MAC_WXHICON(a) (IconRef(a))
456 #define MAC_WXHCURSOR(a) (CursHandle(a))
457 #define MAC_WXHRGN(a) (RgnHandle(a))
458 #define MAC_WXHWND(a) (WindowPtr(a))
459 #define MAC_WXRECPTR(a) ((Rect*)a)
460 #define MAC_WXPOINTPTR(a) ((Point*)a)
461 #define MAC_WXHMENU(a) ((MenuHandle)a)
463 struct wxOpaqueWindowRef
465 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
466 operator WindowRef() { return m_data
; }
471 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
472 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
473 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
474 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
476 wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
477 wxTopLevelWindowMac
* wxFindWinFromMacWindow( WindowRef inWindow
);
478 wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
480 int wxMacCommandToId( UInt32 macCommandId
);
481 UInt32
wxIdToMacCommand( int wxId
);
482 wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
484 extern wxWindow
* g_MacLastWindow
;
485 pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
486 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
488 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
490 class wxMacControl
: public wxObject
493 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
494 wxMacControl( wxWindow
* peer
, ControlRef control
);
495 wxMacControl( wxWindow
* peer
, WXWidget control
);
497 virtual ~wxMacControl();
501 virtual void Dispose();
503 bool Ok() const { return IsOk(); }
504 bool IsOk() const { return GetControlRef() != NULL
; }
506 void SetReferenceInNativeControl();
507 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
509 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
510 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
512 virtual void SetReference( URefCon data
);
514 void operator= (ControlRef c) { m_controlRef = c; }
515 operator ControlRef () { return m_controlRef; }
516 operator ControlRef * () { return &m_controlRef; }
518 // accessing data and values
520 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
521 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
522 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
523 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
524 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
526 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
528 virtual SInt32
GetValue() const;
529 virtual SInt32
GetMaximum() const;
530 virtual SInt32
GetMinimum() const;
532 virtual void SetValue( SInt32 v
);
533 virtual void SetMinimum( SInt32 v
);
534 virtual void SetMaximum( SInt32 v
);
536 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
537 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
539 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
540 virtual bool HasFocus() const;
541 virtual bool NeedsFocusRect() const;
542 virtual void SetNeedsFocusRect( bool needs
);
546 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
549 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
552 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
554 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
556 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
558 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
560 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
562 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
564 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
566 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
568 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
571 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
573 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
576 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
578 wxASSERT_MSG( err
== noErr
,
579 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
580 inPartCode
, (int)inTag
) );
583 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
586 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
588 template <typename T
> T
GetData( ResType inTag
) const
590 return GetData
<T
>( kControlEntireControl
, inTag
);
593 // Flash the control for the specified amount of time
594 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
596 virtual void VisibilityChanged( bool shown
);
597 virtual void SuperChangedPosition();
600 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
601 virtual void SetBackground( const wxBrush
&brush
);
602 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
603 void SetActionProc( ControlActionUPP actionProc
);
604 void SetViewSize( SInt32 viewSize
);
605 SInt32
GetViewSize() const;
607 virtual bool IsVisible() const;
608 virtual void SetVisibility( bool visible
, bool redraw
);
609 virtual bool IsEnabled() const;
610 virtual bool IsActive() const;
611 virtual void Enable( bool enable
);
613 // invalidates this control and all children
614 virtual void InvalidateWithChildren();
615 virtual void SetDrawingEnabled( bool enable
);
617 virtual bool GetNeedsDisplay() const;
619 // where is in native window relative coordinates
620 virtual void SetNeedsDisplay( RgnHandle where
);
621 // where is in native window relative coordinates
622 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
624 // if rect = NULL, entire view
625 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
627 // in native parent window relative coordinates
628 virtual void GetRect( Rect
*r
);
630 // in native parent window relative coordinates
631 virtual void SetRect( Rect
*r
);
633 virtual void GetRectInWindowCoords( Rect
*r
);
634 virtual void GetBestRect( Rect
*r
);
635 virtual void SetLabel( const wxString
&title
);
636 // converts from Toplevel-Content relative to local
637 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
639 virtual void GetFeatures( UInt32
*features
);
640 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
641 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
643 bool IsRootControl() { return m_isRootControl
; }
645 wxWindow
* GetPeer() const
650 // to be moved into a tab control class
652 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
654 ControlRef m_controlRef
;
658 bool m_needsFocusRect
;
659 bool m_isRootControl
;
660 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
663 // ============================================================================
664 // DataBrowser Wrapper
665 // ============================================================================
667 // basing on DataBrowserItemIDs
670 class wxMacDataBrowserControl
: public wxMacControl
673 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
674 wxMacDataBrowserControl() {}
676 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
678 OSStatus
GetItemCount( DataBrowserItemID container
,
680 DataBrowserItemState state
,
681 ItemCount
*numItems
) const;
683 OSStatus
GetItems( DataBrowserItemID container
,
685 DataBrowserItemState state
,
689 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
690 DataBrowserTableViewColumnIndex position
);
692 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
694 OSStatus
AutoSizeColumns();
696 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
697 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
699 OSStatus
SetHeaderButtonHeight( UInt16 height
);
700 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
702 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
703 const DataBrowserItemID
*items
,
704 DataBrowserPropertyID preSortProperty
,
705 DataBrowserPropertyID propertyID
) const;
707 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
708 const DataBrowserItemID
*items
,
709 DataBrowserPropertyID preSortProperty
);
710 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
711 const DataBrowserItemID
*items
,
712 DataBrowserPropertyID preSortProperty
);
713 OSStatus
RevealItem( DataBrowserItemID item
,
714 DataBrowserPropertyID propertyID
,
715 DataBrowserRevealOptions options
) const;
717 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
718 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
719 bool IsItemSelected( DataBrowserItemID item
) const;
720 OSStatus
SetSelectedItems( UInt32 numItems
,
721 const DataBrowserItemID
*items
,
722 DataBrowserSetOption operation
);
724 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
725 DataBrowserItemID
* item
) const;
726 OSStatus
GetItemRow( DataBrowserItemID item
,
727 DataBrowserTableViewRowIndex
* row
) const;
729 OSStatus
SetDefaultRowHeight( UInt16 height
);
730 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
732 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
733 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
735 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
736 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
738 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
739 OSStatus
SetDefaultColumnWidth( UInt16 width
);
741 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
743 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
745 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
746 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
748 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
749 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
751 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
752 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
754 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
755 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
757 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
758 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
760 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
761 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
763 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
766 static pascal void DataBrowserItemNotificationProc(
768 DataBrowserItemID itemID
,
769 DataBrowserItemNotification message
,
770 DataBrowserItemDataRef itemData
);
772 virtual void ItemNotification(
773 DataBrowserItemID itemID
,
774 DataBrowserItemNotification message
,
775 DataBrowserItemDataRef itemData
) = 0;
777 static pascal OSStatus
DataBrowserGetSetItemDataProc(
779 DataBrowserItemID itemID
,
780 DataBrowserPropertyID property
,
781 DataBrowserItemDataRef itemData
,
782 Boolean changeValue
);
784 virtual OSStatus
GetSetItemData(
785 DataBrowserItemID itemID
,
786 DataBrowserPropertyID property
,
787 DataBrowserItemDataRef itemData
,
788 Boolean changeValue
) = 0;
790 static pascal Boolean
DataBrowserCompareProc(
792 DataBrowserItemID itemOneID
,
793 DataBrowserItemID itemTwoID
,
794 DataBrowserPropertyID sortProperty
);
796 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
797 DataBrowserItemID itemTwoID
,
798 DataBrowserPropertyID sortProperty
) = 0;
799 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
802 // ============================================================================
803 // Higher-level Databrowser
804 // ============================================================================
806 // basing on data item objects
811 class wxMacDataItemBrowserControl
;
812 class wxMacListBoxItem
;
814 const DataBrowserPropertyID kTextColumnId
= 1024;
815 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
817 // for multi-column controls, we will use this + the column ID to identify the
818 // column. We don't use kTextColumnId there, and ideally the two should merge.
819 const DataBrowserPropertyID kMinColumnId
= 1050;
821 // base API for high-level databrowser operations
823 class wxMacListControl
826 virtual void MacDelete( unsigned int n
) = 0;
827 virtual void MacInsert( unsigned int n
, const wxString
& item
, int column
= -1 ) = 0;
828 virtual void MacInsert( unsigned int n
, const wxArrayString
& items
, int column
= -1 ) = 0;
829 // returns index of newly created line
830 virtual int MacAppend( const wxString
& item
) = 0;
831 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
832 virtual void MacClear() = 0;
833 virtual void MacDeselectAll() = 0;
834 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
835 virtual int MacGetSelection() const = 0;
836 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
837 virtual bool MacIsSelected( unsigned int n
) const = 0;
838 virtual void MacScrollTo( unsigned int n
) = 0;
839 virtual wxString
MacGetString( unsigned int n
) const = 0;
840 virtual unsigned int MacGetCount() const = 0;
842 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
843 virtual void * MacGetClientData( unsigned int) const = 0;
845 virtual ~wxMacListControl() { }
848 // base class for databrowser items
858 virtual ~wxMacDataItem();
860 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
861 const wxMacDataItem
*,
862 DataBrowserPropertyID property
) const;
864 // returns true if access was successful, otherwise false
865 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
866 DataBrowserPropertyID property
,
867 DataBrowserItemDataRef itemData
,
870 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
871 DataBrowserItemNotification message
,
872 DataBrowserItemDataRef itemData
) const;
874 void SetLabel( const wxString
& str
);
875 const wxString
& GetLabel() const;
877 void SetOrder( SInt32 order
);
878 SInt32
GetOrder() const;
880 void SetData( void* data
);
881 void* GetData() const;
883 void SetColumn( short col
);
888 wxMacCFStringHolder m_cfLabel
;
891 DataBrowserPropertyID m_colId
;
897 SortOrder_Text_Ascending
,
898 SortOrder_Text_Descending
901 typedef wxMacDataItem
* wxMacDataItemPtr
;
902 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
904 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
906 class wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
909 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
910 wxMacDataItemBrowserControl() {}
911 // create a list item (can be a subclass of wxMacListBoxItem)
913 virtual wxMacDataItem
* CreateItem();
915 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
916 void GetItems(const wxMacDataItem
* container
, bool recurse
,
917 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
919 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
921 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
922 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
924 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
925 DataBrowserPropertyID property
) const;
926 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
927 DataBrowserPropertyID property
) const;
929 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
930 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
932 int GetColumnWidth(int colId
);
933 void SetColumnWidth(int colId
, int width
);
935 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
936 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
938 void RemoveAllItems(wxMacDataItem
*container
);
939 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
940 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
942 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
943 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
944 void SetSelectedAllItems( DataBrowserSetOption option
);
945 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
947 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
949 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
951 // item aware methods, to be used in subclasses
953 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
954 const wxMacDataItem
* itemTwoID
,
955 DataBrowserPropertyID sortProperty
);
957 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
958 DataBrowserPropertyID property
,
959 DataBrowserItemDataRef itemData
,
960 Boolean changeValue
);
962 virtual void ItemNotification(
963 const wxMacDataItem
* itemID
,
964 DataBrowserItemNotification message
,
965 DataBrowserItemDataRef itemData
);
967 // as we are getting the same events for human and API selection we have to suppress
968 // events in the latter case, since this will be used from many subclasses we keep it here
970 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
971 bool SuppressSelection( bool suppress
);
974 // wxMacListControl Methods
977 virtual void MacDelete( unsigned int n
);
978 virtual void MacInsert( unsigned int n
, const wxString
& item
, int column
= -1 );
979 virtual void MacInsert( unsigned int n
, const wxArrayString
& items
, int column
= -1 );
980 virtual int MacAppend( const wxString
& item
);
981 virtual void MacClear();
985 virtual void MacDeselectAll();
986 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
987 virtual int MacGetSelection() const;
988 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
989 virtual bool MacIsSelected( unsigned int n
) const;
993 virtual void MacScrollTo( unsigned int n
);
997 virtual void MacSetString( unsigned int n
, const wxString
& item
);
998 virtual void MacSetClientData( unsigned int n
, void * data
);
999 virtual wxString
MacGetString( unsigned int n
) const;
1000 virtual void * MacGetClientData( unsigned int) const;
1001 virtual unsigned int MacGetCount() const;
1005 virtual wxClientDataType
GetClientDataType() const;
1006 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
1007 //virtual ListSortOrder GetSortOrder() const;
1008 //virtual void SetSortOrder(const ListSortOrder sort);
1014 ListSortOrder m_sortOrder
;
1015 wxClientDataType m_clientDataItemsType
;
1017 // ID aware base methods, should be 'final' ie not changed in subclasses
1019 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
1020 DataBrowserItemID itemTwoID
,
1021 DataBrowserPropertyID sortProperty
);
1023 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
1024 DataBrowserPropertyID property
,
1025 DataBrowserItemDataRef itemData
,
1026 Boolean changeValue
);
1028 virtual void ItemNotification(
1029 DataBrowserItemID itemID
,
1030 DataBrowserItemNotification message
,
1031 DataBrowserItemDataRef itemData
);
1036 bool m_suppressSelection
;
1037 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
1040 class wxMacDataItemBrowserSelectionSuppressor
1043 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
1044 ~wxMacDataItemBrowserSelectionSuppressor();
1049 wxMacDataItemBrowserControl
* m_browser
;
1052 // ============================================================================
1053 // platform listbox implementation
1054 // ============================================================================
1056 // exposed for reuse in wxCheckListBox
1058 class wxMacListBoxItem
: public wxMacDataItem
1063 virtual ~wxMacListBoxItem();
1065 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
1066 DataBrowserItemNotification message
,
1067 DataBrowserItemDataRef itemData
) const;
1070 class wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
1073 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
1074 wxMacDataBrowserListControl() {}
1075 virtual ~wxMacDataBrowserListControl();
1077 virtual wxMacDataItem
* CreateItem();
1081 wxWindow
* GetPeer() const;
1083 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
1086 // ============================================================================
1087 // graphics implementation
1088 // ============================================================================
1090 #if wxMAC_USE_CORE_GRAPHICS && !wxUSE_GRAPHICS_CONTEXT
1092 class WXDLLEXPORT wxMacCGPath
: public wxGraphicPath
1094 DECLARE_NO_COPY_CLASS(wxMacCGPath
)
1099 // Starts a new subpath at
1100 void MoveToPoint( wxCoord x1
, wxCoord y1
);
1101 void AddLineToPoint( wxCoord x1
, wxCoord y1
);
1102 void AddQuadCurveToPoint( wxCoord cx1
, wxCoord cy1
, wxCoord x1
, wxCoord y1
);
1103 void AddRectangle( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1104 void AddCircle( wxCoord x
, wxCoord y
, wxCoord r
);
1106 // draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2)
1107 virtual void AddArcToPoint( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord r
) ;
1108 virtual void AddArc( wxCoord x
, wxCoord y
, wxCoord r
, double startAngle
, double endAngle
, bool clockwise
) ;
1110 // closes the current subpath
1111 void CloseSubpath();
1113 CGPathRef
GetPath() const;
1115 CGMutablePathRef m_path
;
1118 class WXDLLEXPORT wxMacCGContext
: public wxGraphicContext
1120 DECLARE_NO_COPY_CLASS(wxMacCGContext
)
1123 wxMacCGContext( CGrafPtr port
);
1124 wxMacCGContext( CGContextRef cgcontext
);
1126 virtual ~wxMacCGContext();
1128 virtual void Clip( const wxRegion
®ion
);
1129 virtual void StrokePath( const wxGraphicPath
*p
);
1130 virtual void DrawPath( const wxGraphicPath
*p
, int fillStyle
= wxWINDING_RULE
);
1131 virtual void FillPath( const wxGraphicPath
*p
, const wxColor
&fillColor
, int fillStyle
= wxWINDING_RULE
);
1133 virtual wxGraphicPath
* CreatePath();
1134 virtual void SetPen( const wxPen
&pen
) ;
1135 virtual void SetBrush( const wxBrush
&brush
);
1136 CGContextRef
GetNativeContext();
1137 void SetNativeContext( CGContextRef cg
);
1138 CGPathDrawingMode
GetDrawingMode() const { return m_mode
; }
1140 virtual void Translate( wxCoord dx
, wxCoord dy
);
1141 virtual void Scale( wxCoord xScale
, wxCoord yScale
);
1142 virtual void DrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1143 virtual void DrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
1144 virtual void PushState();
1145 virtual void PopState();
1147 virtual void DrawText( const wxString
&str
, wxCoord x
, wxCoord y
, double angle
) ;
1149 virtual void GetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
1150 wxCoord
*descent
, wxCoord
*externalLeading
) const ;
1152 virtual void GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const ;
1154 virtual void SetFont( const wxFont
&font
) ;
1156 virtual void SetTextColor( const wxColour
&col
) ;
1158 CGContextRef m_cgContext
;
1160 CGPathDrawingMode m_mode
;
1161 ATSUStyle m_macATSUIStyle
;
1164 wxColor m_textForegroundColor
;
1167 #endif // wxMAC_USE_CORE_GRAPHICS
1169 #ifdef __WXMAC_OSX__
1171 CGColorSpaceRef
wxMacGetGenericRGBColorSpace(void);
1172 void wxMacMemoryBufferReleaseProc(void *info
, const void *data
, size_t size
);
1176 class WXDLLEXPORT wxBitmapRefData
: public wxGDIRefData
1178 friend class WXDLLIMPEXP_FWD_CORE wxIcon
;
1179 friend class WXDLLIMPEXP_FWD_CORE wxCursor
;
1181 wxBitmapRefData(int width
, int height
, int depth
);
1183 wxBitmapRefData(const wxBitmapRefData
&tocopy
);
1185 virtual ~wxBitmapRefData();
1188 bool Ok() const { return IsOk(); }
1189 bool IsOk() const { return m_ok
; }
1190 void SetOk( bool isOk
) { m_ok
= isOk
; }
1192 void SetWidth( int width
) { m_width
= width
; }
1193 void SetHeight( int height
) { m_height
= height
; }
1194 void SetDepth( int depth
) { m_depth
= depth
; }
1196 int GetWidth() const { return m_width
; }
1197 int GetHeight() const { return m_height
; }
1198 int GetDepth() const { return m_depth
; }
1200 void *GetRawAccess() const;
1201 void *BeginRawAccess();
1202 void EndRawAccess();
1204 bool HasAlpha() const { return m_hasAlpha
; }
1205 void UseAlpha( bool useAlpha
);
1209 wxPalette m_bitmapPalette
;
1210 #endif // wxUSE_PALETTE
1212 wxMask
* m_bitmapMask
; // Optional mask
1213 #ifdef __WXMAC_OSX__
1214 CGImageRef
CGImageCreate() const;
1217 // returns true if the bitmap has a size that
1218 // can be natively transferred into a true icon
1219 // if no is returned GetIconRef will still produce
1220 // an icon but it will be generated via a PICT and
1221 // rescaled to 16 x 16
1222 bool HasNativeSize();
1224 // caller should increase ref count if needed longer
1225 // than the bitmap exists
1226 IconRef
GetIconRef();
1228 // returns a Pict from the bitmap content
1229 PicHandle
GetPictHandle();
1230 GWorldPtr
GetHBITMAP(GWorldPtr
* mask
= NULL
) const;
1231 void UpdateAlphaMask() const;
1234 bool Create(int width
, int height
, int depth
);
1242 wxMemoryBuffer m_memBuf
;
1243 int m_rawAccessCount
;
1245 #ifdef __WXMAC_OSX__
1246 mutable CGImageRef m_cgImageRef
;
1249 PicHandle m_pictHandle
;
1250 GWorldPtr m_hBitmap
;
1251 GWorldPtr m_hMaskBitmap
;
1252 wxMemoryBuffer m_maskMemBuf
;
1253 int m_maskBytesPerRow
;
1256 class WXDLLEXPORT wxIconRefData
: public wxGDIRefData
1260 wxIconRefData( WXHICON
);
1261 virtual ~wxIconRefData() { Free(); }
1264 virtual void Free();
1266 void SetWidth( int width
) { m_width
= width
; }
1267 void SetHeight( int height
) { m_height
= height
; }
1269 int GetWidth() const { return m_width
; }
1270 int GetHeight() const { return m_height
; }
1272 WXHICON
GetHICON() const { return (WXHICON
) m_iconRef
; }
1281 ControlRef
wxMacFindControlUnderMouse( wxTopLevelWindowMac
* toplevelWindow
, const Point
& location
, WindowRef window
, ControlPartCode
*outPart
);
1285 #ifdef WORDS_BIGENDIAN
1286 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1288 *rect
= (**pict
).picFrame
;
1292 inline Rect
* wxMacGetPictureBounds( PicHandle pict
, Rect
* rect
)
1294 return QDGetPictureBounds( pict
, rect
);
1302 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1305 static UPP sHandler = NULL; \
1306 if ( sHandler == NULL ) \
1307 sHandler = New##UPP( x ); \
1311 //---------------------------------------------------------------------------
1312 // wxMac string conversions
1313 //---------------------------------------------------------------------------
1315 void wxMacSetupConverters();
1316 void wxMacCleanupConverters();
1318 void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
1319 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
1323 wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
1324 OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
1325 wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
1331 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
);
1332 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
);