qtbindings 4.8.6.3-x64-mingw32 → 4.8.6.4-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/bin/2.4/rbrcc.exe +0 -0
  4. data/bin/2.4/rbuic4.exe +0 -0
  5. data/bin/2.4/smokeapi.exe +0 -0
  6. data/bin/2.4/smokedeptool.exe +0 -0
  7. data/examples/tutorial/t10/cannon.rb +72 -72
  8. data/examples/tutorial/t10/lcdrange.rb +45 -45
  9. data/examples/tutorial/t10/t10.rb +55 -55
  10. data/examples/tutorial/t11/cannon.rb +123 -124
  11. data/examples/tutorial/t11/lcdrange.rb +45 -45
  12. data/examples/tutorial/t11/t11.rb +65 -65
  13. data/examples/tutorial/t12/cannon.rb +157 -158
  14. data/examples/tutorial/t12/lcdrange.rb +58 -59
  15. data/examples/tutorial/t12/t12.rb +65 -66
  16. data/examples/tutorial/t13/cannon.rb +206 -208
  17. data/examples/tutorial/t13/gamebrd.rb +112 -113
  18. data/examples/tutorial/t13/lcdrange.rb +59 -60
  19. data/examples/tutorial/t13/t13.rb +11 -11
  20. data/examples/tutorial/t14/cannon.rb +262 -263
  21. data/examples/tutorial/t14/gamebrd.rb +122 -123
  22. data/examples/tutorial/t14/lcdrange.rb +61 -63
  23. data/examples/tutorial/t14/t14.rb +11 -11
  24. data/examples/tutorial/t3/t3.rb +17 -18
  25. data/examples/tutorial/t4/t4.rb +23 -25
  26. data/examples/tutorial/t5/t5.rb +35 -37
  27. data/examples/tutorial/t6/t6.rb +48 -52
  28. data/examples/tutorial/t7/lcdrange.rb +32 -32
  29. data/examples/tutorial/t7/t7.rb +40 -42
  30. data/examples/tutorial/t8/cannon.rb +37 -38
  31. data/examples/tutorial/t8/lcdrange.rb +45 -45
  32. data/examples/tutorial/t8/t8.rb +43 -43
  33. data/examples/tutorial/t9/cannon.rb +44 -45
  34. data/examples/tutorial/t9/lcdrange.rb +46 -46
  35. data/examples/tutorial/t9/t9.rb +43 -43
  36. data/lib/2.4/libqtruby4shared.dll +0 -0
  37. data/lib/2.4/libsmokebase.dll +0 -0
  38. data/lib/2.4/libsmokeqtcore.dll +0 -0
  39. data/lib/2.4/libsmokeqtdeclarative.dll +0 -0
  40. data/lib/{2.2 → 2.4}/libsmokeqtgui.dll +0 -0
  41. data/lib/2.4/libsmokeqthelp.dll +0 -0
  42. data/lib/2.4/libsmokeqtmultimedia.dll +0 -0
  43. data/lib/2.4/libsmokeqtnetwork.dll +0 -0
  44. data/lib/2.4/libsmokeqtopengl.dll +0 -0
  45. data/lib/2.4/libsmokeqtscript.dll +0 -0
  46. data/lib/2.4/libsmokeqtsql.dll +0 -0
  47. data/lib/2.4/libsmokeqtsvg.dll +0 -0
  48. data/lib/2.4/libsmokeqttest.dll +0 -0
  49. data/lib/2.4/libsmokeqtuitools.dll +0 -0
  50. data/lib/2.4/libsmokeqtwebkit.dll +0 -0
  51. data/lib/2.4/libsmokeqtxml.dll +0 -0
  52. data/lib/2.4/libsmokeqtxmlpatterns.dll +0 -0
  53. data/lib/2.4/qtdeclarative.so +0 -0
  54. data/lib/2.4/qtruby4.so +0 -0
  55. data/lib/2.4/qtscript.so +0 -0
  56. data/lib/2.4/qttest.so +0 -0
  57. data/lib/2.4/qtuitools.so +0 -0
  58. data/lib/2.4/qtwebkit.so +0 -0
  59. data/lib/Qt4.rb +119 -111
  60. data/lib/qtbindings_version.rb +2 -2
  61. data/qtbindings.gemspec +18 -18
  62. data/qtbindingsnative.gemspec +19 -19
  63. metadata +38 -114
  64. data/bin/2.0/rbrcc.exe +0 -0
  65. data/bin/2.0/rbuic4.exe +0 -0
  66. data/bin/2.0/smokeapi.exe +0 -0
  67. data/bin/2.0/smokedeptool.exe +0 -0
  68. data/bin/2.1/rbrcc.exe +0 -0
  69. data/bin/2.1/rbuic4.exe +0 -0
  70. data/bin/2.1/smokeapi.exe +0 -0
  71. data/bin/2.1/smokedeptool.exe +0 -0
  72. data/bin/2.2/rbrcc.exe +0 -0
  73. data/bin/2.2/rbuic4.exe +0 -0
  74. data/bin/2.2/smokeapi.exe +0 -0
  75. data/bin/2.2/smokedeptool.exe +0 -0
  76. data/bin/2.3/rbrcc.exe +0 -0
  77. data/bin/2.3/rbuic4.exe +0 -0
  78. data/bin/2.3/smokeapi.exe +0 -0
  79. data/bin/2.3/smokedeptool.exe +0 -0
  80. data/lib/2.0/libqtruby4shared.dll +0 -0
  81. data/lib/2.0/libsmokebase.dll +0 -0
  82. data/lib/2.0/libsmokeqtcore.dll +0 -0
  83. data/lib/2.0/libsmokeqtdeclarative.dll +0 -0
  84. data/lib/2.0/libsmokeqtgui.dll +0 -0
  85. data/lib/2.0/libsmokeqthelp.dll +0 -0
  86. data/lib/2.0/libsmokeqtmultimedia.dll +0 -0
  87. data/lib/2.0/libsmokeqtnetwork.dll +0 -0
  88. data/lib/2.0/libsmokeqtopengl.dll +0 -0
  89. data/lib/2.0/libsmokeqtscript.dll +0 -0
  90. data/lib/2.0/libsmokeqtsql.dll +0 -0
  91. data/lib/2.0/libsmokeqtsvg.dll +0 -0
  92. data/lib/2.0/libsmokeqttest.dll +0 -0
  93. data/lib/2.0/libsmokeqtuitools.dll +0 -0
  94. data/lib/2.0/libsmokeqtwebkit.dll +0 -0
  95. data/lib/2.0/libsmokeqtxml.dll +0 -0
  96. data/lib/2.0/libsmokeqtxmlpatterns.dll +0 -0
  97. data/lib/2.0/qtdeclarative.so +0 -0
  98. data/lib/2.0/qtruby4.so +0 -0
  99. data/lib/2.0/qtscript.so +0 -0
  100. data/lib/2.0/qttest.so +0 -0
  101. data/lib/2.0/qtuitools.so +0 -0
  102. data/lib/2.0/qtwebkit.so +0 -0
  103. data/lib/2.1/libqtruby4shared.dll +0 -0
  104. data/lib/2.1/libsmokebase.dll +0 -0
  105. data/lib/2.1/libsmokeqtcore.dll +0 -0
  106. data/lib/2.1/libsmokeqtdeclarative.dll +0 -0
  107. data/lib/2.1/libsmokeqtgui.dll +0 -0
  108. data/lib/2.1/libsmokeqthelp.dll +0 -0
  109. data/lib/2.1/libsmokeqtmultimedia.dll +0 -0
  110. data/lib/2.1/libsmokeqtnetwork.dll +0 -0
  111. data/lib/2.1/libsmokeqtopengl.dll +0 -0
  112. data/lib/2.1/libsmokeqtscript.dll +0 -0
  113. data/lib/2.1/libsmokeqtsql.dll +0 -0
  114. data/lib/2.1/libsmokeqtsvg.dll +0 -0
  115. data/lib/2.1/libsmokeqttest.dll +0 -0
  116. data/lib/2.1/libsmokeqtuitools.dll +0 -0
  117. data/lib/2.1/libsmokeqtwebkit.dll +0 -0
  118. data/lib/2.1/libsmokeqtxml.dll +0 -0
  119. data/lib/2.1/libsmokeqtxmlpatterns.dll +0 -0
  120. data/lib/2.1/qtdeclarative.so +0 -0
  121. data/lib/2.1/qtruby4.so +0 -0
  122. data/lib/2.1/qtscript.so +0 -0
  123. data/lib/2.1/qttest.so +0 -0
  124. data/lib/2.1/qtuitools.so +0 -0
  125. data/lib/2.1/qtwebkit.so +0 -0
  126. data/lib/2.2/libqtruby4shared.dll +0 -0
  127. data/lib/2.2/libsmokebase.dll +0 -0
  128. data/lib/2.2/libsmokeqtcore.dll +0 -0
  129. data/lib/2.2/libsmokeqtdeclarative.dll +0 -0
  130. data/lib/2.2/libsmokeqthelp.dll +0 -0
  131. data/lib/2.2/libsmokeqtmultimedia.dll +0 -0
  132. data/lib/2.2/libsmokeqtnetwork.dll +0 -0
  133. data/lib/2.2/libsmokeqtopengl.dll +0 -0
  134. data/lib/2.2/libsmokeqtscript.dll +0 -0
  135. data/lib/2.2/libsmokeqtsql.dll +0 -0
  136. data/lib/2.2/libsmokeqtsvg.dll +0 -0
  137. data/lib/2.2/libsmokeqttest.dll +0 -0
  138. data/lib/2.2/libsmokeqtuitools.dll +0 -0
  139. data/lib/2.2/libsmokeqtwebkit.dll +0 -0
  140. data/lib/2.2/libsmokeqtxml.dll +0 -0
  141. data/lib/2.2/libsmokeqtxmlpatterns.dll +0 -0
  142. data/lib/2.2/qtdeclarative.so +0 -0
  143. data/lib/2.2/qtruby4.so +0 -0
  144. data/lib/2.2/qtscript.so +0 -0
  145. data/lib/2.2/qttest.so +0 -0
  146. data/lib/2.2/qtuitools.so +0 -0
  147. data/lib/2.2/qtwebkit.so +0 -0
  148. data/lib/2.3/libqtruby4shared.dll +0 -0
  149. data/lib/2.3/libsmokebase.dll +0 -0
  150. data/lib/2.3/libsmokeqtcore.dll +0 -0
  151. data/lib/2.3/libsmokeqtdeclarative.dll +0 -0
  152. data/lib/2.3/libsmokeqtgui.dll +0 -0
  153. data/lib/2.3/libsmokeqthelp.dll +0 -0
  154. data/lib/2.3/libsmokeqtmultimedia.dll +0 -0
  155. data/lib/2.3/libsmokeqtnetwork.dll +0 -0
  156. data/lib/2.3/libsmokeqtopengl.dll +0 -0
  157. data/lib/2.3/libsmokeqtscript.dll +0 -0
  158. data/lib/2.3/libsmokeqtsql.dll +0 -0
  159. data/lib/2.3/libsmokeqtsvg.dll +0 -0
  160. data/lib/2.3/libsmokeqttest.dll +0 -0
  161. data/lib/2.3/libsmokeqtuitools.dll +0 -0
  162. data/lib/2.3/libsmokeqtwebkit.dll +0 -0
  163. data/lib/2.3/libsmokeqtxml.dll +0 -0
  164. data/lib/2.3/libsmokeqtxmlpatterns.dll +0 -0
  165. data/lib/2.3/qtdeclarative.so +0 -0
  166. data/lib/2.3/qtruby4.so +0 -0
  167. data/lib/2.3/qtscript.so +0 -0
  168. data/lib/2.3/qttest.so +0 -0
  169. data/lib/2.3/qtuitools.so +0 -0
  170. data/lib/2.3/qtwebkit.so +0 -0
  171. data/lib/qtbindings_qt_version.rb +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c20c8b549395535dbba6d7857227d5e13349ae78
4
- data.tar.gz: 8f87e82509d358bda908b5a3bbc4bc8c496b95ff
3
+ metadata.gz: fa1699d08ad883c9e42bf004d9429ebc1c6dfddb
4
+ data.tar.gz: 598fbef04b742792dbcb2784f7484f81e9cbc48b
5
5
  SHA512:
6
- metadata.gz: b6a99ac8522802619663d0f34ee5ad2011bb8477af31bea7f9f4981322f3fc5e609138613593d49ec188de4e2a1560247c7a6b1d80fde30a8aa7fde43fbd8a66
7
- data.tar.gz: f425ab0fced5086fee34973ae1341c852bcaaef9a7d004571820158ac61ce69ba75ca6e49122ce643e93658567b3df412931471e36339c4571813241c26b331e
6
+ metadata.gz: 699d13384726607602260fe1be898252f514cd1967fb6ff48572d541fd677f86599bb0b4a66a0d2003e6827a489734e1efc6f038ab7276cb0a98e996e7997c66
7
+ data.tar.gz: fabe6a944ec33cc320fec79b56bce8b91d15408e08bc99958a04dda5a2acce3933545930263932b3d86f250d9a0e6183ea57e0ff7d18f8c91a796f800bc8b6f8
data/Rakefile CHANGED
@@ -39,7 +39,7 @@ def clear_version
39
39
  file.write("QTBINDINGS_VERSION = '0.0.0.0'\n")
40
40
  file.write("QTBINDINGS_RELEASE_DATE = ''\n")
41
41
  end
42
- File.open('lib/qtbindings_qt_version.rb', 'w') do |file|
42
+ File.open('qtlib/qtbindings_qt_version.rb', 'w') do |file|
43
43
  file.write("QTBINDINGS_QT_VERSION = '0.0.0.0'\n")
44
44
  file.write("QTBINDINGS_QT_RELEASE_DATE = ''\n")
45
45
  end
Binary file
Binary file
Binary file
Binary file
@@ -1,72 +1,72 @@
1
- require 'Qt'
2
-
3
- class CannonField < Qt::Widget
4
- signals 'angleChanged(int)', 'forceChanged(int)'
5
- slots 'setAngle(int)', 'setForce(int)'
6
-
7
- def initialize(parent = nil)
8
- super
9
- @ang = 45
10
- @f = 0
11
- setPalette( Qt::Palette.new( Qt::Color.new( 250, 250, 200) ) )
12
- setAutoFillBackground(true)
13
- end
14
-
15
- def setAngle( degrees )
16
- if degrees < 5
17
- degrees = 5
18
- elsif degrees > 70
19
- degrees = 70
20
- end
21
- if @ang == degrees
22
- return
23
- end
24
- @ang = degrees
25
- repaint()
26
- emit angleChanged( @ang )
27
- end
28
-
29
- def setForce( newton )
30
- if newton < 0
31
- newton = 0
32
- end
33
- if @f == newton
34
- return
35
- end
36
- @f = newton
37
- emit forceChanged( @f )
38
- end
39
-
40
- def paintEvent( e )
41
- if !e.rect().intersects( cannonRect() )
42
- return
43
- end
44
-
45
- cr = cannonRect()
46
- pix = Qt::Pixmap.new( cr.size() )
47
- pix.fill( self, cr.topLeft() )
48
-
49
- painter = Qt::Painter.new( pix )
50
- painter.setBrush( Qt::Brush.new(Qt::blue) )
51
- painter.setPen( Qt::NoPen )
52
- painter.translate( 0, pix.height() - 1 )
53
- painter.drawPie( Qt::Rect.new(-35, -35, 70, 70), 0, 90*16 )
54
- painter.rotate( - @ang )
55
- painter.drawRect( Qt::Rect.new(33, -4, 15, 8) )
56
- painter.end()
57
-
58
- painter.begin(self)
59
- painter.drawPixmap(cr.topLeft(), pix )
60
- painter.end()
61
- end
62
-
63
- def cannonRect()
64
- r = Qt::Rect.new( 0, 0, 50, 50)
65
- r.moveBottomLeft( rect().bottomLeft() )
66
- return r
67
- end
68
-
69
- def sizePolicy()
70
- return Qt::SizePolicy.new( Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding )
71
- end
72
- end
1
+ require 'Qt'
2
+
3
+ class CannonField < Qt::Widget
4
+ signals 'angleChanged(int)', 'forceChanged(int)'
5
+ slots 'setAngle(int)', 'setForce(int)'
6
+
7
+ def initialize(parent = nil)
8
+ super
9
+ @ang = 45
10
+ @f = 0
11
+ setPalette(Qt::Palette.new(Qt::Color.new(250, 250, 200)))
12
+ setAutoFillBackground(true)
13
+ end
14
+
15
+ def setAngle(degrees)
16
+ if degrees < 5
17
+ degrees = 5
18
+ elsif degrees > 70
19
+ degrees = 70
20
+ end
21
+ if @ang == degrees
22
+ return
23
+ end
24
+ @ang = degrees
25
+ repaint()
26
+ emit angleChanged(@ang)
27
+ end
28
+
29
+ def setForce(newton)
30
+ if newton < 0
31
+ newton = 0
32
+ end
33
+ if @f == newton
34
+ return
35
+ end
36
+ @f = newton
37
+ emit forceChanged(@f)
38
+ end
39
+
40
+ def paintEvent(e)
41
+ if !e.rect().intersects(cannonRect())
42
+ return
43
+ end
44
+
45
+ cr = cannonRect()
46
+ pix = Qt::Pixmap.new(cr.size())
47
+ pix.fill(self, cr.topLeft())
48
+
49
+ painter = Qt::Painter.new(pix)
50
+ painter.setBrush(Qt::Brush.new(Qt::blue))
51
+ painter.setPen(Qt::NoPen)
52
+ painter.translate(0, pix.height() - 1)
53
+ painter.drawPie(Qt::Rect.new(-35, -35, 70, 70), 0, 90 * 16)
54
+ painter.rotate(- @ang)
55
+ painter.drawRect(Qt::Rect.new(33, -4, 15, 8))
56
+ painter.end()
57
+
58
+ painter.begin(self)
59
+ painter.drawPixmap(cr.topLeft(), pix)
60
+ painter.end()
61
+ end
62
+
63
+ def cannonRect()
64
+ r = Qt::Rect.new(0, 0, 50, 50)
65
+ r.moveBottomLeft(rect().bottomLeft())
66
+ return r
67
+ end
68
+
69
+ def sizePolicy()
70
+ return Qt::SizePolicy.new(Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding)
71
+ end
72
+ end
@@ -1,45 +1,45 @@
1
- require 'Qt'
2
-
3
- class LCDRange < Qt::Widget
4
- signals 'valueChanged(int)'
5
- slots 'setValue(int)', 'setRange(int, int)'
6
-
7
- def initialize(parent = nil)
8
- super
9
- lcd = Qt::LCDNumber.new(2)
10
- @slider = Qt::Slider.new(Qt::Horizontal)
11
- @slider.range = 0..99
12
- @slider.setValue(0)
13
- connect(@slider, SIGNAL('valueChanged(int)'), lcd, SLOT('display(int)'))
14
- connect(@slider, SIGNAL('valueChanged(int)'), SIGNAL('valueChanged(int)'))
15
-
16
- layout = Qt::VBoxLayout.new
17
- layout.addWidget(lcd)
18
- layout.addWidget(@slider)
19
- setLayout(layout)
20
-
21
- setFocusProxy(@slider)
22
- end
23
-
24
- def value()
25
- @slider.value()
26
- end
27
-
28
- def setValue( value )
29
- @slider.setValue( value )
30
- end
31
-
32
- def range=( r )
33
- setRange(r.begin, r.end)
34
- end
35
-
36
- def setRange( minVal, maxVal )
37
- if minVal < 0 || maxVal > 99 || minVal > maxVal
38
- qWarning( "LCDRange::setRange(#{minVal},#{maxVal})\n" +
39
- "\tRange must be 0..99\n" +
40
- "\tand minVal must not be greater than maxVal" )
41
- return
42
- end
43
- @slider.range = minVal..maxVal
44
- end
45
- end
1
+ require 'Qt'
2
+
3
+ class LCDRange < Qt::Widget
4
+ signals 'valueChanged(int)'
5
+ slots 'setValue(int)', 'setRange(int, int)'
6
+
7
+ def initialize(parent = nil)
8
+ super
9
+ lcd = Qt::LCDNumber.new(2)
10
+ @slider = Qt::Slider.new(Qt::Horizontal)
11
+ @slider.range = 0..99
12
+ @slider.setValue(0)
13
+ connect(@slider, SIGNAL('valueChanged(int)'), lcd, SLOT('display(int)'))
14
+ connect(@slider, SIGNAL('valueChanged(int)'), SIGNAL('valueChanged(int)'))
15
+
16
+ layout = Qt::VBoxLayout.new
17
+ layout.addWidget(lcd)
18
+ layout.addWidget(@slider)
19
+ setLayout(layout)
20
+
21
+ setFocusProxy(@slider)
22
+ end
23
+
24
+ def value()
25
+ @slider.value()
26
+ end
27
+
28
+ def setValue(value)
29
+ @slider.setValue(value)
30
+ end
31
+
32
+ def range=(r)
33
+ setRange(r.begin, r.end)
34
+ end
35
+
36
+ def setRange(minVal, maxVal)
37
+ if minVal < 0 || maxVal > 99 || minVal > maxVal
38
+ qWarning("LCDRange::setRange(#{minVal},#{maxVal})\n" +
39
+ "\tRange must be 0..99\n" +
40
+ "\tand minVal must not be greater than maxVal")
41
+ return
42
+ end
43
+ @slider.range = minVal..maxVal
44
+ end
45
+ end
@@ -1,55 +1,55 @@
1
- #!/usr/bin/env ruby
2
- $VERBOSE = true; $:.unshift File.dirname($0)
3
-
4
- require 'Qt'
5
- require './lcdrange.rb'
6
- require './cannon.rb'
7
-
8
- class MyWidget < Qt::Widget
9
- def initialize(parent = nil)
10
- super
11
- quit = Qt::PushButton.new('Quit')
12
- quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold))
13
-
14
- connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()'))
15
-
16
- angle = LCDRange.new( self )
17
- angle.range = 5..70
18
-
19
- force = LCDRange.new( self )
20
- force.range = 10..50
21
-
22
- cannonField = CannonField.new( self )
23
-
24
- connect( angle, SIGNAL('valueChanged(int)'),
25
- cannonField, SLOT('setAngle(int)') )
26
- connect( cannonField, SIGNAL('angleChanged(int)'),
27
- angle, SLOT('setValue(int)') )
28
-
29
- connect( force, SIGNAL('valueChanged(int)'),
30
- cannonField, SLOT('setForce(int)') )
31
- connect( cannonField, SIGNAL('forceChanged(int)'),
32
- force, SLOT('setValue(int)') )
33
-
34
- leftLayout = Qt::VBoxLayout.new()
35
- leftLayout.addWidget( angle )
36
- leftLayout.addWidget( force )
37
-
38
- gridLayout = Qt::GridLayout.new
39
- gridLayout.addWidget( quit, 0, 0 )
40
- gridLayout.addLayout(leftLayout, 1, 0)
41
- gridLayout.addWidget( cannonField, 1, 1, 2, 1 )
42
- gridLayout.setColumnStretch( 1, 10 )
43
- setLayout(gridLayout)
44
-
45
- angle.setValue( 60 )
46
- force.setValue( 25 )
47
- angle.setFocus()
48
- end
49
- end
50
-
51
- app = Qt::Application.new(ARGV)
52
- widget = MyWidget.new
53
- widget.setGeometry( 100, 100, 500, 355 )
54
- widget.show
55
- app.exec
1
+ #!/usr/bin/env ruby
2
+ $VERBOSE = true; $:.unshift File.dirname($0)
3
+
4
+ require 'Qt'
5
+ require_relative 'lcdrange.rb'
6
+ require_relative 'cannon.rb'
7
+
8
+ class MyWidget < Qt::Widget
9
+ def initialize(parent = nil)
10
+ super
11
+ quit = Qt::PushButton.new('Quit')
12
+ quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold))
13
+
14
+ connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()'))
15
+
16
+ angle = LCDRange.new(self)
17
+ angle.range = 5..70
18
+
19
+ force = LCDRange.new(self)
20
+ force.range = 10..50
21
+
22
+ cannonField = CannonField.new(self)
23
+
24
+ connect(angle, SIGNAL('valueChanged(int)'),
25
+ cannonField, SLOT('setAngle(int)'))
26
+ connect(cannonField, SIGNAL('angleChanged(int)'),
27
+ angle, SLOT('setValue(int)'))
28
+
29
+ connect(force, SIGNAL('valueChanged(int)'),
30
+ cannonField, SLOT('setForce(int)'))
31
+ connect(cannonField, SIGNAL('forceChanged(int)'),
32
+ force, SLOT('setValue(int)'))
33
+
34
+ leftLayout = Qt::VBoxLayout.new()
35
+ leftLayout.addWidget(angle)
36
+ leftLayout.addWidget(force)
37
+
38
+ gridLayout = Qt::GridLayout.new
39
+ gridLayout.addWidget(quit, 0, 0)
40
+ gridLayout.addLayout(leftLayout, 1, 0)
41
+ gridLayout.addWidget(cannonField, 1, 1, 2, 1)
42
+ gridLayout.setColumnStretch(1, 10)
43
+ setLayout(gridLayout)
44
+
45
+ angle.setValue(60)
46
+ force.setValue(25)
47
+ angle.setFocus()
48
+ end
49
+ end
50
+
51
+ app = Qt::Application.new(ARGV)
52
+ widget = MyWidget.new
53
+ widget.setGeometry(100, 100, 500, 355)
54
+ widget.show
55
+ app.exec
@@ -1,124 +1,123 @@
1
- include Math
2
- require 'Qt'
3
-
4
- class CannonField < Qt::Widget
5
-
6
- signals 'angleChanged(int)', 'forceChanged(int)'
7
- slots 'setAngle(int)', 'setForce(int)', 'shoot()', 'moveShot()'
8
-
9
- def initialize(parent = nil)
10
- super
11
- @currentAngle = 45
12
- @currentForce = 0
13
- @timerCount = 0
14
- @autoShootTimer = Qt::Timer.new( self )
15
- connect( @autoShootTimer, SIGNAL('timeout()'),
16
- self, SLOT('moveShot()') )
17
- @shootAngle = 0
18
- @shootForce = 0
19
- setPalette( Qt::Palette.new( Qt::Color.new( 250, 250, 200) ) )
20
- setAutoFillBackground(true)
21
- @barrelRect = Qt::Rect.new(33, -4, 15, 8)
22
- end
23
-
24
- def setAngle( degrees )
25
- if degrees < 5
26
- degrees = 5
27
- elsif degrees > 70
28
- degrees = 70
29
- end
30
- if @currentAngle == degrees
31
- return
32
- end
33
- @currentAngle = degrees
34
- update( cannonRect() )
35
- emit angleChanged( @currentAngle )
36
- end
37
-
38
- def setForce( newton )
39
- if newton < 0
40
- newton = 0
41
- end
42
- if @currentForce == newton
43
- return
44
- end
45
- @currentForce = newton
46
- emit forceChanged( @currentForce )
47
- end
48
-
49
- def shoot()
50
- if @autoShootTimer.isActive()
51
- return
52
- end;
53
- @timerCount = 0
54
- @shootAngle = @currentAngle
55
- @shootForce = @currentForce
56
- @autoShootTimer.start( 5 )
57
- end
58
-
59
- def moveShot()
60
- r = Qt::Region.new( shotRect() )
61
- @timerCount += 1
62
-
63
- shotR = shotRect()
64
-
65
- if shotR.x() > width() || shotR.y() > height()
66
- @autoShootTimer.stop()
67
- else
68
- r = r.unite( Qt::Region.new( shotR ) )
69
- end
70
- update( r )
71
- end
72
-
73
- def paintEvent( e )
74
- p = Qt::Painter.new( self )
75
- paintCannon( p )
76
- if @autoShootTimer.isActive()
77
- paintShot( p )
78
- end
79
- p.end()
80
- end
81
-
82
- def paintShot( p )
83
- p.setPen( Qt::NoPen )
84
- p.setBrush( Qt::Brush.new(Qt::black) )
85
- p.drawRect( shotRect() )
86
- end
87
-
88
- def paintCannon(painter)
89
- painter.setPen(Qt::NoPen)
90
- painter.setBrush(Qt::Brush.new(Qt::blue))
91
-
92
- painter.save()
93
- painter.translate(0, height())
94
- painter.drawPie( Qt::Rect.new(-35, -35, 70, 70), 0, 90*16 )
95
- painter.rotate( - @currentAngle )
96
- painter.drawRect( @barrelRect )
97
- painter.restore()
98
- end
99
-
100
- def cannonRect()
101
- r = Qt::Rect.new( 0, 0, 50, 50)
102
- r.moveBottomLeft( rect().bottomLeft() )
103
- return r
104
- end
105
-
106
- def shotRect()
107
- gravity = 4.0
108
-
109
- time = @timerCount / 40.0
110
- velocity = @shootForce
111
- radians = @shootAngle*3.14159265/180.0
112
-
113
- velx = velocity*cos( radians )
114
- vely = velocity*sin( radians )
115
- x0 = ( @barrelRect.right() + 5.0 )*cos(radians)
116
- y0 = ( @barrelRect.right() + 5.0 )*sin(radians)
117
- x = x0 + velx*time
118
- y = y0 + vely*time - 0.5*gravity*time*time
119
-
120
- r = Qt::Rect.new( 0, 0, 6, 6 );
121
- r.moveCenter( Qt::Point.new( x.round, height() - 1 - y.round ) )
122
- return r
123
- end
124
- end
1
+ include Math
2
+ require 'Qt'
3
+
4
+ class CannonField < Qt::Widget
5
+ signals 'angleChanged(int)', 'forceChanged(int)'
6
+ slots 'setAngle(int)', 'setForce(int)', 'shoot()', 'moveShot()'
7
+
8
+ def initialize(parent = nil)
9
+ super
10
+ @currentAngle = 45
11
+ @currentForce = 0
12
+ @timerCount = 0
13
+ @autoShootTimer = Qt::Timer.new(self)
14
+ connect(@autoShootTimer, SIGNAL('timeout()'),
15
+ self, SLOT('moveShot()'))
16
+ @shootAngle = 0
17
+ @shootForce = 0
18
+ setPalette(Qt::Palette.new(Qt::Color.new(250, 250, 200)))
19
+ setAutoFillBackground(true)
20
+ @barrelRect = Qt::Rect.new(33, -4, 15, 8)
21
+ end
22
+
23
+ def setAngle(degrees)
24
+ if degrees < 5
25
+ degrees = 5
26
+ elsif degrees > 70
27
+ degrees = 70
28
+ end
29
+ if @currentAngle == degrees
30
+ return
31
+ end
32
+ @currentAngle = degrees
33
+ update(cannonRect())
34
+ emit angleChanged(@currentAngle)
35
+ end
36
+
37
+ def setForce(newton)
38
+ if newton < 0
39
+ newton = 0
40
+ end
41
+ if @currentForce == newton
42
+ return
43
+ end
44
+ @currentForce = newton
45
+ emit forceChanged(@currentForce)
46
+ end
47
+
48
+ def shoot()
49
+ if @autoShootTimer.isActive()
50
+ return
51
+ end;
52
+ @timerCount = 0
53
+ @shootAngle = @currentAngle
54
+ @shootForce = @currentForce
55
+ @autoShootTimer.start(5)
56
+ end
57
+
58
+ def moveShot()
59
+ r = Qt::Region.new(shotRect())
60
+ @timerCount += 1
61
+
62
+ shotR = shotRect()
63
+
64
+ if shotR.x() > width() || shotR.y() > height()
65
+ @autoShootTimer.stop()
66
+ else
67
+ r = r.unite(Qt::Region.new(shotR))
68
+ end
69
+ update(r)
70
+ end
71
+
72
+ def paintEvent(e)
73
+ p = Qt::Painter.new(self)
74
+ paintCannon(p)
75
+ if @autoShootTimer.isActive()
76
+ paintShot(p)
77
+ end
78
+ p.end()
79
+ end
80
+
81
+ def paintShot(p)
82
+ p.setPen(Qt::NoPen)
83
+ p.setBrush(Qt::Brush.new(Qt::black))
84
+ p.drawRect(shotRect())
85
+ end
86
+
87
+ def paintCannon(painter)
88
+ painter.setPen(Qt::NoPen)
89
+ painter.setBrush(Qt::Brush.new(Qt::blue))
90
+
91
+ painter.save()
92
+ painter.translate(0, height())
93
+ painter.drawPie(Qt::Rect.new(-35, -35, 70, 70), 0, 90 * 16)
94
+ painter.rotate(- @currentAngle)
95
+ painter.drawRect(@barrelRect)
96
+ painter.restore()
97
+ end
98
+
99
+ def cannonRect()
100
+ r = Qt::Rect.new(0, 0, 50, 50)
101
+ r.moveBottomLeft(rect().bottomLeft())
102
+ return r
103
+ end
104
+
105
+ def shotRect()
106
+ gravity = 4.0
107
+
108
+ time = @timerCount / 40.0
109
+ velocity = @shootForce
110
+ radians = @shootAngle * 3.14159265 / 180.0
111
+
112
+ velx = velocity * cos(radians)
113
+ vely = velocity * sin(radians)
114
+ x0 = (@barrelRect.right() + 5.0) * cos(radians)
115
+ y0 = (@barrelRect.right() + 5.0) * sin(radians)
116
+ x = x0 + velx * time
117
+ y = y0 + vely * time - 0.5 * gravity * time * time
118
+
119
+ r = Qt::Rect.new(0, 0, 6, 6);
120
+ r.moveCenter(Qt::Point.new(x.round, height() - 1 - y.round))
121
+ return r
122
+ end
123
+ end