1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
=begin header
button.rb - a part of testgtk.c rewritten in Ruby/GTK2
Copyright (C) 2002-2005 Ruby-GNOME2 Project Team
Rewritten by Hiroshi IGARASHI <igarashi@ueda.info.waseda.ac.jp>
$Date: 2005/07/17 16:55:26 $
$Id: button.rb,v 1.6 2005/07/17 16:55:26 mutoh Exp $
Original Copyright:
GTK - The GIMP Toolkit
Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
=end
require 'sample'
class ButtonSample < SampleWindow
def initialize
super("buttons")
box1 = Gtk::VBox.new(false, 0)
add(box1)
table = Gtk::Table.new(3, 3, false)
table.row_spacings = 5
table.column_spacings = 5
table.border_width = 10
box1.pack_start(table, true, true, 0)
button = [
Gtk::Button.new("button1"),
Gtk::Button.new("button2"),
Gtk::Button.new("button3"),
Gtk::Button.new("button4"),
Gtk::Button.new("button5"),
Gtk::Button.new("button6"),
Gtk::Button.new("button7"),
Gtk::Button.new("button8"),
Gtk::Button.new("button9"),
]
button[0].signal_connect("clicked") do
button_window(button[1])
end
table.attach(button[0], 0, 1, 0, 1,
Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0)
button[1].signal_connect("clicked") do
button_window(button[2])
end
table.attach(button[1], 1, 2, 1, 2,
Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0)
button[2].signal_connect("clicked") do
button_window(button[3])
end
table.attach(button[2], 2, 3, 2, 3,
Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0)
button[3].signal_connect("clicked") do
button_window(button[4])
end
table.attach(button[3], 0, 1, 2, 3,
Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0)
button[4].signal_connect("clicked") do
button_window(button[5])
end
table.attach(button[4], 2, 3, 0, 1,
Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0)
button[5].signal_connect("clicked") do
button_window(button[6])
end
table.attach(button[5], 1, 2, 2, 3,
Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0)
button[6].signal_connect("clicked") do
button_window(button[7])
end
table.attach(button[6], 1, 2, 0, 1,
Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0)
button[7].signal_connect("clicked") do
button_window(button[8])
end
table.attach(button[7], 2, 3, 1, 2,
Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0)
button[8].signal_connect("clicked") do
button_window(button[0])
end
table.attach(button[8], 0, 1, 1, 2,
Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0)
box1.pack_start(Gtk::HSeparator.new, false, true, 0)
box2 = Gtk::VBox.new(false, 10)
box2.border_width = 10
box1.pack_start(box2, false, true, 0)
button[9] = Gtk::Button.new("close")
button[9].signal_connect("clicked") do destroy end
box2.add(button[9])
end
private
def button_window(button)
unless button.visible?
button.show
else
button.hide
end
end
end
|