1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/private.h
3 // Purpose: Private declarations: as this header is only included by
4 // wxWidgets itself, it may contain identifiers which don't start
6 // Author: Stefan Csomor
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_PRIVATE_H_
15 #define _WX_PRIVATE_H_
19 #include <Carbon/Carbon.h>
21 #include "wx/mac/corefoundation/cfstring.h"
22 #include "wx/mac/corefoundation/cfdataref.h"
24 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
25 typedef UInt32 URefCon
;
26 typedef SInt32 SRefCon
;
31 #include "wx/listbox.h"
32 #include "wx/mac/carbon/dc.h"
33 #include "wx/mac/carbon/dcclient.h"
34 #include "wx/mac/carbon/dcmemory.h"
36 class WXDLLIMPEXP_CORE wxMacCGContextStateSaver
38 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver
)
41 wxMacCGContextStateSaver( CGContextRef cg
)
44 CGContextSaveGState( cg
);
46 ~wxMacCGContextStateSaver()
48 CGContextRestoreGState( m_cg
);
56 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
57 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
63 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
64 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
67 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
69 Boolean createFolder
);
70 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
72 Boolean createFolder
);
74 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
75 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
76 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
77 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
78 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
79 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
80 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
81 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
82 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
83 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
84 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
85 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
86 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
87 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
88 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
89 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
90 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
91 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
92 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
93 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
94 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
97 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
98 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
99 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
100 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
103 class WXDLLIMPEXP_CORE wxMacCarbonEvent
113 wxMacCarbonEvent( EventRef event
, bool release
= false )
119 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
122 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
129 ReleaseEvent( m_eventRef
);
132 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
134 verify( (m_eventRef
== NULL
) || m_release
);
135 if ( m_eventRef
&& m_release
)
137 ReleaseEvent( m_eventRef
);
141 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
147 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
149 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
151 return GetParameter( inName
, type
, sizeof( T
) , data
);
153 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
155 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
158 template <typename T
> T
GetParameter( EventParamName inName
)
161 verify_noerr( GetParameter
<T
>( inName
, &value
) );
164 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
167 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
171 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
172 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
174 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
176 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
178 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
180 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
182 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
184 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
186 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
190 return ::GetEventClass( m_eventRef
);
194 return ::GetEventKind( m_eventRef
);
198 return ::GetEventTime( m_eventRef
);
202 return EventTimeToTicks( GetTime() );
204 OSStatus
SetCurrentTime( )
206 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
208 OSStatus
SetTime( EventTime when
)
210 return ::SetEventTime( m_eventRef
, when
);
212 operator EventRef () { return m_eventRef
; }
214 bool IsValid() { return m_eventRef
!= 0; }
221 // helper class for allocating and deallocating Universal Proc Ptrs
224 template <typename procType
, typename uppType
, uppType (*newUPP
)(procType
) , void (*disposeUPP
)(uppType
) > class wxMacUPP
227 wxMacUPP( procType
WXUNUSED(proc
) )
230 m_upp
= (*newUPP
)( NULL
);
237 operator uppType() { return m_upp
; }
242 typedef wxMacUPP
<NMProcPtr
,NMUPP
,NewNMUPP
,DisposeNMUPP
> wxMacNMUPP
;
246 class WXDLLIMPEXP_FWD_CORE wxMacToolTipTimer
;
248 class WXDLLIMPEXP_CORE wxMacToolTip
254 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
269 PicHandle m_backpict
;
273 wxMacToolTipTimer
* m_timer
;
275 wxCFStringRef m_helpTextRef
;
280 WXDLLIMPEXP_CORE
void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
281 WXDLLIMPEXP_CORE
void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
282 WXDLLIMPEXP_CORE CGImageRef
wxMacCreateCGImageFromBitmap( const wxBitmap
& bitmap
);
284 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithCFData( CFDataRef data
);
285 WXDLLIMPEXP_CORE CGDataConsumerRef
wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data
);
286 WXDLLIMPEXP_CORE CGDataProviderRef
wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer
& buf
);
289 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
290 #define MAC_WXHMETAFILE(a) (PicHandle(a))
291 #define MAC_WXHICON(a) (IconRef(a))
292 #define MAC_WXHCURSOR(a) (CursHandle(a))
293 #define MAC_WXHRGN(a) (RgnHandle(a))
294 #define MAC_WXHWND(a) (WindowPtr(a))
295 #define MAC_WXRECPTR(a) ((Rect*)a)
296 #define MAC_WXPOINTPTR(a) ((Point*)a)
297 #define MAC_WXHMENU(a) ((MenuHandle)a)
299 struct wxOpaqueWindowRef
301 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
302 operator WindowRef() { return m_data
; }
307 WXDLLIMPEXP_CORE
void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
308 WXDLLIMPEXP_CORE
void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
309 WXDLLIMPEXP_CORE
void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
310 WXDLLIMPEXP_CORE
void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
312 WXDLLIMPEXP_CORE wxWindow
* wxFindControlFromMacControl(ControlRef inControl
);
313 WXDLLIMPEXP_CORE wxNonOwnedWindow
* wxFindWinFromMacWindow( WindowRef inWindow
);
314 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
316 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
317 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
318 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
320 extern wxWindow
* g_MacLastWindow
;
321 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
322 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
324 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
326 // additional optional event defines
328 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
330 kEventControlFocusPartChanged
= 164
334 class WXDLLIMPEXP_CORE wxMacControl
: public wxObject
337 wxMacControl( wxWindow
* peer
, bool isRootControl
= false );
338 wxMacControl( wxWindow
* peer
, ControlRef control
);
339 wxMacControl( wxWindow
* peer
, WXWidget control
);
341 virtual ~wxMacControl();
345 virtual void Dispose();
347 bool Ok() const { return IsOk(); }
348 bool IsOk() const { return GetControlRef() != NULL
; }
350 void SetReferenceInNativeControl();
351 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
353 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
354 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
356 virtual void SetReference( URefCon data
);
358 void operator= (ControlRef c) { m_controlRef = c; }
359 operator ControlRef () { return m_controlRef; }
360 operator ControlRef * () { return &m_controlRef; }
362 // accessing data and values
364 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
365 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
366 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
367 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
368 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
370 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
372 virtual SInt32
GetValue() const;
373 virtual SInt32
GetMaximum() const;
374 virtual SInt32
GetMinimum() const;
376 virtual void SetValue( SInt32 v
);
377 virtual void SetMinimum( SInt32 v
);
378 virtual void SetMaximum( SInt32 v
);
380 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
381 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
383 virtual OSStatus
SetFocus( ControlFocusPart focusPart
);
384 virtual bool HasFocus() const;
385 virtual bool NeedsFocusRect() const;
386 virtual void SetNeedsFocusRect( bool needs
);
390 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
393 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
396 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
398 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
400 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
402 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
404 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
406 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
408 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
410 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
412 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
415 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
417 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
420 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
424 wxFAIL_MSG( wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
425 inPartCode
, (int)inTag
) );
430 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
433 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
435 template <typename T
> T
GetData( ResType inTag
) const
437 return GetData
<T
>( kControlEntireControl
, inTag
);
440 // Flash the control for the specified amount of time
441 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
443 virtual void VisibilityChanged( bool shown
);
444 virtual void SuperChangedPosition();
447 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
448 virtual void SetBackgroundColour( const wxColour
& col
);
449 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
450 void SetActionProc( ControlActionUPP actionProc
);
451 void SetViewSize( SInt32 viewSize
);
452 SInt32
GetViewSize() const;
454 virtual bool IsVisible() const;
455 virtual void SetVisibility( bool visible
, bool redraw
);
456 virtual bool IsEnabled() const;
457 virtual bool IsActive() const;
458 virtual void Enable( bool enable
);
460 // invalidates this control and all children
461 virtual void InvalidateWithChildren();
462 virtual void SetDrawingEnabled( bool enable
);
463 virtual bool GetNeedsDisplay() const;
465 // where is in native window relative coordinates
466 virtual void SetNeedsDisplay( RgnHandle where
);
467 // where is in native window relative coordinates
468 virtual void SetNeedsDisplay( Rect
* where
= NULL
);
470 // if rect = NULL, entire view
471 virtual void ScrollRect( wxRect
*rect
, int dx
, int dy
);
473 // in native parent window relative coordinates
474 virtual void GetRect( Rect
*r
);
476 // in native parent window relative coordinates
477 virtual void SetRect( Rect
*r
);
479 virtual void GetRectInWindowCoords( Rect
*r
);
480 virtual void GetBestRect( Rect
*r
);
481 virtual void SetLabel( const wxString
&title
);
482 // converts from Toplevel-Content relative to local
483 static void Convert( wxPoint
*pt
, wxMacControl
*convert
, wxMacControl
*to
);
485 virtual void GetFeatures( UInt32
*features
);
486 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
487 virtual OSStatus
SetZOrder( bool above
, wxMacControl
* other
);
489 bool IsRootControl() { return m_isRootControl
; }
491 wxWindow
* GetPeer() const
496 // to be moved into a tab control class
498 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
500 ControlRef m_controlRef
;
504 bool m_needsFocusRect
;
505 bool m_isRootControl
;
506 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
509 // ============================================================================
510 // DataBrowser Wrapper
511 // ============================================================================
513 // basing on DataBrowserItemIDs
516 class WXDLLIMPEXP_CORE wxMacDataBrowserControl
: public wxMacControl
519 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
520 wxMacDataBrowserControl() {}
522 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
524 OSStatus
GetItemCount( DataBrowserItemID container
,
526 DataBrowserItemState state
,
527 ItemCount
*numItems
) const;
529 OSStatus
GetItems( DataBrowserItemID container
,
531 DataBrowserItemState state
,
535 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
536 DataBrowserTableViewColumnIndex position
);
538 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
540 OSStatus
AutoSizeColumns();
542 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
543 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
545 OSStatus
SetHeaderButtonHeight( UInt16 height
);
546 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
548 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
549 const DataBrowserItemID
*items
,
550 DataBrowserPropertyID preSortProperty
,
551 DataBrowserPropertyID propertyID
) const;
553 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
554 const DataBrowserItemID
*items
,
555 DataBrowserPropertyID preSortProperty
);
556 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
557 const DataBrowserItemID
*items
,
558 DataBrowserPropertyID preSortProperty
);
559 OSStatus
RevealItem( DataBrowserItemID item
,
560 DataBrowserPropertyID propertyID
,
561 DataBrowserRevealOptions options
) const;
563 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
564 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
565 bool IsItemSelected( DataBrowserItemID item
) const;
566 OSStatus
SetSelectedItems( UInt32 numItems
,
567 const DataBrowserItemID
*items
,
568 DataBrowserSetOption operation
);
570 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
571 DataBrowserItemID
* item
) const;
572 OSStatus
GetItemRow( DataBrowserItemID item
,
573 DataBrowserTableViewRowIndex
* row
) const;
575 OSStatus
SetDefaultRowHeight( UInt16 height
);
576 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
578 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
579 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
581 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
582 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
584 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
585 OSStatus
SetDefaultColumnWidth( UInt16 width
);
587 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
589 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
591 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
592 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
594 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
595 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
597 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
598 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
600 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
601 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
603 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
604 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
606 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
607 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
609 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
612 static pascal void DataBrowserItemNotificationProc(
614 DataBrowserItemID itemID
,
615 DataBrowserItemNotification message
,
616 DataBrowserItemDataRef itemData
);
618 virtual void ItemNotification(
619 DataBrowserItemID itemID
,
620 DataBrowserItemNotification message
,
621 DataBrowserItemDataRef itemData
) = 0;
623 static pascal OSStatus
DataBrowserGetSetItemDataProc(
625 DataBrowserItemID itemID
,
626 DataBrowserPropertyID property
,
627 DataBrowserItemDataRef itemData
,
628 Boolean changeValue
);
630 virtual OSStatus
GetSetItemData(
631 DataBrowserItemID itemID
,
632 DataBrowserPropertyID property
,
633 DataBrowserItemDataRef itemData
,
634 Boolean changeValue
) = 0;
636 static pascal Boolean
DataBrowserCompareProc(
638 DataBrowserItemID itemOneID
,
639 DataBrowserItemID itemTwoID
,
640 DataBrowserPropertyID sortProperty
);
642 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
643 DataBrowserItemID itemTwoID
,
644 DataBrowserPropertyID sortProperty
) = 0;
645 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
648 // ============================================================================
649 // Higher-level Databrowser
650 // ============================================================================
652 // basing on data item objects
657 class wxMacDataItemBrowserControl
;
658 class wxMacListBoxItem
;
660 const DataBrowserPropertyID kTextColumnId
= 1024;
661 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
663 // for multi-column controls, we will use this + the column ID to identify the
664 // column. We don't use kTextColumnId there, and ideally the two should merge.
665 const DataBrowserPropertyID kMinColumnId
= 1050;
667 // base API for high-level databrowser operations
669 class WXDLLIMPEXP_CORE wxMacListControl
672 virtual void MacDelete( unsigned int n
) = 0;
673 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 ) = 0;
674 // returns index of newly created line
675 virtual int MacAppend( const wxString
& item
) = 0;
676 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
677 virtual void MacClear() = 0;
678 virtual void MacDeselectAll() = 0;
679 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
680 virtual int MacGetSelection() const = 0;
681 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
682 virtual bool MacIsSelected( unsigned int n
) const = 0;
683 virtual void MacScrollTo( unsigned int n
) = 0;
684 virtual wxString
MacGetString( unsigned int n
) const = 0;
685 virtual unsigned int MacGetCount() const = 0;
687 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
688 virtual void * MacGetClientData( unsigned int) const = 0;
690 virtual ~wxMacListControl() { }
693 // base class for databrowser items
699 class WXDLLIMPEXP_CORE wxMacDataItem
703 virtual ~wxMacDataItem();
705 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
706 const wxMacDataItem
*,
707 DataBrowserPropertyID property
) const;
709 // returns true if access was successful, otherwise false
710 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
711 DataBrowserPropertyID property
,
712 DataBrowserItemDataRef itemData
,
715 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
716 DataBrowserItemNotification message
,
717 DataBrowserItemDataRef itemData
) const;
719 void SetLabel( const wxString
& str
);
720 const wxString
& GetLabel() const;
722 void SetOrder( SInt32 order
);
723 SInt32
GetOrder() const;
725 void SetData( void* data
);
726 void* GetData() const;
728 void SetColumn( short col
);
733 wxCFStringRef m_cfLabel
;
736 DataBrowserPropertyID m_colId
;
742 SortOrder_Text_Ascending
,
743 SortOrder_Text_Descending
746 typedef wxMacDataItem
* wxMacDataItemPtr
;
747 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
749 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
751 class WXDLLIMPEXP_CORE wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
754 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
755 wxMacDataItemBrowserControl() {}
756 // create a list item (can be a subclass of wxMacListBoxItem)
758 virtual wxMacDataItem
* CreateItem();
760 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
761 void GetItems(const wxMacDataItem
* container
, bool recurse
,
762 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
764 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
766 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
767 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
769 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
770 DataBrowserPropertyID property
) const;
771 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
772 DataBrowserPropertyID property
) const;
774 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
775 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
777 int GetColumnWidth(int colId
);
778 void SetColumnWidth(int colId
, int width
);
780 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
781 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
783 void RemoveAllItems(wxMacDataItem
*container
);
784 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
785 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
787 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
788 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
789 void SetSelectedAllItems( DataBrowserSetOption option
);
790 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
792 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
794 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
796 // item aware methods, to be used in subclasses
798 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
799 const wxMacDataItem
* itemTwoID
,
800 DataBrowserPropertyID sortProperty
);
802 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
803 DataBrowserPropertyID property
,
804 DataBrowserItemDataRef itemData
,
805 Boolean changeValue
);
807 virtual void ItemNotification(
808 const wxMacDataItem
* itemID
,
809 DataBrowserItemNotification message
,
810 DataBrowserItemDataRef itemData
);
812 // as we are getting the same events for human and API selection we have to suppress
813 // events in the latter case, since this will be used from many subclasses we keep it here
815 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
816 bool SuppressSelection( bool suppress
);
819 // wxMacListControl Methods
822 virtual void MacDelete( unsigned int n
);
823 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 );
824 virtual int MacAppend( const wxString
& item
);
825 virtual void MacClear();
829 virtual void MacDeselectAll();
830 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
831 virtual int MacGetSelection() const;
832 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
833 virtual bool MacIsSelected( unsigned int n
) const;
837 virtual void MacScrollTo( unsigned int n
);
841 virtual void MacSetString( unsigned int n
, const wxString
& item
);
842 virtual void MacSetClientData( unsigned int n
, void * data
);
843 virtual wxString
MacGetString( unsigned int n
) const;
844 virtual void * MacGetClientData( unsigned int) const;
845 virtual unsigned int MacGetCount() const;
849 virtual wxClientDataType
GetClientDataType() const;
850 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
851 //virtual ListSortOrder GetSortOrder() const;
852 //virtual void SetSortOrder(const ListSortOrder sort);
858 ListSortOrder m_sortOrder
;
859 wxClientDataType m_clientDataItemsType
;
861 // ID aware base methods, should be 'final' ie not changed in subclasses
863 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
864 DataBrowserItemID itemTwoID
,
865 DataBrowserPropertyID sortProperty
);
867 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
868 DataBrowserPropertyID property
,
869 DataBrowserItemDataRef itemData
,
870 Boolean changeValue
);
872 virtual void ItemNotification(
873 DataBrowserItemID itemID
,
874 DataBrowserItemNotification message
,
875 DataBrowserItemDataRef itemData
);
880 bool m_suppressSelection
;
881 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
884 class WXDLLIMPEXP_CORE wxMacDataItemBrowserSelectionSuppressor
887 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
888 ~wxMacDataItemBrowserSelectionSuppressor();
893 wxMacDataItemBrowserControl
* m_browser
;
896 // ============================================================================
897 // platform listbox implementation
898 // ============================================================================
900 // exposed for reuse in wxCheckListBox
902 class WXDLLIMPEXP_CORE wxMacListBoxItem
: public wxMacDataItem
907 virtual ~wxMacListBoxItem();
909 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
910 DataBrowserItemNotification message
,
911 DataBrowserItemDataRef itemData
) const;
914 class WXDLLIMPEXP_CORE wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
917 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
918 wxMacDataBrowserListControl() {}
919 virtual ~wxMacDataBrowserListControl();
921 virtual wxMacDataItem
* CreateItem();
925 wxWindow
* GetPeer() const;
927 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
930 // ============================================================================
931 // graphics implementation
932 // ============================================================================
934 // draw the image 'upside down' corrected as HIViewDrawCGImage does
936 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
937 CGContextRef inContext
,
938 const HIRect
* inBounds
,
939 CGImageRef inImage
) ;
941 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
943 CGColorSpaceRef WXDLLIMPEXP_CORE
wxMacGetGenericRGBColorSpace(void);
947 class WXDLLIMPEXP_CORE wxMacDeferredWindowDeleter
: public wxObject
950 wxMacDeferredWindowDeleter( WindowRef windowRef
);
951 virtual ~wxMacDeferredWindowDeleter();
954 WindowRef m_macWindow
;
959 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
962 static UPP sHandler = NULL; \
963 if ( sHandler == NULL ) \
964 sHandler = New##UPP( x ); \
968 //---------------------------------------------------------------------------
969 // wxMac string conversions
970 //---------------------------------------------------------------------------
972 void wxMacSetupConverters();
973 void wxMacCleanupConverters();
975 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
976 WXDLLIMPEXP_BASE wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
980 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
981 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
982 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
988 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
);
989 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
);
993 //---------------------------------------------------------------------------
994 // cocoa bridging utilities
995 //---------------------------------------------------------------------------
997 bool wxMacInitCocoa();
999 class WXDLLIMPEXP_CORE wxMacAutoreleasePool
1002 wxMacAutoreleasePool();
1003 ~wxMacAutoreleasePool();
1010 void wxMacCocoaRelease( void* obj
);
1011 void wxMacCocoaAutorelease( void* obj
);
1012 void wxMacCocoaRetain( void* obj
);
1018 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
1019 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
1020 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
1021 void wxMacCocoaHideCursor();
1022 void wxMacCocoaShowCursor();
1024 typedef struct tagClassicCursor
1031 #else // !wxMAC_USE_COCOA
1035 typedef Cursor ClassicCursor
;
1037 #endif // wxMAC_USE_COCOA
1045 const short kwxCursorBullseye
= 0;
1046 const short kwxCursorBlank
= 1;
1047 const short kwxCursorPencil
= 2;
1048 const short kwxCursorMagnifier
= 3;
1049 const short kwxCursorNoEntry
= 4;
1050 const short kwxCursorPaintBrush
= 5;
1051 const short kwxCursorPointRight
= 6;
1052 const short kwxCursorPointLeft
= 7;
1053 const short kwxCursorQuestionArrow
= 8;
1054 const short kwxCursorRightArrow
= 9;
1055 const short kwxCursorSizeNS
= 10;
1056 const short kwxCursorSize
= 11;
1057 const short kwxCursorSizeNESW
= 12;
1058 const short kwxCursorSizeNWSE
= 13;
1059 const short kwxCursorRoller
= 14;
1060 const short kwxCursorLast
= kwxCursorRoller
;
1062 // exposing our fallback cursor map
1064 extern ClassicCursor gMacCursors
[];