ruby-****@sourc*****
ruby-****@sourc*****
2003年 11月 23日 (日) 23:31:21 JST
------------------------- REMOTE_ADDR = 64.30.138.196 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/?tut-treeview-renderer-types ------------------------- = GtkCellRendererText and Integer, TrueClass and Float Types It has been said before that, when using attributes to connect data from the model to a cell renderer property, the data in the model column specified in Gtk::TreeView#add_attributes must always be of the same type as the data type that the property requires. This is usually true, but there is an exception: if you add a text cell renderer's "text" property to a model column, the model column does not need to be a String, it can also be one of several other classes, e.g. TrueClass, Integer, FixNum, or Float. The text cell renderer will automatically display the values of these types correctly in the tree view. For example: list = Gtk::ListStore.new(String, Integer) renderer = Gtk::CellRenderer.new col = Gtk::TreeViewColumn.new("Age", renderer, :text => 1) Even though the "text" property would require a string value, we use a model column of an integer type when setting attributes. The integer will then automatically be converted into a string before the cell renderer property is set. If you are using a Float class, there is no way to tell the text cell renderer how many digits after the floating point (or comma) should be rendered. If you only want a certain amount of digits after the point/comma, you will need to use a ((<cell data function|tut-treeview-renderer-celldatafunc>)).