goocanvas 0.90.6-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,218 @@
1
+ # -*- indent-tabs-mode: nil -*-
2
+ =begin header
3
+
4
+ demo-fifteen.rb - Canvas test rewritten in Ruby/GNOME
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
+ class CanvasSampleFifteen < Gtk::VBox
32
+ PIECE_SIZE = 50
33
+ SCRAMBLE_MOVES = 32
34
+
35
+ def initialize
36
+ super(false, 4)
37
+ border_width = 4
38
+ show()
39
+
40
+ alignment = Gtk::Alignment.new(0.5, 0.5, 0.0, 0.0)
41
+ pack_start(alignment, true, true, 0)
42
+ alignment.show()
43
+
44
+ frame = Gtk::Frame.new
45
+ frame.set_shadow_type(Gtk::SHADOW_IN);
46
+ alignment.add(frame)
47
+ frame.show()
48
+
49
+ # Create the canvas and board
50
+
51
+ @canvas = Goo::Canvas.new()
52
+ @canvas.set_size_request(PIECE_SIZE * 4 + 1, PIECE_SIZE * 4 + 1)
53
+ #@canvas.set_scroll_region(0, 0, PIECE_SIZE * 4 + 1, PIECE_SIZE * 4 + 1)
54
+ frame.add(@canvas)
55
+ @canvas.show()
56
+
57
+ @board = Array.new(16)
58
+
59
+ 0.upto(14) do |i|
60
+ @board[i] = Piece.new(@canvas.root_item)
61
+ @board[i].setup(self, i)
62
+ end
63
+ @board[15] = nil;
64
+
65
+ # Scramble button
66
+ button = Gtk::Button.new("Scramble")
67
+ pack_start(button, false, false, 0)
68
+ button.signal_connect("clicked") do |button|
69
+ scramble()
70
+ end
71
+ button.show()
72
+ end
73
+
74
+ def test_win
75
+ 0.upto(14) do |i|
76
+ if @board[i].nil? || @board[i].num != i
77
+ return
78
+ end
79
+ end
80
+ dialog = Gtk::MessageDialog.new(parent_window,
81
+ Gtk::Dialog::DESTROY_WITH_PARENT,
82
+ Gtk::MessageDialog::INFO,
83
+ Gtk::MessageDialog::BUTTONS_OK,
84
+ "You stud, you win!")
85
+ dialog.set_modal(true)
86
+ dialog.run_and_close()
87
+ end
88
+
89
+ def piece_enter_notify(item)
90
+ item.text.set_property(:fill_color, "white")
91
+ end
92
+
93
+ def piece_leave_notify(item)
94
+ item.text.set_property(:fill_color, "black")
95
+ end
96
+
97
+ def piece_button_press(item)
98
+ y = item.pos / 4
99
+ x = item.pos % 4
100
+
101
+ move = true
102
+
103
+ if (y > 0) && @board[(y - 1) * 4 + x].nil?
104
+ dx = 0.0
105
+ dy = -1.0
106
+ y -= 1
107
+ elsif (y < 3) && @board[(y + 1) * 4 + x].nil?
108
+ dx = 0.0
109
+ dy = 1.0
110
+ y += 1
111
+ elsif (x > 0) && @board[y * 4 + x - 1].nil?
112
+ dx = -1.0
113
+ dy = 0.0
114
+ x -= 1
115
+ elsif (x < 3) && @board[y * 4 + x + 1].nil?
116
+ dx = 1.0
117
+ dy = 0.0
118
+ x += 1
119
+ else
120
+ move = false
121
+ end
122
+
123
+ if move
124
+ newpos = y * 4 + x
125
+ @board[item.pos] = nil
126
+ @board[newpos] = item
127
+ item.pos = newpos
128
+ item.translate(dx * PIECE_SIZE, dy * PIECE_SIZE)
129
+ test_win()
130
+ end
131
+ end
132
+
133
+
134
+ def scramble
135
+ srand()
136
+ # First, find the blank spot
137
+ pos = 0
138
+ 0.upto(15) do |i|
139
+ if @board[i].nil?
140
+ pos = i
141
+ break
142
+ end
143
+ end
144
+ # "Move the blank spot" around in order to scramble the pieces
145
+
146
+ 0.upto(SCRAMBLE_MOVES) do
147
+ dir = rand(4).to_i
148
+ x = y = 0
149
+
150
+ if (dir == 0) && (pos > 3) # up
151
+ y = -1
152
+ elsif (dir == 1) && (pos < 12) # down
153
+ y = 1
154
+ elsif (dir == 2) && ((pos % 4) != 0) # left
155
+ x = -1
156
+ elsif (dir == 3) && ((pos % 4) != 3) # right
157
+ x = 1
158
+ else
159
+ retry
160
+ end
161
+
162
+ oldpos = pos + y * 4 + x;
163
+ @board[pos] = @board[oldpos];
164
+ @board[oldpos] = nil
165
+ @board[pos].pos = pos
166
+ @board[pos].translate(-x * PIECE_SIZE, -y * PIECE_SIZE)
167
+ pos = oldpos
168
+ end
169
+ end
170
+
171
+ class Piece < Goo::CanvasGroup
172
+ attr_reader :text, :num, :pos
173
+ attr_writer :pos
174
+
175
+ def initialize(*arg)
176
+ super(*arg)
177
+ end
178
+
179
+ def setup(app, i)
180
+ y = i / 4
181
+ x = i % 4
182
+ translate( x * PIECE_SIZE,y * PIECE_SIZE)
183
+
184
+ Goo::CanvasRect.new(self, 0, 0, PIECE_SIZE, PIECE_SIZE,
185
+ :line_width => 1.0,
186
+ :fill_color => get_piece_color(x, y),
187
+ :stroke_color => "black")
188
+
189
+
190
+ @text = Goo::CanvasText.new(self,i.to_s, PIECE_SIZE / 2.0,
191
+ PIECE_SIZE / 2.0, -1, Gtk::ANCHOR_CENTER,
192
+ :font=>"Sans bold 24",
193
+ :fill_color => "black")
194
+ @num = i
195
+ @pos = i
196
+
197
+ self.signal_connect("enter_notify_event") do |item, event|
198
+ app.piece_enter_notify(item)
199
+ end
200
+
201
+ self.signal_connect("leave_notify_event") do |item, event|
202
+ app.piece_leave_notify(item)
203
+ end
204
+
205
+ self.signal_connect("button_press_event") do |item, event|
206
+ app.piece_button_press(item)
207
+ end
208
+ end
209
+
210
+ private
211
+ def get_piece_color(x, y)
212
+ r = ((4 - x) * 255) / 4;
213
+ g = ((4 - y) * 255) / 4;
214
+ b = 128;
215
+ return sprintf("#%02x%02x%02x", r, g, b)
216
+ end
217
+ end
218
+ end