[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-txtw-scrolledwin

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2012年 9月 13日 (木) 12:31:06 JST


-------------------------
REMOTE_ADDR = 184.145.80.187
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-txtw-scrolledwin
-------------------------
@@ -32,6 +32,43 @@
 #######
 
 
+--- The difference between the two implementations of scrollbars
+
+Let's see the difference between the two implementations of scrollbars, first for children without the built in support for scrolling, and then for children with it. In the ((*first example*)) program the child widget we intend to use in a scrolled window will be a table, which as you know has no built in support for scrolling, hence we will need to employ the viewport widget. However, there are two ways of doing this the long way or the short way. 
+
+The short way uses the Gtk::ScrolledWindow#add_with_viewport method:
+
+ swin.add_with_viewport(table1)
+
+
+The long way does the same thing in three steps:
+
+ viewport = Gtk::Viewport.new(swin.hadjustment, swin.vadjustment)
+ viewport.add(table1)
+ swin.add(viewport)
+
+:NOTE:
+    When you create a view port you either have supply horizontal and vertical adjustments, or nil(s) instead.
+
+In the ((*second example*)) we will use a program from the following page, because in it we use the Gtk::TextView and Gtk::TextBuffer widgets, for which explanations you will have to wait also until you arrive to the next page. However, the "textview.rb" example is so simple, that lack of these explanations here will in no way impede our comparison of the differences between the two implementations of scrolbars as announced at the beginning of this paragraph. 
+
+
+Let's look at the two examples:
+
+--- First example, a child without scrolling support:
+
+((*scrolled-table.rb:*))
+
+
+--- Second example, a child with built-in scrolling support:
+
+((*textview.rb*)) (ahead of time):
+
+
+
+
+{{br}}
+{{br}}
 
 
 The following listing demonstrates how to use scrolled windows and viewports. As the scrollbar is moved, the viewport will scroll as well because adjustments are synchronized. New scrolled windows are created with:   Gtk::ScrolledWindow.new(hadjustment = nil, vadjustment = nil), where the two arguments are the scrolled window's adjustments; these will be shared with the scrollbars and the child widget to keep the bars in sync with the child. Though you could supply adjustments you previously created, usually you do not specify any arguments, hence using the default nil(s) instead, which causes the scrolled window to create them for you. In our example the adjustments are used when viewport is created with Gtk::Viewport.new(horizontal, vertical). The viewport adjustments are initialized with those from the scrolled window, ensuring that both containers will be scrolled at the same time.




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