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

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2012年 9月 14日 (金) 05:12:19 JST


-------------------------
REMOTE_ADDR = 184.145.80.187
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-txtw-scrolledwin
-------------------------
@@ -112,8 +112,38 @@
 
 --- Second example, a child with built-in scrolling support:
 
+
+    {{image_right("txtv-scrollingw-demo.png")}}
+
+    Please ignore the fact that we have not yet covered the text view and text buffer widgets. The program is simple enough so you can without too much trouble infer what the two newly introduced widgets do in the presented context. The obvious thing to notice here is the omission of the viewport widget, and that here we add the widget we want to scroll (textview in this case) directly to scrolled window.
+
+
 ((*txtv-scrollingw-demo.rb*)) (ahead of time):
+
 
+ #!/usr/bin/env ruby
+ require 'gtk2'
+ 
+ window = Gtk::Window.new("Scrolling Win. Demo")
+ window.resizable = true
+ window.border_width = 10
+ window.signal_connect('destroy') { Gtk.main_quit }
+ window.set_size_request(250, 150)
+ 
+ textview = Gtk::TextView.new
+ textview.buffer.text = "Your very first TextView widget!\n" +
+                        "Scrolling window demo\n" +
+                        "line2\nline3\nline4\nline5\nline6\n" +
+                        "Last line"
+ 
+ scrolledw = Gtk::ScrolledWindow.new
+ scrolledw.border_width = 5
+ scrolledw.add(textview)
+ scrolledw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS)
+ 
+ window.add(scrolledw)
+ window.show_all
+ Gtk.main
 
 
 




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