add wxDataViewIconTextRenderer
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48449 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
8935265382
commit
c9c13e7043
@ -180,6 +180,35 @@ protected:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewIconTextRenderer
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class wxDataViewIconTextRenderer: public wxDataViewCustomRenderer
|
||||
{
|
||||
public:
|
||||
wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
||||
int align = wxDVR_DEFAULT_ALIGNMENT );
|
||||
virtual ~wxDataViewIconTextRenderer();
|
||||
|
||||
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() { return true; }
|
||||
virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
|
||||
virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
|
||||
|
||||
private:
|
||||
wxDataViewIconText m_value;
|
||||
|
||||
protected:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewDateRenderer
|
||||
// ---------------------------------------------------------
|
||||
|
@ -394,6 +394,8 @@ public:
|
||||
str.Printf( "row number %d", i );
|
||||
m_array.Add( str );
|
||||
}
|
||||
|
||||
m_icon = wxIcon( null_xpm );
|
||||
}
|
||||
|
||||
// helper methods to change the model
|
||||
@ -415,11 +417,14 @@ public:
|
||||
|
||||
virtual unsigned int GetColumnCount() const
|
||||
{
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
virtual wxString GetColumnType( unsigned int col ) const
|
||||
{
|
||||
if (col == 1)
|
||||
return "wxDataViewIconText";
|
||||
|
||||
return "string";
|
||||
}
|
||||
|
||||
@ -434,6 +439,11 @@ public:
|
||||
if (col==0)
|
||||
{
|
||||
variant = m_array[ row ];
|
||||
} else
|
||||
if (col==1)
|
||||
{
|
||||
wxDataViewIconText data( "test", m_icon );
|
||||
variant << data;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -456,6 +466,7 @@ public:
|
||||
}
|
||||
|
||||
wxArrayString m_array;
|
||||
wxIcon m_icon;
|
||||
};
|
||||
|
||||
// -------------------------------------
|
||||
@ -664,7 +675,11 @@ MyFrame::MyFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h):
|
||||
m_listCtrl->AssociateModel( m_list_model.get() );
|
||||
|
||||
m_listCtrl->AppendTextColumn( "editable string", 0, wxDATAVIEW_CELL_EDITABLE, 120 );
|
||||
m_col = m_listCtrl->AppendTextColumn( "index", 1, wxDATAVIEW_CELL_INERT, 120 );
|
||||
|
||||
m_col = new wxDataViewColumn( "icon", new wxDataViewIconTextRenderer, 1, 60 );
|
||||
m_listCtrl->AppendColumn( m_col );
|
||||
|
||||
m_col = m_listCtrl->AppendTextColumn( "index", 2, wxDATAVIEW_CELL_INERT, 120 );
|
||||
|
||||
data_sizer->Add( m_listCtrl, 2, wxGROW );
|
||||
|
||||
|
@ -1890,6 +1890,67 @@ bool wxDataViewDateRenderer::Activate( wxRect cell, wxDataViewModel *model,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewIconTextRenderer
|
||||
// ---------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(wxDataViewIconTextRenderer, wxDataViewCustomRenderer)
|
||||
|
||||
wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(
|
||||
const wxString &varianttype, wxDataViewCellMode mode, int align ) :
|
||||
wxDataViewCustomRenderer( varianttype, mode, align )
|
||||
{
|
||||
SetMode(mode);
|
||||
SetAlignment(align);
|
||||
}
|
||||
|
||||
wxDataViewIconTextRenderer::~wxDataViewIconTextRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxDataViewIconTextRenderer::SetValue( const wxVariant &value )
|
||||
{
|
||||
m_value << value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxDataViewIconTextRenderer::GetValue( wxVariant &value ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxDataViewIconTextRenderer::Render( wxRect cell, wxDC *dc, int state )
|
||||
{
|
||||
dc->SetFont( GetOwner()->GetOwner()->GetFont() );
|
||||
|
||||
const wxIcon &icon = m_value.GetIcon();
|
||||
if (icon.IsOk())
|
||||
{
|
||||
dc->DrawIcon( icon, cell.x, cell.y ); // TODO centre
|
||||
cell.x += icon.GetWidth()+4;
|
||||
}
|
||||
|
||||
dc->DrawText( m_value.GetText(), cell.x, cell.y );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxSize wxDataViewIconTextRenderer::GetSize() const
|
||||
{
|
||||
return wxSize(80,16); // TODO
|
||||
}
|
||||
|
||||
wxControl* wxDataViewIconTextRenderer::CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool wxDataViewIconTextRenderer::GetValueFromEditorCtrl( wxControl* editor, wxVariant &value )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewColumn
|
||||
// ---------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user