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
);
44 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
45 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
48 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
50 Boolean createFolder
);
51 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
53 Boolean createFolder
);
55 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
56 template<> inline EventParamType wxMacGetEventParamType
<HIShapeRef
>() { return typeHIShapeRef
; }
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 void SetReferenceInNativeControl();
293 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
295 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
296 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
298 virtual WXWidget
GetWXWidget() const { return (WXWidget
) m_controlRef
; }
300 virtual bool IsVisible() const;
302 virtual void Raise();
304 virtual void Lower();
306 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
308 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
309 virtual void Move(int x
, int y
, int width
, int height
);
310 virtual void GetPosition( int &x
, int &y
) const;
311 virtual void GetSize( int &width
, int &height
) const;
312 virtual void SetControlSize( wxWindowVariant variant
) ;
314 // where is in native window relative coordinates
315 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
316 virtual bool GetNeedsDisplay() const;
318 virtual bool CanFocus() const;
319 // return true if successful
320 virtual bool SetFocus();
321 virtual bool HasFocus() const;
323 void RemoveFromParent();
324 void Embed( wxWidgetImpl
*parent
);
326 void SetDefaultButton( bool isDefault
);
328 void SetLabel( const wxString
& title
, wxFontEncoding encoding
);
330 void SetCursor( const wxCursor
& cursor
);
334 wxInt32
GetValue() const;
335 void SetValue( wxInt32 v
);
336 wxBitmap
GetBitmap() const;
337 void SetBitmap( const wxBitmap
& bitmap
);
338 void SetBitmapPosition( wxDirection dir
);
339 void SetupTabs( const wxNotebook
¬ebook
);
341 void GetBestRect( wxRect
*r
) const;
342 bool IsEnabled() const;
343 void Enable( bool enable
);
344 bool ButtonClickDidStateChange() { return false ;}
345 void SetMinimum( wxInt32 v
);
346 void SetMaximum( wxInt32 v
);
348 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
350 // temp convenience methods
352 void GetBestRect( Rect
*r
) const;
354 void operator= (ControlRef c) { m_controlRef = c; }
355 operator ControlRef () { return m_controlRef; }
356 operator ControlRef * () { return &m_controlRef; }
358 // accessing data and values
360 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
361 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
362 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
363 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
364 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
366 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
368 virtual wxInt32
GetMaximum() const;
369 virtual wxInt32
GetMinimum() const;
371 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
372 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
376 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
379 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
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( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
388 return SetData( inPartCode
, 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
SetData( ResType inTag
, const T
& data
)
396 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
398 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
401 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
403 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
406 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
410 wxFAIL_MSG( wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
411 inPartCode
, (int)inTag
) );
416 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
419 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
421 template <typename T
> T
GetData( ResType inTag
) const
423 return GetData
<T
>( kControlEntireControl
, inTag
);
426 // Flash the control for the specified amount of time
428 virtual void VisibilityChanged( bool shown
);
429 virtual void SuperChangedPosition();
432 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
433 virtual void SetBackgroundColour( const wxColour
& col
);
434 virtual bool SetBackgroundStyle(wxBackgroundStyle style
);
435 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
436 void SetActionProc( ControlActionUPP actionProc
);
437 SInt32
GetViewSize() const;
439 virtual void SetVisibility( bool visible
);
441 virtual bool IsActive() const;
443 // invalidates this control and all children
444 virtual void InvalidateWithChildren();
445 virtual void SetDrawingEnabled( bool enable
);
447 // in native parent window relative coordinates
449 virtual void GetRectInWindowCoords( Rect
*r
);
452 virtual void GetFeatures( UInt32
*features
);
454 // to be moved into a tab control class
456 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
458 virtual void InstallEventHandler( WXWidget control
= NULL
);
460 WXEVENTHANDLERREF m_macControlEventHandler
;
461 ControlRef m_controlRef
;
464 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
467 // ============================================================================
468 // DataBrowser Wrapper
469 // ============================================================================
471 // basing on DataBrowserItemIDs
474 class WXDLLIMPEXP_CORE wxMacDataBrowserControl
: public wxMacControl
477 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
478 wxMacDataBrowserControl() {}
480 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
482 OSStatus
GetItemCount( DataBrowserItemID container
,
484 DataBrowserItemState state
,
485 ItemCount
*numItems
) const;
487 OSStatus
GetItems( DataBrowserItemID container
,
489 DataBrowserItemState state
,
493 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
494 DataBrowserTableViewColumnIndex position
);
496 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
498 OSStatus
AutoSizeColumns();
500 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
501 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
503 OSStatus
SetHeaderButtonHeight( UInt16 height
);
504 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
506 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
507 const DataBrowserItemID
*items
,
508 DataBrowserPropertyID preSortProperty
,
509 DataBrowserPropertyID propertyID
) const;
511 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
512 const DataBrowserItemID
*items
,
513 DataBrowserPropertyID preSortProperty
);
514 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
515 const DataBrowserItemID
*items
,
516 DataBrowserPropertyID preSortProperty
);
517 OSStatus
RevealItem( DataBrowserItemID item
,
518 DataBrowserPropertyID propertyID
,
519 DataBrowserRevealOptions options
) const;
521 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
522 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
523 bool IsItemSelected( DataBrowserItemID item
) const;
524 OSStatus
SetSelectedItems( UInt32 numItems
,
525 const DataBrowserItemID
*items
,
526 DataBrowserSetOption operation
);
528 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
529 DataBrowserItemID
* item
) const;
530 OSStatus
GetItemRow( DataBrowserItemID item
,
531 DataBrowserTableViewRowIndex
* row
) const;
533 OSStatus
SetDefaultRowHeight( UInt16 height
);
534 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
536 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
537 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
539 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
540 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
542 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
543 OSStatus
SetDefaultColumnWidth( UInt16 width
);
545 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
547 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
549 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
550 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
552 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
553 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
555 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
556 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
558 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
559 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
561 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
562 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
564 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
565 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
567 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
569 OSStatus
GetItemPartBounds( DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
);
572 static pascal void DataBrowserItemNotificationProc(
574 DataBrowserItemID itemID
,
575 DataBrowserItemNotification message
,
576 DataBrowserItemDataRef itemData
);
578 virtual void ItemNotification(
579 DataBrowserItemID itemID
,
580 DataBrowserItemNotification message
,
581 DataBrowserItemDataRef itemData
) = 0;
583 static pascal OSStatus
DataBrowserGetSetItemDataProc(
585 DataBrowserItemID itemID
,
586 DataBrowserPropertyID property
,
587 DataBrowserItemDataRef itemData
,
588 Boolean changeValue
);
590 virtual OSStatus
GetSetItemData(
591 DataBrowserItemID itemID
,
592 DataBrowserPropertyID property
,
593 DataBrowserItemDataRef itemData
,
594 Boolean changeValue
) = 0;
596 static pascal Boolean
DataBrowserCompareProc(
598 DataBrowserItemID itemOneID
,
599 DataBrowserItemID itemTwoID
,
600 DataBrowserPropertyID sortProperty
);
602 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
603 DataBrowserItemID itemTwoID
,
604 DataBrowserPropertyID sortProperty
) = 0;
605 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
608 // ============================================================================
609 // Higher-level Databrowser
610 // ============================================================================
612 // basing on data item objects
617 class wxMacDataItemBrowserControl
;
618 class wxMacListBoxItem
;
620 const DataBrowserPropertyID kTextColumnId
= 1024;
621 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
623 // for multi-column controls, we will use this + the column ID to identify the
624 // column. We don't use kTextColumnId there, and ideally the two should merge.
625 const DataBrowserPropertyID kMinColumnId
= 1050;
627 // base API for high-level databrowser operations
629 // base class for databrowser items
636 class WXDLLIMPEXP_CORE wxMacDataItem
640 virtual ~wxMacDataItem();
644 class WXDLLIMPEXP_CORE wxMacDataItem
648 virtual ~wxMacDataItem();
650 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
651 const wxMacDataItem
*,
652 DataBrowserPropertyID property
) const;
654 // returns true if access was successful, otherwise false
655 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
656 DataBrowserPropertyID property
,
657 DataBrowserItemDataRef itemData
,
660 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
661 DataBrowserItemNotification message
,
662 DataBrowserItemDataRef itemData
) const;
664 void SetOrder( SInt32 order
);
665 SInt32
GetOrder() const;
674 SortOrder_Text_Ascending
,
675 SortOrder_Text_Descending
678 typedef wxMacDataItem
* wxMacDataItemPtr
;
679 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
680 typedef void * wxListColumnId
;
682 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
684 class WXDLLIMPEXP_CORE wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
687 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
688 wxMacDataItemBrowserControl() {}
689 // create a list item (can be a subclass of wxMacListBoxItem)
691 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
692 void GetItems(const wxMacDataItem
* container
, bool recurse
,
693 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
695 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
697 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
698 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
700 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
701 DataBrowserPropertyID property
) const;
702 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
703 DataBrowserPropertyID property
) const;
705 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
706 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
708 int GetColumnWidth(int colId
);
709 void SetColumnWidth(int colId
, int width
);
711 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
712 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
714 void RemoveAllItems(wxMacDataItem
*container
);
715 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
716 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
718 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
719 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
720 void SetSelectedAllItems( DataBrowserSetOption option
);
721 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
723 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
725 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
729 virtual void MacDelete( unsigned int n
);
730 virtual void MacInsert( unsigned int n
, wxMacDataItem
* item
);
731 virtual void MacClear();
735 virtual unsigned int MacGetCount() const;
739 // as we are getting the same events for human and API selection we have to suppress
740 // events in the latter case, since this will be used from many subclasses we keep it here
742 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
743 bool SuppressSelection( bool suppress
);
747 virtual wxClientDataType
GetClientDataType() const;
748 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
749 //virtual ListSortOrder GetSortOrder() const;
750 //virtual void SetSortOrder(const ListSortOrder sort);
756 ListSortOrder m_sortOrder
;
757 wxClientDataType m_clientDataItemsType
;
759 // ID aware base methods, should be 'final' ie not changed in subclasses
761 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
762 DataBrowserItemID itemTwoID
,
763 DataBrowserPropertyID sortProperty
);
765 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
766 DataBrowserPropertyID property
,
767 DataBrowserItemDataRef itemData
,
768 Boolean changeValue
);
770 virtual void ItemNotification(
771 DataBrowserItemID itemID
,
772 DataBrowserItemNotification message
,
773 DataBrowserItemDataRef itemData
);
778 bool m_suppressSelection
;
779 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
782 class WXDLLIMPEXP_CORE wxMacDataItemBrowserSelectionSuppressor
785 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
786 ~wxMacDataItemBrowserSelectionSuppressor();
791 wxMacDataItemBrowserControl
* m_browser
;
794 // ============================================================================
795 // platform listbox implementation
796 // ============================================================================
798 // exposed for reuse in wxCheckListBox
800 class WXDLLIMPEXP_CORE wxMacListBoxItem
: public wxMacDataItem
805 virtual ~wxMacListBoxItem();
807 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
808 DataBrowserPropertyID property
,
809 DataBrowserItemDataRef itemData
,
812 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
813 DataBrowserItemNotification message
,
814 DataBrowserItemDataRef itemData
) const;
818 class WXDLLIMPEXP_CORE wxMacDataBrowserColumn
: public wxListWidgetColumn
821 wxMacDataBrowserColumn( DataBrowserPropertyID propertyId
, DataBrowserPropertyType colType
, bool editable
)
822 : m_property(propertyId
), m_editable(editable
), m_type( colType
)
825 ~wxMacDataBrowserColumn()
828 DataBrowserPropertyID
GetProperty() const { return m_property
; }
830 bool IsEditable() const { return m_editable
; }
832 DataBrowserPropertyType
GetType() const { return m_type
; }
835 DataBrowserPropertyID m_property
;
837 DataBrowserPropertyType m_type
;
840 WX_DEFINE_ARRAY_PTR(wxMacDataBrowserColumn
*, wxArrayMacDataBrowserColumns
);
843 class WXDLLIMPEXP_CORE wxMacDataBrowserCellValue
: public wxListWidgetCellValue
846 wxMacDataBrowserCellValue(DataBrowserItemDataRef data
) : m_data(data
) {}
847 virtual ~wxMacDataBrowserCellValue() {}
849 virtual void Set( CFStringRef value
);
850 virtual void Set( const wxString
& value
);
851 virtual void Set( int value
) ;
852 virtual void Check( bool check
);
854 virtual int GetIntValue() const ;
855 virtual wxString
GetStringValue() const ;
857 DataBrowserItemDataRef m_data
;
861 class WXDLLIMPEXP_CORE wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
, public wxListWidgetImpl
864 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
865 wxMacDataBrowserListControl() {}
866 virtual ~wxMacDataBrowserListControl();
868 // wxListWidgetImpl Methods
870 wxListWidgetColumn
* InsertTextColumn( unsigned int pos
, const wxString
& title
, bool editable
= false,
871 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) ;
872 wxListWidgetColumn
* InsertCheckColumn( unsigned int pos
, const wxString
& title
, bool editable
= false,
873 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) ;
875 wxMacDataBrowserColumn
* DoInsertColumn( unsigned int pos
, DataBrowserPropertyID property
,
876 const wxString
& title
, bool editable
,
877 DataBrowserPropertyType colType
, SInt16 just
, int width
);
880 virtual void ListDelete( unsigned int n
);
881 virtual void ListInsert( unsigned int n
);
882 virtual void ListClear();
886 virtual void ListDeselectAll();
887 virtual void ListSetSelection( unsigned int n
, bool select
, bool multi
= false );
888 virtual int ListGetSelection() const;
889 virtual int ListGetSelections( wxArrayInt
& aSelections
) const;
890 virtual bool ListIsSelected( unsigned int n
) const;
894 virtual void ListScrollTo( unsigned int n
);
898 virtual unsigned int ListGetCount() const;
900 virtual void UpdateLine( unsigned int n
, wxListWidgetColumn
* col
= NULL
);
901 virtual void UpdateLineToEnd( unsigned int n
) ;
905 wxMacDataBrowserColumn
* GetColumnFromProperty( DataBrowserPropertyID
);
908 virtual void ItemNotification(
909 DataBrowserItemID itemID
,
910 DataBrowserItemNotification message
,
911 DataBrowserItemDataRef itemData
);
914 wxArrayMacDataBrowserColumns m_columns
;
917 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
920 // ============================================================================
921 // graphics implementation
922 // ============================================================================
924 // draw the image 'upside down' corrected as HIViewDrawCGImage does
926 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
927 CGContextRef inContext
,
928 const HIRect
* inBounds
,
929 CGImageRef inImage
) ;
931 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
935 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
938 static UPP sHandler = NULL; \
939 if ( sHandler == NULL ) \
940 sHandler = New##UPP( x ); \
944 //---------------------------------------------------------------------------
945 // wxMac string conversions
946 //---------------------------------------------------------------------------
948 void wxMacSetupConverters();
949 void wxMacCleanupConverters();
955 WXDLLIMPEXP_BASE wxString
wxMacFSRefToPath( const FSRef
*fsRef
, CFStringRef additionalPathComponent
= NULL
);
956 WXDLLIMPEXP_BASE OSStatus
wxMacPathToFSRef( const wxString
&path
, FSRef
*fsRef
);
957 WXDLLIMPEXP_BASE wxString
wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname
);
959 //---------------------------------------------------------------------------
960 // cocoa bridging utilities
961 //---------------------------------------------------------------------------
963 bool wxMacInitCocoa();
965 typedef Cursor ClassicCursor
;
973 const short kwxCursorBullseye
= 0;
974 const short kwxCursorBlank
= 1;
975 const short kwxCursorPencil
= 2;
976 const short kwxCursorMagnifier
= 3;
977 const short kwxCursorNoEntry
= 4;
978 const short kwxCursorPaintBrush
= 5;
979 const short kwxCursorPointRight
= 6;
980 const short kwxCursorPointLeft
= 7;
981 const short kwxCursorQuestionArrow
= 8;
982 const short kwxCursorRightArrow
= 9;
983 const short kwxCursorSizeNS
= 10;
984 const short kwxCursorSize
= 11;
985 const short kwxCursorSizeNESW
= 12;
986 const short kwxCursorSizeNWSE
= 13;
987 const short kwxCursorRoller
= 14;
988 const short kwxCursorLast
= kwxCursorRoller
;
990 // exposing our fallback cursor map
992 extern ClassicCursor gMacCursors
[];
1000 class wxNonOwnedWindowCarbonImpl
: public wxNonOwnedWindowImpl
1003 wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow
* nonownedwnd
) ;
1005 wxNonOwnedWindowCarbonImpl();
1006 virtual ~wxNonOwnedWindowCarbonImpl();
1008 virtual void WillBeDestroyed() ;
1009 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
1010 long style
, long extraStyle
, const wxString
& name
) ;
1011 void Create( wxWindow
* parent
, WXWindow nativeWindow
);
1013 WXWindow
GetWXWindow() const;
1016 bool Show(bool show
);
1017 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
1021 bool SetTransparent(wxByte alpha
);
1022 bool SetBackgroundColour(const wxColour
& col
);
1023 void SetExtraStyle( long exStyle
);
1024 bool SetBackgroundStyle(wxBackgroundStyle style
);
1025 bool CanSetTransparent();
1026 void MoveWindow(int x
, int y
, int width
, int height
);
1027 void GetPosition( int &x
, int &y
) const;
1028 void GetSize( int &width
, int &height
) const;
1029 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
1031 bool SetShape(const wxRegion
& region
);
1033 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
1035 virtual bool IsMaximized() const;
1037 virtual bool IsIconized() const;
1039 virtual void Iconize( bool iconize
);
1041 virtual void Maximize(bool maximize
);
1043 virtual bool IsFullScreen() const;
1045 virtual bool ShowFullScreen(bool show
, long style
);
1047 virtual void ShowWithoutActivating();
1049 virtual void RequestUserAttention(int flags
);
1051 virtual void ScreenToWindow( int *x
, int *y
);
1053 virtual void WindowToScreen( int *x
, int *y
);
1054 virtual bool IsActive();
1057 bool MacGetUnifiedAppearance() const ;
1058 void MacChangeWindowAttributes( wxUint32 attributesToSet
, wxUint32 attributesToClear
) ;
1059 wxUint32
MacGetWindowAttributes() const ;
1060 void MacSetMetalAppearance( bool set
) ;
1061 bool MacGetMetalAppearance() const ;
1062 void MacSetUnifiedAppearance( bool set
);
1064 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
1066 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
1068 void MacInstallTopLevelWindowEventHandler();
1070 WXEVENTHANDLERREF m_macEventHandler
;
1071 WindowRef m_macWindow
;
1072 void * m_macFullScreenData
;
1073 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCarbonImpl
)