1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/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_
17 #include "wx/osx/core/private.h"
19 #include <Carbon/Carbon.h>
21 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
22 typedef UInt32 URefCon
;
23 typedef SInt32 SRefCon
;
28 #include "wx/listbox.h"
29 #include "wx/osx/carbon/dc.h"
30 #include "wx/osx/carbon/dcclient.h"
31 #include "wx/osx/carbon/dcmemory.h"
35 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
36 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
39 WXDLLIMPEXP_CORE wxWindowMac
* wxFindWindowFromWXWidget(WXWidget inControl
);
40 // TODO REMOVE WXDLLIMPEXP_CORE wxNonOwnedWindow* wxFindWindowFromWXWindow( WXWindow inWindow );
45 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
46 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
49 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
51 Boolean createFolder
);
52 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
54 Boolean createFolder
);
56 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
57 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
58 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
59 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
60 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
61 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
62 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
63 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
64 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
65 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
66 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
67 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
68 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
69 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
70 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
71 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
72 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
73 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
74 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
75 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
76 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
79 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
80 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
81 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
82 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
85 class WXDLLIMPEXP_CORE wxMacCarbonEvent
95 wxMacCarbonEvent( EventRef event
, bool release
= false )
101 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
104 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
111 ReleaseEvent( m_eventRef
);
114 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
116 verify( (m_eventRef
== NULL
) || m_release
);
117 if ( m_eventRef
&& m_release
)
119 ReleaseEvent( m_eventRef
);
123 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
129 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
131 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
133 return GetParameter( inName
, type
, sizeof( T
) , data
);
135 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
137 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
140 template <typename T
> T
GetParameter( EventParamName inName
)
143 verify_noerr( GetParameter
<T
>( inName
, &value
) );
146 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
149 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
153 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
154 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
156 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
158 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
160 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
162 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
164 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
166 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
168 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
172 return ::GetEventClass( m_eventRef
);
176 return ::GetEventKind( m_eventRef
);
180 return ::GetEventTime( m_eventRef
);
184 return EventTimeToTicks( GetTime() );
186 OSStatus
SetCurrentTime( )
188 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
190 OSStatus
SetTime( EventTime when
)
192 return ::SetEventTime( m_eventRef
, when
);
194 operator EventRef () { return m_eventRef
; }
196 bool IsValid() { return m_eventRef
!= 0; }
204 class WXDLLIMPEXP_FWD_CORE wxMacToolTipTimer
;
206 class WXDLLIMPEXP_CORE wxMacToolTip
212 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
227 PicHandle m_backpict
;
231 wxMacToolTipTimer
* m_timer
;
233 wxCFStringRef m_helpTextRef
;
238 WXDLLIMPEXP_CORE
void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
239 WXDLLIMPEXP_CORE
void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
241 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
242 #define MAC_WXHMETAFILE(a) (PicHandle(a))
243 #define MAC_WXHICON(a) (IconRef(a))
244 #define MAC_WXHCURSOR(a) (CursHandle(a))
245 #define MAC_WXHRGN(a) (RgnHandle(a))
246 #define MAC_WXHWND(a) (WindowPtr(a))
247 #define MAC_WXRECPTR(a) ((Rect*)a)
248 #define MAC_WXPOINTPTR(a) ((Point*)a)
249 #define MAC_WXHMENU(a) ((MenuHandle)a)
251 struct wxOpaqueWindowRef
253 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
254 operator WindowRef() { return m_data
; }
259 WXDLLIMPEXP_CORE
void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
260 WXDLLIMPEXP_CORE
void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
261 WXDLLIMPEXP_CORE
void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
262 WXDLLIMPEXP_CORE
void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
264 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
266 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
267 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
268 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
270 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
271 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
273 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
275 // additional optional event defines
277 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
279 kEventControlFocusPartChanged
= 164
283 class WXDLLIMPEXP_CORE wxMacControl
: public wxWidgetImpl
286 wxMacControl( wxWindowMac
* peer
, bool isRootControl
= false );
288 virtual ~wxMacControl();
292 virtual void Destroy();
294 void SetReferenceInNativeControl();
295 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
297 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
298 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
300 virtual WXWidget
GetWXWidget() const { return (WXWidget
) m_controlRef
; }
302 virtual void SetReference( URefCon data
);
304 virtual bool IsVisible() const;
306 virtual void Raise();
308 virtual void Lower();
310 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
312 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
313 virtual void Move(int x
, int y
, int width
, int height
);
314 virtual void GetPosition( int &x
, int &y
) const;
315 virtual void GetSize( int &width
, int &height
) const;
317 // where is in native window relative coordinates
318 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
319 virtual bool GetNeedsDisplay() const;
321 virtual bool CanFocus() const;
322 // return true if successful
323 virtual bool SetFocus();
324 virtual bool HasFocus() const;
326 void RemoveFromParent();
327 void Embed( wxWidgetImpl
*parent
);
329 void operator= (ControlRef c) { m_controlRef = c; }
330 operator ControlRef () { return m_controlRef; }
331 operator ControlRef * () { return &m_controlRef; }
333 // accessing data and values
335 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
336 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
337 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
338 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
339 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
341 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
343 virtual SInt32
GetValue() const;
344 virtual SInt32
GetMaximum() const;
345 virtual SInt32
GetMinimum() const;
347 virtual void SetValue( SInt32 v
);
348 virtual void SetMinimum( SInt32 v
);
349 virtual void SetMaximum( SInt32 v
);
351 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
352 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
356 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
359 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
362 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
364 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
366 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
368 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
370 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
372 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
374 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
376 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
378 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
381 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
383 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
386 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
390 wxFAIL_MSG( wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
391 inPartCode
, (int)inTag
) );
396 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
399 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
401 template <typename T
> T
GetData( ResType inTag
) const
403 return GetData
<T
>( kControlEntireControl
, inTag
);
406 // Flash the control for the specified amount of time
407 virtual void Flash( ControlPartCode part
, UInt32 ticks
= 8 );
409 virtual void VisibilityChanged( bool shown
);
410 virtual void SuperChangedPosition();
413 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
);
414 virtual void SetBackgroundColour( const wxColour
& col
);
415 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
416 void SetActionProc( ControlActionUPP actionProc
);
417 void SetViewSize( SInt32 viewSize
);
418 SInt32
GetViewSize() const;
420 virtual void SetVisibility( bool visible
);
421 virtual bool IsEnabled() const;
422 virtual bool IsActive() const;
423 virtual void Enable( bool enable
);
425 // invalidates this control and all children
426 virtual void InvalidateWithChildren();
427 virtual void SetDrawingEnabled( bool enable
);
429 // in native parent window relative coordinates
431 virtual void GetRectInWindowCoords( Rect
*r
);
432 virtual void GetBestRect( Rect
*r
);
434 virtual void SetLabel( const wxString
&title
);
436 virtual void GetFeatures( UInt32
*features
);
437 virtual OSStatus
GetRegion( ControlPartCode partCode
, RgnHandle region
);
439 // to be moved into a tab control class
441 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
443 void InstallEventHandler()
445 MacInstallEventHandler( m_controlRef
, m_wxPeer
);
448 static void MacInstallEventHandler( ControlRef control
, wxWindowMac
* wxPeer
);
450 WXEVENTHANDLERREF m_macControlEventHandler
;
451 ControlRef m_controlRef
;
454 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
457 // ============================================================================
458 // DataBrowser Wrapper
459 // ============================================================================
461 // basing on DataBrowserItemIDs
464 class WXDLLIMPEXP_CORE wxMacDataBrowserControl
: public wxMacControl
467 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
468 wxMacDataBrowserControl() {}
470 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
472 OSStatus
GetItemCount( DataBrowserItemID container
,
474 DataBrowserItemState state
,
475 ItemCount
*numItems
) const;
477 OSStatus
GetItems( DataBrowserItemID container
,
479 DataBrowserItemState state
,
483 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
484 DataBrowserTableViewColumnIndex position
);
486 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
488 OSStatus
AutoSizeColumns();
490 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
491 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
493 OSStatus
SetHeaderButtonHeight( UInt16 height
);
494 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
496 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
497 const DataBrowserItemID
*items
,
498 DataBrowserPropertyID preSortProperty
,
499 DataBrowserPropertyID propertyID
) const;
501 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
502 const DataBrowserItemID
*items
,
503 DataBrowserPropertyID preSortProperty
);
504 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
505 const DataBrowserItemID
*items
,
506 DataBrowserPropertyID preSortProperty
);
507 OSStatus
RevealItem( DataBrowserItemID item
,
508 DataBrowserPropertyID propertyID
,
509 DataBrowserRevealOptions options
) const;
511 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
512 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
513 bool IsItemSelected( DataBrowserItemID item
) const;
514 OSStatus
SetSelectedItems( UInt32 numItems
,
515 const DataBrowserItemID
*items
,
516 DataBrowserSetOption operation
);
518 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
519 DataBrowserItemID
* item
) const;
520 OSStatus
GetItemRow( DataBrowserItemID item
,
521 DataBrowserTableViewRowIndex
* row
) const;
523 OSStatus
SetDefaultRowHeight( UInt16 height
);
524 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
526 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
527 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
529 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
530 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
532 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
533 OSStatus
SetDefaultColumnWidth( UInt16 width
);
535 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
537 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
539 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
540 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
542 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
543 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
545 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
546 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
548 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
549 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
551 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
552 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
554 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
555 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
557 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
560 static pascal void DataBrowserItemNotificationProc(
562 DataBrowserItemID itemID
,
563 DataBrowserItemNotification message
,
564 DataBrowserItemDataRef itemData
);
566 virtual void ItemNotification(
567 DataBrowserItemID itemID
,
568 DataBrowserItemNotification message
,
569 DataBrowserItemDataRef itemData
) = 0;
571 static pascal OSStatus
DataBrowserGetSetItemDataProc(
573 DataBrowserItemID itemID
,
574 DataBrowserPropertyID property
,
575 DataBrowserItemDataRef itemData
,
576 Boolean changeValue
);
578 virtual OSStatus
GetSetItemData(
579 DataBrowserItemID itemID
,
580 DataBrowserPropertyID property
,
581 DataBrowserItemDataRef itemData
,
582 Boolean changeValue
) = 0;
584 static pascal Boolean
DataBrowserCompareProc(
586 DataBrowserItemID itemOneID
,
587 DataBrowserItemID itemTwoID
,
588 DataBrowserPropertyID sortProperty
);
590 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
591 DataBrowserItemID itemTwoID
,
592 DataBrowserPropertyID sortProperty
) = 0;
593 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
596 // ============================================================================
597 // Higher-level Databrowser
598 // ============================================================================
600 // basing on data item objects
605 class wxMacDataItemBrowserControl
;
606 class wxMacListBoxItem
;
608 const DataBrowserPropertyID kTextColumnId
= 1024;
609 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
611 // for multi-column controls, we will use this + the column ID to identify the
612 // column. We don't use kTextColumnId there, and ideally the two should merge.
613 const DataBrowserPropertyID kMinColumnId
= 1050;
615 // base API for high-level databrowser operations
617 class WXDLLIMPEXP_CORE wxMacListControl
620 virtual void MacDelete( unsigned int n
) = 0;
621 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 ) = 0;
622 // returns index of newly created line
623 virtual int MacAppend( const wxString
& item
) = 0;
624 virtual void MacSetString( unsigned int n
, const wxString
& item
) = 0;
625 virtual void MacClear() = 0;
626 virtual void MacDeselectAll() = 0;
627 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
) = 0;
628 virtual int MacGetSelection() const = 0;
629 virtual int MacGetSelections( wxArrayInt
& aSelections
) const = 0;
630 virtual bool MacIsSelected( unsigned int n
) const = 0;
631 virtual void MacScrollTo( unsigned int n
) = 0;
632 virtual wxString
MacGetString( unsigned int n
) const = 0;
633 virtual unsigned int MacGetCount() const = 0;
635 virtual void MacSetClientData( unsigned int n
, void * data
) = 0;
636 virtual void * MacGetClientData( unsigned int) const = 0;
638 virtual ~wxMacListControl() { }
641 // base class for databrowser items
647 class WXDLLIMPEXP_CORE wxMacDataItem
651 virtual ~wxMacDataItem();
653 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
654 const wxMacDataItem
*,
655 DataBrowserPropertyID property
) const;
657 // returns true if access was successful, otherwise false
658 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
659 DataBrowserPropertyID property
,
660 DataBrowserItemDataRef itemData
,
663 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
664 DataBrowserItemNotification message
,
665 DataBrowserItemDataRef itemData
) const;
667 void SetLabel( const wxString
& str
);
668 const wxString
& GetLabel() const;
670 void SetOrder( SInt32 order
);
671 SInt32
GetOrder() const;
673 void SetData( void* data
);
674 void* GetData() const;
676 void SetColumn( short col
);
681 wxCFStringRef m_cfLabel
;
684 DataBrowserPropertyID m_colId
;
690 SortOrder_Text_Ascending
,
691 SortOrder_Text_Descending
694 typedef wxMacDataItem
* wxMacDataItemPtr
;
695 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
697 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
699 class WXDLLIMPEXP_CORE wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
, public wxMacListControl
702 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
703 wxMacDataItemBrowserControl() {}
704 // create a list item (can be a subclass of wxMacListBoxItem)
706 virtual wxMacDataItem
* CreateItem();
708 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
709 void GetItems(const wxMacDataItem
* container
, bool recurse
,
710 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
712 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
714 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
715 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
717 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
718 DataBrowserPropertyID property
) const;
719 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
720 DataBrowserPropertyID property
) const;
722 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
723 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
725 int GetColumnWidth(int colId
);
726 void SetColumnWidth(int colId
, int width
);
728 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
729 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
731 void RemoveAllItems(wxMacDataItem
*container
);
732 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
733 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
735 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
736 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
737 void SetSelectedAllItems( DataBrowserSetOption option
);
738 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
740 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
742 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
744 // item aware methods, to be used in subclasses
746 virtual Boolean
CompareItems(const wxMacDataItem
* itemOneID
,
747 const wxMacDataItem
* itemTwoID
,
748 DataBrowserPropertyID sortProperty
);
750 virtual OSStatus
GetSetItemData(wxMacDataItem
* itemID
,
751 DataBrowserPropertyID property
,
752 DataBrowserItemDataRef itemData
,
753 Boolean changeValue
);
755 virtual void ItemNotification(
756 const wxMacDataItem
* itemID
,
757 DataBrowserItemNotification message
,
758 DataBrowserItemDataRef itemData
);
760 // as we are getting the same events for human and API selection we have to suppress
761 // events in the latter case, since this will be used from many subclasses we keep it here
763 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
764 bool SuppressSelection( bool suppress
);
767 // wxMacListControl Methods
770 virtual void MacDelete( unsigned int n
);
771 virtual void MacInsert( unsigned int n
, const wxArrayStringsAdapter
& items
, int column
= -1 );
772 virtual int MacAppend( const wxString
& item
);
773 virtual void MacClear();
777 virtual void MacDeselectAll();
778 virtual void MacSetSelection( unsigned int n
, bool select
, bool multi
= false );
779 virtual int MacGetSelection() const;
780 virtual int MacGetSelections( wxArrayInt
& aSelections
) const;
781 virtual bool MacIsSelected( unsigned int n
) const;
785 virtual void MacScrollTo( unsigned int n
);
789 virtual void MacSetString( unsigned int n
, const wxString
& item
);
790 virtual void MacSetClientData( unsigned int n
, void * data
);
791 virtual wxString
MacGetString( unsigned int n
) const;
792 virtual void * MacGetClientData( unsigned int) const;
793 virtual unsigned int MacGetCount() const;
797 virtual wxClientDataType
GetClientDataType() const;
798 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
799 //virtual ListSortOrder GetSortOrder() const;
800 //virtual void SetSortOrder(const ListSortOrder sort);
806 ListSortOrder m_sortOrder
;
807 wxClientDataType m_clientDataItemsType
;
809 // ID aware base methods, should be 'final' ie not changed in subclasses
811 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
812 DataBrowserItemID itemTwoID
,
813 DataBrowserPropertyID sortProperty
);
815 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
816 DataBrowserPropertyID property
,
817 DataBrowserItemDataRef itemData
,
818 Boolean changeValue
);
820 virtual void ItemNotification(
821 DataBrowserItemID itemID
,
822 DataBrowserItemNotification message
,
823 DataBrowserItemDataRef itemData
);
828 bool m_suppressSelection
;
829 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
832 class WXDLLIMPEXP_CORE wxMacDataItemBrowserSelectionSuppressor
835 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
836 ~wxMacDataItemBrowserSelectionSuppressor();
841 wxMacDataItemBrowserControl
* m_browser
;
844 // ============================================================================
845 // platform listbox implementation
846 // ============================================================================
848 // exposed for reuse in wxCheckListBox
850 class WXDLLIMPEXP_CORE wxMacListBoxItem
: public wxMacDataItem
855 virtual ~wxMacListBoxItem();
857 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
858 DataBrowserItemNotification message
,
859 DataBrowserItemDataRef itemData
) const;
862 class WXDLLIMPEXP_CORE wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
865 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
866 wxMacDataBrowserListControl() {}
867 virtual ~wxMacDataBrowserListControl();
869 virtual wxMacDataItem
* CreateItem();
871 virtual void ItemNotification(
872 const wxMacDataItem
* itemID
,
873 DataBrowserItemNotification message
,
874 DataBrowserItemDataRef itemData
);
878 // wxWindow * GetPeer() const;
880 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
883 // ============================================================================
884 // graphics implementation
885 // ============================================================================
887 // draw the image 'upside down' corrected as HIViewDrawCGImage does
889 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
890 CGContextRef inContext
,
891 const HIRect
* inBounds
,
892 CGImageRef inImage
) ;
894 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
898 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
901 static UPP sHandler = NULL; \
902 if ( sHandler == NULL ) \
903 sHandler = New##UPP( x ); \
907 //---------------------------------------------------------------------------
908 // wxMac string conversions
909 //---------------------------------------------------------------------------
911 void wxMacSetupConverters();
912 void wxMacCleanupConverters();
914 WXDLLIMPEXP_BASE
void wxMacStringToPascal( const wxString
&from
, StringPtr to
);
915 WXDLLIMPEXP_BASE wxString
wxMacMakeStringFromPascal( ConstStringPtr from
);
919 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
920 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
921 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
923 //---------------------------------------------------------------------------
924 // cocoa bridging utilities
925 //---------------------------------------------------------------------------
927 bool wxMacInitCocoa();
929 typedef Cursor ClassicCursor
;
937 const short kwxCursorBullseye
= 0;
938 const short kwxCursorBlank
= 1;
939 const short kwxCursorPencil
= 2;
940 const short kwxCursorMagnifier
= 3;
941 const short kwxCursorNoEntry
= 4;
942 const short kwxCursorPaintBrush
= 5;
943 const short kwxCursorPointRight
= 6;
944 const short kwxCursorPointLeft
= 7;
945 const short kwxCursorQuestionArrow
= 8;
946 const short kwxCursorRightArrow
= 9;
947 const short kwxCursorSizeNS
= 10;
948 const short kwxCursorSize
= 11;
949 const short kwxCursorSizeNESW
= 12;
950 const short kwxCursorSizeNWSE
= 13;
951 const short kwxCursorRoller
= 14;
952 const short kwxCursorLast
= kwxCursorRoller
;
954 // exposing our fallback cursor map
956 extern ClassicCursor gMacCursors
[];
964 class wxNonOwnedWindowCarbonImpl
: public wxNonOwnedWindowImpl
967 wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow
* nonownedwnd
) ;
968 wxNonOwnedWindowCarbonImpl();
969 virtual ~wxNonOwnedWindowCarbonImpl();
971 virtual void Destroy() ;
972 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
973 long style
, long extraStyle
, const wxString
& name
) ;
975 WXWindow
GetWXWindow() const;
978 bool Show(bool show
);
979 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
983 bool SetTransparent(wxByte alpha
);
984 bool SetBackgroundColour(const wxColour
& col
);
985 void SetExtraStyle( long exStyle
);
986 bool SetBackgroundStyle(wxBackgroundStyle style
);
987 bool CanSetTransparent();
988 void MoveWindow(int x
, int y
, int width
, int height
);
989 void GetPosition( int &x
, int &y
) const;
990 void GetSize( int &width
, int &height
) const;
991 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
993 bool SetShape(const wxRegion
& region
);
995 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
997 virtual bool IsMaximized() const;
999 virtual bool IsIconized() const;
1001 virtual void Iconize( bool iconize
);
1003 virtual void Maximize(bool maximize
);
1005 virtual bool IsFullScreen() const;
1007 virtual bool ShowFullScreen(bool show
, long style
);
1009 virtual void RequestUserAttention(int flags
);
1011 virtual void ScreenToWindow( int *x
, int *y
);
1013 virtual void WindowToScreen( int *x
, int *y
);
1016 bool MacGetUnifiedAppearance() const ;
1017 void MacChangeWindowAttributes( wxUint32 attributesToSet
, wxUint32 attributesToClear
) ;
1018 wxUint32
MacGetWindowAttributes() const ;
1019 void MacSetMetalAppearance( bool set
) ;
1020 bool MacGetMetalAppearance() const ;
1021 void MacSetUnifiedAppearance( bool set
);
1023 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
1025 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
1027 void MacInstallTopLevelWindowEventHandler();
1029 WXEVENTHANDLERREF m_macEventHandler
;
1030 WindowRef m_macWindow
;
1031 void * m_macFullScreenData
;
1032 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCarbonImpl
)