1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/mac/carbon/databrow.h
3 // Purpose: Classes and functions for the Carbon data browser
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DATABROW_H_
13 #define _WX_DATABROW_H_
18 # include <Carbon/Carbon.h>
20 # include <Debugging.h>
21 # include <Appearance.h>
22 # include <Controls.h>
23 # include <ControlDefinitions.h>
26 # include <CoreServices.h>
29 #if UNIVERSAL_INTERFACES_VERSION < 0x0342
30 #error "please update to Apple's latest universal headers from http://developer.apple.com/sdk/"
33 #ifndef MAC_OS_X_VERSION_10_3
34 #define MAC_OS_X_VERSION_10_3 1030
37 #ifndef MAC_OS_X_VERSION_10_4
38 #define MAC_OS_X_VERSION_10_4 1040
41 #ifndef MAC_OS_X_VERSION_10_5
42 #define MAC_OS_X_VERSION_10_5 1050
45 #ifdef __WXMAC_CARBON__
46 # include "wx/mac/corefoundation/cfstring.h"
49 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
50 typedef UInt32 URefCon
;
51 typedef SInt32 SRefCon
;
56 #include "wx/mac/private.h"
58 WX_DEFINE_ARRAY_SIZE_T(size_t,wxArrayDataBrowserItemID
);
60 // ============================================================================
61 // wxMacDataBrowserTableViewControl
62 // ============================================================================
64 // this is a wrapper class for the Mac OS X data browser environment,
65 // it covers all general data brower functionality,
68 // data browser's property IDs have a reserved ID range from 0 - 1023
69 // therefore, the first usable property ID is 'kMinPropertyID'
70 DataBrowserPropertyID
const kMinPropertyID
= 1024;
72 class wxMacDataBrowserTableViewControl
: public wxMacControl
76 // constructors / destructor
78 wxMacDataBrowserTableViewControl(wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
);
79 wxMacDataBrowserTableViewControl(void)
86 OSStatus
SetCallbacks (DataBrowserCallbacks
const* callbacks
);
87 OSStatus
SetCustomCallbacks(DataBrowserCustomCallbacks
const* customCallbacks
);
92 OSStatus
GetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
) const;
94 OSStatus
SetHeaderDesc(DataBrowserPropertyID property
, DataBrowserListViewHeaderDesc
* desc
);
99 OSStatus
AutoSizeColumns();
101 OSStatus
EnableCellSizeModification(bool enableHeight
=true, bool enableWidth
=true); // enables or disables the column width and row height modification (default: false)
103 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
104 OSStatus
GetAttributes (OptionBits
* attributes
);
106 OSStatus
GetColumnWidth (DataBrowserPropertyID column
, UInt16
*width
) const; // returns the column width in pixels
107 OSStatus
GetDefaultColumnWidth(UInt16
*width
) const; // returns the default column width in pixels
108 OSStatus
GetDefaultRowHeight (UInt16
* height
) const;
109 OSStatus
GetHeaderButtonHeight(UInt16
*height
);
110 OSStatus
GetPartBounds (DataBrowserItemID item
, DataBrowserPropertyID property
, DataBrowserPropertyPart part
, Rect
* bounds
);
111 OSStatus
GetRowHeight (DataBrowserItemID item
, UInt16
*height
) const;
112 OSStatus
GetScrollPosition (UInt32
* top
, UInt32
*left
) const;
114 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
115 OSStatus
SetAttributes (OptionBits attributes
);
117 OSStatus
SetColumnWidth(DataBrowserPropertyID column
, UInt16 width
); // sets the column width in pixels
118 OSStatus
SetDefaultColumnWidth( UInt16 width
);
119 OSStatus
SetDefaultRowHeight( UInt16 height
);
120 OSStatus
SetHasScrollBars( bool horiz
, bool vert
);
121 OSStatus
SetHeaderButtonHeight( UInt16 height
);
122 OSStatus
SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
);
123 OSStatus
SetRowHeight( DataBrowserItemID item
, UInt16 height
);
124 OSStatus
SetScrollPosition( UInt32 top
, UInt32 left
);
129 OSStatus
GetColumnCount (UInt32
* numColumns
) const;
130 OSStatus
GetColumnIndex (DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex
* index
) const; // returns for the passed property the corresponding column index
131 OSStatus
GetFreePropertyID(DataBrowserPropertyID
* propertyID
) const; // this method returns a property id that is valid and currently not used; if it cannot be found 'errDataBrowerPropertyNotSupported' is returned
132 OSStatus
GetPropertyFlags (DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags
*flags
) const;
133 OSStatus
GetPropertyID (DataBrowserItemDataRef itemData
, DataBrowserPropertyID
* propertyID
); // returns for the passed item data reference the corresponding property ID
134 OSStatus
GetPropertyID (DataBrowserTableViewColumnIndex index
, DataBrowserPropertyID
* propertyID
); // returns for the passed column index the corresponding property ID
136 OSStatus
IsUsedPropertyID(DataBrowserPropertyID propertyID
) const; // checks if passed property id is used by the control; no error is returned if the id exists
138 OSStatus
RemoveColumn(DataBrowserTableViewColumnIndex index
);
140 OSStatus
SetColumnIndex (DataBrowserPropertyID propertyID
, DataBrowserTableViewColumnIndex index
);
141 OSStatus
SetDisclosureColumn(DataBrowserPropertyID propertyID
, Boolean expandableRows
=true);
142 OSStatus
SetPropertyFlags (DataBrowserPropertyID propertyID
, DataBrowserPropertyFlags flags
);
147 OSStatus
AddItem(DataBrowserItemID container
, DataBrowserItemID
const* itemID
) // adds a single item
149 return this->AddItems(container
,1,itemID
,kDataBrowserItemNoProperty
);
151 OSStatus
AddItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
); // adds items to the data browser
153 OSStatus
GetFreeItemID(DataBrowserItemID
* id
) const; // this method returns an item id that is valid and currently not used; if it cannot be found 'errDataBrowserItemNotAdded' is returned
154 OSStatus
GetItemCount (ItemCount
* numItems
) const
156 return this->GetItemCount(kDataBrowserNoItem
,true,kDataBrowserItemAnyState
,numItems
);
158 OSStatus
GetItemCount (DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, ItemCount
* numItems
) const;
159 OSStatus
GetItemID (DataBrowserTableViewRowIndex row
, DataBrowserItemID
* item
) const;
160 OSStatus
GetItems (DataBrowserItemID container
, Boolean recurse
, DataBrowserItemState state
, Handle items
) const;
161 OSStatus
GetItemRow (DataBrowserItemID item
, DataBrowserTableViewRowIndex
* row
) const;
163 OSStatus
IsUsedItemID(DataBrowserItemID itemID
) const; // checks if the passed id is in use
165 OSStatus
RevealItem(DataBrowserItemID item
, DataBrowserPropertyID propertyID
, DataBrowserRevealOptions options
) const;
167 OSStatus
RemoveItem(DataBrowserItemID container
, DataBrowserItemID
const* itemID
) // removes a single item
169 return this->RemoveItems(container
,1,itemID
,kDataBrowserItemNoProperty
);
171 OSStatus
RemoveItems(void) // removes all items
173 return this->RemoveItems(kDataBrowserNoItem
,0,NULL
,kDataBrowserItemNoProperty
);
175 OSStatus
RemoveItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
);
177 OSStatus
UpdateItems(void) // updates all items
179 return this->UpdateItems(kDataBrowserNoItem
,0,NULL
,kDataBrowserItemNoProperty
,kDataBrowserNoItem
);
181 OSStatus
UpdateItems(DataBrowserItemID
const* item
) // updates all columns of item
183 return this->UpdateItems(kDataBrowserNoItem
,1,item
,kDataBrowserItemNoProperty
,kDataBrowserNoItem
);
185 OSStatus
UpdateItems(DataBrowserItemID container
, UInt32 numItems
, DataBrowserItemID
const* items
, DataBrowserPropertyID preSortProperty
, DataBrowserPropertyID propertyID
) const;
190 size_t GetSelectedItemIDs(wxArrayDataBrowserItemID
& itemIDs
) const; // returns the number of selected item and the item IDs in the array
191 OSStatus
GetSelectionAnchor(DataBrowserItemID
*first
, DataBrowserItemID
*last
) const;
192 OSStatus
GetSelectionFlags (DataBrowserSelectionFlags
* flags
) const;
194 bool IsItemSelected(DataBrowserItemID item
) const;
196 OSStatus
SetSelectionFlags(DataBrowserSelectionFlags flags
);
197 OSStatus
SetSelectedItems (UInt32 numItems
, DataBrowserItemID
const* itemIDs
, DataBrowserSetOption operation
);
202 OSStatus
GetSortOrder (DataBrowserSortOrder
* order
) const;
203 OSStatus
GetSortProperty(DataBrowserPropertyID
* propertyID
) const;
205 OSStatus
Resort(DataBrowserItemID container
=kDataBrowserNoItem
, Boolean sortChildren
=true);
207 OSStatus
SetSortOrder (DataBrowserSortOrder order
);
208 OSStatus
SetSortProperty(DataBrowserPropertyID propertyID
);
212 // callback functions
214 static pascal Boolean
DataBrowserCompareProc (ControlRef browser
, DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
);
215 static pascal void DataBrowserDrawItemProc (ControlRef browser
, DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16 bitDepth
, Boolean colorDevice
);
216 static pascal OSStatus
DataBrowserGetSetItemDataProc (ControlRef browser
, DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemDataRef itemData
, Boolean getValue
);
217 static pascal void DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
);
219 virtual Boolean
DataBrowserCompareProc (DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
) = 0;
220 virtual void DataBrowserDrawItemProc (DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16 bitDepth
, Boolean colorDevice
) = 0;
221 virtual OSStatus
DataBrowserGetSetItemDataProc (DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemDataRef itemData
, Boolean getValue
) = 0;
222 virtual void DataBrowserItemNotificationProc(DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
) = 0;
225 // wxWidget internal stuff
227 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl
)
230 // ============================================================================
231 // wxMacDataBrowserListViewControl
232 // ============================================================================
234 // this class is a wrapper for a list view which incorporates all general
235 // data browser functionality of the inherited table view control class;
236 // the term list view is in this case Mac OS X specific and is not related
237 // to any wxWidget naming conventions
239 class wxMacDataBrowserListViewControl
: public wxMacDataBrowserTableViewControl
243 // constructors / destructor
245 wxMacDataBrowserListViewControl(wxWindow
* peer
, wxPoint
const& pos
, wxSize
const& size
, long style
) : wxMacDataBrowserTableViewControl(peer
,pos
,size
,style
)
252 OSStatus
AddColumn(DataBrowserListViewColumnDesc
*columnDesc
, DataBrowserTableViewColumnIndex position
);
259 // ============================================================================
260 // wxMacDataViewDataBrowserListViewControl
261 // ============================================================================
263 // internal interface class between wxDataViewCtrl (wxWidget) and the data
264 // browser (Mac OS X)
266 class wxMacDataViewDataBrowserListViewControl
: public wxMacDataBrowserListViewControl
270 // constructors / destructor
272 wxMacDataViewDataBrowserListViewControl(wxWindow
* peer
, wxPoint
const& pos
, wxSize
const& size
, long style
);
276 // callback functions (inherited from wxMacDataBrowserTableViewControl)
278 virtual Boolean
DataBrowserCompareProc (DataBrowserItemID itemOneID
, DataBrowserItemID itemTwoID
, DataBrowserPropertyID sortProperty
);
279 virtual void DataBrowserDrawItemProc (DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemState state
, Rect
const* rectangle
, SInt16 bitDepth
, Boolean colorDevice
);
280 virtual void DataBrowserItemNotificationProc(DataBrowserItemID itemID
, DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
);
281 virtual OSStatus
DataBrowserGetSetItemDataProc (DataBrowserItemID itemID
, DataBrowserPropertyID property
, DataBrowserItemDataRef itemData
, Boolean getValue
);
286 typedef wxMacDataViewDataBrowserListViewControl
* wxMacDataViewDataBrowserListViewControlPointer
;
291 #endif // _WX_DATABROW_H_