ruby-****@sourc*****
ruby-****@sourc*****
2013年 3月 31日 (日) 01:18:42 JST
------------------------- REMOTE_ADDR = 70.49.48.128 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-dancr-rbcatut-intro ------------------------- @@ -299,11 +299,9 @@ class BasicWindow < Gtk::Window def initialize(title = nil) super(Gtk::Window::TOPLEVEL) - set_title(title) if title set_size_request(250, 200) border_width = 10 - signal_connect("key_press_event") do |widget, event| if event.state.control_mask? and event.keyval == Gdk::Keyval::GDK_q destroy @@ -312,40 +310,31 @@ false end end - signal_connect("delete_event") { |widget, event| quit } signal_connect("destroy") { Gtk.main_quit } - puts "DEBUG:initialize completed in class BasicWindow" end - def quit puts "DEBUG: quiting Hiki example" destroy false end end - - + class CairoWindow < BasicWindow - PI = Math::PI RAD2DEG = 180/PI DEG2RAD = PI/180 - + BLACK=[0,0,0]; RED=[1,0,0]; GREEN=[0,1,0]; BLUE=[0,0,1]; TURQUOISE=[0,1,1]; PINK=[1,0,1]; YELLOW=[1,1,0]; WHITE=[1,1,1] GRAY=[0.8,0.8,0.8] - + def initialize(title=nil) super unless Gdk.cairo_available? raise "This program requires GTK+ 2.8.0 or later and cairo support" end - drawing_area = Gtk::DrawingArea.new add(drawing_area) - drawing_area.signal_connect("expose_event") do |w, e| cr = w.window.create_cairo_context cr.rectangle(e.area.x, e.area.y, e.area.width, e.area.height) @@ -354,18 +345,5 @@ end puts "DEBUG:initialize completed in class CairoWindow" end - def draw(cr, drawing_area) - width, height = drawing_area.window.size - # Fill the background with gray cr.set_source_rgb(GRAY) cr.rectangle(0, 0, width, height) cr.fill() end end - end @@ -373,7 +360,-5 @@ # ------- REQUIRED FILES: ----------- {{br}} {{br}} -(12.3.0.4){{br}} + :To run the examples in this article download the following files into your program directory: + (12.3.0.4){{br}} * hiki2-gtk-w-cairo.rb' .......... module file; see section 12.3.0.3 ((<Hiki Gtk With Cairo Module Download File|tut-gtk2-dancr-rbcatut-intro#Hiki Gtk With Cairo Module Download File>)).