Cleanup of wxDataViewCtrl cell activation code.
Fix confusion of what cell activation is and inconsistence with native handling in GTK+. Document the distinction between activating (~ editing) a cell and activating (double-clicking) the whole item. Deprecate wxDataViewCustomRenderer::LeftClick() and Activate() methods, replace them with single ActivateCell() that is called for both kinds of activation. Fix implementations so that ActivateCell() is not called on double-click, when it shouldn't, and vice versa: don't send wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED for cell activation. Partially reverts r67099 -- restores old 2.9 signatures of compatibility LeftClick() and Activate() methods. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69473 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -228,23 +228,39 @@ public:
|
||||
// Return the size of the item appropriate to its current value.
|
||||
virtual wxSize GetSize() const = 0;
|
||||
|
||||
// Define virtual function which are called when the item is activated
|
||||
// (double-clicked or Enter is pressed on it), clicked or the user starts
|
||||
// to drag it: by default they all simply return false indicating that the
|
||||
// events are not handled
|
||||
// Define virtual function which are called when a key is pressed on the
|
||||
// item, clicked or the user starts to drag it: by default they all simply
|
||||
// return false indicating that the events are not handled
|
||||
|
||||
virtual bool Activate(const wxRect& WXUNUSED(cell),
|
||||
wxDataViewModel *WXUNUSED(model),
|
||||
const wxDataViewItem & WXUNUSED(item),
|
||||
unsigned int WXUNUSED(col))
|
||||
{ return false; }
|
||||
virtual bool ActivateCell(const wxRect& cell,
|
||||
wxDataViewModel *model,
|
||||
const wxDataViewItem & item,
|
||||
unsigned int col,
|
||||
const wxMouseEvent* mouseEvent)
|
||||
{
|
||||
// Compatibility code
|
||||
if ( mouseEvent )
|
||||
return LeftClick(mouseEvent->GetPosition(), cell, model, item, col);
|
||||
else
|
||||
return Activate(cell, model, item, col);
|
||||
}
|
||||
|
||||
virtual bool LeftClick(const wxPoint& WXUNUSED(cursor),
|
||||
const wxRect& WXUNUSED(cell),
|
||||
wxDataViewModel *WXUNUSED(model),
|
||||
const wxDataViewItem & WXUNUSED(item),
|
||||
unsigned int WXUNUSED(col) )
|
||||
{ return false; }
|
||||
// Deprecated, use (and override) ActivateCell() instead
|
||||
wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(
|
||||
virtual bool Activate(wxRect WXUNUSED(cell),
|
||||
wxDataViewModel *WXUNUSED(model),
|
||||
const wxDataViewItem & WXUNUSED(item),
|
||||
unsigned int WXUNUSED(col)),
|
||||
return false; )
|
||||
|
||||
// Deprecated, use (and override) ActivateCell() instead
|
||||
wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(
|
||||
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(const wxPoint& WXUNUSED(cursor),
|
||||
const wxRect& WXUNUSED(cell),
|
||||
|
@@ -41,23 +41,16 @@ public:
|
||||
|
||||
// implementation
|
||||
|
||||
// These callbacks are used by generic implementation of wxDVC itself.
|
||||
// They're different from the corresponding Activate/LeftClick() methods
|
||||
// which should only be overridable for the custom renderers while the
|
||||
// generic implementation uses these ones for all of them, including the
|
||||
// standard ones.
|
||||
// This callback is used by generic implementation of wxDVC itself. It's
|
||||
// different from the corresponding ActivateCell() method which should only
|
||||
// be overridable for the custom renderers while the generic implementation
|
||||
// uses this one for all of them, including the standard ones.
|
||||
|
||||
virtual bool WXOnActivate(const wxRect& WXUNUSED(cell),
|
||||
wxDataViewModel *WXUNUSED(model),
|
||||
const wxDataViewItem & WXUNUSED(item),
|
||||
unsigned int WXUNUSED(col))
|
||||
{ return false; }
|
||||
|
||||
virtual bool WXOnLeftClick(const wxPoint& WXUNUSED(cursor),
|
||||
const wxRect& WXUNUSED(cell),
|
||||
wxDataViewModel *WXUNUSED(model),
|
||||
const wxDataViewItem & WXUNUSED(item),
|
||||
unsigned int WXUNUSED(col) )
|
||||
virtual bool WXActivateCell(const wxRect& WXUNUSED(cell),
|
||||
wxDataViewModel *WXUNUSED(model),
|
||||
const wxDataViewItem & WXUNUSED(item),
|
||||
unsigned int WXUNUSED(col),
|
||||
const wxMouseEvent* WXUNUSED(mouseEvent))
|
||||
{ return false; }
|
||||
|
||||
private:
|
||||
|
@@ -26,21 +26,13 @@ public:
|
||||
|
||||
// see the explanation of the following WXOnXXX() methods in wx/generic/dvrenderer.h
|
||||
|
||||
virtual bool WXOnActivate(const wxRect& cell,
|
||||
wxDataViewModel *model,
|
||||
const wxDataViewItem& item,
|
||||
unsigned int col)
|
||||
virtual bool WXActivateCell(const wxRect& cell,
|
||||
wxDataViewModel *model,
|
||||
const wxDataViewItem& item,
|
||||
unsigned int col,
|
||||
const wxMouseEvent *mouseEvent)
|
||||
{
|
||||
return Activate(cell, model, item, col);
|
||||
}
|
||||
|
||||
virtual bool WXOnLeftClick(const wxPoint& cursor,
|
||||
const wxRect& cell,
|
||||
wxDataViewModel *model,
|
||||
const wxDataViewItem &item,
|
||||
unsigned int col)
|
||||
{
|
||||
return LeftClick(cursor, cell, model, item, col);
|
||||
return ActivateCell(cell, model, item, col, mouseEvent);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -121,16 +113,11 @@ public:
|
||||
wxSize GetSize() const;
|
||||
|
||||
// Implementation only, don't use nor override
|
||||
virtual bool WXOnLeftClick(const wxPoint& cursor,
|
||||
const wxRect& cell,
|
||||
wxDataViewModel *model,
|
||||
const wxDataViewItem& item,
|
||||
unsigned int col);
|
||||
|
||||
virtual bool WXOnActivate(const wxRect& cell,
|
||||
wxDataViewModel *model,
|
||||
const wxDataViewItem& item,
|
||||
unsigned int col);
|
||||
virtual bool WXActivateCell(const wxRect& cell,
|
||||
wxDataViewModel *model,
|
||||
const wxDataViewItem& item,
|
||||
unsigned int col,
|
||||
const wxMouseEvent *mouseEvent);
|
||||
private:
|
||||
bool m_toggle;
|
||||
|
||||
|
Reference in New Issue
Block a user