ruby-****@sourc*****
ruby-****@sourc*****
2012年 9月 22日 (土) 04:48:36 JST
------------------------- REMOTE_ADDR = 184.145.80.187 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-trees ------------------------- @@ -114,7 +114,10 @@ window.show_all Gtk.main -With the new version of our example program we obtained slightly different presentation, namely the view, with the contents of the first column in parent nodes sitting next to the "expander arrow" adjusted to the left of that column, and the content of this very same column for children rows indented to the right side of the column, however, without the "expander arrow", so user can discern between the two kinds of rows. The model however, with the exception of new parent child division, did not change. The only difference between the original "liststore.rb" listing and the modified "treestore.rb" version of our Gtk::TreeView example programs where the first employs the Gtk::ListStore and the second the Gtk::TreeStore is in the creation but not in the structure of the models i.e.((*stores,*))hence the tree model here keeps the same structure as the list model in the original program, with three columns defined as Boolean, Integer and a String. What changed is the initializ ation process as well as the structure of GroceryItem class, which now includes a controlling field (attribute) called @product_type, to store a flag determining the parent/child relationship, and which subsequently is used in the model (store) initialization loop to drive either parent or child nodes creation and initialization. This, by the way, is the only thing that reflects the parent child division in the model, namely parent rows are created with nil argument (Gtk::TreeStore#append(parent=nil)), whereas children rows have this argument set to their respective parents. Incidentally, this is also different in the two source code listings, namely Gtk::ListStore#append comes with no argument. Additionally in our "treestore.rb" example, the total numbers of items to be bought in either category is calculated in separate sub-loop for each category. Note, that this initialization processing arrangement requires that all categories are bundled together in the initialization a rray of GroceryItem objects. This requirement is forced both by the creation of groups of children underneath the parent node, as well as by the way total number of products to purchase is handled. +With the new version of our example program we obtained slightly different presentation, namely the view, with the contents of the first column in parent nodes sitting next to the "expander arrow" adjusted to the left of that column, and the content of this very same column for children rows indented to the right side of the column, however, without the "expander arrow", so user can discern between the two kinds of rows. The model however, with the exception of new parent child division, did not change. + + +The only difference between the original "liststore.rb" listing and the modified "treestore.rb" version of our Gtk::TreeView example programs where the first employs the Gtk::ListStore and the second the Gtk::TreeStore is in the creation but not in the structure of the models i.e.((*stores,*))hence the tree model here keeps the same structure as the list model in the original program, with three columns defined as Boolean, Integer and a String. What changed is the initialization process as well as the structure of GroceryItem class, which now includes a controlling field (attribute) called @product_type, to store a flag determining the parent/child relationship, and which subsequently is used in the model (store) initialization loop to drive either parent or child nodes creation and initialization. This, by the way, is the only thing that reflects the parent child division in the model, namely parent rows are created with nil argument (Gtk::TreeStore#append(parent=nil)), w hereas children rows have this argument set to their respective parents. Incidentally, this is also different in the two source code listings, namely Gtk::ListStore#append comes with no argument. Additionally in our "treestore.rb" example, the total numbers of items to be bought in either category is calculated in separate sub-loop for each category. Note, that this initialization processing arrangement requires that all categories are bundled together in the initialization array of GroceryItem objects. This requirement is forced both by the creation of groups of children underneath the parent node, as well as by the way total number of products to purchase is handled. Adding columns and renderers renderers is performed in the same manner with both list and tree models, because columns are part of the view not the model: :Reminder: What is MVC