wxWidgets/include/wx/generic/dvrenderers.h
Václav Slavík dc73d7f5d4 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
2011-10-19 16:20:17 +00:00

185 lines
6.3 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/dvrenderers.h
// Purpose: All generic wxDataViewCtrl renderer classes
// Author: Robert Roebling, Vadim Zeitlin
// Created: 2009-11-07 (extracted from wx/generic/dataview.h)
// RCS-ID: $Id$
// Copyright: (c) 2006 Robert Roebling
// (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_DVRENDERERS_H_
#define _WX_GENERIC_DVRENDERERS_H_
// ---------------------------------------------------------
// wxDataViewCustomRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
{
public:
wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
// see the explanation of the following WXOnXXX() methods in wx/generic/dvrenderer.h
virtual bool WXActivateCell(const wxRect& cell,
wxDataViewModel *model,
const wxDataViewItem& item,
unsigned int col,
const wxMouseEvent *mouseEvent)
{
return ActivateCell(cell, model, item, col, mouseEvent);
}
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
};
// ---------------------------------------------------------
// wxDataViewTextRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
{
public:
wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
bool SetValue( const wxVariant &value );
bool GetValue( wxVariant &value ) const;
virtual bool Render(wxRect cell, wxDC *dc, int state);
virtual wxSize GetSize() const;
// in-place editing
virtual bool HasEditorCtrl() const;
virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
const wxVariant &value );
virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value );
protected:
wxString m_text;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
};
// ---------------------------------------------------------
// wxDataViewBitmapRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
{
public:
wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
bool SetValue( const wxVariant &value );
bool GetValue( wxVariant &value ) const;
bool Render( wxRect cell, wxDC *dc, int state );
wxSize GetSize() const;
private:
wxIcon m_icon;
wxBitmap m_bitmap;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
};
// ---------------------------------------------------------
// wxDataViewToggleRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
{
public:
wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
bool SetValue( const wxVariant &value );
bool GetValue( wxVariant &value ) const;
bool Render( wxRect cell, wxDC *dc, int state );
wxSize GetSize() const;
// Implementation only, don't use nor override
virtual bool WXActivateCell(const wxRect& cell,
wxDataViewModel *model,
const wxDataViewItem& item,
unsigned int col,
const wxMouseEvent *mouseEvent);
private:
bool m_toggle;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
};
// ---------------------------------------------------------
// wxDataViewProgressRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
{
public:
wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
const wxString &varianttype = wxT("long"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
bool SetValue( const wxVariant &value );
bool GetValue( wxVariant& value ) const;
virtual bool Render(wxRect cell, wxDC *dc, int state);
virtual wxSize GetSize() const;
private:
wxString m_label;
int m_value;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
};
// ---------------------------------------------------------
// wxDataViewIconTextRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
{
public:
wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
bool SetValue( const wxVariant &value );
bool GetValue( wxVariant &value ) const;
virtual bool Render(wxRect cell, wxDC *dc, int state);
virtual wxSize GetSize() const;
virtual bool HasEditorCtrl() const { return true; }
virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
const wxVariant &value );
virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value );
private:
wxDataViewIconText m_value;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
};
#endif // _WX_GENERIC_DVRENDERERS_H_