[ruby-gnome2-doc-cvs] [Hiki] update - tut-treeview-renderer-attributes

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2004年 4月 3日 (土) 06:18:48 JST


-------------------------
REMOTE_ADDR = 200.216.151.125
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/en/?tut-treeview-renderer-attributes
-------------------------
+ {{link "tut-treeview-renderer-renderer", "tut-treeview-renderer", "tut-treeview", "tut-treeview-renderer-celldatafunc"}}
  = Attributes
  
  An attribute is a connection between a cell renderer property and a field/column in the model. Whenever a cell is to be rendered, a cell renderer property will be set to the values of the specified model column of the row that is to be rendered. It is very important that the column's data type is the same type that a property takes according to the API reference manual. Here is some code to look at:
  
    renderer = Gtk::CellRendererText.new
    col = Gtk::TreeViewColumn.new("First Name", renderer, :text => 0)
  
  You can also add attribute mappings to a column which already exists:
  
    col.add_attribute(renderer, "text",  0)
  
  This means that the text cell renderer property "text" will be set to the string in model column 0 of each row to be drawn. It is important to realize that Gtk::TreeView#add_attribute will set the property to whatever is specificed in the model column ((*at the time of rendering*)).
  
  There are two more noteworthy things about Gtk::CellRenderer properties: one is that sometimes there are different properties which do the same, but take different arguments, such as the "foreground" and "foreground-gdk" properties of Gtk::CellRendererText (which specify the text colour). The "foreground" property take a colour in string form, such as "Orange" or "CornflowerBlue", whereas "foreground-gdk" takes a Gdk::Color argument. It is up to you to decide which one to use - the effect will be the same. The other thing worth mentioning is that most properties have a "foo-set" property taking a boolean value as argument, such as "foreground-set". This is useful when you want to have a certain setting have an effect or not. If you set the "foreground" property, but set "foreground-set" to FALSE, then your foreground color setting will be disregarded. This is useful in cell data functions, or, for example, if you want set the foreground colour to a certain value at start-up
 , but only want this to be in effect in some columns, but not in others (in which case you could just connect the "foreground-set" property to a model column).
  
  Setting column attributes is the most straight-forward way to get your model data to be displayed. This is usually used whenever you want the data in the model to be displayed exactly as it is in the model.
  
  Another way to get your model data displayed on the screen is to set up ((<cell data functions|tut-treeview-renderer-celldatafunc>)).





ruby-gnome2-cvs メーリングリストの案内
Back to archive index