]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/databrow.h
Cast for argument to delete[] - VC6 doesn't want to delete a const pointer
[wxWidgets.git] / include / wx / mac / carbon / databrow.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/mac/carbon/databrow.h
3 // Purpose: Classes and functions for the Carbon data browser
4 // Author:
5 // Modified by:
6 // Created: 2007-05-18
7 // RCS-ID: $Id$
8 // Copyright: (c)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DATABROW_H_
13 #define _WX_DATABROW_H_
14
15 #include "wx/defs.h"
16
17 #ifdef __DARWIN__
18 # include <Carbon/Carbon.h>
19 #else
20 # include <Debugging.h>
21 # include <Appearance.h>
22 # include <Controls.h>
23 # include <ControlDefinitions.h>
24 # include <LowMem.h>
25 # include <Gestalt.h>
26 # include <CoreServices.h>
27 #endif
28
29 #if UNIVERSAL_INTERFACES_VERSION < 0x0342
30 #error "please update to Apple's latest universal headers from http://developer.apple.com/sdk/"
31 #endif
32
33 #ifndef MAC_OS_X_VERSION_10_3
34 #define MAC_OS_X_VERSION_10_3 1030
35 #endif
36
37 #ifndef MAC_OS_X_VERSION_10_4
38 #define MAC_OS_X_VERSION_10_4 1040
39 #endif
40
41 #ifndef MAC_OS_X_VERSION_10_5
42 #define MAC_OS_X_VERSION_10_5 1050
43 #endif
44
45 #ifdef __WXMAC_CARBON__
46 # include "wx/mac/corefoundation/cfstring.h"
47 #endif
48
49 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
50 typedef UInt32 URefCon;
51 typedef SInt32 SRefCon;
52 #endif
53
54 #if wxUSE_GUI
55
56 #include "wx/mac/private.h"
57
58 WX_DEFINE_ARRAY_SIZE_T(size_t,wxArrayDataBrowserItemID);
59
60 // ============================================================================
61 // wxMacDataBrowserTableViewControl
62 // ============================================================================
63 //
64 // this is a wrapper class for the Mac OS X data browser environment,
65 // it covers all general data brower functionality,
66 //
67
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;
71
72 class wxMacDataBrowserTableViewControl : public wxMacControl
73 {
74 public:
75 //
76 // constructors / destructor
77 //
78 wxMacDataBrowserTableViewControl(wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
79 wxMacDataBrowserTableViewControl(void)
80 {
81 }
82
83 //
84 // callback handling
85 //
86 OSStatus SetCallbacks (DataBrowserCallbacks const* callbacks);
87 OSStatus SetCustomCallbacks(DataBrowserCustomCallbacks const* customCallbacks);
88
89 //
90 // header handling
91 //
92 OSStatus GetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc) const;
93
94 OSStatus SetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc);
95
96 //
97 // layout handling
98 //
99 OSStatus AutoSizeColumns();
100
101 OSStatus EnableCellSizeModification(bool enableHeight=true, bool enableWidth=true); // enables or disables the column width and row height modification (default: false)
102
103 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
104 OSStatus GetAttributes (OptionBits* attributes);
105 #endif
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;
113
114 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
115 OSStatus SetAttributes (OptionBits attributes);
116 #endif
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 SetIndent(float Indent);
124 OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height);
125 OSStatus SetScrollPosition( UInt32 top , UInt32 left );
126
127 //
128 // column handling
129 //
130 OSStatus GetColumnCount (UInt32* numColumns) const;
131 OSStatus GetColumnIndex (DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex* index) const; // returns for the passed property the corresponding column index
132 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
133 OSStatus GetPropertyFlags (DataBrowserPropertyID propertyID, DataBrowserPropertyFlags *flags ) const;
134 OSStatus GetPropertyID (DataBrowserItemDataRef itemData, DataBrowserPropertyID* propertyID); // returns for the passed item data reference the corresponding property ID
135 OSStatus GetPropertyID (DataBrowserTableViewColumnIndex index, DataBrowserPropertyID* propertyID); // returns for the passed column index the corresponding property ID
136
137 OSStatus IsUsedPropertyID(DataBrowserPropertyID propertyID) const; // checks if passed property id is used by the control; no error is returned if the id exists
138
139 OSStatus RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID);
140 OSStatus RemoveColumnByIndex (DataBrowserTableViewColumnIndex index);
141
142 OSStatus SetColumnIndex (DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex index);
143 OSStatus SetDisclosureColumn(DataBrowserPropertyID propertyID, Boolean expandableRows=false);
144 OSStatus SetPropertyFlags (DataBrowserPropertyID propertyID, DataBrowserPropertyFlags flags);
145
146 //
147 // item handling
148 //
149 OSStatus AddItem(DataBrowserItemID container, DataBrowserItemID const* itemID) // adds a single item
150 {
151 return this->AddItems(container,1,itemID,kDataBrowserItemNoProperty);
152 }
153 OSStatus AddItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty); // adds items to the data browser
154
155 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
156 OSStatus GetItemCount (ItemCount* numItems) const
157 {
158 return this->GetItemCount(kDataBrowserNoItem,true,kDataBrowserItemAnyState,numItems);
159 }
160 OSStatus GetItemCount (DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, ItemCount* numItems) const;
161 OSStatus GetItemID (DataBrowserTableViewRowIndex row, DataBrowserItemID* item) const;
162 OSStatus GetItems (DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, Handle items) const;
163 OSStatus GetItemRow (DataBrowserItemID item, DataBrowserTableViewRowIndex* row) const;
164
165 OSStatus IsUsedItemID(DataBrowserItemID itemID) const; // checks if the passed id is in use
166
167 OSStatus RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const;
168
169 OSStatus RemoveItem(DataBrowserItemID container, DataBrowserItemID const* itemID) // removes a single item
170 {
171 return this->RemoveItems(container,1,itemID,kDataBrowserItemNoProperty);
172 }
173 OSStatus RemoveItems(void) // removes all items
174 {
175 return this->RemoveItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty);
176 }
177 OSStatus RemoveItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty);
178
179 OSStatus UpdateItems(void) // updates all items
180 {
181 return this->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
182 }
183 OSStatus UpdateItems(DataBrowserItemID const* item) // updates all columns of item
184 {
185 return this->UpdateItems(kDataBrowserNoItem,1,item,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
186 }
187 OSStatus UpdateItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty, DataBrowserPropertyID propertyID) const;
188
189 //
190 // item selection
191 //
192 size_t GetSelectedItemIDs(wxArrayDataBrowserItemID& itemIDs) const; // returns the number of selected item and the item IDs in the array
193 OSStatus GetSelectionAnchor(DataBrowserItemID *first, DataBrowserItemID *last) const;
194 OSStatus GetSelectionFlags (DataBrowserSelectionFlags* flags) const;
195
196 bool IsItemSelected(DataBrowserItemID item) const;
197
198 OSStatus SetSelectionFlags(DataBrowserSelectionFlags flags);
199 OSStatus SetSelectedItems (UInt32 numItems, DataBrowserItemID const* itemIDs, DataBrowserSetOption operation);
200
201 //
202 // item sorting
203 //
204 OSStatus GetSortOrder (DataBrowserSortOrder* order) const;
205 OSStatus GetSortProperty(DataBrowserPropertyID* propertyID) const;
206
207 OSStatus Resort(DataBrowserItemID container=kDataBrowserNoItem, Boolean sortChildren=true);
208
209 OSStatus SetSortOrder (DataBrowserSortOrder order);
210 OSStatus SetSortProperty(DataBrowserPropertyID propertyID);
211
212 //
213 // container handling
214 //
215 OSStatus CloseContainer(DataBrowserItemID containerID);
216
217 OSStatus OpenContainer(DataBrowserItemID containerID);
218
219 protected :
220 //
221 // standard callback functions
222 //
223 static pascal Boolean DataBrowserCompareProc (ControlRef browser, DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty);
224 static pascal void DataBrowserGetContextualMenuProc(ControlRef browser, MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection);
225 static pascal OSStatus DataBrowserGetSetItemDataProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue);
226 static pascal void DataBrowserItemNotificationProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData);
227
228 virtual Boolean DataBrowserCompareProc (DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty) = 0;
229 virtual void DataBrowserGetContextualMenuProc(MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection) = 0;
230 virtual OSStatus DataBrowserGetSetItemDataProc (DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue) = 0;
231 virtual void DataBrowserItemNotificationProc (DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData) = 0;
232
233 //
234 // callback functions for customized types
235 //
236 static pascal void DataBrowserDrawItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice);
237 static pascal Boolean DataBrowserEditItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit);
238 static pascal Boolean DataBrowserHitTestProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect);
239 static pascal DataBrowserTrackingResult DataBrowserTrackingProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers);
240
241 virtual void DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice) = 0;
242 virtual Boolean DataBrowserEditItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit) = 0;
243 virtual Boolean DataBrowserHitTestProc (DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect) = 0;
244 virtual DataBrowserTrackingResult DataBrowserTrackingProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers) = 0;
245
246 private:
247 //
248 // wxWidget internal stuff
249 //
250 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl)
251 };
252
253 // ============================================================================
254 // wxMacDataBrowserListViewControl
255 // ============================================================================
256 //
257 // this class is a wrapper for a list view which incorporates all general
258 // data browser functionality of the inherited table view control class;
259 // the term list view is in this case Mac OS X specific and is not related
260 // to any wxWidget naming conventions
261 //
262 class wxMacDataBrowserListViewControl : public wxMacDataBrowserTableViewControl
263 {
264 public:
265 //
266 // constructors / destructor
267 //
268 wxMacDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style) : wxMacDataBrowserTableViewControl(peer,pos,size,style)
269 {
270 }
271
272 //
273 // column handling
274 //
275 OSStatus AddColumn(DataBrowserListViewColumnDesc *columnDesc, DataBrowserTableViewColumnIndex position);
276
277 protected:
278 private:
279 };
280
281
282 // ============================================================================
283 // wxMacDataViewDataBrowserListViewControl
284 // ============================================================================
285 //
286 // internal interface class between wxDataViewCtrl (wxWidget) and the data
287 // browser (Mac OS X)
288 //
289 class wxMacDataViewDataBrowserListViewControl : public wxMacDataBrowserListViewControl
290 {
291 public:
292 //
293 // constructors / destructor
294 //
295 wxMacDataViewDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style);
296
297 protected:
298 //
299 // standard callback functions (inherited from wxMacDataBrowserTableViewControl)
300 //
301 virtual Boolean DataBrowserCompareProc (DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty);
302 virtual void DataBrowserItemNotificationProc (DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData);
303 virtual void DataBrowserGetContextualMenuProc(MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection);
304 virtual OSStatus DataBrowserGetSetItemDataProc (DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemDataRef itemData, Boolean getValue);
305
306 //
307 // callback functions for customized types (inherited from wxMacDataBrowserTableViewControl)
308 //
309 virtual void DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice);
310 virtual Boolean DataBrowserEditItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit);
311 virtual Boolean DataBrowserHitTestProc (DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect);
312 virtual DataBrowserTrackingResult DataBrowserTrackingProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers);
313
314 private:
315 };
316
317 typedef wxMacDataViewDataBrowserListViewControl* wxMacDataViewDataBrowserListViewControlPointer;
318
319
320 #endif // WX_GUI
321
322 #endif // _WX_DATABROW_H_