[gtkmm] Mapping from a TreeModel data to a CellRenderer



I'm missing the part of the puzzle where I can connect a stock
CellRenderer to an element stored in a Model. I have something like this:

class Res
{
   std::string id;
public:
    Res (const std::string &id_): id (id_) {
    }
     
    std::string get_id () const {
        return id;
    }
};

    Gtk::TreeModelColumn<Res*> col_text;
    Gtk::TreeModel::ColumnRecord cols;
    cols.add (col_text);
  
    lstore = Gtk::ListStore::create (cols);
    set_model (lstore);
    Gtk::TreeViewColumn *view_column = new Gtk::TreeViewColumn ("");
    Gtk::CellRenderer   *cell_renderer = new Gtk::CellRendererText;
    view_column->pack_start (*Gtk::manage (cell_renderer), true);
    view_column->set_renderer (*cell_renderer, col_text);
   
    append_column (*Gtk::manage (view_column));

so here's the tricky part: How do I create a CellRenderer subclass that
re-uses the CellRendererText implementation, but takes the string to
render from the Res* supplied by the model, by calling get_id on it?

-- 
   .--= ULLA! =---------------------.   `We are not here to give users what
   \     http://cactus.rulez.org     \   they want'  -- RMS, at GUADEC 2001
    `---= cactus cactus rulez org =---'
A számítógép egy másodperc alatt töb hibát tud ejteni, mint 20 matematikus 20 év alatt.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]