Re: Changing TreeView Cell Renderers
- From: Murray Cumming <murrayc murrayc com>
- To: Bob Caryl <bob fis-cal com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: Changing TreeView Cell Renderers
- Date: Sat, 19 Mar 2005 11:55:45 +0100
On Fri, 2005-03-18 at 15:53 -0600, Bob Caryl wrote:
> Hello all,
>
> I'm trying to use a treeview and I would like to have a boolean field in
> the data to be rendered as a checkbox and be editable.
>
> The code I'm using looks like this:
>
> class ModelColumns : public Gtk::TreeModel::ColumnRecord
> {
> public:
> ModelColumns()
> { add(m_disp);
> add(m_check);
> add(m_tag);
> add(m_desg);
> add(m_exec);
> }
> Gtk::TreeModelColumn<Glib::ustring> m_disp;
> // column for menu display text
> Gtk::TreeModelColumn<gboolean> m_check;
C++ has bool. gboolean is actually an int, used in C because it does not
have bool.
Just use append_column() with a bool column and you will get a checkbox
by default.
> // column for check button
> Gtk::TreeModelColumn<Glib::ustring> m_tag; //
> column for menu xml tag
> Gtk::TreeModelColumn<Glib::ustring> m_desg;
> // column for menu designator text
> Gtk::TreeModelColumn<Glib::ustring> m_exec;
> // column for menu action text.
> };
>
> ModelColumns m_columns;
> // columns for Gtk::ListStore object
> Glib::RefPtr<Gtk::TreeStore> list; //
> our listore object for the treeview
>
>
> list = Gtk::TreeStore::create(m_columns);
> tree->append_column_editable(" SEL ", m_columns.m_check);
> tree->append_column(" Name ", m_columns.m_disp);
>
> Gtk::CellRendererToggle *toggle = new Gtk::CellRendererToggle;
> Gtk::TreeView::Column *pColumn = tree->get_column(0);
> pColumn->clear();
> pColumn->pack_start(*toggle);
>
>
> The foregoing code does indeed place a checkbox type renderer in the
> column cell, but it does not appropriately display the data, nor is it
> editable. Oh yeah, that code does not appear inline like that in the
> app.. just wanted to show all the declarations and definitions.
>
> Any ideas on what I'm omitting or doing wrong here?
>
> Thanks,
> Bob Caryl
--
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]