[gtkmm] Custom types in a Gtk::TreeView
- From: Roger Leigh <roger whinlatter uklinux net>
- To: gtkmm-list gnome org
- Subject: [gtkmm] Custom types in a Gtk::TreeView
- Date: Tue, 06 Apr 2004 12:01:44 +0100
I've written a custom class, numeric, which does fast fixed-point
arithmetic. I'd like to display this directly in a Gtk::TreeView.
After adding it to the TreeModel, and then adding the column to the
view, no problems occur, but when I try to set the data, I get errors:
(test:24166): GLib-GObject-WARNING **: unable to set property
`text' of type `gchararray' from value of type `glibmm__CustomBoxed_N4EPIC7numericE'
What is the best way to convert from "numeric" to a "Glib::ustring".
I've overloaded std::ostream operator<< in the class, but this doesn't
appear to be used.
I can see that I can create a custom cell_data_func handler to set
property_text, but since I will be using this in quite a lot of
different treeviews, I don't want to have to write a handler for each
numeric column in each view.
Would deriving a custom CellRenderer from CellRendererText be a
possibility? What I can't see here is what method is called to turn
the object in the model into a Glib::ustring. How does the
CellRenderer "know" which TreeModelColumn it is rendering?
If I create a custom CellRenderer, is it possible to make this the
default renderer for a particular type, so when I add a new view
column to the treeview this renderer is chosen automatically?
Many thanks,
Roger
--
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]