class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
{
public:
- wxDataViewTreeCtrl();
- wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
- const wxValidator& validator = wxDefaultValidator );
- ~wxDataViewTreeCtrl();
+ wxDataViewTreeCtrl() { Init(); }
+ wxDataViewTreeCtrl(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
+ const wxValidator& validator = wxDefaultValidator)
+ {
+ Init();
- bool Create( wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
- const wxValidator& validator = wxDefaultValidator );
+ Create(parent, id, pos, size, style, validator);
+ }
+
+ virtual ~wxDataViewTreeCtrl();
+
+ bool Create(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
+ const wxValidator& validator = wxDefaultValidator);
wxDataViewTreeStore *GetStore()
{ return (wxDataViewTreeStore*) GetModel(); }
void OnSize( wxSizeEvent &event );
private:
- wxImageList *m_imageList;
+ void Init()
+ {
+ m_imageList = NULL;
+ }
+
+ wxImageList *m_imageList;
private:
DECLARE_EVENT_TABLE()
wxDataViewModel *musicModel = new MyMusicModel;
m_musicCtrl->AssociateModel( musicModel );
musicModel->DecRef(); // avoid memory leak !!
-
+
// add columns now
@endcode
data.push_back( wxVariant("row 3") );
listctrl->AppendItem( data );
@endcode
-
+
@beginStyleTable
See wxDataViewCtrl for the list of supported styles.
@endStyleTable
-
+
@beginEventEmissionTable
See wxDataViewCtrl for the list of events emitted by this class.
@endEventTable
@name Column management functions
*/
//@{
-
+
/**
Appends a column to the control and additionally appends a
column to the store with the type string.
/**
Appends a text column to the control and the store.
-
+
See wxDataViewColumn::wxDataViewColumn for more info about
the parameters.
*/
wxDataViewColumn *AppendTextColumn( const wxString &label,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
- int width = -1, wxAlignment align = wxALIGN_LEFT,
+ int width = -1, wxAlignment align = wxALIGN_LEFT,
int flags = wxDATAVIEW_COL_RESIZABLE );
/**
Appends a toggle column to the control and the store.
-
+
See wxDataViewColumn::wxDataViewColumn for more info about
the parameters.
*/
wxDataViewColumn *AppendToggleColumn( const wxString &label,
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
- int width = -1, wxAlignment align = wxALIGN_LEFT,
+ int width = -1, wxAlignment align = wxALIGN_LEFT,
int flags = wxDATAVIEW_COL_RESIZABLE );
/**
*/
wxDataViewColumn *AppendProgressColumn( const wxString &label,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
- int width = -1, wxAlignment align = wxALIGN_LEFT,
+ int width = -1, wxAlignment align = wxALIGN_LEFT,
int flags = wxDATAVIEW_COL_RESIZABLE );
/**
*/
wxDataViewColumn *AppendIconTextColumn( const wxString &label,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
- int width = -1, wxAlignment align = wxALIGN_LEFT,
+ int width = -1, wxAlignment align = wxALIGN_LEFT,
int flags = wxDATAVIEW_COL_RESIZABLE );
/**
Inserts a column to the control and additionally inserts a
column to the list store with the type @a varianttype.
*/
- void InsertColumn( unsigned int pos, wxDataViewColumn *column,
+ void InsertColumn( unsigned int pos, wxDataViewColumn *column,
const wxString &varianttype );
/**
void PrependColumn( wxDataViewColumn *column, const wxString &varianttype );
//@}
-
-
+
+
/**
@name Item management functions
*/
//@{
-
+
/**
Appends an item (=row) to the control and store.
*/
respective column.
*/
bool GetToggleValue( unsigned int row, unsigned int col ) const;
-
+
//@}
};
and forwards most of its API to that class.
Additionally, it uses a wxImageList to store a list of icons.
- The main purpose of this class is to represent a possible replacement for
- wxTreeCtrl.
+ The main purpose of this class is to provide a simple upgrade path for code
+ using wxTreeCtrl.
@beginStyleTable
See wxDataViewCtrl for the list of supported styles.
@endStyleTable
-
+
@beginEventEmissionTable
See wxDataViewCtrl for the list of events emitted by this class.
@endEventTable
wxDataViewTreeCtrl();
/**
- Constructor. Calls Create().
+ Constructor.
+
+ Calls Create().
*/
wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxDV_NO_HEADER,
+ long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
const wxValidator& validator = wxDefaultValidator);
/**
/**
Creates the control and a wxDataViewTreeStore as its internal model.
+
+ The default tree column created by this method is an editable column
+ using wxDataViewIconTextRenderer as its renderer.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxDV_NO_HEADER,
+ long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
const wxValidator& validator = wxDefaultValidator);
/**
@event{EVT_DATAVIEW_CACHE_HINT(id, func)}
Process a @c wxEVT_COMMAND_DATAVIEW_CACHE_HINT event.
@endEventTable
-
+
@library{wxadv}
@category{events,dvc}
*/
EVT_SIZE( wxDataViewTreeCtrl::OnSize )
END_EVENT_TABLE()
-wxDataViewTreeCtrl::wxDataViewTreeCtrl()
+wxDataViewTreeCtrl::~wxDataViewTreeCtrl()
{
- m_imageList = NULL;
+ delete m_imageList;
}
-wxDataViewTreeCtrl::wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id,
+bool wxDataViewTreeCtrl::Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator )
{
- m_imageList = NULL;
- Create( parent, id, pos, size, style, validator );
+ if ( !wxDataViewCtrl::Create( parent, id, pos, size, style, validator ) )
+ return false;
+ // create the standard model and a column in the tree
wxDataViewTreeStore *store = new wxDataViewTreeStore;
AssociateModel( store );
store->DecRef();
- AppendIconTextColumn(wxString(),0,wxDATAVIEW_CELL_INERT,-1);
-}
-
-wxDataViewTreeCtrl::~wxDataViewTreeCtrl()
-{
- if (m_imageList)
- delete m_imageList;
-}
+ AppendIconTextColumn(wxString(),0,wxDATAVIEW_CELL_EDITABLE,-1);
-bool wxDataViewTreeCtrl::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 );
+ return true;
}
void wxDataViewTreeCtrl::SetImageList( wxImageList *imagelist )
{
- if (m_imageList)
- delete m_imageList;
+ delete m_imageList;
m_imageList = imagelist;
}