#define DATAVIEW_DEFAULT_STYLE (wxDV_MULTIPLE|wxDV_HORIZ_RULES|wxDV_VERT_RULES)
-// -------------------------------------
-// MySpinCtrlInPlaceRenderer
-// -------------------------------------
-
-class MySpinCtrlInPlaceRenderer: public wxDataViewCustomRenderer
-{
-public:
- MySpinCtrlInPlaceRenderer() :
- wxDataViewCustomRenderer( wxT("long"), wxDATAVIEW_CELL_EDITABLE ) { }
-
-
- virtual bool HasEditorCtrl()
- {
- return true;
- }
- virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value )
- {
- long l = value;
- return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
- labelRect.GetTopLeft(), labelRect.GetSize(), -0, -1, 2010, l );
- }
- virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value )
- {
- wxSpinCtrl *sc = (wxSpinCtrl*) editor;
- long l = sc->GetValue();
- value = l;
- return true;
- }
-
- bool Render( wxRect rect, wxDC *dc, int WXUNUSED(state) )
- {
- wxString str;
- str.Printf( wxT("%d"), (int) m_data );
- dc->SetTextForeground( *wxBLACK );
- dc->DrawText( str, rect.x, rect.y );
- return true;
- }
- wxSize GetSize() const
- {
- return wxSize(80,16);
- }
- bool SetValue( const wxVariant &value )
- {
- m_data = value.GetLong();
- return true;
- }
- bool GetValue( wxVariant &value ) const
- {
- value = m_data;
- return true;
- }
-
-private:
- long m_data;
-};
-
-
-
// -------------------------------------
// MyMusicModel
// -------------------------------------
{
wxDataViewIconText data( "test", m_icon );
variant << data;
- }
- else
+ } else
+ if (col==2)
{
- wxString str;
- str.Printf( "row %d col %d", row, col );
- variant = str;
+ if ((row % 2) == 1)
+ variant = "Blue";
+ else
+ variant = "Italic";
}
}
+
+ virtual bool GetAttr( unsigned int row, unsigned int col, wxDataViewItemAttr &attr )
+ {
+ if (col != 2)
+ return false;
+
+ if ((row % 2) == 1)
+ attr.SetColour( *wxBLUE );
+ else
+ attr.SetItalic( true );
+
+ return true;
+ }
virtual bool SetValue( const wxVariant &variant,
unsigned int row, unsigned int col )
m_music_model = new MyMusicModel;
m_musicCtrl->AssociateModel( m_music_model.get() );
- wxDataViewColumn *col = m_musicCtrl->AppendTextColumn( "Title", 0, wxDATAVIEW_CELL_INERT, 200,
+ /* wxDataViewColumn *col = */ m_musicCtrl->AppendTextColumn( "Title", 0, wxDATAVIEW_CELL_INERT, 200,
DEFAULT_ALIGN, wxDATAVIEW_COL_SORTABLE );
#if 0
// Call this and sorting is enabled
m_musicCtrl->AppendTextColumn( "Artist", 1, wxDATAVIEW_CELL_EDITABLE, 150,
DEFAULT_ALIGN, wxDATAVIEW_COL_SORTABLE );
- MySpinCtrlInPlaceRenderer *sr = new MySpinCtrlInPlaceRenderer;
+ wxDataViewSpinRenderer *sr = new wxDataViewSpinRenderer( 0, 2010 );
wxDataViewColumn *column = new wxDataViewColumn( "year", sr, 2, -1, wxALIGN_CENTRE, wxDATAVIEW_COL_SORTABLE );
m_musicCtrl->AppendColumn( column );
m_listCtrl->AppendTextColumn( "editable string", 0, wxDATAVIEW_CELL_EDITABLE, 120 );
m_listCtrl->AppendIconTextColumn( "icon", 1, wxDATAVIEW_CELL_INERT, 60 );
- m_listCtrl->AppendTextColumn( "index", 2, wxDATAVIEW_CELL_INERT, 120 );
+
+ wxDataViewTextRendererAttr *ra = new wxDataViewTextRendererAttr;
+ column = new wxDataViewColumn( "attributes", ra, 2 );
+ m_listCtrl->AppendColumn( column );
data_sizer->Add( m_listCtrl, 2, wxGROW );
/* XPM */
-static char *small1_xpm[] = {
+static const char *small1_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 6 1",
". c Black",
void MyFrame::OnTestTreeCtrl(wxCommandEvent& WXUNUSED(event) )
{
- wxDialog dialog( this, -1, "Test wxDataViewTreeStore" );
+ wxDialog dialog( this, -1, wxString(wxT("Test wxDataViewTreeStore")));
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
wxDataViewCtrl *treectrl = new wxDataViewCtrl( &dialog, -1,
wxDefaultPosition, wxSize(300,200), wxDV_NO_HEADER );
- treectrl->AppendIconTextColumn( "no label", 0, wxDATAVIEW_CELL_INERT, 200 );
- main_sizer->Add( treectrl, 1, wxGROW );
-
wxDataViewTreeStore *store = new wxDataViewTreeStore;
wxDataViewItem parent = store->AppendContainer( wxDataViewItem(0), "Root 1", wxIcon(small1_xpm) );
wxDataViewItem child = store->AppendItem( parent, "Child 1", wxIcon(small1_xpm) );
child = store->AppendItem( parent, "Child 2", wxIcon(small1_xpm) );
child = store->AppendItem( parent, "Child 3", wxIcon(small1_xpm) );
-
treectrl->AssociateModel( store );
-
store->DecRef();
+ treectrl->AppendIconTextColumn( "no label", 0, wxDATAVIEW_CELL_INERT, 200 );
+
+ main_sizer->Add( treectrl, 1, wxGROW );
+
+
wxSizer *button_sizer = dialog.CreateButtonSizer( wxOK );
if (button_sizer)
main_sizer->Add( button_sizer, 0, wxGROW|wxALL, 10 );
wxLogMessage("wxEVT_MOUSE_RIGHT_UP, Click Point is X: %d, Y: %d", event.GetX(), event.GetY());
}
-void MyFrame::OnGoto( wxCommandEvent &event)
+void MyFrame::OnGoto(wxCommandEvent& WXUNUSED(event))
{
wxDataViewItem item = m_list_model->GetItem( 50 );
m_listCtrl->EnsureVisible(item,m_col);