ruby-****@sourc*****
ruby-****@sourc*****
2012年 9月 22日 (土) 04:13:48 JST
------------------------- REMOTE_ADDR = 184.145.80.187 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-trees ------------------------- @@ -114,7 +114,7 @@ window.show_all Gtk.main -With the new version of our example program we obtained slightly different presentation, namely the view. 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 version "treestore.rb" 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 ini tialization. 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. Additionally 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. +With the new version of our example program we obtained slightly different presentation, namely the view. 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 version "treestore.rb" 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 ini tialization. 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 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