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 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
18 typedef UInt32 URefCon
;
19 typedef SInt32 SRefCon
;
24 #include "wx/osx/uma.h"
26 #include "wx/listbox.h"
27 #include "wx/osx/dc.h"
28 #include "wx/osx/dcclient.h"
29 #include "wx/osx/dcmemory.h"
33 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
34 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
40 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
41 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
44 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
46 Boolean createFolder
);
47 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
49 Boolean createFolder
);
51 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
52 template<> inline EventParamType wxMacGetEventParamType
<HIShapeRef
>() { return typeHIShapeRef
; }
53 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
54 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
55 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
56 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
57 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
58 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
59 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
60 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
61 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
62 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
63 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
64 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
65 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
66 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
67 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
68 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
69 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
70 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
71 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
72 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
75 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
76 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
77 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
78 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
81 class WXDLLIMPEXP_CORE wxMacCarbonEvent
91 wxMacCarbonEvent( EventRef event
, bool release
= false )
97 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
100 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
107 ReleaseEvent( m_eventRef
);
110 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
112 verify( (m_eventRef
== NULL
) || m_release
);
113 if ( m_eventRef
&& m_release
)
115 ReleaseEvent( m_eventRef
);
119 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
125 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
127 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
129 return GetParameter( inName
, type
, sizeof( T
) , data
);
131 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
133 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
136 template <typename T
> T
GetParameter( EventParamName inName
)
139 verify_noerr( GetParameter
<T
>( inName
, &value
) );
142 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
145 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
149 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
150 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
152 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
154 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
156 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
158 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
160 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
162 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
164 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
168 return ::GetEventClass( m_eventRef
);
172 return ::GetEventKind( m_eventRef
);
176 return ::GetEventTime( m_eventRef
);
180 return EventTimeToTicks( GetTime() );
182 OSStatus
SetCurrentTime( )
184 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
186 OSStatus
SetTime( EventTime when
)
188 return ::SetEventTime( m_eventRef
, when
);
190 operator EventRef () { return m_eventRef
; }
192 bool IsValid() { return m_eventRef
!= 0; }
200 class WXDLLIMPEXP_FWD_CORE wxMacToolTipTimer
;
202 class WXDLLIMPEXP_CORE wxMacToolTip
208 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
223 PicHandle m_backpict
;
227 wxMacToolTipTimer
* m_timer
;
229 wxCFStringRef m_helpTextRef
;
234 WXDLLIMPEXP_CORE
void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
235 WXDLLIMPEXP_CORE
void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
237 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
238 #define MAC_WXHMETAFILE(a) (PicHandle(a))
239 #define MAC_WXHICON(a) (IconRef(a))
240 #define MAC_WXHCURSOR(a) (CursHandle(a))
241 #define MAC_WXHRGN(a) (RgnHandle(a))
242 #define MAC_WXHWND(a) (WindowPtr(a))
243 #define MAC_WXRECPTR(a) ((Rect*)a)
244 #define MAC_WXPOINTPTR(a) ((Point*)a)
245 #define MAC_WXHMENU(a) ((MenuHandle)a)
247 struct wxOpaqueWindowRef
249 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
250 operator WindowRef() { return m_data
; }
255 WXDLLIMPEXP_CORE
void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
256 WXDLLIMPEXP_CORE
void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
257 WXDLLIMPEXP_CORE
void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
258 WXDLLIMPEXP_CORE
void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
260 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
262 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
263 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
264 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
266 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
267 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
269 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
271 // additional optional event defines
273 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
275 kEventControlFocusPartChanged
= 164
279 class WXDLLIMPEXP_CORE wxMacControl
: public wxWidgetImpl
282 wxMacControl( wxWindowMac
* peer
, bool isRootControl
= false, bool isUserPane
= false );
284 virtual ~wxMacControl();
288 void SetReferenceInNativeControl();
289 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
291 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
292 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
294 virtual WXWidget
GetWXWidget() const { return (WXWidget
) m_controlRef
; }
296 virtual bool IsVisible() const;
298 virtual void Raise();
300 virtual void Lower();
302 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
304 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
305 virtual void Move(int x
, int y
, int width
, int height
);
306 virtual void GetPosition( int &x
, int &y
) const;
307 virtual void GetSize( int &width
, int &height
) const;
308 virtual void SetControlSize( wxWindowVariant variant
) ;
310 // where is in native window relative coordinates
311 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
312 virtual bool GetNeedsDisplay() const;
314 virtual bool CanFocus() const;
315 // return true if successful
316 virtual bool SetFocus();
317 virtual bool HasFocus() const;
319 void RemoveFromParent();
320 void Embed( wxWidgetImpl
*parent
);
322 void SetDefaultButton( bool isDefault
);
324 void SetLabel( const wxString
& title
, wxFontEncoding encoding
);
326 void SetCursor( const wxCursor
& cursor
);
330 wxInt32
GetValue() const;
331 void SetValue( wxInt32 v
);
332 wxBitmap
GetBitmap() const;
333 void SetBitmap( const wxBitmap
& bitmap
);
334 void SetBitmapPosition( wxDirection dir
);
335 void SetupTabs( const wxNotebook
¬ebook
);
337 void GetBestRect( wxRect
*r
) const;
338 bool IsEnabled() const;
339 void Enable( bool enable
);
340 bool ButtonClickDidStateChange() { return false ;}
341 void SetMinimum( wxInt32 v
);
342 void SetMaximum( wxInt32 v
);
344 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
346 // temp convenience methods
348 void GetBestRect( Rect
*r
) const;
350 void operator= (ControlRef c) { m_controlRef = c; }
351 operator ControlRef () { return m_controlRef; }
352 operator ControlRef * () { return &m_controlRef; }
354 // accessing data and values
356 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
357 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
358 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
359 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
360 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
362 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
364 virtual wxInt32
GetMaximum() const;
365 virtual wxInt32
GetMinimum() const;
367 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
368 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
372 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
375 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
378 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
380 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
382 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
384 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
386 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
388 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
390 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
392 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
394 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
397 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
399 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
402 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
406 wxFAIL_MSG( wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
407 inPartCode
, (int)inTag
) );
412 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
415 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
417 template <typename T
> T
GetData( ResType inTag
) const
419 return GetData
<T
>( kControlEntireControl
, inTag
);
422 // Flash the control for the specified amount of time
424 virtual void VisibilityChanged( bool shown
);
425 virtual void SuperChangedPosition();
428 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
429 virtual void SetBackgroundColour( const wxColour
& col
);
430 virtual bool SetBackgroundStyle(wxBackgroundStyle style
);
431 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
432 void SetActionProc( ControlActionUPP actionProc
);
433 SInt32
GetViewSize() const;
435 virtual void SetVisibility( bool visible
);
437 virtual bool IsActive() const;
439 // invalidates this control and all children
440 virtual void InvalidateWithChildren();
441 virtual void SetDrawingEnabled( bool enable
);
443 // in native parent window relative coordinates
445 virtual void GetRectInWindowCoords( Rect
*r
);
448 virtual void GetFeatures( UInt32
*features
);
450 // to be moved into a tab control class
452 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
454 virtual void InstallEventHandler( WXWidget control
= NULL
);
456 WXEVENTHANDLERREF m_macControlEventHandler
;
457 ControlRef m_controlRef
;
460 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
463 // ============================================================================
464 // DataBrowser Wrapper
465 // ============================================================================
467 // basing on DataBrowserItemIDs
470 class WXDLLIMPEXP_CORE wxMacDataBrowserControl
: public wxMacControl
473 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
474 wxMacDataBrowserControl() {}
476 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
478 OSStatus
GetItemCount( DataBrowserItemID container
,
480 DataBrowserItemState state
,
481 ItemCount
*numItems
) const;
483 OSStatus
GetItems( DataBrowserItemID container
,
485 DataBrowserItemState state
,
489 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
490 DataBrowserTableViewColumnIndex position
);
492 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
494 OSStatus
AutoSizeColumns();
496 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
497 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
499 OSStatus
SetHeaderButtonHeight( UInt16 height
);
500 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
502 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
503 const DataBrowserItemID
*items
,
504 DataBrowserPropertyID preSortProperty
,
505 DataBrowserPropertyID propertyID
) const;
507 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
508 const DataBrowserItemID
*items
,
509 DataBrowserPropertyID preSortProperty
);
510 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
511 const DataBrowserItemID
*items
,
512 DataBrowserPropertyID preSortProperty
);
513 OSStatus
RevealItem( DataBrowserItemID item
,
514 DataBrowserPropertyID propertyID
,
515 DataBrowserRevealOptions options
) const;
517 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
518 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
519 bool IsItemSelected( DataBrowserItemID item
) const;
520 OSStatus
SetSelectedItems( UInt32 numItems
,
521 const DataBrowserItemID
*items
,
522 DataBrowserSetOption operation
);
524 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
525 DataBrowserItemID
* item
) const;
526 OSStatus
GetItemRow( DataBrowserItemID item
,
527 DataBrowserTableViewRowIndex
* row
) const;
529 OSStatus
SetDefaultRowHeight( UInt16 height
);
530 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
532 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
533 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
535 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
536 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
538 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
539 OSStatus
SetDefaultColumnWidth( UInt16 width
);
541 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
543 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
545 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
546 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
548 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
549 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
551 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
552 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
554 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
555 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
557 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
558 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
560 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
561 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
563 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
565 OSStatus
GetItemPartBounds( DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
);
568 static pascal void DataBrowserItemNotificationProc(
570 DataBrowserItemID itemID
,
571 DataBrowserItemNotification message
,
572 DataBrowserItemDataRef itemData
);
574 virtual void ItemNotification(
575 DataBrowserItemID itemID
,
576 DataBrowserItemNotification message
,
577 DataBrowserItemDataRef itemData
) = 0;
579 static pascal OSStatus
DataBrowserGetSetItemDataProc(
581 DataBrowserItemID itemID
,
582 DataBrowserPropertyID property
,
583 DataBrowserItemDataRef itemData
,
584 Boolean changeValue
);
586 virtual OSStatus
GetSetItemData(
587 DataBrowserItemID itemID
,
588 DataBrowserPropertyID property
,
589 DataBrowserItemDataRef itemData
,
590 Boolean changeValue
) = 0;
592 static pascal Boolean
DataBrowserCompareProc(
594 DataBrowserItemID itemOneID
,
595 DataBrowserItemID itemTwoID
,
596 DataBrowserPropertyID sortProperty
);
598 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
599 DataBrowserItemID itemTwoID
,
600 DataBrowserPropertyID sortProperty
) = 0;
601 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
604 // ============================================================================
605 // Higher-level Databrowser
606 // ============================================================================
608 // basing on data item objects
613 class wxMacDataItemBrowserControl
;
614 class wxMacListBoxItem
;
616 const DataBrowserPropertyID kTextColumnId
= 1024;
617 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
619 // for multi-column controls, we will use this + the column ID to identify the
620 // column. We don't use kTextColumnId there, and ideally the two should merge.
621 const DataBrowserPropertyID kMinColumnId
= 1050;
623 // base API for high-level databrowser operations
625 // base class for databrowser items
632 class WXDLLIMPEXP_CORE wxMacDataItem
636 virtual ~wxMacDataItem();
640 class WXDLLIMPEXP_CORE wxMacDataItem
644 virtual ~wxMacDataItem();
646 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
647 const wxMacDataItem
*,
648 DataBrowserPropertyID property
) const;
650 // returns true if access was successful, otherwise false
651 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
652 DataBrowserPropertyID property
,
653 DataBrowserItemDataRef itemData
,
656 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
657 DataBrowserItemNotification message
,
658 DataBrowserItemDataRef itemData
) const;
660 void SetOrder( SInt32 order
);
661 SInt32
GetOrder() const;
670 SortOrder_Text_Ascending
,
671 SortOrder_Text_Descending
674 typedef wxMacDataItem
* wxMacDataItemPtr
;
675 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
676 typedef void * wxListColumnId
;
678 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
680 class WXDLLIMPEXP_CORE wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
683 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
684 wxMacDataItemBrowserControl() {}
685 // create a list item (can be a subclass of wxMacListBoxItem)
687 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
688 void GetItems(const wxMacDataItem
* container
, bool recurse
,
689 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
691 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
693 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
694 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
696 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
697 DataBrowserPropertyID property
) const;
698 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
699 DataBrowserPropertyID property
) const;
701 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
702 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
704 int GetColumnWidth(int colId
);
705 void SetColumnWidth(int colId
, int width
);
707 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
708 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
710 void RemoveAllItems(wxMacDataItem
*container
);
711 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
712 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
714 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
715 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
716 void SetSelectedAllItems( DataBrowserSetOption option
);
717 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
719 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
721 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
725 virtual void MacDelete( unsigned int n
);
726 virtual void MacInsert( unsigned int n
, wxMacDataItem
* item
);
727 virtual void MacClear();
731 virtual unsigned int MacGetCount() const;
735 // as we are getting the same events for human and API selection we have to suppress
736 // events in the latter case, since this will be used from many subclasses we keep it here
738 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
739 bool SuppressSelection( bool suppress
);
743 virtual wxClientDataType
GetClientDataType() const;
744 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
745 //virtual ListSortOrder GetSortOrder() const;
746 //virtual void SetSortOrder(const ListSortOrder sort);
752 ListSortOrder m_sortOrder
;
753 wxClientDataType m_clientDataItemsType
;
755 // ID aware base methods, should be 'final' ie not changed in subclasses
757 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
758 DataBrowserItemID itemTwoID
,
759 DataBrowserPropertyID sortProperty
);
761 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
762 DataBrowserPropertyID property
,
763 DataBrowserItemDataRef itemData
,
764 Boolean changeValue
);
766 virtual void ItemNotification(
767 DataBrowserItemID itemID
,
768 DataBrowserItemNotification message
,
769 DataBrowserItemDataRef itemData
);
774 bool m_suppressSelection
;
775 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
778 class WXDLLIMPEXP_CORE wxMacDataItemBrowserSelectionSuppressor
781 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
782 ~wxMacDataItemBrowserSelectionSuppressor();
787 wxMacDataItemBrowserControl
* m_browser
;
790 // ============================================================================
791 // platform listbox implementation
792 // ============================================================================
794 // exposed for reuse in wxCheckListBox
796 class WXDLLIMPEXP_CORE wxMacListBoxItem
: public wxMacDataItem
801 virtual ~wxMacListBoxItem();
803 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
804 DataBrowserPropertyID property
,
805 DataBrowserItemDataRef itemData
,
808 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
809 DataBrowserItemNotification message
,
810 DataBrowserItemDataRef itemData
) const;
814 class WXDLLIMPEXP_CORE wxMacDataBrowserColumn
: public wxListWidgetColumn
817 wxMacDataBrowserColumn( DataBrowserPropertyID propertyId
, DataBrowserPropertyType colType
, bool editable
)
818 : m_property(propertyId
), m_editable(editable
), m_type( colType
)
821 ~wxMacDataBrowserColumn()
824 DataBrowserPropertyID
GetProperty() const { return m_property
; }
826 bool IsEditable() const { return m_editable
; }
828 DataBrowserPropertyType
GetType() const { return m_type
; }
831 DataBrowserPropertyID m_property
;
833 DataBrowserPropertyType m_type
;
836 WX_DEFINE_ARRAY_PTR(wxMacDataBrowserColumn
*, wxArrayMacDataBrowserColumns
);
839 class WXDLLIMPEXP_CORE wxMacDataBrowserCellValue
: public wxListWidgetCellValue
842 wxMacDataBrowserCellValue(DataBrowserItemDataRef data
) : m_data(data
) {}
843 virtual ~wxMacDataBrowserCellValue() {}
845 virtual void Set( CFStringRef value
);
846 virtual void Set( const wxString
& value
);
847 virtual void Set( int value
) ;
848 virtual void Check( bool check
);
850 virtual int GetIntValue() const ;
851 virtual wxString
GetStringValue() const ;
853 DataBrowserItemDataRef m_data
;
857 class WXDLLIMPEXP_CORE wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
, public wxListWidgetImpl
860 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
861 wxMacDataBrowserListControl() {}
862 virtual ~wxMacDataBrowserListControl();
864 // wxListWidgetImpl Methods
866 wxListWidgetColumn
* InsertTextColumn( unsigned int pos
, const wxString
& title
, bool editable
= false,
867 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) ;
868 wxListWidgetColumn
* InsertCheckColumn( unsigned int pos
, const wxString
& title
, bool editable
= false,
869 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) ;
871 wxMacDataBrowserColumn
* DoInsertColumn( unsigned int pos
, DataBrowserPropertyID property
,
872 const wxString
& title
, bool editable
,
873 DataBrowserPropertyType colType
, SInt16 just
, int width
);
876 virtual void ListDelete( unsigned int n
);
877 virtual void ListInsert( unsigned int n
);
878 virtual void ListClear();
882 virtual void ListDeselectAll();
883 virtual void ListSetSelection( unsigned int n
, bool select
, bool multi
= false );
884 virtual int ListGetSelection() const;
885 virtual int ListGetSelections( wxArrayInt
& aSelections
) const;
886 virtual bool ListIsSelected( unsigned int n
) const;
890 virtual void ListScrollTo( unsigned int n
);
894 virtual unsigned int ListGetCount() const;
895 virtual int DoListHitTest( const wxPoint
& inpoint
) const;
897 virtual void UpdateLine( unsigned int n
, wxListWidgetColumn
* col
= NULL
);
898 virtual void UpdateLineToEnd( unsigned int n
) ;
902 wxMacDataBrowserColumn
* GetColumnFromProperty( DataBrowserPropertyID
);
905 virtual void ItemNotification(
906 DataBrowserItemID itemID
,
907 DataBrowserItemNotification message
,
908 DataBrowserItemDataRef itemData
);
911 wxArrayMacDataBrowserColumns m_columns
;
914 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
917 // ============================================================================
918 // graphics implementation
919 // ============================================================================
921 // draw the image 'upside down' corrected as HIViewDrawCGImage does
923 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
924 CGContextRef inContext
,
925 const HIRect
* inBounds
,
926 CGImageRef inImage
) ;
928 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
932 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
935 static UPP sHandler = NULL; \
936 if ( sHandler == NULL ) \
937 sHandler = New##UPP( x ); \
941 //---------------------------------------------------------------------------
942 // cocoa bridging utilities
943 //---------------------------------------------------------------------------
945 bool wxMacInitCocoa();
947 typedef Cursor ClassicCursor
;
955 const short kwxCursorBullseye
= 0;
956 const short kwxCursorBlank
= 1;
957 const short kwxCursorPencil
= 2;
958 const short kwxCursorMagnifier
= 3;
959 const short kwxCursorNoEntry
= 4;
960 const short kwxCursorPaintBrush
= 5;
961 const short kwxCursorPointRight
= 6;
962 const short kwxCursorPointLeft
= 7;
963 const short kwxCursorQuestionArrow
= 8;
964 const short kwxCursorRightArrow
= 9;
965 const short kwxCursorSizeNS
= 10;
966 const short kwxCursorSize
= 11;
967 const short kwxCursorSizeNESW
= 12;
968 const short kwxCursorSizeNWSE
= 13;
969 const short kwxCursorRoller
= 14;
970 const short kwxCursorWatch
= 15;
971 const short kwxCursorLast
= kwxCursorWatch
;
973 // exposing our fallback cursor map
975 extern ClassicCursor gMacCursors
[];
983 class wxNonOwnedWindowCarbonImpl
: public wxNonOwnedWindowImpl
986 wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow
* nonownedwnd
) ;
988 wxNonOwnedWindowCarbonImpl();
989 virtual ~wxNonOwnedWindowCarbonImpl();
991 virtual void WillBeDestroyed() ;
992 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
993 long style
, long extraStyle
, const wxString
& name
) ;
994 void Create( wxWindow
* parent
, WXWindow nativeWindow
);
996 WXWindow
GetWXWindow() const;
999 bool Show(bool show
);
1000 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
1004 bool SetTransparent(wxByte alpha
);
1005 bool SetBackgroundColour(const wxColour
& col
);
1006 void SetExtraStyle( long exStyle
);
1007 bool SetBackgroundStyle(wxBackgroundStyle style
);
1008 bool CanSetTransparent();
1009 void MoveWindow(int x
, int y
, int width
, int height
);
1010 void GetPosition( int &x
, int &y
) const;
1011 void GetSize( int &width
, int &height
) const;
1012 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
1014 bool SetShape(const wxRegion
& region
);
1016 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
1018 virtual bool IsMaximized() const;
1020 virtual bool IsIconized() const;
1022 virtual void Iconize( bool iconize
);
1024 virtual void Maximize(bool maximize
);
1026 virtual bool IsFullScreen() const;
1028 virtual bool ShowFullScreen(bool show
, long style
);
1030 virtual void ShowWithoutActivating();
1032 virtual void RequestUserAttention(int flags
);
1034 virtual void ScreenToWindow( int *x
, int *y
);
1036 virtual void WindowToScreen( int *x
, int *y
);
1037 virtual bool IsActive();
1040 bool MacGetUnifiedAppearance() const ;
1041 void MacChangeWindowAttributes( wxUint32 attributesToSet
, wxUint32 attributesToClear
) ;
1042 wxUint32
MacGetWindowAttributes() const ;
1043 void MacSetMetalAppearance( bool set
) ;
1044 bool MacGetMetalAppearance() const ;
1045 void MacSetUnifiedAppearance( bool set
);
1047 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
1049 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
1051 void MacInstallTopLevelWindowEventHandler();
1053 WXEVENTHANDLERREF m_macEventHandler
;
1054 WindowRef m_macWindow
;
1055 void * m_macFullScreenData
;
1056 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCarbonImpl
)