void DeleteItem( unsigned pos );
void DeleteAllItems();
- void SetStringValue( const wxString &value, unsigned int row, unsigned int col )
- { SetValueByRow( value, row, col ); }
- wxString GetStringValue( unsigned int row, unsigned int col )
- { wxVariant value; GetValueByRow( value, row, col ); return value.GetString(); }
-
// override base virtuals
virtual unsigned int GetColumnCount() const;
wxArrayString m_cols;
};
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewListCtrl: public wxDataViewCtrl
+{
+public:
+ wxDataViewListCtrl();
+ wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
+ const wxValidator& validator = wxDefaultValidator );
+ ~wxDataViewListCtrl();
+
+ bool Create( wxWindow *parent, wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
+ const wxValidator& validator = wxDefaultValidator );
+
+ wxDataViewListStore *GetStore()
+ { return (wxDataViewListStore*) GetModel(); }
+ const wxDataViewListStore *GetStore() const
+ { return (const wxDataViewListStore*) GetModel(); }
+
+ void AppendCol( wxDataViewColumn *column, const wxString &varianttype );
+ void PrependCol( wxDataViewColumn *column, const wxString &varianttype );
+ void InsertCol( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype );
+
+ wxDataViewColumn *AppendTextCol( const wxString &label,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+ int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
+ wxDataViewColumn *AppendToggleCol( const wxString &label,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
+ int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
+ wxDataViewColumn *AppendProgressCol( const wxString &label,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+ int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
+ wxDataViewColumn *AppendIconTextCol( const wxString &label,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+ int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
+
+ void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL )
+ { GetStore()->AppendItem( values, data ); }
+ void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL )
+ { GetStore()->PrependItem( values, data ); }
+ void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL )
+ { GetStore()->InsertItem( row, values, data ); }
+ void DeleteItem( unsigned row )
+ { GetStore()->DeleteItem( row ); }
+ void DeleteAllItems()
+ { GetStore()->DeleteAllItems(); }
+
+ void SetValue( const wxVariant &value, unsigned int row, unsigned int col )
+ { GetStore()->SetValueByRow( value, row, col ); }
+
+ void SetTextValue( const wxString &value, unsigned int row, unsigned int col )
+ { GetStore()->SetValueByRow( value, row, col ); }
+ wxString GetTextValue( unsigned int row, unsigned int col ) const
+ { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetString(); }
+
+ void SetToggleValue( bool value, unsigned int row, unsigned int col )
+ { GetStore()->SetValueByRow( value, row, col ); }
+ bool GetToggleValue( unsigned int row, unsigned int col ) const
+ { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetBool(); }
+
+ void OnSize( wxSizeEvent &event );
+
+private:
+ DECLARE_EVENT_TABLE()
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl)
+};
//-----------------------------------------------------------------------------
// wxDataViewTreeStore
wxDataViewTreeStoreNode *m_root;
};
+//-----------------------------------------------------------------------------
+
class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
{
public:
MyMusicModelNode *node = (MyMusicModelNode*) item.GetID();
// "MyMusic" also has no parent
- if (node == m_root || node == NULL)
+ if (node == m_root)
return wxDataViewItem(0);
return wxDataViewItem( (void*) node->GetParent() );
memcpy( dest, buffer, strlen(buffer)+1 );
return true;
}
-
+
wxDataViewItem GetNinthItem()
{
return wxDataViewItem( m_ninth );
SetMenuBar(menu_bar);
CreateStatusBar();
-
+
wxPanel *panel = new wxPanel( this, -1 );
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
bottom_sizer->Add( m_log, 1, wxGROW );
-#if 1
- // wxDataViewTreeStore
-
- wxDataViewCtrl *treectrl = new wxDataViewCtrl( panel, -1,
- wxDefaultPosition, wxSize(100,200), wxDV_NO_HEADER );
-
- wxDataViewTreeStore *store = new wxDataViewTreeStore;
- wxDataViewItem parent = store->AppendContainer( wxDataViewItem(0),wxT("Root 1"), wxIcon(small1_xpm) );
- wxDataViewItem child = store->AppendItem( parent,wxT("Child 1"), wxIcon(small1_xpm) );
- child = store->AppendItem( parent,wxT("Child 2"), wxIcon(small1_xpm) );
- child = store->AppendItem( parent,wxT("Child 3, very long, long, long, long"), wxIcon(small1_xpm) );
- treectrl->AssociateModel( store );
- store->DecRef();
-
- treectrl->AppendIconTextColumn( wxT("no label"), 0, wxDATAVIEW_CELL_INERT, -1, (wxAlignment) 0,
- wxDATAVIEW_COL_RESIZABLE );
-
- bottom_sizer->Add( treectrl, 1 );
+ // wxDataViewListCtrl
+
+ wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( panel, -1,
+ wxDefaultPosition, wxSize(100,200) );
+
+ listctrl->AppendToggleCol( wxT("Toggle") );
+ listctrl->AppendTextCol( wxT("Text") );
+
+ wxVector<wxVariant> data;
+ data.push_back( true );
+ data.push_back( "row 1" );
+ listctrl->AppendItem( data );
+
+ data.clear();
+ data.push_back( false );
+ data.push_back( "row 3" );
+ listctrl->AppendItem( data );
+
+ bottom_sizer->Add( listctrl, 1 );
+
// wxDataViewTreeCtrl
ilist->Add( wxIcon(small1_xpm) );
treectrl2->SetImageList( ilist );
- parent = treectrl2->AppendContainer( wxDataViewItem(0),wxT("Root 1"), 0 );
- child = treectrl2->AppendItem( parent,wxT("Child 1"), 0 );
- child = treectrl2->AppendItem( parent,wxT("Child 2"), 0 );
- child = treectrl2->AppendItem( parent,wxT("Child 3, very long, long, long, long"), 0 );
+ wxDataViewItem parent2 = treectrl2->AppendContainer( wxDataViewItem(0),wxT("Root 1"), 0 );
+ wxDataViewItem child2 = treectrl2->AppendItem( parent2, wxT("Child 1"), 0 );
+ child2 = treectrl2->AppendItem( parent2, wxT("Child 2"), 0 );
+ child2 = treectrl2->AppendItem( parent2, wxT("Child 3, very long, long, long, long"), 0 );
bottom_sizer->Add( treectrl2, 1 );
-#endif
// main sizer
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 );
}
return true;
}
+//-----------------------------------------------------------------------------
+// wxDataViewListCtrl
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxDataViewListCtrl,wxDataViewCtrl)
+
+BEGIN_EVENT_TABLE(wxDataViewListCtrl,wxDataViewCtrl)
+ EVT_SIZE( wxDataViewListCtrl::OnSize )
+END_EVENT_TABLE()
+
+wxDataViewListCtrl::wxDataViewListCtrl()
+{
+}
+
+wxDataViewListCtrl::wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
+ const wxPoint& pos, const wxSize& size, long style,
+ const wxValidator& validator )
+{
+ Create( parent, id, pos, size, style, validator );
+
+ wxDataViewListStore *store = new wxDataViewListStore;
+ AssociateModel( store );
+ store->DecRef();
+}
+
+wxDataViewListCtrl::~wxDataViewListCtrl()
+{
+}
+
+
+bool wxDataViewListCtrl::Create( wxWindow *parent, wxWindowID id,
+ const wxPoint& pos, const wxSize& size, long style,
+ const wxValidator& validator )
+{
+ return wxDataViewCtrl::Create( parent, id, pos, size, style, validator );
+}
+
+void wxDataViewListCtrl::AppendCol( wxDataViewColumn *column, const wxString &varianttype )
+{
+ GetStore()->AppendColumn( varianttype );
+ AppendColumn( column );
+}
+
+void wxDataViewListCtrl::PrependCol( wxDataViewColumn *column, const wxString &varianttype )
+{
+ GetStore()->PrependColumn( varianttype );
+ PrependColumn( column );
+}
+
+void wxDataViewListCtrl::InsertCol( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype )
+{
+ GetStore()->InsertColumn( pos, varianttype );
+ InsertColumn( pos, column );
+}
+
+wxDataViewColumn *wxDataViewListCtrl::AppendTextCol( const wxString &label,
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
+{
+ GetStore()->AppendColumn( wxT("string") );
+ return AppendTextColumn( label, GetStore()->GetColumnCount()-1, mode, width, align, flags );
+}
+
+wxDataViewColumn *wxDataViewListCtrl::AppendToggleCol( const wxString &label,
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
+{
+ GetStore()->AppendColumn( wxT("bool") );
+ return AppendToggleColumn( label, GetStore()->GetColumnCount()-1, mode, width, align, flags );
+}
+
+wxDataViewColumn *wxDataViewListCtrl::AppendProgressCol( const wxString &label,
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
+{
+ GetStore()->AppendColumn( wxT("long") );
+ return AppendProgressColumn( label, GetStore()->GetColumnCount()-1, mode, width, align, flags );
+}
+
+wxDataViewColumn *wxDataViewListCtrl::AppendIconTextCol( const wxString &label,
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
+{
+ GetStore()->AppendColumn( wxT("wxDataViewIconText") );
+ return AppendIconTextColumn( label, GetStore()->GetColumnCount()-1, mode, width, align, flags );
+}
+
+void wxDataViewListCtrl::OnSize( wxSizeEvent &event )
+{
+ event.Skip( true );
+}
+
//-----------------------------------------------------------------------------
// wxDataViewTreeStore
//-----------------------------------------------------------------------------