/*
Implement this data model
- Title Artist Year
--------------------------------------------------------------
+ Title Artist Year Judgement
+--------------------------------------------------------------------------
1: My Music:
2: Pop music
- 3: You are not alone Michael Jackson 1995
- 4: Take a bow Madonna 1994
+ 3: You are not alone Michael Jackson 1995 good
+ 4: Take a bow Madonna 1994 good
5: Classical music
- 6: Ninth Symphony Ludwig v. Beethoven 1824
- 7: German Requiem Johannes Brahms 1868
+ 6: Ninth Symphony Ludwig v. Beethoven 1824 good
+ 7: German Requiem Johannes Brahms 1868 good
*/
m_title = title;
m_artist = artist;
m_year = year;
+ m_quality = "good";
m_isContainer = false;
}
wxString m_title;
wxString m_artist;
int m_year;
+ wxString m_quality;
private:
MyMusicModelNode *m_parent;
virtual unsigned int GetColumnCount() const
{
- return 5;
+ return 6;
}
virtual wxString GetColumnType( unsigned int col ) const
case 0: variant = node->m_title; break;
case 1: variant = node->m_artist; break;
case 2: variant = (long) node->m_year; break;
- case 3:
+ case 3: variant = node->m_quality; break;
+ case 4:
// wxMac doesn't conceal the popularity progress renderer, return 0 for containers
if (IsContainer(item))
variant = (long) 0;
else
variant = (long) 80; // all music is very 80% popular
break;
- case 4:
+ case 5:
// Make size of red square depend on year
if (GetYear(item) < 1900)
variant = (long) 35;
case 0: node->m_title = variant.GetString(); return true;
case 1: node->m_artist = variant.GetString(); return true;
case 2: node->m_year = variant.GetLong(); return true;
+ case 3: node->m_quality = variant.GetString(); return true;
default: wxLogError( wxT("MyMusicModel::SetValue: wrong column") );
}
return false;
virtual wxSize GetSize() const
{
- return wxSize(60,m_height);
+ //return wxSize(60,m_height);
+ return wxSize(60,20);
}
virtual bool SetValue( const wxVariant &value )
wxDataViewTextRenderer *tr = new wxDataViewTextRenderer( wxT("string"), wxDATAVIEW_CELL_INERT );
wxDataViewColumn *column0 = new wxDataViewColumn( wxT("title"), tr, 0, 200, wxALIGN_LEFT,
- wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE );
+ wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE );
m_musicCtrl->AppendColumn( column0 );
#if 0
// Call this and sorting is enabled
// immediatly upon start up.
- column0->SetSortOrder( true );
+ column0->SetAsSortKey();
#endif
tr = new wxDataViewTextRenderer( wxT("string"), wxDATAVIEW_CELL_EDITABLE );
wxDataViewColumn *column1 = new wxDataViewColumn( wxT("artist"), tr, 1, 150, wxALIGN_LEFT,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE );
+ column1->SetMinWidth(150); // this column can't be resized to be smaller
m_musicCtrl->AppendColumn( column1 );
-#if 1
wxDataViewSpinRenderer *sr = new wxDataViewSpinRenderer( 0, 2010, wxDATAVIEW_CELL_EDITABLE, wxALIGN_RIGHT );
- wxDataViewColumn *column2 = new wxDataViewColumn( wxT("year"), sr, 2, 80, wxALIGN_LEFT,
- wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE );
+ wxDataViewColumn *column2 = new wxDataViewColumn( wxT("year"), sr, 2, 60, wxALIGN_LEFT,
+ wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE );
m_musicCtrl->AppendColumn( column2 );
- m_musicCtrl->AppendProgressColumn( wxT("popularity"), 3, wxDATAVIEW_CELL_INERT, 80 );
+ wxArrayString choices;
+ choices.Add( "good" );
+ choices.Add( "bad" );
+ choices.Add( "lousy" );
+ wxDataViewChoiceRenderer *c = new wxDataViewChoiceRenderer( choices, wxDATAVIEW_CELL_EDITABLE, wxALIGN_RIGHT );
+ wxDataViewColumn *column3 = new wxDataViewColumn( wxT("rating"), c, 3, 100, wxALIGN_LEFT,
+ wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE );
+ m_musicCtrl->AppendColumn( column3 );
+
+ m_musicCtrl->AppendProgressColumn( wxT("popularity"), 4, wxDATAVIEW_CELL_INERT, 80 );
MyCustomRenderer *cr = new MyCustomRenderer( wxDATAVIEW_CELL_ACTIVATABLE, wxALIGN_RIGHT );
- wxDataViewColumn *column3 = new wxDataViewColumn( wxT("custom"), cr, 4, -1, wxALIGN_LEFT,
+ wxDataViewColumn *column4 = new wxDataViewColumn( wxT("custom"), cr, 5, -1, wxALIGN_LEFT,
wxDATAVIEW_COL_RESIZABLE );
- m_musicCtrl->AppendColumn( column3 );
-#endif
+ m_musicCtrl->AppendColumn( column4 );
data_sizer->Add( m_musicCtrl, 3, wxGROW );
#endif
wxDataViewTextRendererAttr *ra = new wxDataViewTextRendererAttr;
- wxDataViewColumn *column4 = new wxDataViewColumn(wxT("attributes"), ra, 2 );
- m_listCtrl->AppendColumn( column4 );
+ wxDataViewColumn *column5 = new wxDataViewColumn(wxT("attributes"), ra, 2 );
+ m_listCtrl->AppendColumn( column5 );
data_sizer->Add( m_listCtrl, 2, wxGROW );
wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage(wxT("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, Item: %s"), title );
+
+ if (m_musicCtrl->IsExpanded( event.GetItem() ))
+ wxLogMessage(wxT("Item: %s is expanded"), title );
}
void MyFrame::OnSelectionChanged( wxDataViewEvent &event )
void MyFrame::OnHeaderClick( wxDataViewEvent &event )
{
+ // we need to skip the event to let the default behaviour of sorting by
+ // this column when it is clicked to take place
+ event.Skip();
+
if(!m_log)
return;