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/osx/uma.h"
30 #include "wx/listbox.h"
31 #include "wx/osx/dc.h"
32 #include "wx/osx/dcclient.h"
33 #include "wx/osx/dcmemory.h"
37 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
38 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
41 // TODO REMOVE WXDLLIMPEXP_CORE wxNonOwnedWindow* wxFindWindowFromWXWindow( WXWindow inWindow );
46 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
47 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
50 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
52 Boolean createFolder
);
53 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
55 Boolean createFolder
);
57 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
58 template<> inline EventParamType wxMacGetEventParamType
<HIShapeRef
>() { return typeHIShapeRef
; }
59 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
60 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
61 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
62 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
63 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
64 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
65 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
66 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
67 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
68 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
69 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
70 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
71 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
72 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
73 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
74 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
75 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
76 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
77 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
78 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
81 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
82 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
83 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
84 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
87 class WXDLLIMPEXP_CORE wxMacCarbonEvent
97 wxMacCarbonEvent( EventRef event
, bool release
= false )
103 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
106 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
113 ReleaseEvent( m_eventRef
);
116 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
118 verify( (m_eventRef
== NULL
) || m_release
);
119 if ( m_eventRef
&& m_release
)
121 ReleaseEvent( m_eventRef
);
125 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
131 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
133 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
135 return GetParameter( inName
, type
, sizeof( T
) , data
);
137 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
139 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
142 template <typename T
> T
GetParameter( EventParamName inName
)
145 verify_noerr( GetParameter
<T
>( inName
, &value
) );
148 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
151 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
155 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
156 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
158 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
160 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
162 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
164 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
166 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
168 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
170 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
174 return ::GetEventClass( m_eventRef
);
178 return ::GetEventKind( m_eventRef
);
182 return ::GetEventTime( m_eventRef
);
186 return EventTimeToTicks( GetTime() );
188 OSStatus
SetCurrentTime( )
190 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
192 OSStatus
SetTime( EventTime when
)
194 return ::SetEventTime( m_eventRef
, when
);
196 operator EventRef () { return m_eventRef
; }
198 bool IsValid() { return m_eventRef
!= 0; }
206 class WXDLLIMPEXP_FWD_CORE wxMacToolTipTimer
;
208 class WXDLLIMPEXP_CORE wxMacToolTip
214 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
229 PicHandle m_backpict
;
233 wxMacToolTipTimer
* m_timer
;
235 wxCFStringRef m_helpTextRef
;
240 WXDLLIMPEXP_CORE
void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
241 WXDLLIMPEXP_CORE
void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
243 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
244 #define MAC_WXHMETAFILE(a) (PicHandle(a))
245 #define MAC_WXHICON(a) (IconRef(a))
246 #define MAC_WXHCURSOR(a) (CursHandle(a))
247 #define MAC_WXHRGN(a) (RgnHandle(a))
248 #define MAC_WXHWND(a) (WindowPtr(a))
249 #define MAC_WXRECPTR(a) ((Rect*)a)
250 #define MAC_WXPOINTPTR(a) ((Point*)a)
251 #define MAC_WXHMENU(a) ((MenuHandle)a)
253 struct wxOpaqueWindowRef
255 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
256 operator WindowRef() { return m_data
; }
261 WXDLLIMPEXP_CORE
void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
262 WXDLLIMPEXP_CORE
void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
263 WXDLLIMPEXP_CORE
void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
264 WXDLLIMPEXP_CORE
void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
266 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
268 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
269 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
270 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
272 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
273 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
275 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
277 // additional optional event defines
279 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
281 kEventControlFocusPartChanged
= 164
285 class WXDLLIMPEXP_CORE wxMacControl
: public wxWidgetImpl
288 wxMacControl( wxWindowMac
* peer
, bool isRootControl
= false );
290 virtual ~wxMacControl();
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 bool IsVisible() const;
304 virtual void Raise();
306 virtual void Lower();
308 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
310 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
311 virtual void Move(int x
, int y
, int width
, int height
);
312 virtual void GetPosition( int &x
, int &y
) const;
313 virtual void GetSize( int &width
, int &height
) const;
314 virtual void SetControlSize( wxWindowVariant variant
) ;
316 // where is in native window relative coordinates
317 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
318 virtual bool GetNeedsDisplay() const;
320 virtual bool CanFocus() const;
321 // return true if successful
322 virtual bool SetFocus();
323 virtual bool HasFocus() const;
325 void RemoveFromParent();
326 void Embed( wxWidgetImpl
*parent
);
328 void SetDefaultButton( bool isDefault
);
330 void SetLabel( const wxString
& title
, wxFontEncoding encoding
);
332 void SetCursor( const wxCursor
& cursor
);
336 wxInt32
GetValue() const;
337 void SetValue( wxInt32 v
);
338 wxBitmap
GetBitmap() const;
339 void SetBitmap( const wxBitmap
& bitmap
);
340 void SetBitmapPosition( wxDirection dir
);
341 void SetupTabs( const wxNotebook
¬ebook
);
343 void GetBestRect( wxRect
*r
) const;
344 bool IsEnabled() const;
345 void Enable( bool enable
);
346 bool ButtonClickDidStateChange() { return false ;}
347 void SetMinimum( wxInt32 v
);
348 void SetMaximum( wxInt32 v
);
350 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
352 // temp convenience methods
354 void GetBestRect( Rect
*r
) const;
356 void operator= (ControlRef c) { m_controlRef = c; }
357 operator ControlRef () { return m_controlRef; }
358 operator ControlRef * () { return &m_controlRef; }
360 // accessing data and values
362 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
363 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
364 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
365 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
366 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
368 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
370 virtual wxInt32
GetMaximum() const;
371 virtual wxInt32
GetMinimum() const;
373 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
374 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
378 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
381 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
384 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
386 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
388 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
390 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
392 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
394 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
396 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
398 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
400 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
403 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
405 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
408 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
412 wxFAIL_MSG( wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
413 inPartCode
, (int)inTag
) );
418 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
421 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
423 template <typename T
> T
GetData( ResType inTag
) const
425 return GetData
<T
>( kControlEntireControl
, inTag
);
428 // Flash the control for the specified amount of time
430 virtual void VisibilityChanged( bool shown
);
431 virtual void SuperChangedPosition();
434 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
435 virtual void SetBackgroundColour( const wxColour
& col
);
436 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
437 void SetActionProc( ControlActionUPP actionProc
);
438 SInt32
GetViewSize() const;
440 virtual void SetVisibility( bool visible
);
442 virtual bool IsActive() const;
444 // invalidates this control and all children
445 virtual void InvalidateWithChildren();
446 virtual void SetDrawingEnabled( bool enable
);
448 // in native parent window relative coordinates
450 virtual void GetRectInWindowCoords( Rect
*r
);
453 virtual void GetFeatures( UInt32
*features
);
455 // to be moved into a tab control class
457 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
459 virtual void InstallEventHandler( WXWidget control
= NULL
);
461 WXEVENTHANDLERREF m_macControlEventHandler
;
462 ControlRef m_controlRef
;
465 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
468 // ============================================================================
469 // DataBrowser Wrapper
470 // ============================================================================
472 // basing on DataBrowserItemIDs
475 class WXDLLIMPEXP_CORE wxMacDataBrowserControl
: public wxMacControl
478 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
479 wxMacDataBrowserControl() {}
481 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
483 OSStatus
GetItemCount( DataBrowserItemID container
,
485 DataBrowserItemState state
,
486 ItemCount
*numItems
) const;
488 OSStatus
GetItems( DataBrowserItemID container
,
490 DataBrowserItemState state
,
494 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
495 DataBrowserTableViewColumnIndex position
);
497 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
499 OSStatus
AutoSizeColumns();
501 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
502 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
504 OSStatus
SetHeaderButtonHeight( UInt16 height
);
505 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
507 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
508 const DataBrowserItemID
*items
,
509 DataBrowserPropertyID preSortProperty
,
510 DataBrowserPropertyID propertyID
) const;
512 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
513 const DataBrowserItemID
*items
,
514 DataBrowserPropertyID preSortProperty
);
515 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
516 const DataBrowserItemID
*items
,
517 DataBrowserPropertyID preSortProperty
);
518 OSStatus
RevealItem( DataBrowserItemID item
,
519 DataBrowserPropertyID propertyID
,
520 DataBrowserRevealOptions options
) const;
522 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
523 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
524 bool IsItemSelected( DataBrowserItemID item
) const;
525 OSStatus
SetSelectedItems( UInt32 numItems
,
526 const DataBrowserItemID
*items
,
527 DataBrowserSetOption operation
);
529 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
530 DataBrowserItemID
* item
) const;
531 OSStatus
GetItemRow( DataBrowserItemID item
,
532 DataBrowserTableViewRowIndex
* row
) const;
534 OSStatus
SetDefaultRowHeight( UInt16 height
);
535 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
537 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
538 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
540 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
541 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
543 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
544 OSStatus
SetDefaultColumnWidth( UInt16 width
);
546 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
548 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
550 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
551 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
553 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
554 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
556 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
557 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
559 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
560 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
562 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
563 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
565 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
566 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
568 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
570 OSStatus
GetItemPartBounds( DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
);
573 static pascal void DataBrowserItemNotificationProc(
575 DataBrowserItemID itemID
,
576 DataBrowserItemNotification message
,
577 DataBrowserItemDataRef itemData
);
579 virtual void ItemNotification(
580 DataBrowserItemID itemID
,
581 DataBrowserItemNotification message
,
582 DataBrowserItemDataRef itemData
) = 0;
584 static pascal OSStatus
DataBrowserGetSetItemDataProc(
586 DataBrowserItemID itemID
,
587 DataBrowserPropertyID property
,
588 DataBrowserItemDataRef itemData
,
589 Boolean changeValue
);
591 virtual OSStatus
GetSetItemData(
592 DataBrowserItemID itemID
,
593 DataBrowserPropertyID property
,
594 DataBrowserItemDataRef itemData
,
595 Boolean changeValue
) = 0;
597 static pascal Boolean
DataBrowserCompareProc(
599 DataBrowserItemID itemOneID
,
600 DataBrowserItemID itemTwoID
,
601 DataBrowserPropertyID sortProperty
);
603 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
604 DataBrowserItemID itemTwoID
,
605 DataBrowserPropertyID sortProperty
) = 0;
606 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
609 // ============================================================================
610 // Higher-level Databrowser
611 // ============================================================================
613 // basing on data item objects
618 class wxMacDataItemBrowserControl
;
619 class wxMacListBoxItem
;
621 const DataBrowserPropertyID kTextColumnId
= 1024;
622 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
624 // for multi-column controls, we will use this + the column ID to identify the
625 // column. We don't use kTextColumnId there, and ideally the two should merge.
626 const DataBrowserPropertyID kMinColumnId
= 1050;
628 // base API for high-level databrowser operations
630 // base class for databrowser items
637 class WXDLLIMPEXP_CORE wxMacDataItem
641 virtual ~wxMacDataItem();
645 class WXDLLIMPEXP_CORE wxMacDataItem
649 virtual ~wxMacDataItem();
651 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
652 const wxMacDataItem
*,
653 DataBrowserPropertyID property
) const;
655 // returns true if access was successful, otherwise false
656 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
657 DataBrowserPropertyID property
,
658 DataBrowserItemDataRef itemData
,
661 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
662 DataBrowserItemNotification message
,
663 DataBrowserItemDataRef itemData
) const;
665 void SetOrder( SInt32 order
);
666 SInt32
GetOrder() const;
675 SortOrder_Text_Ascending
,
676 SortOrder_Text_Descending
679 typedef wxMacDataItem
* wxMacDataItemPtr
;
680 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
681 typedef void * wxListColumnId
;
683 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
685 class WXDLLIMPEXP_CORE wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
688 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
689 wxMacDataItemBrowserControl() {}
690 // create a list item (can be a subclass of wxMacListBoxItem)
692 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
693 void GetItems(const wxMacDataItem
* container
, bool recurse
,
694 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
696 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
698 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
699 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
701 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
702 DataBrowserPropertyID property
) const;
703 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
704 DataBrowserPropertyID property
) const;
706 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
707 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
709 int GetColumnWidth(int colId
);
710 void SetColumnWidth(int colId
, int width
);
712 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
713 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
715 void RemoveAllItems(wxMacDataItem
*container
);
716 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
717 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
719 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
720 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
721 void SetSelectedAllItems( DataBrowserSetOption option
);
722 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
724 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
726 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
730 virtual void MacDelete( unsigned int n
);
731 virtual void MacInsert( unsigned int n
, wxMacDataItem
* item
);
732 virtual void MacClear();
736 virtual unsigned int MacGetCount() const;
740 // as we are getting the same events for human and API selection we have to suppress
741 // events in the latter case, since this will be used from many subclasses we keep it here
743 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
744 bool SuppressSelection( bool suppress
);
748 virtual wxClientDataType
GetClientDataType() const;
749 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
750 //virtual ListSortOrder GetSortOrder() const;
751 //virtual void SetSortOrder(const ListSortOrder sort);
757 ListSortOrder m_sortOrder
;
758 wxClientDataType m_clientDataItemsType
;
760 // ID aware base methods, should be 'final' ie not changed in subclasses
762 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
763 DataBrowserItemID itemTwoID
,
764 DataBrowserPropertyID sortProperty
);
766 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
767 DataBrowserPropertyID property
,
768 DataBrowserItemDataRef itemData
,
769 Boolean changeValue
);
771 virtual void ItemNotification(
772 DataBrowserItemID itemID
,
773 DataBrowserItemNotification message
,
774 DataBrowserItemDataRef itemData
);
779 bool m_suppressSelection
;
780 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
783 class WXDLLIMPEXP_CORE wxMacDataItemBrowserSelectionSuppressor
786 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
787 ~wxMacDataItemBrowserSelectionSuppressor();
792 wxMacDataItemBrowserControl
* m_browser
;
795 // ============================================================================
796 // platform listbox implementation
797 // ============================================================================
799 // exposed for reuse in wxCheckListBox
801 class WXDLLIMPEXP_CORE wxMacListBoxItem
: public wxMacDataItem
806 virtual ~wxMacListBoxItem();
808 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
809 DataBrowserPropertyID property
,
810 DataBrowserItemDataRef itemData
,
813 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
814 DataBrowserItemNotification message
,
815 DataBrowserItemDataRef itemData
) const;
819 class WXDLLIMPEXP_CORE wxMacDataBrowserColumn
: public wxListWidgetColumn
822 wxMacDataBrowserColumn( DataBrowserPropertyID propertyId
, DataBrowserPropertyType colType
, bool editable
)
823 : m_property(propertyId
), m_editable(editable
), m_type( colType
)
826 ~wxMacDataBrowserColumn()
829 DataBrowserPropertyID
GetProperty() const { return m_property
; }
831 bool IsEditable() const { return m_editable
; }
833 DataBrowserPropertyType
GetType() const { return m_type
; }
836 DataBrowserPropertyID m_property
;
838 DataBrowserPropertyType m_type
;
841 WX_DEFINE_ARRAY_PTR(wxMacDataBrowserColumn
*, wxArrayMacDataBrowserColumns
);
844 class WXDLLIMPEXP_CORE wxMacDataBrowserCellValue
: public wxListWidgetCellValue
847 wxMacDataBrowserCellValue(DataBrowserItemDataRef data
) : m_data(data
) {}
848 virtual ~wxMacDataBrowserCellValue() {}
850 virtual void Set( CFStringRef value
);
851 virtual void Set( const wxString
& value
);
852 virtual void Set( int value
) ;
853 virtual void Check( bool check
);
855 virtual int GetIntValue() const ;
856 virtual wxString
GetStringValue() const ;
858 DataBrowserItemDataRef m_data
;
862 class WXDLLIMPEXP_CORE wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
, public wxListWidgetImpl
865 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
866 wxMacDataBrowserListControl() {}
867 virtual ~wxMacDataBrowserListControl();
869 // wxListWidgetImpl Methods
871 wxListWidgetColumn
* InsertTextColumn( unsigned int pos
, const wxString
& title
, bool editable
= false,
872 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) ;
873 wxListWidgetColumn
* InsertCheckColumn( unsigned int pos
, const wxString
& title
, bool editable
= false,
874 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) ;
876 wxMacDataBrowserColumn
* DoInsertColumn( unsigned int pos
, DataBrowserPropertyID property
,
877 const wxString
& title
, bool editable
,
878 DataBrowserPropertyType colType
, SInt16 just
, int width
);
881 virtual void ListDelete( unsigned int n
);
882 virtual void ListInsert( unsigned int n
);
883 virtual void ListClear();
887 virtual void ListDeselectAll();
888 virtual void ListSetSelection( unsigned int n
, bool select
, bool multi
= false );
889 virtual int ListGetSelection() const;
890 virtual int ListGetSelections( wxArrayInt
& aSelections
) const;
891 virtual bool ListIsSelected( unsigned int n
) const;
895 virtual void ListScrollTo( unsigned int n
);
899 virtual unsigned int ListGetCount() const;
901 virtual void UpdateLine( unsigned int n
, wxListWidgetColumn
* col
= NULL
);
902 virtual void UpdateLineToEnd( unsigned int n
) ;
904 virtual void ItemNotification(
905 DataBrowserItemID itemID
,
906 DataBrowserItemNotification message
,
907 DataBrowserItemDataRef itemData
);
911 wxMacDataBrowserColumn
* GetColumnFromProperty( DataBrowserPropertyID
);
913 wxArrayMacDataBrowserColumns m_columns
;
916 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
919 // ============================================================================
920 // graphics implementation
921 // ============================================================================
923 // draw the image 'upside down' corrected as HIViewDrawCGImage does
925 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
926 CGContextRef inContext
,
927 const HIRect
* inBounds
,
928 CGImageRef inImage
) ;
930 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
934 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
937 static UPP sHandler = NULL; \
938 if ( sHandler == NULL ) \
939 sHandler = New##UPP( x ); \
943 //---------------------------------------------------------------------------
944 // wxMac string conversions
945 //---------------------------------------------------------------------------
947 void wxMacSetupConverters();
948 void wxMacCleanupConverters();
954 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
955 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
956 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
958 //---------------------------------------------------------------------------
959 // cocoa bridging utilities
960 //---------------------------------------------------------------------------
962 bool wxMacInitCocoa();
964 typedef Cursor ClassicCursor
;
972 const short kwxCursorBullseye
= 0;
973 const short kwxCursorBlank
= 1;
974 const short kwxCursorPencil
= 2;
975 const short kwxCursorMagnifier
= 3;
976 const short kwxCursorNoEntry
= 4;
977 const short kwxCursorPaintBrush
= 5;
978 const short kwxCursorPointRight
= 6;
979 const short kwxCursorPointLeft
= 7;
980 const short kwxCursorQuestionArrow
= 8;
981 const short kwxCursorRightArrow
= 9;
982 const short kwxCursorSizeNS
= 10;
983 const short kwxCursorSize
= 11;
984 const short kwxCursorSizeNESW
= 12;
985 const short kwxCursorSizeNWSE
= 13;
986 const short kwxCursorRoller
= 14;
987 const short kwxCursorLast
= kwxCursorRoller
;
989 // exposing our fallback cursor map
991 extern ClassicCursor gMacCursors
[];
999 class wxNonOwnedWindowCarbonImpl
: public wxNonOwnedWindowImpl
1002 wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow
* nonownedwnd
) ;
1003 wxNonOwnedWindowCarbonImpl();
1004 virtual ~wxNonOwnedWindowCarbonImpl();
1006 virtual void Destroy() ;
1007 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
1008 long style
, long extraStyle
, const wxString
& name
) ;
1010 WXWindow
GetWXWindow() const;
1013 bool Show(bool show
);
1014 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
1018 bool SetTransparent(wxByte alpha
);
1019 bool SetBackgroundColour(const wxColour
& col
);
1020 void SetExtraStyle( long exStyle
);
1021 bool SetBackgroundStyle(wxBackgroundStyle style
);
1022 bool CanSetTransparent();
1023 void MoveWindow(int x
, int y
, int width
, int height
);
1024 void GetPosition( int &x
, int &y
) const;
1025 void GetSize( int &width
, int &height
) const;
1026 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
1028 bool SetShape(const wxRegion
& region
);
1030 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
1032 virtual bool IsMaximized() const;
1034 virtual bool IsIconized() const;
1036 virtual void Iconize( bool iconize
);
1038 virtual void Maximize(bool maximize
);
1040 virtual bool IsFullScreen() const;
1042 virtual bool ShowFullScreen(bool show
, long style
);
1044 virtual void ShowWithoutActivating();
1046 virtual void RequestUserAttention(int flags
);
1048 virtual void ScreenToWindow( int *x
, int *y
);
1050 virtual void WindowToScreen( int *x
, int *y
);
1051 virtual bool IsActive();
1054 bool MacGetUnifiedAppearance() const ;
1055 void MacChangeWindowAttributes( wxUint32 attributesToSet
, wxUint32 attributesToClear
) ;
1056 wxUint32
MacGetWindowAttributes() const ;
1057 void MacSetMetalAppearance( bool set
) ;
1058 bool MacGetMetalAppearance() const ;
1059 void MacSetUnifiedAppearance( bool set
);
1061 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
1063 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
1065 void MacInstallTopLevelWindowEventHandler();
1067 WXEVENTHANDLERREF m_macEventHandler
;
1068 WindowRef m_macWindow
;
1069 void * m_macFullScreenData
;
1070 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCarbonImpl
)