ruby-****@sourc*****
ruby-****@sourc*****
2012年 8月 24日 (金) 09:41:31 JST
------------------------- REMOTE_ADDR = 70.49.49.99 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-treeview-model-reference ------------------------- @@ -1,8 +1,9 @@ = Refering to Rows: Gtk::TreeIter, Gtk::TreePath, Gtk::TreeRowReference {{link "tut-treeview-model-data", "tut-treeview-model", "tut-treeview", "tut-treeview-model-add"}} There are different ways to refer to a specific row. The two you will have to deal with are Gtk::TreeIter and Gtk::TreePath. +:((*Tree Path*)): A Gtk::TreePath is a comparatively straight-forward way to describe the logical position of a row in the model. As a Gtk::TreeView always displays all rows in a model, a tree path always describes the same row in both model and view. {{image_right "treepath.png"}} @@ -13,6 +14,8 @@ If you operate with tree paths, you are most likely to use a given tree path, and use methods like Gtk::TreePath#up!, Gtk::TreePath#down!, Gtk::TreePath#next!, Gtk::TreePath#prev!, Gtk::TreePath#ancestor?, Gtk::TreePath#decendent?. Note that this way you can construct and operate on tree paths that refer to rows that do not exist in model or view. +:((*Tree Iterator*)): Another way to refer to a row in a list or tree model is Gtk::TreeIter. A tree iter is just a structure that contains a couple of pointers that mean something to the model you are using. Tree iters are used internally by models, and they often contain a direct pointer to the internal data of the row in question. You should never look at the content of a tree iter and you must not modify it directly either. All tree models provide methods that operate on tree iters (e.g. add or remove an item to or from the child of the row specified by a given tree iter, or move to the next element in the tree or list, etc.). Tree iters are used to retrieve data from the store, and to put data into the store. You also get a tree iter as result if you add a new row to the store using Gtk::ListStore#append or Gtk::TreeStore#append.