goocanvas 0.90.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +87 -0
- data/README +37 -0
- data/Rakefile +14 -0
- data/ext/goocanvas/Makefile +162 -0
- data/ext/goocanvas/depend +5 -0
- data/ext/goocanvas/extconf.rb +66 -0
- data/ext/goocanvas/goocanvas.def +2 -0
- data/ext/goocanvas/goocanvas.so +0 -0
- data/ext/goocanvas/rbgoo_canvasversion.h +25 -0
- data/ext/goocanvas/rbgoocairo.c +74 -0
- data/ext/goocanvas/rbgoocairo.o +0 -0
- data/ext/goocanvas/rbgoocanvas.c +236 -0
- data/ext/goocanvas/rbgoocanvas.h +66 -0
- data/ext/goocanvas/rbgoocanvas.o +0 -0
- data/ext/goocanvas/rbgoocanvasellipse.c +50 -0
- data/ext/goocanvas/rbgoocanvasellipse.o +0 -0
- data/ext/goocanvas/rbgoocanvasgroup.c +41 -0
- data/ext/goocanvas/rbgoocanvasgroup.o +0 -0
- data/ext/goocanvas/rbgoocanvasimage.c +45 -0
- data/ext/goocanvas/rbgoocanvasimage.o +0 -0
- data/ext/goocanvas/rbgoocanvasitem.c +358 -0
- data/ext/goocanvas/rbgoocanvasitem.o +0 -0
- data/ext/goocanvas/rbgoocanvaspolyline.c +102 -0
- data/ext/goocanvas/rbgoocanvaspolyline.o +0 -0
- data/ext/goocanvas/rbgoocanvasrect.c +47 -0
- data/ext/goocanvas/rbgoocanvasrect.o +0 -0
- data/ext/goocanvas/rbgoocanvasstyle.c +61 -0
- data/ext/goocanvas/rbgoocanvasstyle.o +0 -0
- data/ext/goocanvas/rbgoocanvastable.c +41 -0
- data/ext/goocanvas/rbgoocanvastable.o +0 -0
- data/ext/goocanvas/rbgoocanvastext.c +58 -0
- data/ext/goocanvas/rbgoocanvastext.o +0 -0
- data/ext/goocanvas/rbgoocanvaswidget.c +48 -0
- data/ext/goocanvas/rbgoocanvaswidget.o +0 -0
- data/ext/goocanvas/rbgooutils.c +44 -0
- data/ext/goocanvas/rbgooutils.o +0 -0
- data/ext/goocanvas/ruby-goocanvas.pc +3 -0
- data/extconf.rb +49 -0
- data/lib/goocanvas.rb +145 -0
- data/sample/demo-arrowhead.rb +315 -0
- data/sample/demo-fifteen.rb +218 -0
- data/sample/demo-primitives.rb +720 -0
- data/sample/demo.rb +84 -0
- data/sample/flower.png +0 -0
- data/sample/scalability-demo.rb +130 -0
- data/sample/simple-demo.rb +35 -0
- data/sample/table-demo.rb +137 -0
- data/sample/toroid.png +0 -0
- data/sample/units-demo.rb +80 -0
- data/sample/widgets-demo.rb +197 -0
- metadata +133 -0
@@ -0,0 +1,197 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'goocanvas'
|
3
|
+
|
4
|
+
num_added_widgets = 0
|
5
|
+
added_widget_items = []
|
6
|
+
canvas = nil
|
7
|
+
move_item = nil
|
8
|
+
|
9
|
+
def create_focus_box(canvas, x, y, width, height, color)
|
10
|
+
root = canvas.root_item
|
11
|
+
item = Goo::CanvasRect.new(root, x, y, width, height, :stroke_pattern => nil, :fill_color => color, :line_width => 5.0, :can_focus => true)
|
12
|
+
|
13
|
+
item.signal_connect('focus_in_event') do
|
14
|
+
puts "#{color} received focus-in event"
|
15
|
+
# Note that this is only for testing. Setting item properties to indicate
|
16
|
+
# focus isn't a good idea for real apps, as there may be multiple views.
|
17
|
+
item.stroke_color = 'black'
|
18
|
+
false
|
19
|
+
end
|
20
|
+
|
21
|
+
item.signal_connect('focus_out_event') do
|
22
|
+
puts "#{color} received focus-out event"
|
23
|
+
# Note that this is only for testing. Setting item properties to indicate
|
24
|
+
# focus isn't a good idea for real apps, as there may be multiple views.
|
25
|
+
item.stroke_pattern = nil
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
item.signal_connect('button_press_event') do
|
30
|
+
puts "#{color} received button-press event"
|
31
|
+
item.canvas.grab_focus(item)
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
item.signal_connect('key_press_event') do
|
36
|
+
puts "#{color} received key-press event"
|
37
|
+
false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_button(hbox, button_name, &click_action)
|
42
|
+
w = Gtk::Button.new(button_name)
|
43
|
+
hbox.pack_start(w, false, false, 0)
|
44
|
+
w.show
|
45
|
+
w.signal_connect('clicked', &click_action)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Create the window and widgets.
|
49
|
+
window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
|
50
|
+
window.set_default_size(640, 600)
|
51
|
+
window.show
|
52
|
+
window.signal_connect('delete_event') { Gtk.main_quit }
|
53
|
+
|
54
|
+
vbox = Gtk::VBox.new(false, 4)
|
55
|
+
vbox.border_width = 4
|
56
|
+
vbox.show
|
57
|
+
window.add(vbox)
|
58
|
+
|
59
|
+
hbox = Gtk::HBox.new(false, 4)
|
60
|
+
vbox.pack_start(hbox, false, false, 0)
|
61
|
+
hbox.show
|
62
|
+
|
63
|
+
add_button(hbox, 'Add Widget') do
|
64
|
+
if num_added_widgets % 2 == 1
|
65
|
+
widget = Gtk::Label.new("Hello World")
|
66
|
+
else
|
67
|
+
widget = Gtk::Entry.new
|
68
|
+
end
|
69
|
+
|
70
|
+
root = canvas.root_item
|
71
|
+
witem = Goo::CanvasWidget.new(root, widget, num_added_widgets * 50, num_added_widgets * 50, 200, 50, nil)
|
72
|
+
|
73
|
+
added_widget_items.push(witem)
|
74
|
+
num_added_widgets += 1
|
75
|
+
end
|
76
|
+
|
77
|
+
add_button(hbox, 'Remove Widget') do
|
78
|
+
root = canvas.root_item
|
79
|
+
witem = added_widget_items.pop
|
80
|
+
if witem
|
81
|
+
root.remove_child(witem)
|
82
|
+
num_added_widgets -= 1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
move_index = 0
|
87
|
+
Moves = [
|
88
|
+
[ 50, 50, -1, -1 ],
|
89
|
+
[ 300, 100, -1, -1 ],
|
90
|
+
[ 200, 200, -1, -1 ],
|
91
|
+
[ 400, 100, -1, -1 ],
|
92
|
+
]
|
93
|
+
|
94
|
+
add_button(hbox, 'Move Widget') do
|
95
|
+
move_item.x = Moves[move_index][0]
|
96
|
+
move_item.y = Moves[move_index][1]
|
97
|
+
move_item.width = Moves[move_index][2]
|
98
|
+
move_item.height = Moves[move_index][3]
|
99
|
+
move_index = (move_index + 1) % 4
|
100
|
+
end
|
101
|
+
|
102
|
+
# here we have to do a little more complicated than in C because Ruby/Gtk+'s enums are not ints and we can't do + 1 on them
|
103
|
+
moving_anchor = Gtk::ANCHOR_CENTER.to_i
|
104
|
+
add_button(hbox, 'Change Anchor') do
|
105
|
+
puts "Setting anchor to: #{Gtk::AnchorType.new(moving_anchor).name}"
|
106
|
+
move_item.anchor = moving_anchor
|
107
|
+
moving_anchor += 1
|
108
|
+
moving_anchor = Gtk::ANCHOR_CENTER.to_i if moving_anchor > Gtk::ANCHOR_EAST.to_i
|
109
|
+
end
|
110
|
+
|
111
|
+
add_button(hbox, 'Change Widget') do
|
112
|
+
witem = added_widget_items.last
|
113
|
+
if witem
|
114
|
+
if witem.widget.instance_of?(Gtk::Entry)
|
115
|
+
witem.widget = Gtk::Label.new("Hello World")
|
116
|
+
else
|
117
|
+
witem.widget = Gtk::Entry.new
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
hbox = Gtk::HBox.new(false, 4)
|
123
|
+
vbox.pack_start(hbox, false, false, 0)
|
124
|
+
hbox.show
|
125
|
+
|
126
|
+
add_button(hbox, 'Hide Canvas') { canvas.hide }
|
127
|
+
add_button(hbox, 'Show Canvas') { canvas.show }
|
128
|
+
add_button(hbox, 'Hide Item') { move_item.visibility = Goo::CanvasItem::INVISIBLE }
|
129
|
+
add_button(hbox, 'Show Item') { move_item.visibility = Goo::CanvasItem::VISIBLE }
|
130
|
+
add_button(hbox, 'Change Transform') { move_item.translate(25, 25) }
|
131
|
+
|
132
|
+
scrolled_win = Gtk::ScrolledWindow.new
|
133
|
+
scrolled_win.shadow_type = Gtk::SHADOW_IN
|
134
|
+
scrolled_win.show
|
135
|
+
vbox.pack_start(scrolled_win, true, true, 0)
|
136
|
+
|
137
|
+
canvas = Goo::Canvas.new
|
138
|
+
canvas.flags = Gtk::Widget::CAN_FOCUS
|
139
|
+
canvas.set_size_request(600, 450)
|
140
|
+
canvas.set_bounds(0, 0, 1000, 1000)
|
141
|
+
scrolled_win.add(canvas)
|
142
|
+
|
143
|
+
root = canvas.root_item
|
144
|
+
|
145
|
+
# Add a few simple items.
|
146
|
+
label = Gtk::Label.new("Hello World")
|
147
|
+
witem = Goo::CanvasWidget.new(root, label, 50, 50, 200, 100, nil)
|
148
|
+
|
149
|
+
entry = Gtk::Entry.new
|
150
|
+
move_item = Goo::CanvasWidget.new(root, entry, 50, 250, 200, 50, nil)
|
151
|
+
|
152
|
+
entry = Gtk::Entry.new
|
153
|
+
entry.text = "Size: -1 x -1"
|
154
|
+
witem = Goo::CanvasWidget.new(root, entry, 50, 300, -1, -1, nil)
|
155
|
+
|
156
|
+
entry = Gtk::Entry.new
|
157
|
+
entry.text = "Size: 100 x -1"
|
158
|
+
witem = Goo::CanvasWidget.new(root, entry, 50, 350, 100, -1, nil)
|
159
|
+
|
160
|
+
# Use a textview so we can see the width & height of the widget.
|
161
|
+
scrolled_win = Gtk::ScrolledWindow.new
|
162
|
+
scrolled_win.shadow_type = Gtk::SHADOW_IN
|
163
|
+
scrolled_win.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_NEVER)
|
164
|
+
textview = Gtk::TextView.new
|
165
|
+
buffer = textview.buffer
|
166
|
+
buffer.text = "Size: -1 x 100"
|
167
|
+
textview.show
|
168
|
+
scrolled_win.add(textview)
|
169
|
+
scrolled_win.set_size_request(160, 50)
|
170
|
+
witem = Goo::CanvasWidget.new(root, scrolled_win, 50, 400, -1, 100, nil)
|
171
|
+
|
172
|
+
# Create a vbox item with several child entry widgets to check focus traversal.
|
173
|
+
vbox = Gtk::VBox.new(false, 4)
|
174
|
+
|
175
|
+
entry = Gtk::Entry.new
|
176
|
+
entry.show
|
177
|
+
vbox.pack_start(entry, false, false, 0)
|
178
|
+
|
179
|
+
entry = Gtk::Entry.new
|
180
|
+
entry.show
|
181
|
+
vbox.pack_start(entry, false, false, 0)
|
182
|
+
|
183
|
+
entry = Gtk::Entry.new
|
184
|
+
entry.show
|
185
|
+
vbox.pack_start(entry, false, false, 0)
|
186
|
+
|
187
|
+
witem = Goo::CanvasWidget.new(root, vbox, 50, 600, -1, -1, nil)
|
188
|
+
|
189
|
+
# Create a few normal canvas items that take keyboard focus.
|
190
|
+
create_focus_box(canvas, 110, 80, 50, 30, 'red')
|
191
|
+
create_focus_box(canvas, 300, 160, 50, 30, 'orange')
|
192
|
+
create_focus_box(canvas, 500, 50, 50, 30, 'yellow')
|
193
|
+
|
194
|
+
canvas.show
|
195
|
+
|
196
|
+
# Pass control to the GTK+ main event loop.
|
197
|
+
Gtk.main
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: goocanvas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 379
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 90
|
9
|
+
- 6
|
10
|
+
version: 0.90.6
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- The Ruby-GNOME2 Proejct Team
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-30 00:00:00 +09:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: gtk2
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 379
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 90
|
33
|
+
- 6
|
34
|
+
version: 0.90.6
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Ruby/GooCanvas is a Ruby binding of GooCanvas.
|
38
|
+
email: ruby-gnome2-devel-en@lists.sourceforge.net
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions:
|
42
|
+
- ext/goocanvas/extconf.rb
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- ChangeLog
|
47
|
+
- README
|
48
|
+
- Rakefile
|
49
|
+
- extconf.rb
|
50
|
+
- lib/goocanvas.rb
|
51
|
+
- ext/goocanvas/rbgoocanvastext.c
|
52
|
+
- ext/goocanvas/rbgoocanvasimage.o
|
53
|
+
- ext/goocanvas/goocanvas.so
|
54
|
+
- ext/goocanvas/rbgoocanvasimage.c
|
55
|
+
- ext/goocanvas/rbgoocanvaspolyline.o
|
56
|
+
- ext/goocanvas/rbgoocanvastable.c
|
57
|
+
- ext/goocanvas/rbgooutils.c
|
58
|
+
- ext/goocanvas/rbgoocanvas.c
|
59
|
+
- ext/goocanvas/rbgoocanvasstyle.o
|
60
|
+
- ext/goocanvas/rbgoo_canvasversion.h
|
61
|
+
- ext/goocanvas/rbgoocanvaspolyline.c
|
62
|
+
- ext/goocanvas/Makefile
|
63
|
+
- ext/goocanvas/rbgoocanvastable.o
|
64
|
+
- ext/goocanvas/rbgoocairo.c
|
65
|
+
- ext/goocanvas/rbgoocanvas.o
|
66
|
+
- ext/goocanvas/rbgooutils.o
|
67
|
+
- ext/goocanvas/extconf.rb
|
68
|
+
- ext/goocanvas/goocanvas.def
|
69
|
+
- ext/goocanvas/rbgoocairo.o
|
70
|
+
- ext/goocanvas/ruby-goocanvas.pc
|
71
|
+
- ext/goocanvas/rbgoocanvasrect.c
|
72
|
+
- ext/goocanvas/rbgoocanvasellipse.c
|
73
|
+
- ext/goocanvas/rbgoocanvasitem.c
|
74
|
+
- ext/goocanvas/rbgoocanvasstyle.c
|
75
|
+
- ext/goocanvas/rbgoocanvasrect.o
|
76
|
+
- ext/goocanvas/rbgoocanvasitem.o
|
77
|
+
- ext/goocanvas/rbgoocanvaswidget.c
|
78
|
+
- ext/goocanvas/rbgoocanvaswidget.o
|
79
|
+
- ext/goocanvas/rbgoocanvasellipse.o
|
80
|
+
- ext/goocanvas/rbgoocanvas.h
|
81
|
+
- ext/goocanvas/depend
|
82
|
+
- ext/goocanvas/rbgoocanvasgroup.c
|
83
|
+
- ext/goocanvas/rbgoocanvasgroup.o
|
84
|
+
- ext/goocanvas/rbgoocanvastext.o
|
85
|
+
- sample/toroid.png
|
86
|
+
- sample/flower.png
|
87
|
+
- sample/demo-fifteen.rb
|
88
|
+
- sample/table-demo.rb
|
89
|
+
- sample/demo.rb
|
90
|
+
- sample/widgets-demo.rb
|
91
|
+
- sample/demo-primitives.rb
|
92
|
+
- sample/demo-arrowhead.rb
|
93
|
+
- sample/scalability-demo.rb
|
94
|
+
- sample/units-demo.rb
|
95
|
+
- sample/simple-demo.rb
|
96
|
+
has_rdoc: true
|
97
|
+
homepage: http://ruby-gnome2.sourceforge.jp/
|
98
|
+
licenses: []
|
99
|
+
|
100
|
+
post_install_message: This library is experimental.
|
101
|
+
rdoc_options: []
|
102
|
+
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 61
|
111
|
+
segments:
|
112
|
+
- 1
|
113
|
+
- 8
|
114
|
+
- 5
|
115
|
+
version: 1.8.5
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
hash: 3
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
version: "0"
|
125
|
+
requirements: []
|
126
|
+
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 1.3.7
|
129
|
+
signing_key:
|
130
|
+
specification_version: 3
|
131
|
+
summary: Ruby/GooCanvas is a Ruby binding of GooCanvas.
|
132
|
+
test_files: []
|
133
|
+
|