/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/carbon/dataview.h
-// Purpose: wxDataViewCtrl native implementation header
+// Name: wx/osx/carbon/dataview.h
+// Purpose: wxDataViewCtrl native implementation header for carbon
// Author:
-// Id: $Id$
-// Copyright: (c) 2007
+// 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()
+ {
+ }
+ wxDataViewColumnNativeData(DataBrowserPropertyID initPropertyID)
+ :m_PropertyID(initPropertyID)
+ {
+ }
//
-// inherited methods from wxDataViewRendererBase
+// data access methods
//
- virtual int GetAlignment() const
- {
- return this->m_alignment;
- }
- virtual wxDataViewCellMode GetMode() const
+ DataBrowserPropertyID GetPropertyID() const
{
- return this->m_mode;
+ return m_PropertyID;
}
- virtual bool GetValue(wxVariant& value) const
+
+ void SetPropertyID(DataBrowserPropertyID newPropertyID)
{
- value = this->m_value;
- return true;
+ 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()
{
}
- 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() const
{
- return this->m_dataReference;
+ return m_ItemDataRef;
}
- wxVariant const& GetValue() const
+ DataBrowserPropertyType GetPropertyType() const
{
- return this->m_value;
+ return 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_dataReference = newDataReference;
+ m_ItemDataRef = newItemDataRef;
+ }
+ void SetPropertyType(DataBrowserPropertyType newPropertyType)
+ {
+ 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
+ DataBrowserItemDataRef m_ItemDataRef;
- int m_alignment; // contains the alignment flags
-
- wxDataViewCellMode m_mode; // storing the mode that determines how the cell is going to be shown
-
- 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;
+
+// array of data browser item IDs
+WX_DEFINE_ARRAY_SIZE_T(size_t,wxArrayDataBrowserItemID);
-class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
+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()
+ {
+ }
+ ~wxMacDataBrowserTableViewControl();
//
-// methods handling render space
+// callback handling
//
- virtual wxSize GetSize() const = 0;
+ OSStatus SetCallbacks (DataBrowserCallbacks const* callbacks);
+ OSStatus SetCustomCallbacks(DataBrowserCustomCallbacks const* customCallbacks);
//
-// methods handling user actions
+// DnD handling
//
- virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
-
- 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; }
+ OSStatus EnableAutomaticDragTracking(bool enable=true);
//
-// device context handling
+// header handling
//
- virtual wxDC* GetDC(); // creates a device context and keeps it
+ OSStatus GetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc) const;
+
+ OSStatus SetHeaderDesc(DataBrowserPropertyID property, DataBrowserListViewHeaderDesc* desc);
//
-// implementation
+// layout handling
//
- virtual bool Render(); // declared in wxDataViewRenderer but will not be used here, therefore calling this function will
- // return 'true' without having done anything
-
- virtual WXDataBrowserPropertyType GetPropertyType() const;
+ OSStatus AutoSizeColumns();
- void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer
+ OSStatus EnableCellSizeModification(bool enableHeight=true, bool enableWidth=true); // enables or disables the column width and row height modification (default: false)
-protected:
-private:
-//
-// variables
-//
- wxControl* m_editorCtrlPtr; // pointer to an in-place editor control
+#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;
- wxDC* m_DCPtr;
+#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 );
//
-// wxWidget internal stuff
+// column handling
//
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
-};
+ 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
-// ---------------------------------------------------------
-// wxDataViewTextRenderer
-// ---------------------------------------------------------
+ OSStatus IsUsedPropertyID(DataBrowserPropertyID propertyID) const; // checks if passed property id is used by the control; no error is returned if the id exists
-class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
-{
-public:
-//
-// constructors / destructor
-//
- wxDataViewTextRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
+ OSStatus RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID);
+ OSStatus RemoveColumnByIndex (DataBrowserTableViewColumnIndex index);
-//
-// inherited functions from wxDataViewRenderer
-//
- virtual bool Render();
+ 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 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 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 RemoveItems(container,1,itemID,kDataBrowserItemNoProperty);
+ }
+ OSStatus RemoveItems(void) // removes all items
+ {
+ return 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 UpdateItems(container,1,item,kDataBrowserItemNoProperty,kDataBrowserItemNoProperty);
+ }
+ OSStatus UpdateItems(void) // updates all items
+ {
+ return 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;
-
-protected:
-private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewToggleRenderer
-// ---------------------------------------------------------
+ OSStatus GetSortOrder (DataBrowserSortOrder* order) const;
+ OSStatus GetSortProperty(DataBrowserPropertyID* propertyID) const;
-class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
-{
-public:
- wxDataViewIconTextRenderer(wxString const& varianttype = wxT("wxDataViewIconText"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
+ OSStatus Resort(DataBrowserItemID container=kDataBrowserNoItem, Boolean sortChildren=true);
-//
-// inherited functions from wxDataViewRenderer
-//
- virtual bool Render();
+ OSStatus SetSortOrder (DataBrowserSortOrder order);
+ OSStatus SetSortProperty(DataBrowserPropertyID propertyID);
//
-// implementation
+// container handling
//
- virtual WXDataBrowserPropertyType GetPropertyType() const;
+ OSStatus CloseContainer(DataBrowserItemID containerID);
-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
-{
-public:
- // constructors / destructor
- wxDataViewColumn(const wxString& title,
- wxDataViewRenderer* renderer,
- unsigned int model_column,
- int width = wxDVC_DEFAULT_WIDTH,
- wxAlignment align = wxALIGN_CENTER,
- int flags = wxDATAVIEW_COL_RESIZABLE)
- : wxDataViewColumnBase(renderer, model_column),
- m_title(title)
- {
- Init(width, align, flags);
- }
-
- wxDataViewColumn(const wxBitmap& bitmap,
- wxDataViewRenderer* renderer,
- unsigned int model_column,
- int width = wxDVC_DEFAULT_WIDTH,
- wxAlignment align = wxALIGN_CENTER,
- int flags = wxDATAVIEW_COL_RESIZABLE)
- : wxDataViewColumnBase(bitmap, renderer, model_column)
- {
- Init(width, align, flags);
- }
-
- // implement wxHeaderColumnBase pure virtual methods
- virtual wxAlignment GetAlignment() const { return m_alignment; }
- virtual int GetFlags() const { return m_flags; }
- virtual int GetMaxWidth() const { return m_maxWidth; }
- virtual int GetMinWidth() const { return m_minWidth; }
- virtual wxString GetTitle() const { return m_title; }
- virtual int GetWidth() const { return m_width; }
- virtual bool IsHidden() const { return false; } // TODO
- virtual bool IsSortOrderAscending() const { return m_ascending; }
-
- virtual void SetAlignment(wxAlignment align);
- virtual void SetBitmap (wxBitmap const& bitmap);
- virtual void SetFlags (int flags) { SetIndividualFlags(flags); }
- virtual void SetHidden(bool WXUNUSED(hidden)) { } // TODO
- 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);
-
- // implementation only
- WXDataBrowserPropertyID GetPropertyID() const
- {
- return m_propertyID;
- }
-
- void SetPropertyID(WXDataBrowserPropertyID newID)
- {
- m_propertyID = newID;
- }
- void SetWidthVariable(int NewWidth)
- {
- m_width = NewWidth;
- }
-
-private:
- // common part of all ctors
- void Init(int width, wxAlignment align, int flags)
- {
- m_ascending = true;
- m_flags = flags & ~wxDATAVIEW_COL_HIDDEN; // TODO
- m_maxWidth = 30000;
- m_minWidth = 0;
- m_width = width >= 0 ? width : wxDVC_DEFAULT_WIDTH;
- m_alignment = align;
- }
-
- bool m_ascending; // sorting order
-
- // each column is identified by its unique property ID (NOT by the column
- // index)
- WXDataBrowserPropertyID m_propertyID;
-
- 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
-};
-// ---------------------------------------------------------
-// wxDataViewCtrl
-// ---------------------------------------------------------
-class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
+// ============================================================================
+// 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:
- 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();
-
//
-// implementation
+// constructors / destructor
//
+ wxMacDataViewDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style);
+
+ //
+ // column related methods (inherited from wxDataViewWidgetImpl)
+ //
+ virtual bool ClearColumns ();
+ 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 () const;
+ virtual wxRect GetRectangle (wxDataViewItem const& item, wxDataViewColumn const* columnPtr);
+ virtual bool IsExpanded (wxDataViewItem const& item) const;
+ virtual bool Reload ();
+ 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);
- // 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
+ //
+ // 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 ();
+ virtual void Unselect (wxDataViewItem const& item);
+ virtual void UnselectAll ();
+
+ //
+ // sorting related methods
+ //
+ virtual wxDataViewColumn* GetSortingColumn () const;
+ virtual void Resort ();
+
+ //
+ // 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 ();
+
+ //
+ // other methods
+ //
+ wxDataViewCtrl* GetDataViewCtrl() const
{
- return GetClassDefaultAttributes(GetWindowVariant());
+ return dynamic_cast<wxDataViewCtrl*>(GetWXPeer());
}
- 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
//
+// standard callback functions (inherited from wxMacDataBrowserTableViewControl)
+//
+ 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);
- 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
+//
+// callback functions for customized types (inherited from wxMacDataBrowserTableViewControl)
+//
+ 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);
- wxDataViewCustomRenderer* m_CustomRendererPtr; // pointer to a valid custom renderer while editing; this class does NOT own the pointer
+//
+// 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);
- wxDataViewItem m_CustomRendererItem; // currently edited item by the customerenderer; it is invalid while not editing
+//
+// drag & drop helper methods
+//
+ wxDataFormat GetDnDDataFormat(wxDataObjectComposite* dataObjects);
+ wxDataObjectComposite* GetDnDDataObjects(DragReference dragRef, ItemReference itemRef) const; // create the data objects from the native dragged object
- 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_