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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/bin/2.4/rbrcc.exe +0 -0
- data/bin/2.4/rbuic4.exe +0 -0
- data/bin/2.4/smokeapi.exe +0 -0
- data/bin/2.4/smokedeptool.exe +0 -0
- data/examples/tutorial/t10/cannon.rb +72 -72
- data/examples/tutorial/t10/lcdrange.rb +45 -45
- data/examples/tutorial/t10/t10.rb +55 -55
- data/examples/tutorial/t11/cannon.rb +123 -124
- data/examples/tutorial/t11/lcdrange.rb +45 -45
- data/examples/tutorial/t11/t11.rb +65 -65
- data/examples/tutorial/t12/cannon.rb +157 -158
- data/examples/tutorial/t12/lcdrange.rb +58 -59
- data/examples/tutorial/t12/t12.rb +65 -66
- data/examples/tutorial/t13/cannon.rb +206 -208
- data/examples/tutorial/t13/gamebrd.rb +112 -113
- data/examples/tutorial/t13/lcdrange.rb +59 -60
- data/examples/tutorial/t13/t13.rb +11 -11
- data/examples/tutorial/t14/cannon.rb +262 -263
- data/examples/tutorial/t14/gamebrd.rb +122 -123
- data/examples/tutorial/t14/lcdrange.rb +61 -63
- data/examples/tutorial/t14/t14.rb +11 -11
- data/examples/tutorial/t3/t3.rb +17 -18
- data/examples/tutorial/t4/t4.rb +23 -25
- data/examples/tutorial/t5/t5.rb +35 -37
- data/examples/tutorial/t6/t6.rb +48 -52
- data/examples/tutorial/t7/lcdrange.rb +32 -32
- data/examples/tutorial/t7/t7.rb +40 -42
- data/examples/tutorial/t8/cannon.rb +37 -38
- data/examples/tutorial/t8/lcdrange.rb +45 -45
- data/examples/tutorial/t8/t8.rb +43 -43
- data/examples/tutorial/t9/cannon.rb +44 -45
- data/examples/tutorial/t9/lcdrange.rb +46 -46
- data/examples/tutorial/t9/t9.rb +43 -43
- data/lib/2.4/libqtruby4shared.dll +0 -0
- data/lib/2.4/libsmokebase.dll +0 -0
- data/lib/2.4/libsmokeqtcore.dll +0 -0
- data/lib/2.4/libsmokeqtdeclarative.dll +0 -0
- data/lib/{2.2 → 2.4}/libsmokeqtgui.dll +0 -0
- data/lib/2.4/libsmokeqthelp.dll +0 -0
- data/lib/2.4/libsmokeqtmultimedia.dll +0 -0
- data/lib/2.4/libsmokeqtnetwork.dll +0 -0
- data/lib/2.4/libsmokeqtopengl.dll +0 -0
- data/lib/2.4/libsmokeqtscript.dll +0 -0
- data/lib/2.4/libsmokeqtsql.dll +0 -0
- data/lib/2.4/libsmokeqtsvg.dll +0 -0
- data/lib/2.4/libsmokeqttest.dll +0 -0
- data/lib/2.4/libsmokeqtuitools.dll +0 -0
- data/lib/2.4/libsmokeqtwebkit.dll +0 -0
- data/lib/2.4/libsmokeqtxml.dll +0 -0
- data/lib/2.4/libsmokeqtxmlpatterns.dll +0 -0
- data/lib/2.4/qtdeclarative.so +0 -0
- data/lib/2.4/qtruby4.so +0 -0
- data/lib/2.4/qtscript.so +0 -0
- data/lib/2.4/qttest.so +0 -0
- data/lib/2.4/qtuitools.so +0 -0
- data/lib/2.4/qtwebkit.so +0 -0
- data/lib/Qt4.rb +119 -111
- data/lib/qtbindings_version.rb +2 -2
- data/qtbindings.gemspec +18 -18
- data/qtbindingsnative.gemspec +19 -19
- metadata +38 -114
- data/bin/2.0/rbrcc.exe +0 -0
- data/bin/2.0/rbuic4.exe +0 -0
- data/bin/2.0/smokeapi.exe +0 -0
- data/bin/2.0/smokedeptool.exe +0 -0
- data/bin/2.1/rbrcc.exe +0 -0
- data/bin/2.1/rbuic4.exe +0 -0
- data/bin/2.1/smokeapi.exe +0 -0
- data/bin/2.1/smokedeptool.exe +0 -0
- data/bin/2.2/rbrcc.exe +0 -0
- data/bin/2.2/rbuic4.exe +0 -0
- data/bin/2.2/smokeapi.exe +0 -0
- data/bin/2.2/smokedeptool.exe +0 -0
- data/bin/2.3/rbrcc.exe +0 -0
- data/bin/2.3/rbuic4.exe +0 -0
- data/bin/2.3/smokeapi.exe +0 -0
- data/bin/2.3/smokedeptool.exe +0 -0
- data/lib/2.0/libqtruby4shared.dll +0 -0
- data/lib/2.0/libsmokebase.dll +0 -0
- data/lib/2.0/libsmokeqtcore.dll +0 -0
- data/lib/2.0/libsmokeqtdeclarative.dll +0 -0
- data/lib/2.0/libsmokeqtgui.dll +0 -0
- data/lib/2.0/libsmokeqthelp.dll +0 -0
- data/lib/2.0/libsmokeqtmultimedia.dll +0 -0
- data/lib/2.0/libsmokeqtnetwork.dll +0 -0
- data/lib/2.0/libsmokeqtopengl.dll +0 -0
- data/lib/2.0/libsmokeqtscript.dll +0 -0
- data/lib/2.0/libsmokeqtsql.dll +0 -0
- data/lib/2.0/libsmokeqtsvg.dll +0 -0
- data/lib/2.0/libsmokeqttest.dll +0 -0
- data/lib/2.0/libsmokeqtuitools.dll +0 -0
- data/lib/2.0/libsmokeqtwebkit.dll +0 -0
- data/lib/2.0/libsmokeqtxml.dll +0 -0
- data/lib/2.0/libsmokeqtxmlpatterns.dll +0 -0
- data/lib/2.0/qtdeclarative.so +0 -0
- data/lib/2.0/qtruby4.so +0 -0
- data/lib/2.0/qtscript.so +0 -0
- data/lib/2.0/qttest.so +0 -0
- data/lib/2.0/qtuitools.so +0 -0
- data/lib/2.0/qtwebkit.so +0 -0
- data/lib/2.1/libqtruby4shared.dll +0 -0
- data/lib/2.1/libsmokebase.dll +0 -0
- data/lib/2.1/libsmokeqtcore.dll +0 -0
- data/lib/2.1/libsmokeqtdeclarative.dll +0 -0
- data/lib/2.1/libsmokeqtgui.dll +0 -0
- data/lib/2.1/libsmokeqthelp.dll +0 -0
- data/lib/2.1/libsmokeqtmultimedia.dll +0 -0
- data/lib/2.1/libsmokeqtnetwork.dll +0 -0
- data/lib/2.1/libsmokeqtopengl.dll +0 -0
- data/lib/2.1/libsmokeqtscript.dll +0 -0
- data/lib/2.1/libsmokeqtsql.dll +0 -0
- data/lib/2.1/libsmokeqtsvg.dll +0 -0
- data/lib/2.1/libsmokeqttest.dll +0 -0
- data/lib/2.1/libsmokeqtuitools.dll +0 -0
- data/lib/2.1/libsmokeqtwebkit.dll +0 -0
- data/lib/2.1/libsmokeqtxml.dll +0 -0
- data/lib/2.1/libsmokeqtxmlpatterns.dll +0 -0
- data/lib/2.1/qtdeclarative.so +0 -0
- data/lib/2.1/qtruby4.so +0 -0
- data/lib/2.1/qtscript.so +0 -0
- data/lib/2.1/qttest.so +0 -0
- data/lib/2.1/qtuitools.so +0 -0
- data/lib/2.1/qtwebkit.so +0 -0
- data/lib/2.2/libqtruby4shared.dll +0 -0
- data/lib/2.2/libsmokebase.dll +0 -0
- data/lib/2.2/libsmokeqtcore.dll +0 -0
- data/lib/2.2/libsmokeqtdeclarative.dll +0 -0
- data/lib/2.2/libsmokeqthelp.dll +0 -0
- data/lib/2.2/libsmokeqtmultimedia.dll +0 -0
- data/lib/2.2/libsmokeqtnetwork.dll +0 -0
- data/lib/2.2/libsmokeqtopengl.dll +0 -0
- data/lib/2.2/libsmokeqtscript.dll +0 -0
- data/lib/2.2/libsmokeqtsql.dll +0 -0
- data/lib/2.2/libsmokeqtsvg.dll +0 -0
- data/lib/2.2/libsmokeqttest.dll +0 -0
- data/lib/2.2/libsmokeqtuitools.dll +0 -0
- data/lib/2.2/libsmokeqtwebkit.dll +0 -0
- data/lib/2.2/libsmokeqtxml.dll +0 -0
- data/lib/2.2/libsmokeqtxmlpatterns.dll +0 -0
- data/lib/2.2/qtdeclarative.so +0 -0
- data/lib/2.2/qtruby4.so +0 -0
- data/lib/2.2/qtscript.so +0 -0
- data/lib/2.2/qttest.so +0 -0
- data/lib/2.2/qtuitools.so +0 -0
- data/lib/2.2/qtwebkit.so +0 -0
- data/lib/2.3/libqtruby4shared.dll +0 -0
- data/lib/2.3/libsmokebase.dll +0 -0
- data/lib/2.3/libsmokeqtcore.dll +0 -0
- data/lib/2.3/libsmokeqtdeclarative.dll +0 -0
- data/lib/2.3/libsmokeqtgui.dll +0 -0
- data/lib/2.3/libsmokeqthelp.dll +0 -0
- data/lib/2.3/libsmokeqtmultimedia.dll +0 -0
- data/lib/2.3/libsmokeqtnetwork.dll +0 -0
- data/lib/2.3/libsmokeqtopengl.dll +0 -0
- data/lib/2.3/libsmokeqtscript.dll +0 -0
- data/lib/2.3/libsmokeqtsql.dll +0 -0
- data/lib/2.3/libsmokeqtsvg.dll +0 -0
- data/lib/2.3/libsmokeqttest.dll +0 -0
- data/lib/2.3/libsmokeqtuitools.dll +0 -0
- data/lib/2.3/libsmokeqtwebkit.dll +0 -0
- data/lib/2.3/libsmokeqtxml.dll +0 -0
- data/lib/2.3/libsmokeqtxmlpatterns.dll +0 -0
- data/lib/2.3/qtdeclarative.so +0 -0
- data/lib/2.3/qtruby4.so +0 -0
- data/lib/2.3/qtscript.so +0 -0
- data/lib/2.3/qttest.so +0 -0
- data/lib/2.3/qtuitools.so +0 -0
- data/lib/2.3/qtwebkit.so +0 -0
- data/lib/qtbindings_qt_version.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa1699d08ad883c9e42bf004d9429ebc1c6dfddb
|
4
|
+
data.tar.gz: 598fbef04b742792dbcb2784f7484f81e9cbc48b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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('
|
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
|
data/bin/2.4/rbrcc.exe
ADDED
Binary file
|
data/bin/2.4/rbuic4.exe
ADDED
Binary file
|
Binary file
|
Binary file
|
@@ -1,72 +1,72 @@
|
|
1
|
-
require 'Qt'
|
2
|
-
|
3
|
-
class CannonField < Qt::Widget
|
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
|
-
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
|
-
|
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
|
-
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
class MyWidget < Qt::Widget
|
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
|
-
end
|
50
|
-
|
51
|
-
app = Qt::Application.new(ARGV)
|
52
|
-
widget = MyWidget.new
|
53
|
-
widget.setGeometry(
|
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
|
-
|
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
|
-
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
|