Merge branch 'dvc-more-fixes'

More, mostly event-related, wxDataViewCtrl fixes.

See https://github.com/wxWidgets/wxWidgets/pull/718
This commit is contained in:
Vadim Zeitlin
2018-02-05 13:59:43 +01:00
12 changed files with 160 additions and 82 deletions

View File

@@ -755,6 +755,12 @@ public:
virtual bool SetHeaderAttr(const wxItemAttr& WXUNUSED(attr))
{ return false; }
// Set the colour used for the "alternate" rows when wxDV_ROW_LINES is on.
// Also only supported in the generic version, which returns true to
// indicate it.
virtual bool SetAlternateRowColour(const wxColour& WXUNUSED(colour))
{ return false; }
virtual wxVisualAttributes GetDefaultAttributes() const wxOVERRIDE
{
return GetClassDefaultAttributes(GetWindowVariant());
@@ -853,7 +859,6 @@ public:
// for wxEVT_DATAVIEW_ITEM_EDITING_DONE only
bool IsEditCancelled() const { return m_editCancelled; }
void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; }
// for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
wxDataViewColumn *GetDataViewColumn() const { return m_column; }
@@ -897,11 +902,12 @@ public:
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
void SetColumn( int col ) { m_col = col; }
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
void SetItem( const wxDataViewItem &item ) { m_item = item; }
#endif // WXWIN_COMPATIBILITY_3_0
void SetColumn( int col ) { m_col = col; }
void SetEditCancelled() { m_editCancelled = true; }
protected:
wxDataViewItem m_item;
int m_col;

View File

@@ -241,15 +241,18 @@ protected:
// (typically selection with dark background). For internal use only.
virtual bool IsHighlighted() const = 0;
// Called from {Cancel,Finish}Editing() to cleanup m_editorCtrl
void DestroyEditControl();
// Helper of PrepareForItem() also used in StartEditing(): returns the
// value checking that its type matches our GetVariantType().
wxVariant CheckedGetValue(const wxDataViewModel* model,
const wxDataViewItem& item,
unsigned column) const;
// Validates the given value (if it is non-null) and sends (in any case)
// ITEM_EDITING_DONE event and, finally, updates the model with the value
// (f it is valid, of course) if the event wasn't vetoed.
bool DoHandleEditingDone(wxVariant* value);
wxString m_variantType;
wxDataViewColumn *m_owner;
wxWeakRef<wxWindow> m_editorCtrl;
@@ -261,7 +264,10 @@ protected:
// renderer is required
wxDataViewCtrl* GetView() const;
protected:
private:
// Called from {Called,Finish}Editing() and dtor to cleanup m_editorCtrl
void DestroyEditControl();
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase);
};

View File

@@ -277,10 +277,11 @@ public:
virtual bool SetHeaderAttr(const wxItemAttr& attr) wxOVERRIDE;
// These methods are specific to generic wxDataViewCtrl implementation and
virtual bool SetAlternateRowColour(const wxColour& colour) wxOVERRIDE;
// This method is specific to generic wxDataViewCtrl implementation and
// should not be used in portable code.
wxColour GetAlternateRowColour() const { return m_alternateRowColour; }
void SetAlternateRowColour(const wxColour& colour);
// The returned pointer is null if the control has wxDV_NO_HEADER style.
//

View File

@@ -47,9 +47,10 @@ public:
// called when the cell value was edited by user with the new value
//
// it validates the new value and notifies the model about the change by
// calling GtkOnCellChanged() if it was accepted
virtual void GtkOnTextEdited(const char *itempath, const wxString& value);
// it uses GtkGetValueFromString() to parse the new value, then validates
// it by calling Validate() and notifies the model about the change if it
// passes validation
void GtkOnTextEdited(const char *itempath, const wxString& value);
GtkCellRenderer* GetGtkHandle() { return m_renderer; }
void GtkInitHandlers();
@@ -78,14 +79,16 @@ protected:
virtual bool IsHighlighted() const wxOVERRIDE;
virtual void GtkOnCellChanged(const wxVariant& value,
const wxDataViewItem& item,
unsigned col);
// Apply our effective alignment (i.e. m_alignment if specified or the
// associated column alignment by default) to the given renderer.
void GtkApplyAlignment(GtkCellRenderer *renderer);
// This method is used to interpret the string entered by user and by
// default just uses it as is, but can be overridden for classes requiring
// special treatment.
virtual wxVariant GtkGetValueFromString(const wxString& str) const;
GtkCellRenderer *m_renderer;
int m_alignment;

View File

@@ -228,9 +228,7 @@ public:
virtual void GtkPackIntoColumn(GtkTreeViewColumn *column) wxOVERRIDE;
protected:
virtual void GtkOnCellChanged(const wxVariant& value,
const wxDataViewItem& item,
unsigned col) wxOVERRIDE;
virtual wxVariant GtkGetValueFromString(const wxString& str) const wxOVERRIDE;
private:
wxDataViewIconText m_value;
@@ -281,7 +279,7 @@ public:
virtual bool GetValue( wxVariant &value ) const wxOVERRIDE;
private:
virtual void GtkOnTextEdited(const char *itempath, const wxString& str) wxOVERRIDE;
virtual wxVariant GtkGetValueFromString(const wxString& str) const;
};