[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-dnd-intro

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2012年 12月 8日 (土) 02:18:01 JST


-------------------------
REMOTE_ADDR = 184.145.84.49
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-dnd-intro
-------------------------
@@ -380,12 +380,68 @@
 
 {{image_right("treeview-builtin-dnd-s1.png")}}
 
-Our first example program will show that only with a line of code you can get the complete drag-and-drop behaviour for free. All you need is to set up the reorderable attribute to true, by using the 'Gtk::TreeView#reorderable=' method. The drag objects here are the tree view rows, regardless whether they are leaf or nodes with children. When you left-click, hold the mouse button down and drag the mouse simultaneously the cursor changes to the 'move-icon' and the row you are dragging appears underneath it. If you look carefully, when dragging, you will notice that a potential drop position is shown, namely, the items over which you are dragging the row get highlighted, and the when you are in-between i.e., above or below rows a line appears. If you are dropping the dragged row onto a highlighted row it will become it's child, but if you drop it when the line indicator is shown, the dragged item will be placed at that position.
+This example program will show that only with a line of code you can get the complete drag-and-drop behaviour for free. All you need is to set up the reorderable attribute to true, by using the 'Gtk::TreeView#reorderable=' method. The drag objects here are the tree view rows, regardless whether they are leaf or nodes with children. When you left-click, hold the mouse button down and drag the mouse simultaneously the cursor changes to the 'move-icon' and the row you are dragging appears underneath it. If you look carefully, when dragging, you will notice that a potential drop position is shown, namely, the items over which you are dragging the row get highlighted, and the when you are in-between i.e., above or below rows a line appears. If you are dropping the dragged row onto a highlighted row it will become it's child, but if you drop it when the line indicator is shown, the dragged item will be placed at that position.
 
+# (10.3.1.1.1)
+:Office Supplies Array Initialization Module
 
+    In 'treeview-built-in-dnd.rb' example program we use auxiliary initialization application dependent module. If this module were useful also in many other tutorial example programs it would be wise to place it in a common directory or folder, along with our 'HikiGtk' module file (hiki-gtk.rb). However, we decided to place it in the same directory where also the example 'treeview-built-in-dnd.rb' program resides. This requires in the example program we tell Ruby interpreter to also include our current directory, from which we are going to run our example code, in the load path (look for the declarative statement ((*"$: << '.'"*)) at the beginning of the example program).
+
+    Following is the module file, which you should copy in your working directory along with the program example:
+
+    ((*init-office-supp-arr.rb*))
+    
+     # This file is planed to be loaded from the same directory in which
+     # the example program resides. 
+     #
+     # Its name should be: 'init-office-supp-arr.rb'
+     module InitializeOfficeSuppliesFromASCItable
+       # Tree View  Iinitialization  Array Of Arrays:
+       # name,   qty,  Children
+       # ---------------------------------------------
+       INIT_ARRAY = [
+         ['Stationery',  nil,  [
+             ['Letter paper',       "500 sheets",  nil],
+             ['Envelopes',          "200",         nil],
+             ['Computer paper',  nil,    [
+                 ['Legal',  "1 box",      nil],
+                 ['Letter', "2 boxes",    nil],
+               ]
+             ]
+           ]
+         ],
+         ['Notebooks & Writing Pads',  nil,  [
+             ['Memo Book',   "10",  nil],
+             ['Journals',    "5",  nil],
+           ]
+         ],
+         ['Computer Accessories',  nil,  [
+             ['Printer Tonner',  "2x C501AB",  nil],
+             ['RWCDs&DVD',       "100x 4GB",  nil],
+           ]
+         ],
+       ]
+       class OfficeSupplies
+         attr_accessor :name, :qty, :children
+         def initialize(name, qty, children)
+           @name, @qty, @children = name, qty, children
+           arr = []
+           if @children
+             @children.each do |row|
+               arr << OfficeSupplies.new(*row)
+             end
+             @children = arr
+           end
+         end
+       end
+     end
+
+
+
+
 
+Let's look now at the example program:
 
-Let's look at the code:
 
 
 ((*treeview-built-in-dnd.rb*))




ruby-gnome2-cvs メーリングリストの案内
Back to archive index