/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/carbon/dataview.h
-// Purpose: wxDataViewCtrl native implementation header
-// Author:
-// Id: $Id$
-// Copyright: (c) 2007
+// Name: wx/osx/carbon/dataview.h
+// Purpose: wxDataViewCtrl native implementation header for carbon
+// Author:
+// Id: $Id: dataview.h 57374 2009-01-27
+// Copyright: (c) 2009
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_MACCARBONDATAVIEWCTRL_H_
-#define _WX_MACCARBONDATAVIEWCTRL_H_
+#ifndef _WX_DATAVIEWCTRL_CARBON_H_
+#define _WX_DATAVIEWCTRL_CARBON_H_
-// --------------------------------------------------------
-// Type definitions to mask native types
-// --------------------------------------------------------
+#include "wx/defs.h"
-typedef void* WXDataBrowserItemDataRef;
-typedef unsigned long WXDataBrowserPropertyType;
-typedef wxUint32 WXDataBrowserPropertyID;
+#if wxUSE_GUI
-// ---------------------------------------------------------
-// wxDataViewRenderer
-// ---------------------------------------------------------
+#include "wx/osx/core/dataview.h"
+#include "wx/osx/private.h"
-class WXDLLIMPEXP_ADV wxDataViewRenderer : public wxDataViewRendererBase
+// ============================================================================
+// wxDataViewColumnNativeData
+// ============================================================================
+class wxDataViewColumnNativeData
{
public:
//
// constructors / destructor
//
- wxDataViewRenderer(wxString const& varianttype, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
+ wxDataViewColumnNativeData(void)
+ {
+ }
+ wxDataViewColumnNativeData(DataBrowserPropertyID initPropertyID)
+ :m_PropertyID(initPropertyID)
+ {
+ }
//
-// inherited methods from wxDataViewRendererBase
+// data access methods
//
- virtual int GetAlignment() const
+ DataBrowserPropertyID GetPropertyID(void) const
{
- return this->m_alignment;
+ return this->m_PropertyID;
}
- virtual wxDataViewCellMode GetMode() const
- {
- return this->m_mode;
- }
- virtual bool GetValue(wxVariant& value) const
+
+ void SetPropertyID(DataBrowserPropertyID newPropertyID)
{
- value = this->m_value;
- return true;
+ this->m_PropertyID = newPropertyID;
}
- virtual void SetAlignment(int WXUNUSED(align)) // is always identical to the header alignment
+protected:
+private:
+//
+// variables
+//
+ DataBrowserPropertyID m_PropertyID; // each column is identified by its unique property ID (NOT by the column's index)
+};
+
+// ============================================================================
+// wxDataViewRendererNativeData
+// ============================================================================
+class wxDataViewRendererNativeData
+{
+public:
+//
+// constructors / destructor
+//
+ wxDataViewRendererNativeData(void)
{
}
- virtual void SetMode(wxDataViewCellMode mode);
- virtual bool SetValue(wxVariant const& newValue)
+ wxDataViewRendererNativeData(DataBrowserPropertyType initPropertyType, DataBrowserItemDataRef initItemDataRef=NULL)
+ :m_ItemDataRef(initItemDataRef), m_PropertyType(initPropertyType)
{
- this->m_value = newValue;
- return true;
}
//
-// implementation
+// data access methods
//
- WXDataBrowserItemDataRef GetDataReference() const
+ DataBrowserItemDataRef GetItemDataRef(void) const
{
- return this->m_dataReference;
+ return this->m_ItemDataRef;
}
- wxVariant const& GetValue() const
+ DataBrowserPropertyType GetPropertyType(void) const
{
- return this->m_value;
+ return this->m_PropertyType;
}
- virtual WXDataBrowserPropertyType GetPropertyType() const = 0;
-
- virtual bool Render() = 0; // a call to the appropriate data browser function filling the data reference with the stored datum;
- // returns 'true' if the data value could be rendered, 'false' otherwise
-
- void SetDataReference(WXDataBrowserItemDataRef const& newDataReference)
+ void SetItemDataRef(DataBrowserItemDataRef newItemDataRef)
+ {
+ this->m_ItemDataRef = newItemDataRef;
+ }
+ void SetPropertyType(DataBrowserPropertyType newPropertyType)
{
- this->m_dataReference = newDataReference;
+ this->m_PropertyType = newPropertyType;
}
+protected:
private:
//
// variables
//
- WXDataBrowserItemDataRef m_dataReference; // data reference of the data browser; the data will be assigned to this reference during rendering
-
- int m_alignment; // contains the alignment flags
-
- wxDataViewCellMode m_mode; // storing the mode that determines how the cell is going to be shown
+ DataBrowserItemDataRef m_ItemDataRef;
- wxVariant m_value; // value that is going to be rendered
+ DataBrowserPropertyType m_PropertyType;
+};
+// ============================================================================
+// wxMacDataBrowserTableViewControl
+// ============================================================================
//
-// wxWidget internal stuff
+// This is a wrapper class for the Mac OS X data browser environment.
+// It covers all data brower functionality for the native browser's list
+// and column style.
//
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
-};
-// ---------------------------------------------------------
-// wxDataViewCustomRenderer
-// ---------------------------------------------------------
+// data browser's property IDs have a reserved ID range from 0 - 1023
+// therefore, the first usable property ID is 'kMinPropertyID'
+DataBrowserPropertyID const kMinPropertyID = 1024;
-class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
+// array of data browser item IDs
+WX_DEFINE_ARRAY_SIZE_T(size_t,wxArrayDataBrowserItemID);
+
+class wxMacDataBrowserTableViewControl : public wxMacControl
{
public:
//
// constructors / destructor
//
- wxDataViewCustomRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
- virtual ~wxDataViewCustomRenderer();
-
- void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
+ wxMacDataBrowserTableViewControl(wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
+ wxMacDataBrowserTableViewControl(void)
+ {
+ }
+ ~wxMacDataBrowserTableViewControl(void);
//
-// methods handling render space
-//
- virtual wxSize GetSize() const = 0;
-
+// callback handling
//
-// methods handling user actions
-//
- virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
+ OSStatus SetCallbacks (DataBrowserCallbacks const* callbacks);
+ OSStatus SetCustomCallbacks(DataBrowserCustomCallbacks const* customCallbacks);
- virtual bool Activate( wxRect WXUNUSED(cell),
- wxDataViewModel *WXUNUSED(model),
- const wxDataViewItem & WXUNUSED(item),
- unsigned int WXUNUSED(col) )
- { return false; }
-
- virtual bool LeftClick( wxPoint WXUNUSED(cursor),
- wxRect WXUNUSED(cell),
- wxDataViewModel *WXUNUSED(model),
- const wxDataViewItem & WXUNUSED(item),
- unsigned int WXUNUSED(col) )
- { return false; }
-
- virtual bool StartDrag( wxPoint WXUNUSED(cursor),
- wxRect WXUNUSED(cell),
- wxDataViewModel *WXUNUSED(model),
- const wxDataViewItem & WXUNUSED(item),
- unsigned int WXUNUSED(col) )
- { return false; }
-
//
-// device context handling
+// DnD handling
//
- virtual wxDC* GetDC(); // creates a device context and keeps it
+ OSStatus EnableAutomaticDragTracking(bool enable=true);
//
-// implementation
+// header handling
//
- virtual bool Render(); // declared in wxDataViewRenderer but will not be used here, therefore calling this function will
- // return 'true' without having done anything
+ OSStatus GetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc) const;
- virtual WXDataBrowserPropertyType GetPropertyType() const;
+ OSStatus SetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc);
- void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer
-
-protected:
-private:
//
-// variables
+// layout handling
//
- wxControl* m_editorCtrlPtr; // pointer to an in-place editor control
+ OSStatus AutoSizeColumns();
- wxDC* m_DCPtr;
+ OSStatus EnableCellSizeModification(bool enableHeight=true, bool enableWidth=true); // enables or disables the column width and row height modification (default: false)
-//
-// wxWidget internal stuff
-//
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
-};
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+ OSStatus GetAttributes (OptionBits* attributes);
+#endif
+ OSStatus GetColumnWidth (DataBrowserPropertyID column, UInt16 *width ) const; // returns the column width in pixels
+ OSStatus GetDefaultColumnWidth(UInt16 *width ) const; // returns the default column width in pixels
+ OSStatus GetDefaultRowHeight (UInt16 * height ) const;
+ OSStatus GetHeaderButtonHeight(UInt16 *height );
+ OSStatus GetPartBounds (DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserPropertyPart part, Rect* bounds);
+ OSStatus GetRowHeight (DataBrowserItemID item , UInt16 *height) const;
+ OSStatus GetScrollPosition (UInt32* top, UInt32 *left) const;
-// ---------------------------------------------------------
-// wxDataViewTextRenderer
-// ---------------------------------------------------------
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+ OSStatus SetAttributes (OptionBits attributes);
+#endif
+ OSStatus SetColumnWidth(DataBrowserPropertyID column, UInt16 width); // sets the column width in pixels
+ OSStatus SetDefaultColumnWidth( UInt16 width );
+ OSStatus SetDefaultRowHeight( UInt16 height );
+ OSStatus SetHasScrollBars( bool horiz, bool vert );
+ OSStatus SetHeaderButtonHeight( UInt16 height );
+ OSStatus SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle);
+ OSStatus SetIndent(float Indent);
+ OSStatus SetItemRowHeight( DataBrowserItemID item , UInt16 height);
+ OSStatus SetScrollPosition( UInt32 top , UInt32 left );
-class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
-{
-public:
//
-// constructors / destructor
+// column handling
//
- wxDataViewTextRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
+ OSStatus GetColumnCount (UInt32* numColumns) const;
+ OSStatus GetColumnIndex (DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex* index) const; // returns for the passed property the corresponding column index
+ 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
+ OSStatus GetPropertyFlags (DataBrowserPropertyID propertyID, DataBrowserPropertyFlags *flags ) const;
+ OSStatus GetPropertyID (DataBrowserItemDataRef itemData, DataBrowserPropertyID* propertyID) const; // returns for the passed item data reference the corresponding property ID
+ OSStatus GetPropertyID (DataBrowserTableViewColumnIndex index, DataBrowserPropertyID* propertyID) const; // returns for the passed column index the corresponding property ID
+
+ OSStatus IsUsedPropertyID(DataBrowserPropertyID propertyID) const; // checks if passed property id is used by the control; no error is returned if the id exists
-//
-// inherited functions from wxDataViewRenderer
-//
- virtual bool Render();
+ OSStatus RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID);
+ OSStatus RemoveColumnByIndex (DataBrowserTableViewColumnIndex index);
+
+ OSStatus SetColumnIndex (DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex index);
+ OSStatus SetDisclosureColumn(DataBrowserPropertyID propertyID, Boolean expandableRows=false);
+ OSStatus SetPropertyFlags (DataBrowserPropertyID propertyID, DataBrowserPropertyFlags flags);
//
-// implementation
+// item handling
//
- virtual WXDataBrowserPropertyType GetPropertyType() const;
+ OSStatus AddItem(DataBrowserItemID container, DataBrowserItemID const* itemID) // adds a single item
+ {
+ return this->AddItems(container,1,itemID,kDataBrowserItemNoProperty);
+ }
+ OSStatus AddItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty); // adds items to the data browser
-protected:
-private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
-};
+ 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
+ OSStatus GetItemCount (ItemCount* numItems) const
+ {
+ return this->GetItemCount(kDataBrowserNoItem,true,kDataBrowserItemAnyState,numItems);
+ }
+ OSStatus GetItemCount (DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, ItemCount* numItems) const;
+ OSStatus GetItemID (DataBrowserTableViewRowIndex row, DataBrowserItemID* item) const;
+ OSStatus GetItems (DataBrowserItemID container, Boolean recurse, DataBrowserItemState state, Handle items) const;
+ OSStatus GetItemRow (DataBrowserItemID item, DataBrowserTableViewRowIndex* row) const;
+ OSStatus GetItemState (DataBrowserItemID item, DataBrowserItemState* state) const;
-// ---------------------------------------------------------
-// wxDataViewTextRendererAttr
-// ---------------------------------------------------------
+ OSStatus IsUsedItemID(DataBrowserItemID itemID) const; // checks if the passed id is in use
-class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer
-{
-public:
-//
-// constructors / destructor
-//
- wxDataViewTextRendererAttr(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
+ OSStatus RevealItem(DataBrowserItemID item, DataBrowserPropertyID propertyID, DataBrowserRevealOptions options) const;
-private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr)
-};
+ OSStatus RemoveItem(DataBrowserItemID container, DataBrowserItemID const* itemID) // removes a single item
+ {
+ return this->RemoveItems(container,1,itemID,kDataBrowserItemNoProperty);
+ }
+ OSStatus RemoveItems(void) // removes all items
+ {
+ return this->RemoveItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty);
+ }
+ OSStatus RemoveItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty);
-// ---------------------------------------------------------
-// wxDataViewBitmapRenderer
-// ---------------------------------------------------------
+ OSStatus UpdateItem(DataBrowserItemID container, DataBrowserItemID const* item) // updates all columns of the passed item
+ {
+ return this->UpdateItems(container,1,item,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
+ }
+ OSStatus UpdateItems(void) // updates all items
+ {
+ return this->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
+ }
+ OSStatus UpdateItems(DataBrowserItemID container, UInt32 numItems, DataBrowserItemID const* items, DataBrowserPropertyID preSortProperty, DataBrowserPropertyID propertyID) const;
-class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
-{
-public:
//
-// constructors / destructor
+// item selection
//
- wxDataViewBitmapRenderer(wxString const& varianttype=wxT("wxBitmap"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
+ size_t GetSelectedItemIDs(wxArrayDataBrowserItemID& itemIDs) const; // returns the number of selected item and the item IDs in the array
+ OSStatus GetSelectionAnchor(DataBrowserItemID *first, DataBrowserItemID *last) const;
+ OSStatus GetSelectionFlags (DataBrowserSelectionFlags* flags) const;
-//
-// inherited functions from wxDataViewRenderer
-//
- virtual bool Render();
+ bool IsItemSelected(DataBrowserItemID item) const;
+
+ OSStatus SetSelectionFlags(DataBrowserSelectionFlags flags);
+ OSStatus SetSelectedItems (UInt32 numItems, DataBrowserItemID const* itemIDs, DataBrowserSetOption operation);
//
-// implementation
+// item sorting
//
- virtual WXDataBrowserPropertyType GetPropertyType() const;
+ OSStatus GetSortOrder (DataBrowserSortOrder* order) const;
+ OSStatus GetSortProperty(DataBrowserPropertyID* propertyID) const;
-protected:
-private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
-};
+ OSStatus Resort(DataBrowserItemID container=kDataBrowserNoItem, Boolean sortChildren=true);
-// ---------------------------------------------------------
-// wxDataViewToggleRenderer
-// ---------------------------------------------------------
+ OSStatus SetSortOrder (DataBrowserSortOrder order);
+ OSStatus SetSortProperty(DataBrowserPropertyID propertyID);
-class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
-{
-public:
- wxDataViewIconTextRenderer(wxString const& varianttype = wxT("wxDataViewIconText"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
//
-// inherited functions from wxDataViewRenderer
+// container handling
//
- virtual bool Render();
+ OSStatus CloseContainer(DataBrowserItemID containerID);
-//
-// implementation
-//
- virtual WXDataBrowserPropertyType GetPropertyType() const;
-
-protected:
-private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewToggleRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
-{
-public:
- wxDataViewToggleRenderer(wxString const& varianttype = wxT("bool"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
+ OSStatus OpenContainer(DataBrowserItemID containerID);
+protected :
//
-// inherited functions from wxDataViewRenderer
+// standard callback functions
//
- virtual bool Render();
+ static pascal Boolean DataBrowserCompareProc (ControlRef browser, DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty);
+ static pascal void DataBrowserGetContextualMenuProc(ControlRef browser, MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection);
+ static pascal OSStatus DataBrowserGetSetItemDataProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue);
+ static pascal void DataBrowserItemNotificationProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData);
+
+ virtual Boolean DataBrowserCompareProc (DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty) = 0;
+ virtual void DataBrowserGetContextualMenuProc(MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection) = 0;
+ virtual OSStatus DataBrowserGetSetItemDataProc (DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue) = 0;
+ virtual void DataBrowserItemNotificationProc (DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData) = 0;
//
-// implementation
+// callback functions for customized types
//
- virtual WXDataBrowserPropertyType GetPropertyType() const;
+ static pascal void DataBrowserDrawItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice);
+ static pascal Boolean DataBrowserEditItemProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit);
+ static pascal Boolean DataBrowserHitTestProc (ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect);
+ static pascal DataBrowserTrackingResult DataBrowserTrackingProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers);
-protected:
-private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
-};
+ virtual void DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice) = 0;
+ virtual Boolean DataBrowserEditItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit) = 0;
+ virtual Boolean DataBrowserHitTestProc (DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect) = 0;
+ virtual DataBrowserTrackingResult DataBrowserTrackingProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers) = 0;
-// ---------------------------------------------------------
-// wxDataViewProgressRenderer
-// ---------------------------------------------------------
+//
+// callback functions for drag & drop
+///
+ static pascal Boolean DataBrowserAcceptDragProc (ControlRef browser, DragReference dragRef, DataBrowserItemID itemID);
+ static pascal Boolean DataBrowserAddDragItemProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef);
+ static pascal Boolean DataBrowserReceiveDragProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID);
-class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
-{
-public:
- wxDataViewProgressRenderer(wxString const& label = wxEmptyString, wxString const& varianttype=wxT("long"),
- wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
+ virtual Boolean DataBrowserAcceptDragProc (DragReference dragRef, DataBrowserItemID itemID) = 0;
+ virtual Boolean DataBrowserAddDragItemProc(DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef) = 0;
+ virtual Boolean DataBrowserReceiveDragProc(DragReference dragRef, DataBrowserItemID itemID) = 0;
//
-// inherited functions from wxDataViewRenderer
-//
- virtual bool Render();
-
+// event handler for hit testing
+///
+ void* m_macDataViewCtrlEventHandler;
+
+private:
//
-// implementation
+// wxWidget internal stuff
//
- virtual WXDataBrowserPropertyType GetPropertyType() const;
-
-protected:
-private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
+ DECLARE_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl)
};
-// ---------------------------------------------------------
-// wxDataViewDateRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
+// ============================================================================
+// wxMacDataBrowserListViewControl
+// ============================================================================
+//
+// This class is a wrapper for the native browser's list view style. It expands
+// the inherited functionality of the table view control class.
+// The term list view is in this case Mac OS X specific and is not related
+// to any wxWidget naming conventions.
+//
+class wxMacDataBrowserListViewControl : public wxMacDataBrowserTableViewControl
{
public:
- wxDataViewDateRenderer(wxString const& varianttype=wxT("datetime"), wxDataViewCellMode mode=wxDATAVIEW_CELL_ACTIVATABLE, int align=wxDVR_DEFAULT_ALIGNMENT);
-
//
-// inherited functions from wxDataViewRenderer
+// constructors / destructor
//
- virtual bool Render();
+ wxMacDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style) : wxMacDataBrowserTableViewControl(peer,pos,size,style)
+ {
+ }
//
-// implementation
+// column handling
//
- virtual WXDataBrowserPropertyType GetPropertyType() const;
+ OSStatus AddColumn(DataBrowserListViewColumnDesc *columnDesc, DataBrowserTableViewColumnIndex position);
protected:
private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
};
-// ---------------------------------------------------------
-// wxDataViewColumn
-// ---------------------------------------------------------
-class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
+// ============================================================================
+// wxMacDataViewDataBrowserListViewControl
+// ============================================================================
+//
+// This is the internal interface class between wxDataViewCtrl (wxWidget) and
+// the native data browser (Mac OS X carbon).
+//
+class wxMacDataViewDataBrowserListViewControl : public wxMacDataBrowserListViewControl, public wxDataViewWidgetImpl
{
public:
//
// constructors / destructor
//
- wxDataViewColumn(wxString const& title, wxDataViewRenderer* renderer, unsigned int model_column, int width=80, wxAlignment align=wxALIGN_CENTER,
- int flags=wxDATAVIEW_COL_RESIZABLE);
- wxDataViewColumn(wxBitmap const& bitmap, wxDataViewRenderer* renderer, unsigned int model_column, int width=80, wxAlignment align=wxALIGN_CENTER,
- int flags=wxDATAVIEW_COL_RESIZABLE);
-
-//
-// inherited methods from wxDataViewColumnBase
-//
- virtual wxAlignment GetAlignment() const
- {
- return this->m_alignment;
- }
- virtual int GetFlags() const
- {
- return this->m_flags;
- }
- virtual int GetMaxWidth() const
- {
- return this->m_maxWidth;
- }
- virtual int GetMinWidth() const
- {
- return this->m_minWidth;
- }
- virtual wxString GetTitle() const
- {
- return this->m_title;
- }
- virtual int GetWidth() const
- {
- return this->m_width;
- }
-
- virtual bool IsHidden() const
- {
- return false; // not implemented
- }
- virtual bool IsSortOrderAscending() const
- {
- return this->m_ascending;
- }
+ wxMacDataViewDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style);
+
+ //
+ // column related methods (inherited from wxDataViewWidgetImpl)
+ //
+ virtual bool ClearColumns (void);
+ virtual bool DeleteColumn (wxDataViewColumn* columnPtr);
+ virtual void DoSetExpanderColumn(wxDataViewColumn const* columnPtr);
+ virtual wxDataViewColumn* GetColumn (unsigned int pos) const;
+ virtual int GetColumnPosition (wxDataViewColumn const* columnPtr) const;
+ virtual bool InsertColumn (unsigned int pos, wxDataViewColumn* columnPtr);
+
+ //
+ // item related methods (inherited from wxDataViewWidgetImpl)
+ //
+ virtual bool Add (wxDataViewItem const& parent, wxDataViewItem const& item);
+ virtual bool Add (wxDataViewItem const& parent, wxDataViewItemArray const& items);
+ virtual void Collapse (wxDataViewItem const& item);
+ virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
+ virtual void Expand (wxDataViewItem const& item);
+ virtual unsigned int GetCount (void) const;
+ virtual wxRect GetRectangle (wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
+ virtual bool IsExpanded (wxDataViewItem const& item) const;
+ virtual bool Reload (void);
+ virtual bool Remove (wxDataViewItem const& parent, wxDataViewItem const& item);
+ virtual bool Remove (wxDataViewItem const& parent, wxDataViewItemArray const& item);
+ virtual bool Update (wxDataViewColumn const* columnPtr);
+ virtual bool Update (wxDataViewItem const& parent, wxDataViewItem const& item);
+ virtual bool Update (wxDataViewItem const& parent, wxDataViewItemArray const& items);
+
+ //
+ // model related methods
+ //
+ virtual bool AssociateModel(wxDataViewModel* model);
- virtual void SetAlignment(wxAlignment align);
- virtual void SetBitmap (wxBitmap const& bitmap);
- virtual void SetFlags (int flags);
- virtual void SetHidden(bool WXUNUSED(hidden))
- {
+ //
+ // selection related methods (inherited from wxDataViewWidgetImpl)
+ //
+ virtual int GetSelections(wxDataViewItemArray& sel) const;
+ virtual bool IsSelected (wxDataViewItem const& item) const;
+ virtual void Select (wxDataViewItem const& item);
+ virtual void SelectAll (void);
+ virtual void Unselect (wxDataViewItem const& item);
+ virtual void UnselectAll (void);
+
+ //
+ // sorting related methods
+ //
+ virtual wxDataViewColumn* GetSortingColumn (void) const;
+ virtual void Resort (void);
+
+ //
+ // other methods (inherited from wxDataViewWidgetImpl)
+ //
+ virtual void DoSetIndent (int indent);
+ virtual void HitTest (wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const;
+ virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height);
+ virtual void OnSize (void);
+
+ //
+ // other methods
+ //
+ wxDataViewCtrl* GetDataViewCtrl(void) const
+ {
+ return dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
}
- virtual void SetMaxWidth (int maxWidth);
- virtual void SetMinWidth (int minWidth);
- virtual void SetReorderable(bool reorderable);
- virtual void SetResizeable (bool resizeable);
- virtual void SetSortable (bool sortable);
- virtual void SetSortOrder (bool ascending);
- virtual void SetTitle (wxString const& title);
- virtual void SetWidth (int width);
+protected:
//
-// implementation
+// standard callback functions (inherited from wxMacDataBrowserTableViewControl)
//
- WXDataBrowserPropertyID GetPropertyID() const
- {
- return this->m_propertyID;
- }
-
- void SetPropertyID(WXDataBrowserPropertyID newID)
- {
- this->m_propertyID = newID;
- }
- void SetWidthVariable(int NewWidth)
- {
- this->m_width = NewWidth;
- }
+ virtual Boolean DataBrowserCompareProc (DataBrowserItemID itemOneID, DataBrowserItemID itemTwoID, DataBrowserPropertyID sortProperty);
+ virtual void DataBrowserItemNotificationProc (DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData);
+ virtual void DataBrowserGetContextualMenuProc(MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection);
+ virtual OSStatus DataBrowserGetSetItemDataProc (DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemDataRef itemData, Boolean getValue);
-protected:
-private:
//
-// variables
+// callback functions for customized types (inherited from wxMacDataBrowserTableViewControl)
//
- bool m_ascending; // sorting order
-
- WXDataBrowserPropertyID m_propertyID; // each column is identified by its unique property ID (NOT by the column index)
-
- int m_flags; // flags for the column
- int m_maxWidth; // maximum width for the column
- int m_minWidth; // minimum width for the column
- int m_width; // column width
-
- wxAlignment m_alignment; // column header alignment
-
- wxString m_title; // column title
-
- // wxWidget internal stuff:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
-};
-
-// ---------------------------------------------------------
-// wxDataViewCtrl
-// ---------------------------------------------------------
-class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
-{
-public:
- // Constructors / destructor:
- wxDataViewCtrl()
- {
- this->Init();
- }
- wxDataViewCtrl(wxWindow *parent, wxWindowID id, wxPoint const& pos = wxDefaultPosition, wxSize const& size = wxDefaultSize, long style = 0,
- wxValidator const& validator = wxDefaultValidator)
- {
- this->Init();
- this->Create(parent, id, pos, size, style, validator );
- }
-
- ~wxDataViewCtrl();
-
- // explicit control creation
- bool Create(wxWindow *parent, wxWindowID id, wxPoint const& pos=wxDefaultPosition, wxSize const& size=wxDefaultSize, long style=0,
- wxValidator const& validator=wxDefaultValidator);
-
- virtual wxControl* GetMainWindow() // should disappear as it is not of any use for the native implementation
- {
- return this;
- }
-
- // inherited methods from 'wxDataViewCtrlBase':
- virtual bool AssociateModel(wxDataViewModel* model);
-
- virtual bool AppendColumn(wxDataViewColumn* columnPtr);
- virtual bool PrependColumn(wxDataViewColumn* columnPtr);
- virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
-
- virtual bool ClearColumns();
- virtual bool DeleteColumn(wxDataViewColumn* columnPtr);
- virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
- virtual unsigned int GetColumnCount() const;
- virtual int GetColumnPosition(wxDataViewColumn const* columnPtr) const;
-
- virtual void Collapse(wxDataViewItem const& item);
- virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr=NULL);
- virtual void Expand(wxDataViewItem const& item);
-
- virtual wxDataViewColumn* GetSortingColumn() const;
-
- virtual unsigned int GetCount() const;
- virtual wxRect GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const;
- virtual wxDataViewItem GetSelection() const;
- virtual int GetSelections(wxDataViewItemArray& sel) const;
-
- virtual void HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const;
-
- virtual bool IsSelected(wxDataViewItem const& item) const;
-
- virtual void SelectAll();
- virtual void Select(wxDataViewItem const& item);
- virtual void SetSelections(wxDataViewItemArray const& sel);
-
- virtual void Unselect(wxDataViewItem const& item);
- virtual void UnselectAll();
+ virtual void DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice);
+ virtual Boolean DataBrowserEditItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit);
+ virtual Boolean DataBrowserHitTestProc (DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Rect const* mouseRect);
+ virtual DataBrowserTrackingResult DataBrowserTrackingProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point startPt, EventModifiers modifiers);
//
-// implementation
+// callback functions for drag & drop (inherited from wxMacDataBrowserTableViewControl)
//
+ virtual Boolean DataBrowserAcceptDragProc (DragReference dragRef, DataBrowserItemID itemID);
+ virtual Boolean DataBrowserAddDragItemProc(DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef);
+ virtual Boolean DataBrowserReceiveDragProc(DragReference dragRef, DataBrowserItemID itemID);
- // adds all children of the passed parent to the control; if 'parentItem' is invalid the root(s) is/are added:
- void AddChildrenLevel(wxDataViewItem const& parentItem);
-
- // finishes editing of custom items; if no custom item is currently edited the method does nothing
- void FinishCustomItemEditing();
-
- // returns a pointer to a column;
- // in case the pointer cannot be found NULL is returned:
- wxDataViewColumn* GetColumnPtr(WXDataBrowserPropertyID propertyID) const;
- // returns the current being rendered item of the customized renderer (this item is only valid during editing)
- wxDataViewItem const& GetCustomRendererItem() const
- {
- return this->m_CustomRendererItem;
- }
- // returns a pointer to a customized renderer (this pointer is only valid during editing)
- wxDataViewCustomRenderer* GetCustomRendererPtr() const
- {
- return this->m_CustomRendererPtr;
- }
-
- // checks if currently a delete process is running:
- bool IsDeleting() const
- {
- return this->m_Deleting;
- }
-
- // with CG, we need to get the context from an kEventControlDraw event
- // unfortunately, the DataBrowser callbacks don't provide the context
- // and we need it, so we need to set/remove it before and after draw
- // events so we can access it in the callbacks.
- void MacSetDrawingContext(void* context)
- {
- this->m_cgContext = context;
- }
- void* MacGetDrawingContext() const
- {
- return this->m_cgContext;
- }
-
- // sets the currently being edited item of the custom renderer
- void SetCustomRendererItem(wxDataViewItem const& NewItem)
- {
- this->m_CustomRendererItem = NewItem;
- }
- // sets the custom renderer
- void SetCustomRendererPtr(wxDataViewCustomRenderer* NewCustomRendererPtr)
- {
- this->m_CustomRendererPtr = NewCustomRendererPtr;
- }
- // sets the flag indicating a deletion process:
- void SetDeleting(bool deleting)
- {
- this->m_Deleting = deleting;
- }
-
- virtual wxVisualAttributes GetDefaultAttributes() const
- {
- return GetClassDefaultAttributes(GetWindowVariant());
- }
-
- static wxVisualAttributes
- GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
-
-protected:
- // inherited methods from wxDataViewCtrlBase:
- virtual void DoSetExpanderColumn();
- virtual void DoSetIndent();
-
- // event handling:
- void OnSize(wxSizeEvent &event);
-
-private:
- // type definitions:
- WX_DECLARE_HASH_MAP(WXDataBrowserPropertyID,wxDataViewColumn*,wxIntegerHash,wxIntegerEqual,ColumnPointerHashMapType);
-
- // initializing of local variables:
- void Init();
-
-///
-// variables
//
+// drag & drop helper methods
+//
+ wxDataFormat GetDnDDataFormat(wxDataObjectComposite* dataObjects);
+ wxDataObjectComposite* GetDnDDataObjects(DragReference dragRef, ItemReference itemRef) const; // create the data objects from the native dragged object
- bool m_Deleting; // flag indicating if a delete process is running; this flag is necessary because the notifier indicating an item deletion in the model may be called
- // after the actual deletion of the item; then, the callback function "wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc" may
- // try to update data into variables that are already deleted; this flag will ignore all variable update requests during item deletion
-
- void* m_cgContext; // pointer to core graphics context
-
- wxDataViewCustomRenderer* m_CustomRendererPtr; // pointer to a valid custom renderer while editing; this class does NOT own the pointer
-
- wxDataViewItem m_CustomRendererItem; // currently edited item by the customerenderer; it is invalid while not editing
-
- ColumnPointerHashMapType m_ColumnPointers; // all column pointers are stored in a hash map with the property ID as a key
+//
+// other methods
+//
+ wxDataViewColumn* GetColumnPtr(DataBrowserPropertyID propertyID) const; // returns for the passed property the corresponding pointer to a column; NULL is returned if not found
- // wxWidget internal stuff:
- DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
- DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
- DECLARE_EVENT_TABLE()
+private:
};
+typedef wxMacDataViewDataBrowserListViewControl* wxMacDataViewDataBrowserListViewControlPointer;
+#endif // WX_GUI
#endif // _WX_MACCARBONDATAVIEWCTRL_H_