[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-treev-trees

Zurück zum Archiv-Index

ruby-****@sourc***** ruby-****@sourc*****
2012年 9月 23日 (日) 11:17:43 JST


-------------------------
REMOTE_ADDR = 184.145.80.187
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-trees
-------------------------
@@ -296,7 +296,17 @@
 
 {{image_right("liststore-cdFunc.png")}}
 
-In the first ("Grocery List") program, the block associated with((*set_cell_data_func*))function is checking if "Buy" column contains TRUE. If it does, the background of the column is set to red. Note, how "Buy" column is attached the cell data function, which in turn is attached to the code block, that modifies the cell's background in accordance with the data value in the cell. The second program ("Model/View Column Demo") an effort is made to control the entire row as well as a particular cell in the "Color Name" column. Both programs nicely demonstrate how the helper function and the associated code block are executed for each renderer, effecting each cell of for selected row(s) in every row for the tree store.
+In the first ("Grocery List") program, in the code block associated with((*set_cell_data_func*))method we are checking if "Buy" column contains TRUE. If it does, the background of the column is set to red. Note, that cell renderer is aware of two places where the "Buy" column data exists. (1) The first place is the persistent model column of which the renderer was made aware of by the column constructor, which in a form of hash argument conveyed to it the model column number for((*:text*))attribute (i.e. for the value of "Buy" column in a model row), and (2) the second place is the view column in the tree view, for which cell renderer itself is responsible to update, whenever this column's data in the model changes. 
+
+Obviously, in the tree model there are as many different "Buy" column values as there are rows, and each value in the model has a corresponding value on the display or in the tree view. Depending on the value in each row, the renderer has to render the background either white or red. This happens in the((*set_cell_data_func*))method which is run for every row in the model. All that was just said can be read from the following code snippet:
+
+ renderer = Gtk::CellRendererText.new
+ column   = Gtk::TreeViewColumn.new("Buy", renderer,  :text => BUY_IT)
+ column.set_cell_data_func(renderer) do |col, renderer, model, iter|
+   renderer.background = iter[BUY_IT] ? "red" : nil
+ end
+
+Following is the entire program we discussed above:
 
 ((*liststore-cdFunc.rb*)) ("Grocery List")
 




ruby-gnome2-cvs メーリングリストの案内
Zurück zum Archiv-Index