ruby-****@sourc*****
ruby-****@sourc*****
2012年 8月 14日 (火) 06:17:38 JST
------------------------- REMOTE_ADDR = 184.145.90.35 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-treeview-renderer-attributes ------------------------- @@ -26,7 +26,7 @@ The ((*text*)) property above needs special attention, since this attribute is most likely associated with the model, and hence is automatically rendered by Gtk, provided you set the appropriate column number for text via Gtk::TreeViewColumn.new. You would set ((*text*)) manually only for virtual columns in tree view, or columns that need some intervention at run time. -From the above discussion about column numbers it is important to understand that model columns do not map directly to columns in tree view. While columns in model are determined by the order in which Gtk::ListStore#append or Gtk::TreeStore#append statements are executed, the mapping to view columns is defined by the programmer by defining the column numbers via Gtk::TreeViewColumn.new in ((*:text = column_number*)) idiom or in hash of attributes, when it is used instead. A renderer normally is associated only with a single view column, but can have associated more view columns, as is the case with our example exhibiting ((*:foreground*)) attribute. Each model column is automatically associated with a particular renderer in the order defined by the programmer at the time he or she issues either a Gtk::ListStore#append or a Gtk::TreeStore#append statement. +From the above discussion about column numbers it is important to understand that model columns do not map directly to columns in tree view. While columns in model are determined by the order in which Gtk::Gtk::TreeView#append_column statements are executed, the mapping to view columns is defined by the programmer by defining the column numbers via Gtk::TreeViewColumn.new in ((*:text = column_number*)) idiom or in hash of attributes, when it is used instead. A renderer normally is associated only with a single view column, but can have associated more view columns, as is the case with our example exhibiting ((*:foreground*)) attribute. Each model column is automatically associated with a particular renderer in the order defined by the programmer at the time he or she issues Gtk::TreeView#append_column statements. 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).