Added PrependColumn methods and short cuts. Added test for DeleteColumn to sample
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49233 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
383144c756
commit
736fe67c66
@ -457,6 +457,55 @@ public:
|
||||
wxDataViewModel* GetModel();
|
||||
|
||||
// short cuts
|
||||
wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
|
||||
wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
@ -501,12 +550,13 @@ public:
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
|
||||
wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
|
||||
|
||||
|
||||
virtual bool PrependColumn( wxDataViewColumn *col );
|
||||
virtual bool AppendColumn( wxDataViewColumn *col );
|
||||
|
||||
virtual unsigned int GetColumnCount() const = 0;
|
||||
|
@ -383,6 +383,7 @@ public:
|
||||
|
||||
virtual bool AssociateModel( wxDataViewModel *model );
|
||||
virtual bool AppendColumn( wxDataViewColumn *col );
|
||||
virtual bool PrependColumn( wxDataViewColumn *col );
|
||||
|
||||
virtual void DoSetExpanderColumn();
|
||||
virtual void DoSetIndent();
|
||||
|
@ -339,6 +339,7 @@ public:
|
||||
|
||||
virtual bool AssociateModel( wxDataViewModel *model );
|
||||
|
||||
virtual bool PrependColumn( wxDataViewColumn *col );
|
||||
virtual bool AppendColumn( wxDataViewColumn *col );
|
||||
virtual unsigned int GetColumnCount() const;
|
||||
virtual wxDataViewColumn* GetColumn( unsigned int pos ) const;
|
||||
|
@ -497,6 +497,7 @@ public:
|
||||
|
||||
void OnAddMozart(wxCommandEvent& event);
|
||||
void OnDeleteMusic(wxCommandEvent& event);
|
||||
void OnDeleteYear(wxCommandEvent& event);
|
||||
|
||||
void OnPrependList(wxCommandEvent& event);
|
||||
void OnDeleteList(wxCommandEvent& event);
|
||||
@ -578,6 +579,7 @@ enum
|
||||
|
||||
ID_ADD_MOZART = 100,
|
||||
ID_DELETE_MUSIC = 101,
|
||||
ID_DELETE_YEAR = 102,
|
||||
|
||||
ID_PREPEND_LIST = 200,
|
||||
ID_DELETE_LIST = 201,
|
||||
@ -590,6 +592,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU( ID_EXIT, MyFrame::OnQuit )
|
||||
EVT_BUTTON( ID_ADD_MOZART, MyFrame::OnAddMozart )
|
||||
EVT_BUTTON( ID_DELETE_MUSIC, MyFrame::OnDeleteMusic )
|
||||
EVT_BUTTON( ID_DELETE_YEAR, MyFrame::OnDeleteYear )
|
||||
EVT_BUTTON( ID_PREPEND_LIST, MyFrame::OnPrependList )
|
||||
EVT_BUTTON( ID_DELETE_LIST, MyFrame::OnDeleteList )
|
||||
EVT_BUTTON( ID_GOTO, MyFrame::OnGoto)
|
||||
@ -689,6 +692,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
|
||||
button_sizer->Add( new wxButton( this, ID_ADD_MOZART, "Add Mozart"), 0, wxALL, 10 );
|
||||
button_sizer->Add( new wxButton( this, ID_DELETE_MUSIC, "Delete selected"), 0, wxALL, 10 );
|
||||
button_sizer->Add( new wxButton( this, ID_DELETE_YEAR, "Delete \"Year\" column"), 0, wxALL, 10 );
|
||||
button_sizer->Add( 10, 10, 1 );
|
||||
button_sizer->Add( new wxButton( this, ID_PREPEND_LIST, "Prepend"), 0, wxALL, 10 );
|
||||
button_sizer->Add( new wxButton( this, ID_DELETE_LIST, "Delete selected"), 0, wxALL, 10 );
|
||||
@ -786,6 +790,12 @@ void MyFrame::OnDeleteMusic(wxCommandEvent& WXUNUSED(event) )
|
||||
m_music_model->Delete( items[i] );
|
||||
}
|
||||
|
||||
void MyFrame::OnDeleteYear( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
m_musicCtrl->DeleteColumn( m_musicCtrl->GetColumn( 2 ) );
|
||||
FindWindow( ID_DELETE_YEAR )->Disable();
|
||||
}
|
||||
|
||||
void MyFrame::OnPrependList( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
m_list_model->Prepend( "Test" );
|
||||
|
@ -803,6 +803,139 @@ wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int mode
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependTextColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependIconTextColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependToggleColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependProgressColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependDateColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependBitmapColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependTextColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependIconTextColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependToggleColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependProgressColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependDateColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxDataViewColumn *
|
||||
wxDataViewCtrlBase::PrependBitmapColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
|
||||
{
|
||||
wxDataViewColumn *ret = new wxDataViewColumn( label,
|
||||
new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
|
||||
model_column, width, align, flags );
|
||||
PrependColumn( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
|
||||
{
|
||||
@ -810,6 +943,13 @@ wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
wxDataViewCtrlBase::PrependColumn( wxDataViewColumn *col )
|
||||
{
|
||||
col->SetOwner( (wxDataViewCtrl*) this );
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewEvent
|
||||
// ---------------------------------------------------------
|
||||
|
@ -3759,6 +3759,16 @@ bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxDataViewCtrl::PrependColumn( wxDataViewColumn *col )
|
||||
{
|
||||
if (!wxDataViewCtrlBase::PrependColumn(col))
|
||||
return false;
|
||||
|
||||
m_cols.Insert( col );
|
||||
OnColumnChange();
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxDataViewCtrl::OnColumnChange()
|
||||
{
|
||||
if (m_headerArea)
|
||||
|
@ -3154,6 +3154,19 @@ bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxDataViewCtrl::PrependColumn( wxDataViewColumn *col )
|
||||
{
|
||||
if (!wxDataViewCtrlBase::PrependColumn(col))
|
||||
return false;
|
||||
|
||||
m_cols.Insert( col );
|
||||
|
||||
gtk_tree_view_insert_column( GTK_TREE_VIEW(m_treeview),
|
||||
GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()), 0 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int wxDataViewCtrl::GetColumnCount() const
|
||||
{
|
||||
return m_cols.GetCount();
|
||||
|
Loading…
Reference in New Issue
Block a user