Applied Hartwig's implementation of OS X wxDataViewCtrl

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48052 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2007-08-13 15:56:28 +00:00
parent 967d3d9783
commit 194027acb3
4 changed files with 370 additions and 708 deletions

View File

@@ -53,17 +53,16 @@ typedef SInt32 SRefCon;
#if wxUSE_GUI
#include "wx/hashmap.h"
#include "wx/mac/private.h"
WX_DEFINE_ARRAY_SIZE_T(size_t,wxArrayDataBrowserItemID);
// ============================================================================
// DataBrowser Wrapper
// wxMacDataBrowserTableViewControl
// ============================================================================
//
// basing on DataBrowserItemIDs
// this is a wrapper class for the Mac OS X data browser environment,
// it covers all general data brower functionality,
//
// data browser's property IDs have a reserved ID range from 0 - 1023
@@ -127,18 +126,18 @@ public:
// column handling
//
OSStatus GetColumnCount (UInt32* numColumns) const;
OSStatus GetColumnID (DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id);
OSStatus GetFreePropertyID(DataBrowserPropertyID* id) const; // this method returns a property id that is valid and currently not used; if it cannot be found 'errDataBrowerPropertyNotSupported' is returned
OSStatus GetPropertyColumn(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex* index) 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 (DataBrowserTableViewColumnIndex index, DataBrowserTableViewColumnID* propertyId); // 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
OSStatus RemoveColumn(DataBrowserTableViewColumnIndex position);
OSStatus RemoveColumn(DataBrowserTableViewColumnIndex index);
OSStatus SetColumnPosition (DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position);
OSStatus SetDisclosureColumn(DataBrowserPropertyID property, Boolean expandableRows );
OSStatus SetPropertyFlags (DataBrowserPropertyID property, DataBrowserPropertyFlags flags );
OSStatus SetColumnIndex (DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex index);
OSStatus SetDisclosureColumn(DataBrowserPropertyID propertyID, Boolean expandableRows=true);
OSStatus SetPropertyFlags (DataBrowserPropertyID propertyID, DataBrowserPropertyFlags flags);
//
// item handling
@@ -199,10 +198,10 @@ public:
// item sorting
//
OSStatus GetSortOrder (DataBrowserSortOrder* order) const;
OSStatus GetSortProperty(DataBrowserPropertyID* column) const;
OSStatus GetSortProperty(DataBrowserPropertyID* propertyID) const;
OSStatus SetSortOrder (DataBrowserSortOrder order);
OSStatus SetSortProperty(DataBrowserPropertyID column);
OSStatus SetSortProperty(DataBrowserPropertyID propertyID);
protected :
//
@@ -225,9 +224,14 @@ private:
};
// ============================================================================
// Databrowser class for the list view control
// wxMacDataBrowserListViewControl
// ============================================================================
//
// this class is a wrapper for a list view which incorporates all general
// data browser functionality of the inherited 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:
@@ -249,39 +253,20 @@ private:
// ============================================================================
// Databrowser class for the data view list control model
// wxMacDataViewDataBrowserListViewControl
// ============================================================================
//
// internal interface class between wxDataViewCtrl (wxWidget) and the data
// browser (Mac OS X)
//
// Hash maps used by the data browser for the data view model
//
WX_DECLARE_HASH_MAP(DataBrowserItemID,unsigned long,wxIntegerHash,wxIntegerEqual,ItemIDRowNumberHashMap); // stores for each item ID the model's row number
class wxMacDataViewDataBrowserListViewControl : public wxMacDataBrowserListViewControl
{
public:
//
// constructors / destructor
//
wxMacDataViewDataBrowserListViewControl(wxWindow* peer, wxPoint const& pos, wxSize const& size, long style);
//
// item ID and model matching
//
void ClearItemIDRowPairs(void); // removes all ID row pairs
bool DeleteItemIDRowPair(DataBrowserItemID itemID); // if the id has been removed, 'true' is returned, 'false' is returned if the id did not exist or another error occurred
bool GetRowIndex(unsigned long& rowIndex, DataBrowserItemID itemID) const; // returns 'true' and the rowIndex if the id has been found in the map, otherwise 'false' is returned and rowIndex remains untouched
bool InsertItemIDRowPair(DataBrowserItemID itemID, unsigned long rowIndex); // the pair will only be inserted if the item ID does not exist before the call
void RenumberItemIDRowIndices (unsigned int* newIndices); // for each item ID - row index pair the row index is changed
void RenumberItemIDRowIndicesDeletion (unsigned long decreaseFromIndex); // decreases all row indices by one that are equal or larger than 'decreaseFromIndex'
void RenumberItemIDRowIndicesInsertion(unsigned long increaseFromIndex); // increases all row indices by one that are equal or larger than 'increaseFromIndex'
void ReverseRowIndexNumbering(void); // reverses the order of the indices
protected:
//
// callback functions (inherited from wxMacDataBrowserTableViewControl)
@@ -292,10 +277,6 @@ protected:
virtual OSStatus DataBrowserGetSetItemDataProc (DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean getValue);
private:
//
// variables
//
ItemIDRowNumberHashMap m_itemIDRowNumberMap; // contains for each data browser ID the corresponding line number in the model
};
typedef wxMacDataViewDataBrowserListViewControl* wxMacDataViewDataBrowserListViewControlPointer;

View File

@@ -128,22 +128,22 @@ public:
//
virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
virtual bool Activate(wxRect WXUNUSED(cell), wxDataViewListModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
virtual bool Activate(wxRect WXUNUSED(cell), wxDataViewModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
{
return false;
}
virtual bool LeftClick(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewListModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
virtual bool LeftClick(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
{
return false;
}
virtual bool RightClick(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewListModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
virtual bool RightClick(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
{
return false;
}
virtual bool StartDrag(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewListModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
virtual bool StartDrag(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
{
return false;
}
@@ -471,47 +471,44 @@ private:
// ---------------------------------------------------------
// 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()
{
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 );
}
bool Create(wxWindow *parent, wxWindowID id, wxPoint const& pos=wxDefaultPosition, wxSize const& size=wxDefaultSize, long style=0,
wxValidator const& validator=wxDefaultValidator);
// 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 bool AppendColumn(wxDataViewColumn* columnPtr);
// inherited methods from 'wxDataViewCtrlBase':
virtual bool AppendColumn(wxDataViewColumn* columnPtr);
virtual bool AssociateModel(wxDataViewListModel* model);
virtual bool AssociateModel(wxDataViewModel* model);
virtual void SetSelection( int row ); // -1 for unselect
virtual void SetSelectionRange( unsigned int from, unsigned int to );
virtual void SetSelections( const wxArrayInt& aSelections);
virtual void Unselect( unsigned int row );
virtual bool IsSelected( unsigned int row ) const;
virtual int GetSelection() const;
virtual int GetSelections(wxArrayInt& aSelections) const;
virtual wxControl* GetMainWindow(void) // should disappear as it is not of any use for the native implementation
{
return this;
}
virtual wxControl* GetMainWindow(void) // should disappear as it is not of any use for the native implementation
{
return this;
}
virtual wxDataViewItem GetSelection(void);
//
// implementation
//
// 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);
// 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
@@ -525,11 +522,11 @@ public:
return this->m_cgContext;
}
// reverts the sorting order of the hash map if wxDataViewColumn data and control data do not match;
// wxDataViewColumn data will NOT be updated
void ReverseSorting(DataBrowserPropertyID columnID);
protected:
// inherited methods from wxDataViewCtrlBase:
virtual void DoSetExpanderColumn(void);
virtual void DoSetIndent(void);
// event handling:
void OnSize(wxSizeEvent &event);
@@ -541,7 +538,7 @@ private:
// variables
//
wxDataViewListModelNotifier* m_NotifierPtr; // the notifier is NOT owned by this class but by the associated model
wxDataViewModelNotifier* m_NotifierPtr; // the notifier is NOT owned by this class but by the associated model
void* m_cgContext; // pointer to core graphics context