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
9 // Copyright: (c) Stefan Csomor
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_PRIVATE_H_
14 #define _WX_PRIVATE_H_
16 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
17 typedef UInt32 URefCon
;
18 typedef SInt32 SRefCon
;
23 #include "wx/osx/uma.h"
25 #include "wx/listbox.h"
26 #include "wx/osx/dc.h"
27 #include "wx/osx/dcclient.h"
28 #include "wx/osx/dcmemory.h"
32 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
33 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
);
39 WXDLLIMPEXP_BASE wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
);
40 WXDLLIMPEXP_BASE
void wxMacFilename2FSSpec( const wxString
&path
, FSSpec
*spec
);
43 WXDLLIMPEXP_BASE wxString
wxMacFindFolderNoSeparator(short vRefNum
,
45 Boolean createFolder
);
46 WXDLLIMPEXP_BASE wxString
wxMacFindFolder(short vRefNum
,
48 Boolean createFolder
);
50 template<typename T
> EventParamType
wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
51 template<> inline EventParamType wxMacGetEventParamType
<HIShapeRef
>() { return typeHIShapeRef
; }
52 template<> inline EventParamType wxMacGetEventParamType
<RgnHandle
>() { return typeQDRgnHandle
; }
53 template<> inline EventParamType wxMacGetEventParamType
<ControlRef
>() { return typeControlRef
; }
54 template<> inline EventParamType wxMacGetEventParamType
<WindowRef
>() { return typeWindowRef
; }
55 template<> inline EventParamType wxMacGetEventParamType
<MenuRef
>() { return typeMenuRef
; }
56 template<> inline EventParamType wxMacGetEventParamType
<EventRef
>() { return typeEventRef
; }
57 template<> inline EventParamType wxMacGetEventParamType
<Point
>() { return typeQDPoint
; }
58 template<> inline EventParamType wxMacGetEventParamType
<Rect
>() { return typeQDRectangle
; }
59 template<> inline EventParamType wxMacGetEventParamType
<Boolean
>() { return typeBoolean
; }
60 template<> inline EventParamType wxMacGetEventParamType
<SInt16
>() { return typeSInt16
; }
61 template<> inline EventParamType wxMacGetEventParamType
<SInt32
>() { return typeSInt32
; }
62 template<> inline EventParamType wxMacGetEventParamType
<UInt32
>() { return typeUInt32
; }
63 template<> inline EventParamType wxMacGetEventParamType
<RGBColor
>() { return typeRGBColor
; }
64 template<> inline EventParamType wxMacGetEventParamType
<HICommand
>() { return typeHICommand
; }
65 template<> inline EventParamType wxMacGetEventParamType
<HIPoint
>() { return typeHIPoint
; }
66 template<> inline EventParamType wxMacGetEventParamType
<HISize
>() { return typeHISize
; }
67 template<> inline EventParamType wxMacGetEventParamType
<HIRect
>() { return typeHIRect
; }
68 template<> inline EventParamType wxMacGetEventParamType
<void*>() { return typeVoidPtr
; }
69 template<> inline EventParamType wxMacGetEventParamType
<CFDictionaryRef
>() { return typeCFDictionaryRef
; }
70 template<> inline EventParamType wxMacGetEventParamType
<Collection
>() { return typeCollection
; }
71 template<> inline EventParamType wxMacGetEventParamType
<CGContextRef
>() { return typeCGContextRef
; }
74 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
75 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
76 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
77 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
80 class WXDLLIMPEXP_CORE wxMacCarbonEvent
90 wxMacCarbonEvent( EventRef event
, bool release
= false )
96 wxMacCarbonEvent(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
99 verify_noerr( MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
) );
106 ReleaseEvent( m_eventRef
);
109 OSStatus
Create(UInt32 inClassID
,UInt32 inKind
,EventTime inWhen
= 0 /*now*/,EventAttributes inAttributes
=kEventAttributeNone
)
111 verify( (m_eventRef
== NULL
) || m_release
);
112 if ( m_eventRef
&& m_release
)
114 ReleaseEvent( m_eventRef
);
118 OSStatus err
= MacCreateEvent( NULL
, inClassID
, inKind
,inWhen
,inAttributes
,&m_eventRef
);
124 OSStatus
GetParameter( EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
);
126 template <typename T
> OSStatus
GetParameter( EventParamName inName
, EventParamType type
, T
*data
)
128 return GetParameter( inName
, type
, sizeof( T
) , data
);
130 template <typename T
> OSStatus
GetParameter( EventParamName inName
, T
*data
)
132 return GetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
135 template <typename T
> T
GetParameter( EventParamName inName
)
138 verify_noerr( GetParameter
<T
>( inName
, &value
) );
141 template <typename T
> T
GetParameter( EventParamName inName
, EventParamType inDesiredType
)
144 verify_noerr( GetParameter
<T
>( inName
, inDesiredType
, &value
) );
148 OSStatus
SetParameter( EventParamName inName
, EventParamType inType
, UInt32 inSize
, const void * inData
);
149 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
*data
)
151 return SetParameter( inName
, inDesiredType
, sizeof( T
) , data
);
153 template <typename T
> OSStatus
SetParameter( EventParamName inName
, EventParamType inDesiredType
, const T
& data
)
155 return SetParameter
<T
>( inName
, inDesiredType
, &data
);
157 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
*data
)
159 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , data
);
161 template <typename T
> OSStatus
SetParameter( EventParamName inName
, const T
& data
)
163 return SetParameter
<T
>( inName
, wxMacGetEventParamType
<T
>() , &data
);
167 return ::GetEventClass( m_eventRef
);
171 return ::GetEventKind( m_eventRef
);
175 return ::GetEventTime( m_eventRef
);
179 return EventTimeToTicks( GetTime() );
181 OSStatus
SetCurrentTime( )
183 return ::SetEventTime( m_eventRef
, GetCurrentEventTime() );
185 OSStatus
SetTime( EventTime when
)
187 return ::SetEventTime( m_eventRef
, when
);
189 operator EventRef () { return m_eventRef
; }
191 bool IsValid() { return m_eventRef
!= 0; }
199 class WXDLLIMPEXP_FWD_CORE wxMacToolTipTimer
;
201 class WXDLLIMPEXP_CORE wxMacToolTip
207 void Setup( WindowRef window
, const wxString
& text
, const wxPoint
& localPosition
) ;
222 PicHandle m_backpict
;
226 wxMacToolTipTimer
* m_timer
;
228 wxCFStringRef m_helpTextRef
;
233 WXDLLIMPEXP_CORE
void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 );
234 WXDLLIMPEXP_CORE
void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
);
236 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
237 #define MAC_WXHMETAFILE(a) (PicHandle(a))
238 #define MAC_WXHICON(a) (IconRef(a))
239 #define MAC_WXHCURSOR(a) (CursHandle(a))
240 #define MAC_WXHRGN(a) (RgnHandle(a))
241 #define MAC_WXHWND(a) (WindowPtr(a))
242 #define MAC_WXRECPTR(a) ((Rect*)a)
243 #define MAC_WXPOINTPTR(a) ((Point*)a)
244 #define MAC_WXHMENU(a) ((MenuHandle)a)
246 struct wxOpaqueWindowRef
248 wxOpaqueWindowRef( WindowRef ref
) { m_data
= ref
; }
249 operator WindowRef() { return m_data
; }
254 WXDLLIMPEXP_CORE
void wxMacRectToNative( const wxRect
*wx
, Rect
*n
);
255 WXDLLIMPEXP_CORE
void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
);
256 WXDLLIMPEXP_CORE
void wxMacPointToNative( const wxPoint
* wx
, Point
*n
);
257 WXDLLIMPEXP_CORE
void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
);
259 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacMenu(MenuRef inMenuRef
);
261 WXDLLIMPEXP_CORE
int wxMacCommandToId( UInt32 macCommandId
);
262 WXDLLIMPEXP_CORE UInt32
wxIdToMacCommand( int wxId
);
263 WXDLLIMPEXP_CORE wxMenu
* wxFindMenuFromMacCommand( const HICommand
&macCommandId
, wxMenuItem
* &item
);
265 WXDLLIMPEXP_CORE
pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
);
266 WXDLLIMPEXP_CORE Rect
wxMacGetBoundsForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
= true );
268 ControlActionUPP
GetwxMacLiveScrollbarActionProc();
270 // additional optional event defines
272 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
274 kEventControlFocusPartChanged
= 164
278 class WXDLLIMPEXP_CORE wxMacControl
: public wxWidgetImpl
281 wxMacControl( wxWindowMac
* peer
, bool isRootControl
= false, bool isUserPane
= false );
283 virtual ~wxMacControl();
287 void SetReferenceInNativeControl();
288 static wxMacControl
* GetReferenceFromNativeControl(ControlRef control
);
290 virtual ControlRef
* GetControlRefAddr() { return &m_controlRef
; }
291 virtual ControlRef
GetControlRef() const { return m_controlRef
; }
293 virtual WXWidget
GetWXWidget() const { return (WXWidget
) m_controlRef
; }
295 virtual bool IsVisible() const;
297 virtual void Raise();
299 virtual void Lower();
301 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
303 virtual void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
304 virtual void Move(int x
, int y
, int width
, int height
);
305 virtual void GetPosition( int &x
, int &y
) const;
306 virtual void GetSize( int &width
, int &height
) const;
307 virtual void SetControlSize( wxWindowVariant variant
) ;
309 // where is in native window relative coordinates
310 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
311 virtual bool GetNeedsDisplay() const;
313 virtual bool CanFocus() const;
314 // return true if successful
315 virtual bool SetFocus();
316 virtual bool HasFocus() const;
318 void RemoveFromParent();
319 void Embed( wxWidgetImpl
*parent
);
321 void SetDefaultButton( bool isDefault
);
323 void SetLabel( const wxString
& title
, wxFontEncoding encoding
);
325 void SetCursor( const wxCursor
& cursor
);
329 wxInt32
GetValue() const;
330 void SetValue( wxInt32 v
);
331 wxBitmap
GetBitmap() const;
332 void SetBitmap( const wxBitmap
& bitmap
);
333 void SetBitmapPosition( wxDirection dir
);
335 void GetBestRect( wxRect
*r
) const;
336 bool IsEnabled() const;
337 void Enable( bool enable
);
338 bool ButtonClickDidStateChange() { return false ;}
339 void SetMinimum( wxInt32 v
);
340 void SetMaximum( wxInt32 v
);
342 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
344 // temp convenience methods
346 void GetBestRect( Rect
*r
) const;
348 void operator= (ControlRef c) { m_controlRef = c; }
349 operator ControlRef () { return m_controlRef; }
350 operator ControlRef * () { return &m_controlRef; }
352 // accessing data and values
354 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
355 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
356 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
357 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
358 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
360 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
362 virtual wxInt32
GetMaximum() const;
363 virtual wxInt32
GetMinimum() const;
365 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
366 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
370 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
373 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
376 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
378 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
380 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
382 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
384 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
386 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
388 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
390 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
392 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
395 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
397 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
400 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
404 wxFAIL_MSG( wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
405 inPartCode
, (int)inTag
) );
410 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
413 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
415 template <typename T
> T
GetData( ResType inTag
) const
417 return GetData
<T
>( kControlEntireControl
, inTag
);
420 // Flash the control for the specified amount of time
422 virtual void VisibilityChanged( bool shown
);
423 virtual void SuperChangedPosition();
426 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
427 virtual void SetBackgroundColour( const wxColour
& col
);
428 virtual bool SetBackgroundStyle(wxBackgroundStyle style
);
429 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
430 void SetActionProc( ControlActionUPP actionProc
);
431 SInt32
GetViewSize() const;
433 virtual void SetVisibility( bool visible
);
435 virtual bool IsActive() const;
437 // invalidates this control and all children
438 virtual void InvalidateWithChildren();
439 virtual void SetDrawingEnabled( bool enable
);
441 // in native parent window relative coordinates
443 virtual void GetRectInWindowCoords( Rect
*r
);
446 virtual void GetFeatures( UInt32
*features
);
448 // to be moved into a tab control class
450 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
452 virtual void InstallEventHandler( WXWidget control
= NULL
);
454 WXEVENTHANDLERREF m_macControlEventHandler
;
455 ControlRef m_controlRef
;
458 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
461 // ============================================================================
462 // DataBrowser Wrapper
463 // ============================================================================
465 // basing on DataBrowserItemIDs
468 class WXDLLIMPEXP_CORE wxMacDataBrowserControl
: public wxMacControl
471 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
472 wxMacDataBrowserControl() {}
474 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
476 OSStatus
GetItemCount( DataBrowserItemID container
,
478 DataBrowserItemState state
,
479 ItemCount
*numItems
) const;
481 OSStatus
GetItems( DataBrowserItemID container
,
483 DataBrowserItemState state
,
487 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
488 DataBrowserTableViewColumnIndex position
);
490 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
492 OSStatus
AutoSizeColumns();
494 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
495 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
497 OSStatus
SetHeaderButtonHeight( UInt16 height
);
498 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
500 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
501 const DataBrowserItemID
*items
,
502 DataBrowserPropertyID preSortProperty
,
503 DataBrowserPropertyID propertyID
) const;
505 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
506 const DataBrowserItemID
*items
,
507 DataBrowserPropertyID preSortProperty
);
508 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
509 const DataBrowserItemID
*items
,
510 DataBrowserPropertyID preSortProperty
);
511 OSStatus
RevealItem( DataBrowserItemID item
,
512 DataBrowserPropertyID propertyID
,
513 DataBrowserRevealOptions options
) const;
515 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
516 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
517 bool IsItemSelected( DataBrowserItemID item
) const;
518 OSStatus
SetSelectedItems( UInt32 numItems
,
519 const DataBrowserItemID
*items
,
520 DataBrowserSetOption operation
);
522 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
523 DataBrowserItemID
* item
) const;
524 OSStatus
GetItemRow( DataBrowserItemID item
,
525 DataBrowserTableViewRowIndex
* row
) const;
527 OSStatus
SetDefaultRowHeight( UInt16 height
);
528 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
530 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
531 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
533 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
534 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
536 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
537 OSStatus
SetDefaultColumnWidth( UInt16 width
);
539 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
541 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
543 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
544 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
546 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
547 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
549 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
550 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
552 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
553 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
555 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
556 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
558 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
559 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
561 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
563 OSStatus
GetItemPartBounds( DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
);
566 static pascal void DataBrowserItemNotificationProc(
568 DataBrowserItemID itemID
,
569 DataBrowserItemNotification message
,
570 DataBrowserItemDataRef itemData
);
572 virtual void ItemNotification(
573 DataBrowserItemID itemID
,
574 DataBrowserItemNotification message
,
575 DataBrowserItemDataRef itemData
) = 0;
577 static pascal OSStatus
DataBrowserGetSetItemDataProc(
579 DataBrowserItemID itemID
,
580 DataBrowserPropertyID property
,
581 DataBrowserItemDataRef itemData
,
582 Boolean changeValue
);
584 virtual OSStatus
GetSetItemData(
585 DataBrowserItemID itemID
,
586 DataBrowserPropertyID property
,
587 DataBrowserItemDataRef itemData
,
588 Boolean changeValue
) = 0;
590 static pascal Boolean
DataBrowserCompareProc(
592 DataBrowserItemID itemOneID
,
593 DataBrowserItemID itemTwoID
,
594 DataBrowserPropertyID sortProperty
);
596 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
597 DataBrowserItemID itemTwoID
,
598 DataBrowserPropertyID sortProperty
) = 0;
599 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
602 // ============================================================================
603 // Higher-level Databrowser
604 // ============================================================================
606 // basing on data item objects
611 class wxMacDataItemBrowserControl
;
612 class wxMacListBoxItem
;
614 const DataBrowserPropertyID kTextColumnId
= 1024;
615 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
617 // for multi-column controls, we will use this + the column ID to identify the
618 // column. We don't use kTextColumnId there, and ideally the two should merge.
619 const DataBrowserPropertyID kMinColumnId
= 1050;
621 // base API for high-level databrowser operations
623 // base class for databrowser items
630 class WXDLLIMPEXP_CORE wxMacDataItem
634 virtual ~wxMacDataItem();
638 class WXDLLIMPEXP_CORE wxMacDataItem
642 virtual ~wxMacDataItem();
644 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
645 const wxMacDataItem
*,
646 DataBrowserPropertyID property
) const;
648 // returns true if access was successful, otherwise false
649 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
650 DataBrowserPropertyID property
,
651 DataBrowserItemDataRef itemData
,
654 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
655 DataBrowserItemNotification message
,
656 DataBrowserItemDataRef itemData
) const;
658 void SetOrder( SInt32 order
);
659 SInt32
GetOrder() const;
668 SortOrder_Text_Ascending
,
669 SortOrder_Text_Descending
672 typedef wxMacDataItem
* wxMacDataItemPtr
;
673 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
674 typedef void * wxListColumnId
;
676 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
678 class WXDLLIMPEXP_CORE wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
681 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
682 wxMacDataItemBrowserControl() {}
683 // create a list item (can be a subclass of wxMacListBoxItem)
685 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
686 void GetItems(const wxMacDataItem
* container
, bool recurse
,
687 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
689 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
691 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
692 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
694 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
695 DataBrowserPropertyID property
) const;
696 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
697 DataBrowserPropertyID property
) const;
699 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
700 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
702 int GetColumnWidth(int colId
);
703 void SetColumnWidth(int colId
, int width
);
705 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
706 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
708 void RemoveAllItems(wxMacDataItem
*container
);
709 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
710 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
712 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
713 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
714 void SetSelectedAllItems( DataBrowserSetOption option
);
715 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
717 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
719 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
723 virtual void MacDelete( unsigned int n
);
724 virtual void MacInsert( unsigned int n
, wxMacDataItem
* item
);
725 virtual void MacClear();
729 virtual unsigned int MacGetCount() const;
733 // as we are getting the same events for human and API selection we have to suppress
734 // events in the latter case, since this will be used from many subclasses we keep it here
736 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
737 bool SuppressSelection( bool suppress
);
741 virtual wxClientDataType
GetClientDataType() const;
742 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
743 //virtual ListSortOrder GetSortOrder() const;
744 //virtual void SetSortOrder(const ListSortOrder sort);
750 ListSortOrder m_sortOrder
;
751 wxClientDataType m_clientDataItemsType
;
753 // ID aware base methods, should be 'final' ie not changed in subclasses
755 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
756 DataBrowserItemID itemTwoID
,
757 DataBrowserPropertyID sortProperty
);
759 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
760 DataBrowserPropertyID property
,
761 DataBrowserItemDataRef itemData
,
762 Boolean changeValue
);
764 virtual void ItemNotification(
765 DataBrowserItemID itemID
,
766 DataBrowserItemNotification message
,
767 DataBrowserItemDataRef itemData
);
772 bool m_suppressSelection
;
773 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
776 class WXDLLIMPEXP_CORE wxMacDataItemBrowserSelectionSuppressor
779 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
780 ~wxMacDataItemBrowserSelectionSuppressor();
785 wxMacDataItemBrowserControl
* m_browser
;
788 // ============================================================================
789 // platform listbox implementation
790 // ============================================================================
792 // exposed for reuse in wxCheckListBox
794 class WXDLLIMPEXP_CORE wxMacListBoxItem
: public wxMacDataItem
799 virtual ~wxMacListBoxItem();
801 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
802 DataBrowserPropertyID property
,
803 DataBrowserItemDataRef itemData
,
806 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
807 DataBrowserItemNotification message
,
808 DataBrowserItemDataRef itemData
) const;
812 class WXDLLIMPEXP_CORE wxMacDataBrowserColumn
: public wxListWidgetColumn
815 wxMacDataBrowserColumn( DataBrowserPropertyID propertyId
, DataBrowserPropertyType colType
, bool editable
)
816 : m_property(propertyId
), m_editable(editable
), m_type( colType
)
819 ~wxMacDataBrowserColumn()
822 DataBrowserPropertyID
GetProperty() const { return m_property
; }
824 bool IsEditable() const { return m_editable
; }
826 DataBrowserPropertyType
GetType() const { return m_type
; }
829 DataBrowserPropertyID m_property
;
831 DataBrowserPropertyType m_type
;
834 WX_DEFINE_ARRAY_PTR(wxMacDataBrowserColumn
*, wxArrayMacDataBrowserColumns
);
837 class WXDLLIMPEXP_CORE wxMacDataBrowserCellValue
: public wxListWidgetCellValue
840 wxMacDataBrowserCellValue(DataBrowserItemDataRef data
) : m_data(data
) {}
841 virtual ~wxMacDataBrowserCellValue() {}
843 virtual void Set( CFStringRef value
);
844 virtual void Set( const wxString
& value
);
845 virtual void Set( int value
) ;
846 virtual void Check( bool check
);
848 virtual int GetIntValue() const ;
849 virtual wxString
GetStringValue() const ;
851 DataBrowserItemDataRef m_data
;
855 class WXDLLIMPEXP_CORE wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
, public wxListWidgetImpl
858 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
859 wxMacDataBrowserListControl() {}
860 virtual ~wxMacDataBrowserListControl();
862 // wxListWidgetImpl Methods
864 wxListWidgetColumn
* InsertTextColumn( unsigned int pos
, const wxString
& title
, bool editable
= false,
865 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) ;
866 wxListWidgetColumn
* InsertCheckColumn( unsigned int pos
, const wxString
& title
, bool editable
= false,
867 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) ;
869 wxMacDataBrowserColumn
* DoInsertColumn( unsigned int pos
, DataBrowserPropertyID property
,
870 const wxString
& title
, bool editable
,
871 DataBrowserPropertyType colType
, SInt16 just
, int width
);
874 virtual void ListDelete( unsigned int n
);
875 virtual void ListInsert( unsigned int n
);
876 virtual void ListClear();
880 virtual void ListDeselectAll();
881 virtual void ListSetSelection( unsigned int n
, bool select
, bool multi
= false );
882 virtual int ListGetSelection() const;
883 virtual int ListGetSelections( wxArrayInt
& aSelections
) const;
884 virtual bool ListIsSelected( unsigned int n
) const;
888 virtual void ListScrollTo( unsigned int n
);
892 virtual unsigned int ListGetCount() const;
893 virtual int DoListHitTest( const wxPoint
& inpoint
) const;
895 virtual void UpdateLine( unsigned int n
, wxListWidgetColumn
* col
= NULL
);
896 virtual void UpdateLineToEnd( unsigned int n
) ;
900 wxMacDataBrowserColumn
* GetColumnFromProperty( DataBrowserPropertyID
);
903 virtual void ItemNotification(
904 DataBrowserItemID itemID
,
905 DataBrowserItemNotification message
,
906 DataBrowserItemDataRef itemData
);
909 wxArrayMacDataBrowserColumns m_columns
;
912 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
915 // ============================================================================
916 // graphics implementation
917 // ============================================================================
919 // draw the image 'upside down' corrected as HIViewDrawCGImage does
921 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
922 CGContextRef inContext
,
923 const HIRect
* inBounds
,
924 CGImageRef inImage
) ;
926 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
930 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
933 static UPP sHandler = NULL; \
934 if ( sHandler == NULL ) \
935 sHandler = New##UPP( x ); \
939 //---------------------------------------------------------------------------
940 // cocoa bridging utilities
941 //---------------------------------------------------------------------------
943 bool wxMacInitCocoa();
945 typedef Cursor ClassicCursor
;
953 const short kwxCursorBullseye
= 0;
954 const short kwxCursorBlank
= 1;
955 const short kwxCursorPencil
= 2;
956 const short kwxCursorMagnifier
= 3;
957 const short kwxCursorNoEntry
= 4;
958 const short kwxCursorPaintBrush
= 5;
959 const short kwxCursorPointRight
= 6;
960 const short kwxCursorPointLeft
= 7;
961 const short kwxCursorQuestionArrow
= 8;
962 const short kwxCursorRightArrow
= 9;
963 const short kwxCursorSizeNS
= 10;
964 const short kwxCursorSize
= 11;
965 const short kwxCursorSizeNESW
= 12;
966 const short kwxCursorSizeNWSE
= 13;
967 const short kwxCursorRoller
= 14;
968 const short kwxCursorWatch
= 15;
969 const short kwxCursorLast
= kwxCursorWatch
;
971 // exposing our fallback cursor map
973 extern ClassicCursor gMacCursors
[];
981 class wxNonOwnedWindowCarbonImpl
: public wxNonOwnedWindowImpl
984 wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow
* nonownedwnd
) ;
986 wxNonOwnedWindowCarbonImpl();
987 virtual ~wxNonOwnedWindowCarbonImpl();
989 virtual void WillBeDestroyed() ;
990 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
991 long style
, long extraStyle
, const wxString
& name
) ;
992 void Create( wxWindow
* parent
, WXWindow nativeWindow
);
994 WXWindow
GetWXWindow() const;
997 bool Show(bool show
);
998 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
1002 bool SetTransparent(wxByte alpha
);
1003 bool SetBackgroundColour(const wxColour
& col
);
1004 void SetExtraStyle( long exStyle
);
1005 bool SetBackgroundStyle(wxBackgroundStyle style
);
1006 bool CanSetTransparent();
1007 void MoveWindow(int x
, int y
, int width
, int height
);
1008 void GetPosition( int &x
, int &y
) const;
1009 void GetSize( int &width
, int &height
) const;
1010 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
1012 bool SetShape(const wxRegion
& region
);
1014 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
1016 virtual bool IsMaximized() const;
1018 virtual bool IsIconized() const;
1020 virtual void Iconize( bool iconize
);
1022 virtual void Maximize(bool maximize
);
1024 virtual bool IsFullScreen() const;
1026 virtual bool ShowFullScreen(bool show
, long style
);
1028 virtual void ShowWithoutActivating();
1030 virtual void RequestUserAttention(int flags
);
1032 virtual void ScreenToWindow( int *x
, int *y
);
1034 virtual void WindowToScreen( int *x
, int *y
);
1035 virtual bool IsActive();
1038 bool MacGetUnifiedAppearance() const ;
1039 void MacChangeWindowAttributes( wxUint32 attributesToSet
, wxUint32 attributesToClear
) ;
1040 wxUint32
MacGetWindowAttributes() const ;
1041 void MacSetMetalAppearance( bool set
) ;
1042 bool MacGetMetalAppearance() const ;
1043 void MacSetUnifiedAppearance( bool set
);
1045 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
1047 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
1049 void MacInstallTopLevelWindowEventHandler();
1051 WXEVENTHANDLERREF m_macEventHandler
;
1052 WindowRef m_macWindow
;
1053 void * m_macFullScreenData
;
1054 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCarbonImpl
)