]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/osx/carbon/dataview.h
adding events to single line textcontrols (password is not fully supported)
[wxWidgets.git] / include / wx / osx / carbon / dataview.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/osx/carbon/dataview.h
3// Purpose: wxDataViewCtrl native implementation header for carbon
4// Author:
5// Id: $Id: dataview.h 57374 2009-01-27
6// Copyright: (c) 2009
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_DATAVIEWCTRL_CARBON_H_
11#define _WX_DATAVIEWCTRL_CARBON_H_
12
13#include "wx/defs.h"
14
15#if wxUSE_GUI
16
17#include "wx/osx/core/dataview.h"
18#include "wx/osx/private.h"
19
20// ============================================================================
21// wxDataViewColumnNativeData
22// ============================================================================
23class wxDataViewColumnNativeData
24{
25public:
26//
27// constructors / destructor
28//
29 wxDataViewColumnNativeData(void)
30 {
31 }
32 wxDataViewColumnNativeData(DataBrowserPropertyID initPropertyID)
33 :m_PropertyID(initPropertyID)
34 {
35 }
36
37//
38// data access methods
39//
40 DataBrowserPropertyID GetPropertyID(void) const
41 {
42 return this->m_PropertyID;
43 }
44
45 void SetPropertyID(DataBrowserPropertyID newPropertyID)
46 {
47 this->m_PropertyID = newPropertyID;
48 }
49
50protected:
51private:
52//
53// variables
54//
55 DataBrowserPropertyID m_PropertyID; // each column is identified by its unique property ID (NOT by the column's index)
56};
57
58// ============================================================================
59// wxDataViewRendererNativeData
60// ============================================================================
61class wxDataViewRendererNativeData
62{
63public:
64//
65// constructors / destructor
66//
67 wxDataViewRendererNativeData(void)
68 {
69 }
70 wxDataViewRendererNativeData(DataBrowserPropertyType initPropertyType, DataBrowserItemDataRef initItemDataRef=NULL)
71 :m_ItemDataRef(initItemDataRef), m_PropertyType(initPropertyType)
72 {
73 }
74
75//
76// data access methods
77//
78 DataBrowserItemDataRef GetItemDataRef(void) const
79 {
80 return this->m_ItemDataRef;
81 }
82 DataBrowserPropertyType GetPropertyType(void) const
83 {
84 return this->m_PropertyType;
85 }
86
87 void SetItemDataRef(DataBrowserItemDataRef newItemDataRef)
88 {
89 this->m_ItemDataRef = newItemDataRef;
90 }
91 void SetPropertyType(DataBrowserPropertyType newPropertyType)
92 {
93 this->m_PropertyType = newPropertyType;
94 }
95
96protected:
97private:
98//
99// variables
100//
101 DataBrowserItemDataRef m_ItemDataRef;
102
103 DataBrowserPropertyType m_PropertyType;
104};
105
106// ============================================================================
107// wxMacDataBrowserTableViewControl
108// ============================================================================
109//
110// This is a wrapper class for the Mac OS X data browser environment.
111// It covers all data brower functionality for the native browser's list
112// and column style.
113//
114
115// data browser's property IDs have a reserved ID range from 0 - 1023
116// therefore, the first usable property ID is 'kMinPropertyID'
117DataBrowserPropertyID const kMinPropertyID = 1024;
118
119// array of data browser item IDs
120WX_DEFINE_ARRAY_SIZE_T(size_t,wxArrayDataBrowserItemID);
121
122class wxMacDataBrowserTableViewControl : public wxMacControl
123{
124public:
125//
126// constructors / destructor
127//
128 wxMacDataBrowserTableViewControl(wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
129 wxMacDataBrowserTableViewControl(void)
130 {
131 }
132
133//
134// callback handling
135//
136 OSStatus SetCallbacks (DataBrowserCallbacks const* callbacks);
137 OSStatus SetCustomCallbacks(DataBrowserCustomCallbacks const* customCallbacks);
138
139//
140// DnD handling
141//
142 OSStatus EnableAutomaticDragTracking(bool enable=true);
143
144//
145// header handling
146//
147 OSStatus GetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc) const;
148
149 OSStatus SetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc);
150
151//
152// layout handling
153//
154 OSStatus AutoSizeColumns();
155
156 OSStatus EnableCellSizeModification(bool enableHeight=true, bool enableWidth=true); // enables or disables the column width and row height modification (default: false)
157
158#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
159 OSStatus GetAttributes (OptionBits* attributes);
160#endif
161 OSStatus GetColumnWidth (DataBrowserPropertyID column, UInt16 *width ) const; // returns the column width in pixels
162 OSStatus GetDefaultColumnWidth(UInt16 *width ) const; // returns the default column width in pixels
163 OSStatus GetDefaultRowHeight (UInt16 * height ) const;
164 OSStatus GetHeaderButtonHeight(UInt16 *height );
165 OSStatus GetPartBounds (DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserPropertyPart part, Rect* bounds);
166 OSStatus GetRowHeight (DataBrowserItemID item , UInt16 *height) const;
167 OSStatus GetScrollPosition (UInt32* top, UInt32 *left) const;
168
169#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
170 OSStatus SetAttributes (OptionBits attributes);
171#endif
172 OSStatus SetColumnWidth(DataBrowserPropertyID column, UInt16 width); // sets the column width in pixels
173 OSStatus SetDefaultColumnWidth( UInt16 width );
174 OSStatus SetDefaultRowHeight( UInt16 height );
175 OSStatus SetHasScrollBars( bool horiz, bool vert );
176 OSStatus SetHeaderButtonHeight( UInt16 height );
177 OSStatus SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle);
178 OSStatus SetIndent(float Indent);
179 OSStatus SetItemRowHeight( DataBrowserItemID item , UInt16 height);
180 OSStatus SetScrollPosition( UInt32 top , UInt32 left );
181
182//
183// column handling
184//
185 OSStatus GetColumnCount (UInt32* numColumns) const;
186 OSStatus GetColumnIndex (DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex* index) const; // returns for the passed property the corresponding column index
187 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
188 OSStatus GetPropertyFlags (DataBrowserPropertyID propertyID, DataBrowserPropertyFlags *flags ) const;
189 OSStatus GetPropertyID (DataBrowserItemDataRef itemData, DataBrowserPropertyID* propertyID) const; // returns for the passed item data reference the corresponding property ID
190 OSStatus GetPropertyID (DataBrowserTableViewColumnIndex index, DataBrowserPropertyID* propertyID) const; // returns for the passed column index the corresponding property ID
191
192 OSStatus IsUsedPropertyID(DataBrowserPropertyID propertyID) const; // checks if passed property id is used by the control; no error is returned if the id exists
193
194 OSStatus RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID);
195 OSStatus RemoveColumnByIndex (DataBrowserTableViewColumnIndex index);
196
197 OSStatus SetColumnIndex (DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex index);
198 OSStatus SetDisclosureColumn(DataBrowserPropertyID propertyID, Boolean expandableRows=false);
199 OSStatus SetPropertyFlags (DataBrowserPropertyID propertyID, DataBrowserPropertyFlags flags);
200
201//
202// item handling
203//
204 OSStatus AddItem(DataBrowserItemID container, DataBrowserItemID const* itemID) // adds a single item
205 {
206 return this->AddItems(container,1,itemID,kDataBrowserItemNoProperty);
207 }
208 OSStatus AddItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty); // adds items to the data browser
209
210 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
211 OSStatus GetItemCount (ItemCount* numItems) const
212 {
213 return this->GetItemCount(kDataBrowserNoItem,true,kDataBrowserItemAnyState,numItems);
214 }
215 OSStatus GetItemCount (DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, ItemCount* numItems) const;
216 OSStatus GetItemID (DataBrowserTableViewRowIndex row, DataBrowserItemID* item) const;
217 OSStatus GetItems (DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, Handle items) const;
218 OSStatus GetItemRow (DataBrowserItemID item, DataBrowserTableViewRowIndex* row) const;
219 OSStatus GetItemState (DataBrowserItemID item, DataBrowserItemState* state) const;
220
221 OSStatus IsUsedItemID(DataBrowserItemID itemID) const; // checks if the passed id is in use
222
223 OSStatus RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const;
224
225 OSStatus RemoveItem(DataBrowserItemID container, DataBrowserItemID const* itemID) // removes a single item
226 {
227 return this->RemoveItems(container,1,itemID,kDataBrowserItemNoProperty);
228 }
229 OSStatus RemoveItems(void) // removes all items
230 {
231 return this->RemoveItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty);
232 }
233 OSStatus RemoveItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty);
234
235 OSStatus UpdateItem(DataBrowserItemID container, DataBrowserItemID const* item) // updates all columns of the passed item
236 {
237 return this->UpdateItems(container,1,item,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
238 }
239 OSStatus UpdateItems(void) // updates all items
240 {
241 return this->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
242 }
243 OSStatus UpdateItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty, DataBrowserPropertyID propertyID) const;
244
245//
246// item selection
247//
248 size_t GetSelectedItemIDs(wxArrayDataBrowserItemID& itemIDs) const; // returns the number of selected item and the item IDs in the array
249 OSStatus GetSelectionAnchor(DataBrowserItemID *first, DataBrowserItemID *last) const;
250 OSStatus GetSelectionFlags (DataBrowserSelectionFlags* flags) const;
251
252 bool IsItemSelected(DataBrowserItemID item) const;
253
254 OSStatus SetSelectionFlags(DataBrowserSelectionFlags flags);
255 OSStatus SetSelectedItems (UInt32 numItems, DataBrowserItemID const* itemIDs, DataBrowserSetOption operation);
256
257//
258// item sorting
259//
260 OSStatus GetSortOrder (DataBrowserSortOrder* order) const;
261 OSStatus GetSortProperty(DataBrowserPropertyID* propertyID) const;
262
263 OSStatus Resort(DataBrowserItemID container=kDataBrowserNoItem, Boolean sortChildren=true);
264
265 OSStatus SetSortOrder (DataBrowserSortOrder order);
266 OSStatus SetSortProperty(DataBrowserPropertyID propertyID);
267
268//
269// container handling
270//
271 OSStatus CloseContainer(DataBrowserItemID containerID);
272
273 OSStatus OpenContainer(DataBrowserItemID containerID);
274
275protected :
276//
277// standard callback functions
278//
279 static pascal Boolean DataBrowserCompareProc (ControlRef browser, DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty);
280 static pascal void DataBrowserGetContextualMenuProc(ControlRef browser, MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection);
281 static pascal OSStatus DataBrowserGetSetItemDataProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue);
282 static pascal void DataBrowserItemNotificationProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData);
283
284 virtual Boolean DataBrowserCompareProc (DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty) = 0;
285 virtual void DataBrowserGetContextualMenuProc(MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection) = 0;
286 virtual OSStatus DataBrowserGetSetItemDataProc (DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue) = 0;
287 virtual void DataBrowserItemNotificationProc (DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData) = 0;
288
289//
290// callback functions for customized types
291//
292 static pascal void DataBrowserDrawItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice);
293 static pascal Boolean DataBrowserEditItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit);
294 static pascal Boolean DataBrowserHitTestProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect);
295 static pascal DataBrowserTrackingResult DataBrowserTrackingProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers);
296
297 virtual void DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice) = 0;
298 virtual Boolean DataBrowserEditItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit) = 0;
299 virtual Boolean DataBrowserHitTestProc (DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect) = 0;
300 virtual DataBrowserTrackingResult DataBrowserTrackingProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers) = 0;
301
302//
303// callback functions for drag & drop
304///
305 static pascal Boolean DataBrowserAcceptDragProc (ControlRef browser, DragReference dragRef, DataBrowserItemID itemID);
306 static pascal Boolean DataBrowserAddDragItemProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef);
307 static pascal Boolean DataBrowserReceiveDragProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID);
308
309 virtual Boolean DataBrowserAcceptDragProc (DragReference dragRef, DataBrowserItemID itemID) = 0;
310 virtual Boolean DataBrowserAddDragItemProc(DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef) = 0;
311 virtual Boolean DataBrowserReceiveDragProc(DragReference dragRef, DataBrowserItemID itemID) = 0;
312
313private:
314//
315// wxWidget internal stuff
316//
317 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl)
318};
319
320// ============================================================================
321// wxMacDataBrowserListViewControl
322// ============================================================================
323//
324// This class is a wrapper for the native browser's list view style. It expands
325// the inherited functionality of the table view control class.
326// The term list view is in this case Mac OS X specific and is not related
327// to any wxWidget naming conventions.
328//
329class wxMacDataBrowserListViewControl : public wxMacDataBrowserTableViewControl
330{
331public:
332//
333// constructors / destructor
334//
335 wxMacDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style) : wxMacDataBrowserTableViewControl(peer,pos,size,style)
336 {
337 }
338
339//
340// column handling
341//
342 OSStatus AddColumn(DataBrowserListViewColumnDesc *columnDesc, DataBrowserTableViewColumnIndex position);
343
344protected:
345private:
346};
347
348
349// ============================================================================
350// wxMacDataViewDataBrowserListViewControl
351// ============================================================================
352//
353// This is the internal interface class between wxDataViewCtrl (wxWidget) and
354// the native data browser (Mac OS X carbon).
355//
356class wxMacDataViewDataBrowserListViewControl : public wxMacDataBrowserListViewControl, public wxDataViewWidgetImpl
357{
358public:
359//
360// constructors / destructor
361//
362 wxMacDataViewDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style);
363
364 //
365 // column related methods (inherited from wxDataViewWidgetImpl)
366 //
367 virtual bool ClearColumns (void);
368 virtual bool DeleteColumn (wxDataViewColumn* columnPtr);
369 virtual void DoSetExpanderColumn(wxDataViewColumn const* columnPtr);
370 virtual wxDataViewColumn* GetColumn (unsigned int pos) const;
371 virtual int GetColumnPosition (wxDataViewColumn const* columnPtr) const;
372 virtual bool InsertColumn (unsigned int pos, wxDataViewColumn* columnPtr);
373
374 //
375 // item related methods (inherited from wxDataViewWidgetImpl)
376 //
377 virtual bool Add (wxDataViewItem const& parent, wxDataViewItem const& item);
378 virtual bool Add (wxDataViewItem const& parent, wxDataViewItemArray const& items);
379 virtual void Collapse (wxDataViewItem const& item);
380 virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
381 virtual void Expand (wxDataViewItem const& item);
382 virtual unsigned int GetCount (void) const;
383 virtual wxRect GetRectangle (wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
384 virtual bool IsExpanded (wxDataViewItem const& item) const;
385 virtual bool Reload (void);
386 virtual bool Remove (wxDataViewItem const& parent, wxDataViewItem const& item);
387 virtual bool Remove (wxDataViewItem const& parent, wxDataViewItemArray const& item);
388 virtual bool Update (wxDataViewColumn const* columnPtr);
389 virtual bool Update (wxDataViewItem const& parent, wxDataViewItem const& item);
390 virtual bool Update (wxDataViewItem const& parent, wxDataViewItemArray const& items);
391
392 //
393 // model related methods
394 //
395 virtual bool AssociateModel(wxDataViewModel* model);
396
397 //
398 // selection related methods (inherited from wxDataViewWidgetImpl)
399 //
400 virtual int GetSelections(wxDataViewItemArray& sel) const;
401 virtual bool IsSelected (wxDataViewItem const& item) const;
402 virtual void Select (wxDataViewItem const& item);
403 virtual void SelectAll (void);
404 virtual void Unselect (wxDataViewItem const& item);
405 virtual void UnselectAll (void);
406
407 //
408 // sorting related methods
409 //
410 virtual wxDataViewColumn* GetSortingColumn (void) const;
411 virtual void Resort (void);
412
413 //
414 // other methods (inherited from wxDataViewWidgetImpl)
415 //
416 virtual void DoSetIndent (int indent);
417 virtual void HitTest (wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const;
418 virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height);
419 virtual void OnSize (void);
420
421 //
422 // other methods
423 //
424 wxDataViewCtrl* GetDataViewCtrl(void) const
425 {
426 return dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
427 }
428
429protected:
430//
431// standard callback functions (inherited from wxMacDataBrowserTableViewControl)
432//
433 virtual Boolean DataBrowserCompareProc (DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty);
434 virtual void DataBrowserItemNotificationProc (DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData);
435 virtual void DataBrowserGetContextualMenuProc(MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection);
436 virtual OSStatus DataBrowserGetSetItemDataProc (DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemDataRef itemData, Boolean getValue);
437
438//
439// callback functions for customized types (inherited from wxMacDataBrowserTableViewControl)
440//
441 virtual void DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice);
442 virtual Boolean DataBrowserEditItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit);
443 virtual Boolean DataBrowserHitTestProc (DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect);
444 virtual DataBrowserTrackingResult DataBrowserTrackingProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers);
445
446//
447// callback functions for drag & drop (inherited from wxMacDataBrowserTableViewControl)
448//
449 virtual Boolean DataBrowserAcceptDragProc (DragReference dragRef, DataBrowserItemID itemID);
450 virtual Boolean DataBrowserAddDragItemProc(DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef);
451 virtual Boolean DataBrowserReceiveDragProc(DragReference dragRef, DataBrowserItemID itemID);
452
453//
454// drag & drop helper methods
455//
456 wxDataFormat GetDnDDataFormat(wxDataObjectComposite* dataObjects);
457 wxDataObjectComposite* GetDnDDataObjects(DragReference dragRef, ItemReference itemRef) const; // create the data objects from the native dragged object
458
459//
460// other methods
461//
462 wxDataViewColumn* GetColumnPtr(DataBrowserPropertyID propertyID) const; // returns for the passed property the corresponding pointer to a column; NULL is returned if not found
463
464private:
465};
466
467typedef wxMacDataViewDataBrowserListViewControl* wxMacDataViewDataBrowserListViewControlPointer;
468
469#endif // WX_GUI
470#endif // _WX_MACCARBONDATAVIEWCTRL_H_