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
);
336 void GetBestRect( wxRect
*r
) const;
337 bool IsEnabled() const;
338 void Enable( bool enable
);
339 bool ButtonClickDidStateChange() { return false ;}
340 void SetMinimum( wxInt32 v
);
341 void SetMaximum( wxInt32 v
);
343 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
345 // temp convenience methods
347 void GetBestRect( Rect
*r
) const;
349 void operator= (ControlRef c) { m_controlRef = c; }
350 operator ControlRef () { return m_controlRef; }
351 operator ControlRef * () { return &m_controlRef; }
353 // accessing data and values
355 virtual OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
);
356 virtual OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const;
357 virtual OSStatus
GetDataSize( ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const;
358 virtual OSStatus
SendEvent( EventRef ref
, OptionBits inOptions
= 0 );
359 virtual OSStatus
SendHICommand( HICommand
&command
, OptionBits inOptions
= 0 );
361 virtual OSStatus
SendHICommand( UInt32 commandID
, OptionBits inOptions
= 0 );
363 virtual wxInt32
GetMaximum() const;
364 virtual wxInt32
GetMinimum() const;
366 virtual void SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
);
367 virtual void SetRange( SInt32 minimum
, SInt32 maximum
);
371 Size
GetDataSize( ControlPartCode inPartCode
, ResType inTag
) const
374 verify_noerr( GetDataSize( inPartCode
, inTag
, &sz
) );
377 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
*data
)
379 return SetData( inPartCode
, inTag
, sizeof( T
) , data
);
381 template <typename T
> OSStatus
SetData( ControlPartCode inPartCode
, ResType inTag
, const T
& data
)
383 return SetData( inPartCode
, inTag
, sizeof( T
) , &data
);
385 template <typename T
> OSStatus
SetData( ResType inTag
, const T
*data
)
387 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , data
);
389 template <typename T
> OSStatus
SetData( ResType inTag
, const T
& data
)
391 return SetData( kControlEntireControl
, inTag
, sizeof( T
) , &data
);
393 template <typename T
> OSStatus
GetData( ControlPartCode inPartCode
, ResType inTag
, T
*data
) const
396 return GetData( inPartCode
, inTag
, sizeof( T
) , data
, &dummy
);
398 template <typename T
> T
GetData( ControlPartCode inPartCode
, ResType inTag
) const
401 OSStatus err
= GetData
<T
>( inPartCode
, inTag
, &value
);
405 wxFAIL_MSG( wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
406 inPartCode
, (int)inTag
) );
411 template <typename T
> OSStatus
GetData( ResType inTag
, T
*data
) const
414 return GetData( kControlEntireControl
, inTag
, sizeof( T
) , data
, &dummy
);
416 template <typename T
> T
GetData( ResType inTag
) const
418 return GetData
<T
>( kControlEntireControl
, inTag
);
421 // Flash the control for the specified amount of time
423 virtual void VisibilityChanged( bool shown
);
424 virtual void SuperChangedPosition();
427 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
428 virtual void SetBackgroundColour( const wxColour
& col
);
429 virtual bool SetBackgroundStyle(wxBackgroundStyle style
);
430 virtual ControlPartCode
HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
);
431 void SetActionProc( ControlActionUPP actionProc
);
432 SInt32
GetViewSize() const;
434 virtual void SetVisibility( bool visible
);
436 virtual bool IsActive() const;
438 // invalidates this control and all children
439 virtual void InvalidateWithChildren();
440 virtual void SetDrawingEnabled( bool enable
);
442 // in native parent window relative coordinates
444 virtual void GetRectInWindowCoords( Rect
*r
);
447 virtual void GetFeatures( UInt32
*features
);
449 // to be moved into a tab control class
451 virtual OSStatus
SetTabEnabled( SInt16 tabNo
, bool enable
);
453 virtual void InstallEventHandler( WXWidget control
= NULL
);
455 WXEVENTHANDLERREF m_macControlEventHandler
;
456 ControlRef m_controlRef
;
459 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl
)
462 // ============================================================================
463 // DataBrowser Wrapper
464 // ============================================================================
466 // basing on DataBrowserItemIDs
469 class WXDLLIMPEXP_CORE wxMacDataBrowserControl
: public wxMacControl
472 wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
473 wxMacDataBrowserControl() {}
475 OSStatus
SetCallbacks( const DataBrowserCallbacks
*callbacks
);
477 OSStatus
GetItemCount( DataBrowserItemID container
,
479 DataBrowserItemState state
,
480 ItemCount
*numItems
) const;
482 OSStatus
GetItems( DataBrowserItemID container
,
484 DataBrowserItemState state
,
488 OSStatus
AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
489 DataBrowserTableViewColumnIndex position
);
491 OSStatus
RemoveColumn( DataBrowserTableViewColumnIndex position
);
493 OSStatus
AutoSizeColumns();
495 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
496 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
498 OSStatus
SetHeaderButtonHeight( UInt16 height
);
499 OSStatus
GetHeaderButtonHeight( UInt16
*height
);
501 OSStatus
UpdateItems( DataBrowserItemID container
, UInt32 numItems
,
502 const DataBrowserItemID
*items
,
503 DataBrowserPropertyID preSortProperty
,
504 DataBrowserPropertyID propertyID
) const;
506 OSStatus
AddItems( DataBrowserItemID container
, UInt32 numItems
,
507 const DataBrowserItemID
*items
,
508 DataBrowserPropertyID preSortProperty
);
509 OSStatus
RemoveItems( DataBrowserItemID container
, UInt32 numItems
,
510 const DataBrowserItemID
*items
,
511 DataBrowserPropertyID preSortProperty
);
512 OSStatus
RevealItem( DataBrowserItemID item
,
513 DataBrowserPropertyID propertyID
,
514 DataBrowserRevealOptions options
) const;
516 OSStatus
SetSelectionFlags( DataBrowserSelectionFlags
);
517 OSStatus
GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
518 bool IsItemSelected( DataBrowserItemID item
) const;
519 OSStatus
SetSelectedItems( UInt32 numItems
,
520 const DataBrowserItemID
*items
,
521 DataBrowserSetOption operation
);
523 OSStatus
GetItemID( DataBrowserTableViewRowIndex row
,
524 DataBrowserItemID
* item
) const;
525 OSStatus
GetItemRow( DataBrowserItemID item
,
526 DataBrowserTableViewRowIndex
* row
) const;
528 OSStatus
SetDefaultRowHeight( UInt16 height
);
529 OSStatus
GetDefaultRowHeight( UInt16
* height
) const;
531 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
532 OSStatus
GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const;
534 OSStatus
GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const;
535 OSStatus
SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
);
537 OSStatus
GetDefaultColumnWidth( UInt16
*width
) const;
538 OSStatus
SetDefaultColumnWidth( UInt16 width
);
540 OSStatus
GetColumnCount( UInt32
* numColumns
) const;
542 OSStatus
GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
);
544 OSStatus
GetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex
*position
) const;
545 OSStatus
SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
);
547 OSStatus
GetScrollPosition( UInt32
*top
, UInt32
*left
) const;
548 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
550 OSStatus
GetSortProperty( DataBrowserPropertyID
*column
) const;
551 OSStatus
SetSortProperty( DataBrowserPropertyID column
);
553 OSStatus
GetSortOrder( DataBrowserSortOrder
*order
) const;
554 OSStatus
SetSortOrder( DataBrowserSortOrder order
);
556 OSStatus
GetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags
*flags
) const;
557 OSStatus
SetPropertyFlags( DataBrowserPropertyID property
, DataBrowserPropertyFlags flags
);
559 OSStatus
GetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
) const;
560 OSStatus
SetHeaderDesc( DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
*desc
);
562 OSStatus
SetDisclosureColumn( DataBrowserPropertyID property
, Boolean expandableRows
);
564 OSStatus
GetItemPartBounds( DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
);
567 static pascal void DataBrowserItemNotificationProc(
569 DataBrowserItemID itemID
,
570 DataBrowserItemNotification message
,
571 DataBrowserItemDataRef itemData
);
573 virtual void ItemNotification(
574 DataBrowserItemID itemID
,
575 DataBrowserItemNotification message
,
576 DataBrowserItemDataRef itemData
) = 0;
578 static pascal OSStatus
DataBrowserGetSetItemDataProc(
580 DataBrowserItemID itemID
,
581 DataBrowserPropertyID property
,
582 DataBrowserItemDataRef itemData
,
583 Boolean changeValue
);
585 virtual OSStatus
GetSetItemData(
586 DataBrowserItemID itemID
,
587 DataBrowserPropertyID property
,
588 DataBrowserItemDataRef itemData
,
589 Boolean changeValue
) = 0;
591 static pascal Boolean
DataBrowserCompareProc(
593 DataBrowserItemID itemOneID
,
594 DataBrowserItemID itemTwoID
,
595 DataBrowserPropertyID sortProperty
);
597 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
598 DataBrowserItemID itemTwoID
,
599 DataBrowserPropertyID sortProperty
) = 0;
600 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl
)
603 // ============================================================================
604 // Higher-level Databrowser
605 // ============================================================================
607 // basing on data item objects
612 class wxMacDataItemBrowserControl
;
613 class wxMacListBoxItem
;
615 const DataBrowserPropertyID kTextColumnId
= 1024;
616 const DataBrowserPropertyID kNumericOrderColumnId
= 1025;
618 // for multi-column controls, we will use this + the column ID to identify the
619 // column. We don't use kTextColumnId there, and ideally the two should merge.
620 const DataBrowserPropertyID kMinColumnId
= 1050;
622 // base API for high-level databrowser operations
624 // base class for databrowser items
631 class WXDLLIMPEXP_CORE wxMacDataItem
635 virtual ~wxMacDataItem();
639 class WXDLLIMPEXP_CORE wxMacDataItem
643 virtual ~wxMacDataItem();
645 virtual bool IsLessThan(wxMacDataItemBrowserControl
*owner
,
646 const wxMacDataItem
*,
647 DataBrowserPropertyID property
) const;
649 // returns true if access was successful, otherwise false
650 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
651 DataBrowserPropertyID property
,
652 DataBrowserItemDataRef itemData
,
655 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
656 DataBrowserItemNotification message
,
657 DataBrowserItemDataRef itemData
) const;
659 void SetOrder( SInt32 order
);
660 SInt32
GetOrder() const;
669 SortOrder_Text_Ascending
,
670 SortOrder_Text_Descending
673 typedef wxMacDataItem
* wxMacDataItemPtr
;
674 const wxMacDataItemPtr wxMacDataBrowserRootContainer
= NULL
;
675 typedef void * wxListColumnId
;
677 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr
, wxArrayMacDataItemPtr
, class WXDLLIMPEXP_CORE
);
679 class WXDLLIMPEXP_CORE wxMacDataItemBrowserControl
: public wxMacDataBrowserControl
682 wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
683 wxMacDataItemBrowserControl() {}
684 // create a list item (can be a subclass of wxMacListBoxItem)
686 unsigned int GetItemCount(const wxMacDataItem
* container
, bool recurse
, DataBrowserItemState state
) const;
687 void GetItems(const wxMacDataItem
* container
, bool recurse
,
688 DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const;
690 unsigned int GetSelectedItemCount( const wxMacDataItem
* container
, bool recurse
) const;
692 unsigned int GetLineFromItem(const wxMacDataItem
*item
) const;
693 wxMacDataItem
* GetItemFromLine(unsigned int n
) const;
695 void UpdateItem(const wxMacDataItem
*container
, const wxMacDataItem
*item
,
696 DataBrowserPropertyID property
) const;
697 void UpdateItems(const wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
,
698 DataBrowserPropertyID property
) const;
700 void InsertColumn(int colId
, DataBrowserPropertyType colType
,
701 const wxString
& title
, SInt16 just
= teFlushDefault
, int defaultWidth
= -1);
703 int GetColumnWidth(int colId
);
704 void SetColumnWidth(int colId
, int width
);
706 void AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
);
707 void AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
709 void RemoveAllItems(wxMacDataItem
*container
);
710 void RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
);
711 void RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&items
);
713 void SetSelectedItem( wxMacDataItem
* item
, DataBrowserSetOption option
);
714 void SetSelectedItems( wxArrayMacDataItemPtr
&items
, DataBrowserSetOption option
);
715 void SetSelectedAllItems( DataBrowserSetOption option
);
716 Boolean
IsItemSelected( const wxMacDataItem
* item
) const;
718 void RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
);
720 void GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const;
724 virtual void MacDelete( unsigned int n
);
725 virtual void MacInsert( unsigned int n
, wxMacDataItem
* item
);
726 virtual void MacClear();
730 virtual unsigned int MacGetCount() const;
734 // as we are getting the same events for human and API selection we have to suppress
735 // events in the latter case, since this will be used from many subclasses we keep it here
737 bool IsSelectionSuppressed() const { return m_suppressSelection
; }
738 bool SuppressSelection( bool suppress
);
742 virtual wxClientDataType
GetClientDataType() const;
743 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
744 //virtual ListSortOrder GetSortOrder() const;
745 //virtual void SetSortOrder(const ListSortOrder sort);
751 ListSortOrder m_sortOrder
;
752 wxClientDataType m_clientDataItemsType
;
754 // ID aware base methods, should be 'final' ie not changed in subclasses
756 virtual Boolean
CompareItems(DataBrowserItemID itemOneID
,
757 DataBrowserItemID itemTwoID
,
758 DataBrowserPropertyID sortProperty
);
760 virtual OSStatus
GetSetItemData(DataBrowserItemID itemID
,
761 DataBrowserPropertyID property
,
762 DataBrowserItemDataRef itemData
,
763 Boolean changeValue
);
765 virtual void ItemNotification(
766 DataBrowserItemID itemID
,
767 DataBrowserItemNotification message
,
768 DataBrowserItemDataRef itemData
);
773 bool m_suppressSelection
;
774 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl
)
777 class WXDLLIMPEXP_CORE wxMacDataItemBrowserSelectionSuppressor
780 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
);
781 ~wxMacDataItemBrowserSelectionSuppressor();
786 wxMacDataItemBrowserControl
* m_browser
;
789 // ============================================================================
790 // platform listbox implementation
791 // ============================================================================
793 // exposed for reuse in wxCheckListBox
795 class WXDLLIMPEXP_CORE wxMacListBoxItem
: public wxMacDataItem
800 virtual ~wxMacListBoxItem();
802 virtual OSStatus
GetSetData(wxMacDataItemBrowserControl
*owner
,
803 DataBrowserPropertyID property
,
804 DataBrowserItemDataRef itemData
,
807 virtual void Notification(wxMacDataItemBrowserControl
*owner
,
808 DataBrowserItemNotification message
,
809 DataBrowserItemDataRef itemData
) const;
813 class WXDLLIMPEXP_CORE wxMacDataBrowserColumn
: public wxListWidgetColumn
816 wxMacDataBrowserColumn( DataBrowserPropertyID propertyId
, DataBrowserPropertyType colType
, bool editable
)
817 : m_property(propertyId
), m_editable(editable
), m_type( colType
)
820 ~wxMacDataBrowserColumn()
823 DataBrowserPropertyID
GetProperty() const { return m_property
; }
825 bool IsEditable() const { return m_editable
; }
827 DataBrowserPropertyType
GetType() const { return m_type
; }
830 DataBrowserPropertyID m_property
;
832 DataBrowserPropertyType m_type
;
835 WX_DEFINE_ARRAY_PTR(wxMacDataBrowserColumn
*, wxArrayMacDataBrowserColumns
);
838 class WXDLLIMPEXP_CORE wxMacDataBrowserCellValue
: public wxListWidgetCellValue
841 wxMacDataBrowserCellValue(DataBrowserItemDataRef data
) : m_data(data
) {}
842 virtual ~wxMacDataBrowserCellValue() {}
844 virtual void Set( CFStringRef value
);
845 virtual void Set( const wxString
& value
);
846 virtual void Set( int value
) ;
847 virtual void Check( bool check
);
849 virtual int GetIntValue() const ;
850 virtual wxString
GetStringValue() const ;
852 DataBrowserItemDataRef m_data
;
856 class WXDLLIMPEXP_CORE wxMacDataBrowserListControl
: public wxMacDataItemBrowserControl
, public wxListWidgetImpl
859 wxMacDataBrowserListControl( wxWindow
*peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
860 wxMacDataBrowserListControl() {}
861 virtual ~wxMacDataBrowserListControl();
863 // wxListWidgetImpl Methods
865 wxListWidgetColumn
* InsertTextColumn( unsigned int pos
, const wxString
& title
, bool editable
= false,
866 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) ;
867 wxListWidgetColumn
* InsertCheckColumn( unsigned int pos
, const wxString
& title
, bool editable
= false,
868 wxAlignment just
= wxALIGN_LEFT
, int defaultWidth
= -1) ;
870 wxMacDataBrowserColumn
* DoInsertColumn( unsigned int pos
, DataBrowserPropertyID property
,
871 const wxString
& title
, bool editable
,
872 DataBrowserPropertyType colType
, SInt16 just
, int width
);
875 virtual void ListDelete( unsigned int n
);
876 virtual void ListInsert( unsigned int n
);
877 virtual void ListClear();
881 virtual void ListDeselectAll();
882 virtual void ListSetSelection( unsigned int n
, bool select
, bool multi
= false );
883 virtual int ListGetSelection() const;
884 virtual int ListGetSelections( wxArrayInt
& aSelections
) const;
885 virtual bool ListIsSelected( unsigned int n
) const;
889 virtual void ListScrollTo( unsigned int n
);
893 virtual unsigned int ListGetCount() const;
894 virtual int DoListHitTest( const wxPoint
& inpoint
) const;
896 virtual void UpdateLine( unsigned int n
, wxListWidgetColumn
* col
= NULL
);
897 virtual void UpdateLineToEnd( unsigned int n
) ;
901 wxMacDataBrowserColumn
* GetColumnFromProperty( DataBrowserPropertyID
);
904 virtual void ItemNotification(
905 DataBrowserItemID itemID
,
906 DataBrowserItemNotification message
,
907 DataBrowserItemDataRef itemData
);
910 wxArrayMacDataBrowserColumns m_columns
;
913 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl
)
916 // ============================================================================
917 // graphics implementation
918 // ============================================================================
920 // draw the image 'upside down' corrected as HIViewDrawCGImage does
922 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
923 CGContextRef inContext
,
924 const HIRect
* inBounds
,
925 CGImageRef inImage
) ;
927 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
931 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
934 static UPP sHandler = NULL; \
935 if ( sHandler == NULL ) \
936 sHandler = New##UPP( x ); \
940 //---------------------------------------------------------------------------
941 // cocoa bridging utilities
942 //---------------------------------------------------------------------------
944 bool wxMacInitCocoa();
946 typedef Cursor ClassicCursor
;
954 const short kwxCursorBullseye
= 0;
955 const short kwxCursorBlank
= 1;
956 const short kwxCursorPencil
= 2;
957 const short kwxCursorMagnifier
= 3;
958 const short kwxCursorNoEntry
= 4;
959 const short kwxCursorPaintBrush
= 5;
960 const short kwxCursorPointRight
= 6;
961 const short kwxCursorPointLeft
= 7;
962 const short kwxCursorQuestionArrow
= 8;
963 const short kwxCursorRightArrow
= 9;
964 const short kwxCursorSizeNS
= 10;
965 const short kwxCursorSize
= 11;
966 const short kwxCursorSizeNESW
= 12;
967 const short kwxCursorSizeNWSE
= 13;
968 const short kwxCursorRoller
= 14;
969 const short kwxCursorWatch
= 15;
970 const short kwxCursorLast
= kwxCursorWatch
;
972 // exposing our fallback cursor map
974 extern ClassicCursor gMacCursors
[];
982 class wxNonOwnedWindowCarbonImpl
: public wxNonOwnedWindowImpl
985 wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow
* nonownedwnd
) ;
987 wxNonOwnedWindowCarbonImpl();
988 virtual ~wxNonOwnedWindowCarbonImpl();
990 virtual void WillBeDestroyed() ;
991 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
992 long style
, long extraStyle
, const wxString
& name
) ;
993 void Create( wxWindow
* parent
, WXWindow nativeWindow
);
995 WXWindow
GetWXWindow() const;
998 bool Show(bool show
);
999 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
1003 bool SetTransparent(wxByte alpha
);
1004 bool SetBackgroundColour(const wxColour
& col
);
1005 void SetExtraStyle( long exStyle
);
1006 bool SetBackgroundStyle(wxBackgroundStyle style
);
1007 bool CanSetTransparent();
1008 void MoveWindow(int x
, int y
, int width
, int height
);
1009 void GetPosition( int &x
, int &y
) const;
1010 void GetSize( int &width
, int &height
) const;
1011 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
1013 bool SetShape(const wxRegion
& region
);
1015 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
1017 virtual bool IsMaximized() const;
1019 virtual bool IsIconized() const;
1021 virtual void Iconize( bool iconize
);
1023 virtual void Maximize(bool maximize
);
1025 virtual bool IsFullScreen() const;
1027 virtual bool ShowFullScreen(bool show
, long style
);
1029 virtual void ShowWithoutActivating();
1031 virtual void RequestUserAttention(int flags
);
1033 virtual void ScreenToWindow( int *x
, int *y
);
1035 virtual void WindowToScreen( int *x
, int *y
);
1036 virtual bool IsActive();
1039 bool MacGetUnifiedAppearance() const ;
1040 void MacChangeWindowAttributes( wxUint32 attributesToSet
, wxUint32 attributesToClear
) ;
1041 wxUint32
MacGetWindowAttributes() const ;
1042 void MacSetMetalAppearance( bool set
) ;
1043 bool MacGetMetalAppearance() const ;
1044 void MacSetUnifiedAppearance( bool set
);
1046 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
1048 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
1050 void MacInstallTopLevelWindowEventHandler();
1052 WXEVENTHANDLERREF m_macEventHandler
;
1053 WindowRef m_macWindow
;
1054 void * m_macFullScreenData
;
1055 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCarbonImpl
)