goocanvas 0.90.6-x86-mingw32

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.
Files changed (136) hide show
  1. data/ChangeLog +87 -0
  2. data/README +37 -0
  3. data/Rakefile +14 -0
  4. data/ext/goocanvas/depend +5 -0
  5. data/ext/goocanvas/extconf.rb +66 -0
  6. data/ext/goocanvas/goocanvas.def +2 -0
  7. data/ext/goocanvas/rbgoocairo.c +74 -0
  8. data/ext/goocanvas/rbgoocanvas.c +236 -0
  9. data/ext/goocanvas/rbgoocanvas.h +66 -0
  10. data/ext/goocanvas/rbgoocanvasellipse.c +50 -0
  11. data/ext/goocanvas/rbgoocanvasgroup.c +41 -0
  12. data/ext/goocanvas/rbgoocanvasimage.c +45 -0
  13. data/ext/goocanvas/rbgoocanvasitem.c +358 -0
  14. data/ext/goocanvas/rbgoocanvaspolyline.c +102 -0
  15. data/ext/goocanvas/rbgoocanvasrect.c +47 -0
  16. data/ext/goocanvas/rbgoocanvasstyle.c +61 -0
  17. data/ext/goocanvas/rbgoocanvastable.c +41 -0
  18. data/ext/goocanvas/rbgoocanvastext.c +58 -0
  19. data/ext/goocanvas/rbgoocanvaswidget.c +48 -0
  20. data/ext/goocanvas/rbgooutils.c +44 -0
  21. data/extconf.rb +49 -0
  22. data/lib/1.8/goocanvas.so +0 -0
  23. data/lib/1.9/goocanvas.so +0 -0
  24. data/lib/goocanvas.rb +145 -0
  25. data/sample/demo-arrowhead.rb +315 -0
  26. data/sample/demo-fifteen.rb +218 -0
  27. data/sample/demo-primitives.rb +720 -0
  28. data/sample/demo.rb +84 -0
  29. data/sample/flower.png +0 -0
  30. data/sample/scalability-demo.rb +130 -0
  31. data/sample/simple-demo.rb +35 -0
  32. data/sample/table-demo.rb +137 -0
  33. data/sample/toroid.png +0 -0
  34. data/sample/units-demo.rb +80 -0
  35. data/sample/widgets-demo.rb +197 -0
  36. data/vendor/local/bin/libgoocanvas-3.dll +0 -0
  37. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvas.h +334 -0
  38. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasatk.h +22 -0
  39. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasellipse.h +120 -0
  40. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasenumtypes.h +33 -0
  41. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasgrid.h +153 -0
  42. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasgroup.h +109 -0
  43. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasimage.h +121 -0
  44. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasitem.h +479 -0
  45. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasitemmodel.h +275 -0
  46. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasitemsimple.h +247 -0
  47. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasmarshal.h +61 -0
  48. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvaspath.h +116 -0
  49. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvaspolyline.h +176 -0
  50. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasprivate.h +59 -0
  51. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasrect.h +121 -0
  52. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasstyle.h +110 -0
  53. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvastable.h +139 -0
  54. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvastext.h +133 -0
  55. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvasutils.h +333 -0
  56. data/vendor/local/include/goocanvas-1.0.0/goocanvas/goocanvaswidget.h +66 -0
  57. data/vendor/local/include/goocanvas-1.0.0/goocanvas/stamp-goocanvasmarshal.h +1 -0
  58. data/vendor/local/lib/libgoocanvas.a +0 -0
  59. data/vendor/local/lib/libgoocanvas.dll.a +0 -0
  60. data/vendor/local/lib/pkgconfig/goocanvas.pc +13 -0
  61. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvas.html +1982 -0
  62. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasEllipse.html +269 -0
  63. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasEllipseModel.html +274 -0
  64. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasGrid.html +469 -0
  65. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasGridModel.html +476 -0
  66. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasGroup.html +183 -0
  67. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasGroupModel.html +184 -0
  68. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasImage.html +247 -0
  69. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasImageModel.html +252 -0
  70. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasItem.html +3014 -0
  71. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasItemModel.html +1764 -0
  72. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasItemModelSimple.html +298 -0
  73. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasItemSimple.html +809 -0
  74. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasPath.html +279 -0
  75. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasPathModel.html +280 -0
  76. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasPolyline.html +369 -0
  77. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasPolylineModel.html +375 -0
  78. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasRect.html +247 -0
  79. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasRectModel.html +252 -0
  80. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasStyle.html +489 -0
  81. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasTable.html +452 -0
  82. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasTableModel.html +452 -0
  83. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasText.html +324 -0
  84. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasTextModel.html +287 -0
  85. data/vendor/local/share/gtk-doc/html/goocanvas/GooCanvasWidget.html +266 -0
  86. data/vendor/local/share/gtk-doc/html/goocanvas/ch01.html +53 -0
  87. data/vendor/local/share/gtk-doc/html/goocanvas/ch02.html +50 -0
  88. data/vendor/local/share/gtk-doc/html/goocanvas/ch03.html +62 -0
  89. data/vendor/local/share/gtk-doc/html/goocanvas/ch04.html +60 -0
  90. data/vendor/local/share/gtk-doc/html/goocanvas/ch05.html +33 -0
  91. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-GooCanvas-Types.html +815 -0
  92. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-architecture.html +157 -0
  93. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-coordinates.html +106 -0
  94. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-creating-items.html +420 -0
  95. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-model-view-canvas.html +246 -0
  96. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-overview.html +106 -0
  97. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-simple-canvas.html +238 -0
  98. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas-wysiwyg.html +84 -0
  99. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas.devhelp +608 -0
  100. data/vendor/local/share/gtk-doc/html/goocanvas/goocanvas.devhelp2 +639 -0
  101. data/vendor/local/share/gtk-doc/html/goocanvas/home.png +0 -0
  102. data/vendor/local/share/gtk-doc/html/goocanvas/index.html +138 -0
  103. data/vendor/local/share/gtk-doc/html/goocanvas/index.sgml +814 -0
  104. data/vendor/local/share/gtk-doc/html/goocanvas/left.png +0 -0
  105. data/vendor/local/share/gtk-doc/html/goocanvas/right.png +0 -0
  106. data/vendor/local/share/gtk-doc/html/goocanvas/style.css +257 -0
  107. data/vendor/local/share/gtk-doc/html/goocanvas/up.png +0 -0
  108. data/vendor/local/share/gtk-doc/tmpl/goocanvas/dummy.sgml +0 -0
  109. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvas-unused.sgml +0 -0
  110. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvas.sgml +536 -0
  111. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasellipse.sgml +82 -0
  112. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasellipsemodel.sgml +82 -0
  113. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasgrid.sgml +176 -0
  114. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasgridmodel.sgml +176 -0
  115. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasgroup.sgml +58 -0
  116. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasgroupmodel.sgml +58 -0
  117. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasimage.sgml +81 -0
  118. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasimagemodel.sgml +81 -0
  119. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasitem.sgml +773 -0
  120. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasitemmodel.sgml +490 -0
  121. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasitemmodelsimple.sgml +135 -0
  122. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasitemsimple.sgml +254 -0
  123. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvaspath.sgml +64 -0
  124. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvaspathmodel.sgml +64 -0
  125. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvaspolyline.sgml +109 -0
  126. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvaspolylinemodel.sgml +109 -0
  127. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasrect.sgml +72 -0
  128. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasrectmodel.sgml +72 -0
  129. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasstyle.sgml +186 -0
  130. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvastable.sgml +158 -0
  131. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvastablemodel.sgml +158 -0
  132. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvastext.sgml +103 -0
  133. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvastextmodel.sgml +93 -0
  134. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvasutils.sgml +241 -0
  135. data/vendor/local/share/gtk-doc/tmpl/goocanvas/goocanvaswidget.sgml +73 -0
  136. metadata +218 -0
data/sample/demo.rb ADDED
@@ -0,0 +1,84 @@
1
+ # -*- indent-tabs-mode: nil -*-
2
+ =begin header
3
+
4
+ demo.rb - Canvas test rewritten in Ruby/GooCanvas
5
+
6
+ Rewritten by Emmanuel Pinault <seatmanu@yahoo.com>
7
+
8
+ Original Copyright:
9
+
10
+ Author : Richard Hestilow <hestgray@ionet.net>
11
+
12
+ Copyright (C) 1998 Free Software Foundation
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2, or (at your option)
17
+ any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27
+ 02111-1307, USA.
28
+
29
+ =end
30
+
31
+ base_dir = File.dirname(__FILE__)
32
+ src_dir = File.expand_path(File.join(base_dir, "..", "src"))
33
+ lib_dir = File.join(src_dir, "lib")
34
+
35
+ $LOAD_PATH.unshift(src_dir)
36
+ $LOAD_PATH.unshift(lib_dir)
37
+ $LOAD_PATH.unshift(base_dir)
38
+
39
+ require 'goocanvas'
40
+ require 'demo-primitives'
41
+ require 'demo-arrowhead'
42
+ require 'demo-fifteen'
43
+
44
+ class GooCanvasSample < Gtk::Window
45
+ def initialize
46
+ super(Gtk::Window::TOPLEVEL)
47
+
48
+ signal_connect("destroy") do |widget, event|
49
+ Gtk::main_quit()
50
+ end
51
+
52
+ signal_connect("key_press_event") do |widget, event|
53
+ if event.state.control_mask? and event.keyval == Gdk::Keyval::GDK_q
54
+ destroy
55
+ true
56
+ else
57
+ false
58
+ end
59
+ end
60
+
61
+ set_default_size(640, 600)
62
+ notebook = Gtk::Notebook.new
63
+ add(notebook)
64
+ notebook.show
65
+
66
+ notebook.append_page(CanvasSamplePrimitives.new(false),
67
+ Gtk::Label.new("Primitives"))
68
+ notebook.append_page(CanvasSampleArrowhead.new,
69
+ Gtk::Label.new("Arrowhead"))
70
+ notebook.append_page(CanvasSampleFifteen.new,
71
+ Gtk::Label.new("Fifteen"))
72
+ # notebook.append_page(CanvasSampleFeatures.new,
73
+ # Gtk::Label.new("Feature"))
74
+ # notebook.append_page(CanvasSampleRichText.new,
75
+ # Gtk::Label.new("Rich Text"))
76
+ # notebook.append_page(CanvasSampleBezierCurve.new,
77
+ # Gtk::Label.new("Bezier Curve"))
78
+ show
79
+ end
80
+ end
81
+
82
+ canvas = GooCanvasSample.new
83
+
84
+ Gtk.main
data/sample/flower.png ADDED
Binary file
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env ruby
2
+ require 'goocanvas'
3
+
4
+ # the values behind the comments are the ones used in the C version
5
+ # but as with them it takes more than 20 sec on my computer for the window
6
+ # to show upm I decreased them a little
7
+ N_GROUP_COLS = 15 #25
8
+ N_GROUP_ROWS = 10 #20
9
+ N_COLS = 10
10
+ N_ROWS = 10
11
+
12
+ PADDING = 10
13
+
14
+ ONLY_ONE = false
15
+
16
+ def setup_canvas(canvas)
17
+ root = canvas.root_item
18
+ root.font = 'Sans 8'
19
+
20
+ item_width = 400
21
+ item_height = 19
22
+
23
+ cell_width = item_width + PADDING * 2
24
+ cell_height = item_height + PADDING * 2
25
+
26
+ group_width = N_COLS * cell_width
27
+ group_height = N_ROWS * cell_height
28
+
29
+ total_width = N_GROUP_COLS * group_width
30
+ total_height = N_GROUP_ROWS * group_height
31
+
32
+ # We use -ve offsets to test if -ve coords are handled correctly.
33
+ left_offset = -total_width / 2
34
+ top_offset = -total_height / 2
35
+
36
+ style = Goo::CanvasStyle.new
37
+ color = Gdk::Color.parse("mediumseagreen")
38
+ pattern = Cairo::SolidPattern.new(color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0)
39
+ style.fill_pattern = pattern
40
+
41
+ style2 = Goo::CanvasStyle.new
42
+ color = Gdk::Color.parse("steelblue")
43
+ pattern = Cairo::SolidPattern.new(color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0)
44
+ style2.fill_pattern = pattern
45
+
46
+ total_items = 0
47
+
48
+ N_GROUP_COLS.times do |group_i|
49
+ N_GROUP_ROWS.times do |group_j|
50
+ group_x = left_offset + (group_i * group_width);
51
+ group_y = top_offset + (group_j * group_height);
52
+
53
+ group = Goo::CanvasGroup.new(root)
54
+ total_items += 1
55
+ group.translate(group_x, group_y)
56
+
57
+ N_COLS.times do |i|
58
+ N_ROWS.times do |j|
59
+ item_x = (i * cell_width) + PADDING
60
+ item_y = (j * cell_height) + PADDING
61
+ rotation = i % 10 * 2
62
+ rotation_x = item_x + item_width / 2
63
+ rotation_y = item_y + item_height / 2
64
+
65
+ current_id = "#{group_x + item_x}, #{group_y + item_y}"
66
+
67
+ item = Goo::CanvasRect.new(group, item_x, item_y, item_width, item_height)
68
+ item.style = (j % 2) == 1 ? style : style2
69
+ item.rotate(rotation, rotation_x, rotation_y)
70
+
71
+ item.signal_connect('motion_notify_event') do
72
+ puts "#{current_id} item received 'motion-notify' signal"
73
+ end
74
+
75
+ item = Goo::CanvasText.new(group, current_id,
76
+ item_x + item_width / 2, item_y + item_height / 2, -1, Gtk::ANCHOR_CENTER)
77
+ item.rotate(rotation, rotation_x, rotation_y)
78
+
79
+ total_items += 2
80
+ break if ONLY_ONE
81
+ end
82
+ break if ONLY_ONE
83
+ end
84
+ break if ONLY_ONE
85
+ end
86
+ break if ONLY_ONE
87
+ end
88
+
89
+ puts "Total items: #{total_items}"
90
+ [ total_width, total_height, left_offset, top_offset ]
91
+ end
92
+
93
+ def create_canvas
94
+ # Create the canvas.
95
+ canvas = Goo::Canvas.new
96
+ canvas.set_size_request(600, 450)
97
+
98
+ start = Time.new
99
+ total_width, total_height, left_offset, top_offset = setup_canvas(canvas)
100
+ puts "Create Canvas Time Used: #{Time.new - start}"
101
+
102
+ start = Time.new
103
+ canvas.set_bounds(left_offset, top_offset, left_offset + total_width, top_offset + total_height)
104
+ canvas.show
105
+
106
+ first_time = true
107
+ canvas.signal_connect("expose_event") do
108
+ if first_time
109
+ puts "Update Canvas Time Used: #{Time.new - start}"
110
+ first_time = false
111
+ end
112
+ false
113
+ end
114
+
115
+ canvas
116
+ end
117
+
118
+ window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
119
+ window.set_default_size(640, 600)
120
+ window.show
121
+ window.signal_connect('delete_event') { Gtk.main_quit }
122
+
123
+ scrolled_win = Gtk::ScrolledWindow.new
124
+ scrolled_win.show
125
+ window.add(scrolled_win)
126
+
127
+ canvas = create_canvas
128
+ scrolled_win.add(canvas)
129
+
130
+ Gtk.main
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ require 'goocanvas'
3
+
4
+ # Create the window and widgets.
5
+ window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
6
+ window.set_default_size(640, 600)
7
+ window.show
8
+ window.signal_connect('delete_event') { Gtk.main_quit }
9
+
10
+ scrolled_win = Gtk::ScrolledWindow.new
11
+ scrolled_win.shadow_type = Gtk::SHADOW_IN
12
+ scrolled_win.show
13
+ window.add(scrolled_win)
14
+
15
+ canvas = Goo::Canvas.new
16
+ canvas.set_size_request(600, 450)
17
+ canvas.set_bounds(0, 0, 1000, 1000)
18
+ canvas.show
19
+ scrolled_win.add(canvas)
20
+
21
+ root = canvas.root_item
22
+
23
+ rect_item = Goo::CanvasRect.new(root, 100, 100, 400, 400,
24
+ :line_width => 10.0,
25
+ :radius_x => 20.0,
26
+ :radius_y => 10.0,
27
+ :stroke_color => 'yellow',
28
+ :fill_color => 'red')
29
+ rect_item.signal_connect('button_press_event') { puts "rect item received button press event\n" }
30
+
31
+ text_item = Goo::CanvasText.new(root, 'Hello World', 300, 300, -1, Gtk::ANCHOR_CENTER, :font => 'Sans 24')
32
+
33
+ text_item.rotate(45, 300, 300)
34
+
35
+ Gtk.main
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env ruby
2
+ require 'goocanvas'
3
+ DEMO_RECT_ITEM = 0
4
+ DEMO_TEXT_ITEM = 1
5
+ DEMO_WIDGET_ITEM = 2
6
+
7
+ def create_demo_item(table, demo_item_type, row, column, rows, columns, text)
8
+ case demo_item_type
9
+ when DEMO_RECT_ITEM
10
+ item = Goo::CanvasRect.new(table, 0, 0, 38, 19, :fill_color => 'red')
11
+ when DEMO_TEXT_ITEM
12
+ item = Goo::CanvasText.new(table, text, 0, 0, -1, Gtk::ANCHOR_NW, nil)
13
+ when DEMO_WIDGET_ITEM
14
+ widget = Gtk::Button.new(text)
15
+ item = Goo::CanvasWidget.new(table, widget, 0, 0, -1, -1)
16
+ end
17
+
18
+ table.set_child_properties(item, :row => row, :column => column, :rows => rows, :columns => columns,
19
+ :x_expand => true, :x_fill => true, :y_expand => true, :y_fill => true)
20
+
21
+ item.signal_connect('button_press_event') do |item, target, event|
22
+ puts "#{text} received 'button-press' signal at #{event.x}, #{event.y} (root: #{event.x_root}, #{event.y_root})"
23
+ true
24
+ end
25
+ end
26
+
27
+ def create_table(parent, row, column, embedding_level, x, y, rotation, scale, demo_item_type)
28
+ # Add a few simple items.
29
+ table = Goo::CanvasTable.new(parent, :row_spacing => 4.0, :column_spacing => 4.0)
30
+
31
+ table.translate(x, y)
32
+ table.rotate(rotation, 0, 0)
33
+ table.scale(scale, scale)
34
+
35
+ parent.set_child_properties(table, :row => row, :column => column, :x_expand => true, :x_fill => true) if row
36
+
37
+ if embedding_level > 0
38
+ level = embedding_level - 1
39
+ create_table(table, 0, 0, level, 50, 50, 0, 0.7, demo_item_type)
40
+ create_table(table, 0, 1, level, 50, 50, 45, 1.0, demo_item_type)
41
+ create_table(table, 0, 2, level, 50, 50, 90, 1.0, demo_item_type)
42
+ create_table(table, 1, 0, level, 50, 50, 135, 1.0, demo_item_type)
43
+ create_table(table, 1, 1, level, 50, 50, 180, 1.5, demo_item_type)
44
+ create_table(table, 1, 2, level, 50, 50, 225, 1.0, demo_item_type)
45
+ create_table(table, 2, 0, level, 50, 50, 270, 1.0, demo_item_type)
46
+ create_table(table, 2, 1, level, 50, 50, 315, 1.0, demo_item_type)
47
+ create_table(table, 2, 2, level, 50, 50, 360, 2.0, demo_item_type)
48
+ else
49
+ create_demo_item(table, demo_item_type, 0, 0, 1, 1, "(0,0)")
50
+ create_demo_item(table, demo_item_type, 0, 1, 1, 1, "(1,0)")
51
+ create_demo_item(table, demo_item_type, 0, 2, 1, 1, "(2,0)")
52
+ create_demo_item(table, demo_item_type, 1, 0, 1, 1, "(0,1)")
53
+ create_demo_item(table, demo_item_type, 1, 1, 1, 1, "(1,1)")
54
+ create_demo_item(table, demo_item_type, 1, 2, 1, 1, "(2,1)")
55
+ create_demo_item(table, demo_item_type, 2, 0, 1, 1, "(0,2)")
56
+ create_demo_item(table, demo_item_type, 2, 1, 1, 1, "(1,2)")
57
+ create_demo_item(table, demo_item_type, 2, 2, 1, 1, "(2,2)")
58
+ end
59
+ table
60
+ end
61
+
62
+ def create_demo_table(root, x, y, width, height)
63
+ table = Goo::CanvasTable.new(root, :row_spacing => 4.0, :column_spacing => 4.0, :width => width, :height => height)
64
+ table.translate(x, y)
65
+
66
+ square = Goo::CanvasRect.new(table, 0.0, 0.0, 50.0, 50.0, :fill_color => 'red')
67
+ table.set_child_properties(square, :row => 0, :column => 0, :x_shrink => true)
68
+ square.signal_connect('button_press_event') do |item, target, event|
69
+ puts "Red square received 'button-press' signal at #{event.x}, #{event.y} (root: #{event.x_root}, #{event.y_root})"
70
+ true
71
+ end
72
+
73
+ circle = Goo::CanvasEllipse.new(table, 0.0, 0.0, 25.0, 25.0, :fill_color => 'blue')
74
+ table.set_child_properties(circle, :row => 0, :column => 1, :x_shrink => true)
75
+ circle.signal_connect('button_press_event') do |item, target, event|
76
+ puts "Blue circle received 'button-press' signal at #{event.x}, #{event.y} (root: #{event.x_root}, #{event.y_root})"
77
+ true
78
+ end
79
+
80
+ triangle = Goo::CanvasPolyline.new(table, true, [ [ 25.0, 0.0], [ 0.0, 50.0 ], [ 50.0, 50.0 ] ], :fill_color => "yellow")
81
+ table.set_child_properties(triangle, :row => 0, :column => 2, :x_shrink => true)
82
+ triangle.signal_connect('button_press_event') do |item, target, event|
83
+ puts "Yellow triangle received 'button-press' signal at #{event.x}, #{event.y} (root: #{event.x_root}, #{event.y_root})"
84
+ true
85
+ end
86
+ end
87
+
88
+ window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
89
+ window.set_default_size(640, 600)
90
+ window.signal_connect('delete_event') { Gtk.main_quit }
91
+
92
+ vbox = Gtk::VBox.new(false, 4)
93
+ vbox.border_width = 4
94
+ vbox.show
95
+ window.add(vbox)
96
+
97
+ hbox = Gtk::HBox.new(false, 4)
98
+ vbox.pack_start(hbox, false, false, 0)
99
+ hbox.show
100
+
101
+ scrolled_win = Gtk::ScrolledWindow.new
102
+ scrolled_win.shadow_type = Gtk::SHADOW_IN
103
+ scrolled_win.show
104
+ vbox.pack_start(scrolled_win, true, true, 0)
105
+
106
+ canvas = Goo::Canvas.new
107
+ canvas.flags = Gtk::Widget::CAN_FOCUS
108
+ canvas.set_size_request(600, 450)
109
+ canvas.set_bounds(0, 0, 1000, 1000)
110
+ scrolled_win.add(canvas)
111
+
112
+ root = canvas.root_item
113
+
114
+ create_demo_table(root, 400, 200, -1, -1)
115
+ create_demo_table(root, 400, 260, 100, -1)
116
+
117
+ create_table(root, nil, nil, 0, 10, 10, 0, 1.0, DEMO_TEXT_ITEM)
118
+ create_table(root, nil, nil, 0, 180, 10, 30, 1.0, DEMO_TEXT_ITEM)
119
+ create_table(root, nil, nil, 0, 350, 10, 60, 1.0, DEMO_TEXT_ITEM)
120
+ create_table(root, nil, nil, 0, 500, 10, 90, 1.0, DEMO_TEXT_ITEM)
121
+
122
+ table = create_table(root, nil, nil, 0, 30, 150, 0, 1.0, DEMO_TEXT_ITEM)
123
+ table.width = 300.0
124
+ table.height = 100.0
125
+
126
+ create_table(root, nil, nil, 1, 200, 200, 30, 0.8, DEMO_TEXT_ITEM)
127
+
128
+ table = create_table(root, nil, nil, 0, 10, 700, 0, 1.0, DEMO_WIDGET_ITEM)
129
+ table.width = 300.0
130
+ table.height = 200.0
131
+
132
+ canvas.show
133
+
134
+ window.show
135
+
136
+ Gtk.main
137
+
data/sample/toroid.png ADDED
Binary file
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+ require 'goocanvas'
3
+
4
+ DATA = {
5
+ Gtk::PaperSize::UNIT_PIXEL => [ 100, 100, 200, 20, 10, 200, 310, 24 ],
6
+ Gtk::PaperSize::UNIT_POINTS => [ 100, 100, 200, 20, 10, 200, 310, 24 ],
7
+ Gtk::PaperSize::UNIT_INCH => [ 1, 1, 3, 0.5, 0.16, 3, 4, 0.3 ],
8
+ Gtk::PaperSize::UNIT_MM => [ 30, 30, 100, 10, 5, 80, 60, 10 ],
9
+ }
10
+
11
+ def setup_canvas(canvas, units, units_name)
12
+ d = DATA[units]
13
+
14
+ root = canvas.root_item
15
+
16
+ item = Goo::CanvasRect.new(root, d[0], d[1], d[2], d[3])
17
+ item.signal_connect('motion_notify_event') { puts "received 'motion-notify' signal" }
18
+
19
+ item = Goo::CanvasText.new(root, "This box is #{d[2]}x#{d[3]} #{units_name}",
20
+ d[0] + d[2] / 2.0, d[1] + d[3] / 2.0, -1, Gtk::ANCHOR_CENTER, :font => "Sans #{d[4]}px")
21
+
22
+ item = Goo::CanvasText.new(root, "This font is #{d[7]} #{units_name} high",
23
+ d[5], d[6], -1, Gtk::ANCHOR_CENTER, :font => "Sans #{d[7]}px")
24
+ end
25
+
26
+ def create_canvas(units, units_name)
27
+ vbox = Gtk::VBox.new(false, 4)
28
+ vbox.show
29
+
30
+ hbox = Gtk::HBox.new(false, 4)
31
+ vbox.pack_start(hbox, false, false, 0)
32
+ hbox.show
33
+
34
+ canvas = Goo::Canvas.new
35
+
36
+ w = Gtk::Label.new('Zoom:')
37
+ hbox.pack_start(w, false, false, 0)
38
+ w.show
39
+
40
+ adj = Gtk::Adjustment.new(1, 0.05, 100, 0.05, 0.5, 0.5)
41
+ w = Gtk::SpinButton.new(adj, 0, 2)
42
+ adj.signal_connect('value_changed') { |new_adj| canvas.scale = new_adj.value }
43
+
44
+ w.set_size_request(50, -1)
45
+ hbox.pack_start(w, false, false, 0)
46
+ w.show
47
+
48
+ scrolled_win = Gtk::ScrolledWindow.new
49
+ vbox.pack_start(scrolled_win, true, true, 0)
50
+ scrolled_win.show
51
+
52
+ # Create the canvas.
53
+ canvas.set_size_request(600, 450)
54
+ setup_canvas(canvas, units, units_name)
55
+
56
+ canvas.set_bounds(0, 0, 1000, 1000)
57
+ canvas.units = units
58
+ canvas.anchor = Gtk::ANCHOR_CENTER
59
+ canvas.show
60
+
61
+ scrolled_win.add(canvas)
62
+
63
+ vbox
64
+ end
65
+
66
+ window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
67
+ window.set_default_size(640, 600)
68
+ window.show
69
+ window.signal_connect('delete_event') { Gtk.main_quit }
70
+
71
+ notebook = Gtk::Notebook.new
72
+ notebook.show
73
+ window.add(notebook)
74
+
75
+ notebook.append_page(create_canvas(Gtk::PaperSize::UNIT_PIXEL, 'pixels'), Gtk::Label.new('Pixels'))
76
+ notebook.append_page(create_canvas(Gtk::PaperSize::UNIT_POINTS, 'points'), Gtk::Label.new('Points'))
77
+ notebook.append_page(create_canvas(Gtk::PaperSize::UNIT_INCH, 'inches'), Gtk::Label.new('Inches'))
78
+ notebook.append_page(create_canvas(Gtk::PaperSize::UNIT_MM, 'millimeters'), Gtk::Label.new('Millimeters'))
79
+
80
+ Gtk.main
@@ -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
Binary file