diff options
Diffstat (limited to 'qtruby/rubylib/tutorial')
31 files changed, 303 insertions, 303 deletions
diff --git a/qtruby/rubylib/tutorial/t1/t1.rb b/qtruby/rubylib/tutorial/t1/t1.rb index 19d8a029..1f2da715 100755 --- a/qtruby/rubylib/tutorial/t1/t1.rb +++ b/qtruby/rubylib/tutorial/t1/t1.rb @@ -1,10 +1,10 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' +retquire 'Qt' -a = Qt::Application.new(ARGV) -hello = Qt::PushButton.new('Hello World!', nil) +a = TQt::Application.new(ARGV) +hello = TQt::PushButton.new('Hello World!', nil) hello.resize(100, 30) a.setMainWidget(hello) hello.show() diff --git a/qtruby/rubylib/tutorial/t10/cannon.rb b/qtruby/rubylib/tutorial/t10/cannon.rb index 3c02f8ff..708eb728 100644 --- a/qtruby/rubylib/tutorial/t10/cannon.rb +++ b/qtruby/rubylib/tutorial/t10/cannon.rb @@ -1,6 +1,6 @@ -require 'Qt' +retquire 'Qt' -class CannonField < Qt::Widget +class CannonField < TQt::Widget signals 'angleChanged(int)', 'forceChanged(int)' slots 'setAngle(int)', 'setForce(int)' @@ -8,7 +8,7 @@ class CannonField < Qt::Widget super @ang = 45 @f = 0 - setPalette( Qt::Palette.new( Qt::Color.new( 250, 250, 200) ) ) + setPalette( TQt::Palette.new( TQt::Color.new( 250, 250, 200) ) ) end def setAngle( degrees ) @@ -42,16 +42,16 @@ class CannonField < Qt::Widget end cr = cannonRect() - pix = Qt::Pixmap.new( cr.size() ) + pix = TQt::Pixmap.new( cr.size() ) pix.fill( self, cr.topLeft() ) - p = Qt::Painter.new( pix ) + p = TQt::Painter.new( pix ) p.setBrush( blue ) - p.setPen( Qt::NoPen ) + p.setPen( TQt::NoPen ) p.translate( 0, pix.height() - 1 ) - p.drawPie( Qt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) + p.drawPie( TQt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) p.rotate( - @ang ) - p.drawRect( Qt::Rect.new(33, -4, 15, 8) ) + p.drawRect( TQt::Rect.new(33, -4, 15, 8) ) p.end() p.begin(self) @@ -60,12 +60,12 @@ class CannonField < Qt::Widget end def cannonRect() - r = Qt::Rect.new( 0, 0, 50, 50) + r = TQt::Rect.new( 0, 0, 50, 50) r.moveBottomLeft( rect().bottomLeft() ) return r end def sizePolicy() - return Qt::SizePolicy.new( Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding ) + return TQt::SizePolicy.new( TQt::SizePolicy::Expanding, TQt::SizePolicy::Expanding ) end end diff --git a/qtruby/rubylib/tutorial/t10/lcdrange.rb b/qtruby/rubylib/tutorial/t10/lcdrange.rb index a0adc842..2e274174 100644 --- a/qtruby/rubylib/tutorial/t10/lcdrange.rb +++ b/qtruby/rubylib/tutorial/t10/lcdrange.rb @@ -1,13 +1,13 @@ -require 'Qt' +retquire 'Qt' -class LCDRange < Qt::VBox +class LCDRange < TQt::VBox signals 'valueChanged(int)' slots 'setValue(int)', 'setRange(int, int)' def initialize(parent, name) super - lcd = Qt::LCDNumber.new(2, self, 'lcd') - @slider = Qt::Slider.new(Qt::VBox::Horizontal, self, 'slider') + lcd = TQt::LCDNumber.new(2, self, 'lcd') + @slider = TQt::Slider.new(TQt::VBox::Horizontal, self, 'slider') @slider.setRange(0, 99) @slider.setValue(0) connect(@slider, SIGNAL('valueChanged(int)'), lcd, SLOT('display(int)')) diff --git a/qtruby/rubylib/tutorial/t10/t10.rb b/qtruby/rubylib/tutorial/t10/t10.rb index 4168d507..cd45261a 100755 --- a/qtruby/rubylib/tutorial/t10/t10.rb +++ b/qtruby/rubylib/tutorial/t10/t10.rb @@ -1,15 +1,15 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' -require 'lcdrange.rb' -require 'cannon.rb' +retquire 'Qt' +retquire 'lcdrange.rb' +retquire 'cannon.rb' -class MyWidget < Qt::Widget +class MyWidget < TQt::Widget def initialize() super - quit = Qt::PushButton.new('Quit', self, 'quit') - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit = TQt::PushButton.new('Quit', self, 'quit') + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) @@ -31,12 +31,12 @@ class MyWidget < Qt::Widget connect( cannonField, SIGNAL('forceChanged(int)'), force, SLOT('setValue(int)') ) - grid = Qt::GridLayout.new( self, 2, 2, 10 ) + grid = TQt::GridLayout.new( self, 2, 2, 10 ) grid.addWidget( quit, 0, 0 ) grid.addWidget( cannonField, 1, 1 ) grid.setColStretch( 1, 10 ) - leftBox = Qt::VBoxLayout.new() + leftBox = TQt::VBoxLayout.new() grid.addLayout( leftBox, 1, 0 ) leftBox.addWidget( angle ) leftBox.addWidget( force ) @@ -47,8 +47,8 @@ class MyWidget < Qt::Widget end end -Qt::Application.setColorSpec( Qt::Application::CustomColor ) -a = Qt::Application.new(ARGV) +TQt::Application.setColorSpec( TQt::Application::CustomColor ) +a = TQt::Application.new(ARGV) w = MyWidget.new w.setGeometry( 100, 100, 500, 355 ) diff --git a/qtruby/rubylib/tutorial/t11/cannon.rb b/qtruby/rubylib/tutorial/t11/cannon.rb index e9446b02..b8fa2826 100644 --- a/qtruby/rubylib/tutorial/t11/cannon.rb +++ b/qtruby/rubylib/tutorial/t11/cannon.rb @@ -1,7 +1,7 @@ include Math -require 'Qt' +retquire 'Qt' -class CannonField < Qt::Widget +class CannonField < TQt::Widget signals 'angleChanged(int)', 'forceChanged(int)' slots 'setAngle(int)', 'setForce(int)', 'shoot()', 'moveShot()' @@ -11,13 +11,13 @@ class CannonField < Qt::Widget @ang = 45 @f = 0 @timerCount = 0; - @autoShootTimer = Qt::Timer.new( self, 'movement handler' ) + @autoShootTimer = TQt::Timer.new( self, 'movement handler' ) connect( @autoShootTimer, SIGNAL('timeout()'), self, SLOT('moveShot()') ); @shoot_ang = 0 @shoot_f = 0 - setPalette( Qt::Palette.new( Qt::Color.new( 250, 250, 200) ) ) - @barrelRect = Qt::Rect.new(33, -4, 15, 8) + setPalette( TQt::Palette.new( TQt::Color.new( 250, 250, 200) ) ) + @barrelRect = TQt::Rect.new(33, -4, 15, 8) end def setAngle( degrees ) @@ -56,7 +56,7 @@ class CannonField < Qt::Widget end def moveShot() - r = Qt::Region.new( shotRect() ) + r = TQt::Region.new( shotRect() ) @timerCount += 1 shotR = shotRect() @@ -64,14 +64,14 @@ class CannonField < Qt::Widget if shotR.x() > width() || shotR.y() > height() @autoShootTimer.stop() else - r = r.unite( Qt::Region.new( shotR ) ) + r = r.unite( TQt::Region.new( shotR ) ) end repaint( r ) end def paintEvent( e ) updateR = e.rect() - p = Qt::Painter.new( self ) + p = TQt::Painter.new( self ) if updateR.intersects( cannonRect() ) paintCannon( p ) @@ -85,20 +85,20 @@ class CannonField < Qt::Widget def paintShot( p ) p.setBrush( black ) - p.setPen( Qt::NoPen ) + p.setPen( TQt::NoPen ) p.drawRect( shotRect() ) end def paintCannon(p) cr = cannonRect() - pix = Qt::Pixmap.new( cr.size() ) + pix = TQt::Pixmap.new( cr.size() ) pix.fill( self, cr.topLeft() ) - tmp = Qt::Painter.new( pix ) + tmp = TQt::Painter.new( pix ) tmp.setBrush( blue ) - tmp.setPen( Qt::NoPen ) + tmp.setPen( TQt::NoPen ) tmp.translate( 0, pix.height() - 1 ) - tmp.drawPie( Qt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) + tmp.drawPie( TQt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) tmp.rotate( - @ang ) tmp.drawRect( @barrelRect ) tmp.end() @@ -107,7 +107,7 @@ class CannonField < Qt::Widget end def cannonRect() - r = Qt::Rect.new( 0, 0, 50, 50) + r = TQt::Rect.new( 0, 0, 50, 50) r.moveBottomLeft( rect().bottomLeft() ) return r end @@ -126,12 +126,12 @@ class CannonField < Qt::Widget x = x0 + velx*time y = y0 + vely*time - 0.5*gravity*time*time - r = Qt::Rect.new( 0, 0, 6, 6 ); - r.moveCenter( Qt::Point.new( x.round, height() - 1 - y.round ) ) + r = TQt::Rect.new( 0, 0, 6, 6 ); + r.moveCenter( TQt::Point.new( x.round, height() - 1 - y.round ) ) return r end def sizePolicy() - return Qt::SizePolicy.new( Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding ) + return TQt::SizePolicy.new( TQt::SizePolicy::Expanding, TQt::SizePolicy::Expanding ) end end diff --git a/qtruby/rubylib/tutorial/t11/lcdrange.rb b/qtruby/rubylib/tutorial/t11/lcdrange.rb index a0adc842..2e274174 100644 --- a/qtruby/rubylib/tutorial/t11/lcdrange.rb +++ b/qtruby/rubylib/tutorial/t11/lcdrange.rb @@ -1,13 +1,13 @@ -require 'Qt' +retquire 'Qt' -class LCDRange < Qt::VBox +class LCDRange < TQt::VBox signals 'valueChanged(int)' slots 'setValue(int)', 'setRange(int, int)' def initialize(parent, name) super - lcd = Qt::LCDNumber.new(2, self, 'lcd') - @slider = Qt::Slider.new(Qt::VBox::Horizontal, self, 'slider') + lcd = TQt::LCDNumber.new(2, self, 'lcd') + @slider = TQt::Slider.new(TQt::VBox::Horizontal, self, 'slider') @slider.setRange(0, 99) @slider.setValue(0) connect(@slider, SIGNAL('valueChanged(int)'), lcd, SLOT('display(int)')) diff --git a/qtruby/rubylib/tutorial/t11/t11.rb b/qtruby/rubylib/tutorial/t11/t11.rb index 8656f6f5..f0d3b895 100755 --- a/qtruby/rubylib/tutorial/t11/t11.rb +++ b/qtruby/rubylib/tutorial/t11/t11.rb @@ -1,15 +1,15 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' -require 'lcdrange.rb' -require 'cannon.rb' +retquire 'Qt' +retquire 'lcdrange.rb' +retquire 'cannon.rb' -class MyWidget < Qt::Widget +class MyWidget < TQt::Widget def initialize() super - quit = Qt::PushButton.new('Quit', self, 'quit') - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit = TQt::PushButton.new('Quit', self, 'quit') + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) @@ -31,22 +31,22 @@ class MyWidget < Qt::Widget connect( cannonField, SIGNAL('forceChanged(int)'), force, SLOT('setValue(int)') ) - shoot = Qt::PushButton.new( '&Shoot', self, 'shoot' ) - shoot.setFont( Qt::Font.new( 'Times', 18, Qt::Font::Bold ) ) + shoot = TQt::PushButton.new( '&Shoot', self, 'shoot' ) + shoot.setFont( TQt::Font.new( 'Times', 18, TQt::Font::Bold ) ) connect( shoot, SIGNAL('clicked()'), cannonField, SLOT('shoot()') ) - grid = Qt::GridLayout.new( self, 2, 2, 10 ) + grid = TQt::GridLayout.new( self, 2, 2, 10 ) grid.addWidget( quit, 0, 0 ) grid.addWidget( cannonField, 1, 1 ) grid.setColStretch( 1, 10 ) - leftBox = Qt::VBoxLayout.new() + leftBox = TQt::VBoxLayout.new() grid.addLayout( leftBox, 1, 0 ) leftBox.addWidget( angle ) leftBox.addWidget( force ) - topBox = Qt::HBoxLayout.new() + topBox = TQt::HBoxLayout.new() grid.addLayout( topBox, 0, 1 ) topBox.addWidget( shoot ) topBox.addStretch( 1 ) @@ -57,8 +57,8 @@ class MyWidget < Qt::Widget end end -Qt::Application.setColorSpec( Qt::Application::CustomColor ) -a = Qt::Application.new(ARGV) +TQt::Application.setColorSpec( TQt::Application::CustomColor ) +a = TQt::Application.new(ARGV) w = MyWidget.new w.setGeometry( 100, 100, 500, 355 ) diff --git a/qtruby/rubylib/tutorial/t12/cannon.rb b/qtruby/rubylib/tutorial/t12/cannon.rb index 1b72cbc0..28afb5c6 100644 --- a/qtruby/rubylib/tutorial/t12/cannon.rb +++ b/qtruby/rubylib/tutorial/t12/cannon.rb @@ -1,7 +1,7 @@ include Math -require 'Qt' +retquire 'Qt' -class CannonField < Qt::Widget +class CannonField < TQt::Widget signals 'hit()', 'missed()', 'angleChanged(int)', 'forceChanged(int)' slots 'setAngle(int)', 'setForce(int)', 'shoot()', 'moveShot()', 'newTarget()' @@ -11,15 +11,15 @@ class CannonField < Qt::Widget @ang = 45 @f = 0 @timerCount = 0; - @autoShootTimer = Qt::Timer.new( self, 'movement handler' ) + @autoShootTimer = TQt::Timer.new( self, 'movement handler' ) connect( @autoShootTimer, SIGNAL('timeout()'), self, SLOT('moveShot()') ); @shoot_ang = 0 @shoot_f = 0 - @target = Qt::Point.new(0, 0) - setPalette( Qt::Palette.new( Qt::Color.new( 250, 250, 200) ) ) + @target = TQt::Point.new(0, 0) + setPalette( TQt::Palette.new( TQt::Color.new( 250, 250, 200) ) ) newTarget() - @barrelRect = Qt::Rect.new(33, -4, 15, 8) + @barrelRect = TQt::Rect.new(33, -4, 15, 8) end def setAngle( degrees ) @@ -62,17 +62,17 @@ class CannonField < Qt::Widget def newTarget() if @@first_time @@first_time = false - midnight = Qt::Time.new( 0, 0, 0 ) - srand( midnight.secsTo(Qt::Time.currentTime()) ) + midnight = TQt::Time.new( 0, 0, 0 ) + srand( midnight.secsTo(TQt::Time.currentTime()) ) end - r = Qt::Region.new( targetRect() ) - @target = Qt::Point.new( 200 + rand(190), + r = TQt::Region.new( targetRect() ) + @target = TQt::Point.new( 200 + rand(190), 10 + rand(255) ) - repaint( r.unite( Qt::Region.new(targetRect()) ) ) + repaint( r.unite( TQt::Region.new(targetRect()) ) ) end def moveShot() - r = Qt::Region.new( shotRect() ) + r = TQt::Region.new( shotRect() ) @timerCount += 1 shotR = shotRect() @@ -84,7 +84,7 @@ class CannonField < Qt::Widget @autoShootTimer.stop() emit missed() else - r = r.unite( Qt::Region.new( shotR ) ) + r = r.unite( TQt::Region.new( shotR ) ) end repaint( r ) @@ -92,7 +92,7 @@ class CannonField < Qt::Widget def paintEvent( e ) updateR = e.rect() - p = Qt::Painter.new( self ) + p = TQt::Painter.new( self ) if updateR.intersects( cannonRect() ) paintCannon( p ) @@ -109,7 +109,7 @@ class CannonField < Qt::Widget def paintShot( p ) p.setBrush( black ) - p.setPen( Qt::NoPen ) + p.setPen( TQt::NoPen ) p.drawRect( shotRect() ) end @@ -121,14 +121,14 @@ class CannonField < Qt::Widget def paintCannon(p) cr = cannonRect() - pix = Qt::Pixmap.new( cr.size() ) + pix = TQt::Pixmap.new( cr.size() ) pix.fill( self, cr.topLeft() ) - tmp = Qt::Painter.new( pix ) + tmp = TQt::Painter.new( pix ) tmp.setBrush( blue ) - tmp.setPen( Qt::NoPen ) + tmp.setPen( TQt::NoPen ) tmp.translate( 0, pix.height() - 1 ) - tmp.drawPie( Qt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) + tmp.drawPie( TQt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) tmp.rotate( - @ang ) tmp.drawRect( @barrelRect ) tmp.end() @@ -137,7 +137,7 @@ class CannonField < Qt::Widget end def cannonRect() - r = Qt::Rect.new( 0, 0, 50, 50) + r = TQt::Rect.new( 0, 0, 50, 50) r.moveBottomLeft( rect().bottomLeft() ) return r end @@ -156,18 +156,18 @@ class CannonField < Qt::Widget x = x0 + velx*time y = y0 + vely*time - 0.5*gravity*time*time - r = Qt::Rect.new( 0, 0, 6, 6 ); - r.moveCenter( Qt::Point.new( x.round, height() - 1 - y.round ) ) + r = TQt::Rect.new( 0, 0, 6, 6 ); + r.moveCenter( TQt::Point.new( x.round, height() - 1 - y.round ) ) return r end def targetRect() - r = Qt::Rect.new( 0, 0, 20, 10 ) - r.moveCenter( Qt::Point.new(@target.x(),height() - 1 - @target.y()) ); + r = TQt::Rect.new( 0, 0, 20, 10 ) + r.moveCenter( TQt::Point.new(@target.x(),height() - 1 - @target.y()) ); return r end def sizePolicy() - return Qt::SizePolicy.new( Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding ) + return TQt::SizePolicy.new( TQt::SizePolicy::Expanding, TQt::SizePolicy::Expanding ) end end diff --git a/qtruby/rubylib/tutorial/t12/lcdrange.rb b/qtruby/rubylib/tutorial/t12/lcdrange.rb index ef5c849d..5e1c96ca 100644 --- a/qtruby/rubylib/tutorial/t12/lcdrange.rb +++ b/qtruby/rubylib/tutorial/t12/lcdrange.rb @@ -1,6 +1,6 @@ -require 'Qt' +retquire 'Qt' -class LCDRange < Qt::VBox +class LCDRange < TQt::VBox signals 'valueChanged(int)' slots 'setValue(int)', 'setRange(int, int)', 'setText(const char *)' @@ -11,12 +11,12 @@ class LCDRange < Qt::VBox end def init() - lcd = Qt::LCDNumber.new(2, self, 'lcd') - @slider = Qt::Slider.new(Qt::VBox::Horizontal, self, 'slider') + lcd = TQt::LCDNumber.new(2, self, 'lcd') + @slider = TQt::Slider.new(TQt::VBox::Horizontal, self, 'slider') @slider.setRange(0, 99) @slider.setValue(0) - @label = Qt::Label.new( ' ', self, 'label' ) - @label.setAlignment( Qt::AlignCenter ) + @label = TQt::Label.new( ' ', self, 'label' ) + @label.setAlignment( TQt::AlignCenter ) connect(@slider, SIGNAL('valueChanged(int)'), lcd, SLOT('display(int)')) connect(@slider, SIGNAL('valueChanged(int)'), SIGNAL('valueChanged(int)')) setFocusProxy(@slider) diff --git a/qtruby/rubylib/tutorial/t12/t12.rb b/qtruby/rubylib/tutorial/t12/t12.rb index a02c3a8e..b1427cb2 100755 --- a/qtruby/rubylib/tutorial/t12/t12.rb +++ b/qtruby/rubylib/tutorial/t12/t12.rb @@ -1,16 +1,16 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' -require 'lcdrange.rb' -require 'cannon.rb' +retquire 'Qt' +retquire 'lcdrange.rb' +retquire 'cannon.rb' -class MyWidget < Qt::Widget +class MyWidget < TQt::Widget def initialize() super - quit = Qt::PushButton.new('&Quit', self, 'quit') - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit = TQt::PushButton.new('&Quit', self, 'quit') + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) @@ -32,22 +32,22 @@ class MyWidget < Qt::Widget connect( cannonField, SIGNAL('forceChanged(int)'), force, SLOT('setValue(int)') ) - shoot = Qt::PushButton.new( '&Shoot', self, 'shoot' ) - shoot.setFont( Qt::Font.new( 'Times', 18, Qt::Font::Bold ) ) + shoot = TQt::PushButton.new( '&Shoot', self, 'shoot' ) + shoot.setFont( TQt::Font.new( 'Times', 18, TQt::Font::Bold ) ) connect( shoot, SIGNAL('clicked()'), cannonField, SLOT('shoot()') ) - grid = Qt::GridLayout.new( self, 2, 2, 10 ) + grid = TQt::GridLayout.new( self, 2, 2, 10 ) grid.addWidget( quit, 0, 0 ) grid.addWidget( cannonField, 1, 1 ) grid.setColStretch( 1, 10 ) - leftBox = Qt::VBoxLayout.new() + leftBox = TQt::VBoxLayout.new() grid.addLayout( leftBox, 1, 0 ) leftBox.addWidget( angle ) leftBox.addWidget( force ) - topBox = Qt::HBoxLayout.new() + topBox = TQt::HBoxLayout.new() grid.addLayout( topBox, 0, 1 ) topBox.addWidget( shoot ) topBox.addStretch( 1 ) @@ -58,8 +58,8 @@ class MyWidget < Qt::Widget end end -Qt::Application.setColorSpec( Qt::Application::CustomColor ) -a = Qt::Application.new(ARGV) +TQt::Application.setColorSpec( TQt::Application::CustomColor ) +a = TQt::Application.new(ARGV) w = MyWidget.new w.setGeometry( 100, 100, 500, 355 ) diff --git a/qtruby/rubylib/tutorial/t13/cannon.rb b/qtruby/rubylib/tutorial/t13/cannon.rb index d99f9a09..556347bc 100644 --- a/qtruby/rubylib/tutorial/t13/cannon.rb +++ b/qtruby/rubylib/tutorial/t13/cannon.rb @@ -1,7 +1,7 @@ -require 'Qt' +retquire 'Qt' include Math -class CannonField < Qt::Widget +class CannonField < TQt::Widget signals 'hit()', 'missed()', 'angleChanged(int)', 'forceChanged(int)', 'canShoot(bool)' @@ -15,16 +15,16 @@ class CannonField < Qt::Widget @ang = 45 @f = 0 @timerCount = 0; - @autoShootTimer = Qt::Timer.new( self, "movement handler" ) + @autoShootTimer = TQt::Timer.new( self, "movement handler" ) connect( @autoShootTimer, SIGNAL('timeout()'), self, SLOT('moveShot()') ); @shoot_ang = 0 @shoot_f = 0 - @target = Qt::Point.new(0, 0) + @target = TQt::Point.new(0, 0) @gameEnded = false - setPalette( Qt::Palette.new( Qt::Color.new( 250, 250, 200) ) ) + setPalette( TQt::Palette.new( TQt::Color.new( 250, 250, 200) ) ) newTarget() - @barrelRect = Qt::Rect.new(33, -4, 15, 8) + @barrelRect = TQt::Rect.new(33, -4, 15, 8) end def angle() @@ -78,13 +78,13 @@ class CannonField < Qt::Widget def newTarget() if @@first_time @@first_time = false - midnight = Qt::Time.new( 0, 0, 0 ) - srand( midnight.secsTo(Qt::Time.currentTime()) ) + midnight = TQt::Time.new( 0, 0, 0 ) + srand( midnight.secsTo(TQt::Time.currentTime()) ) end - r = Qt::Region.new( targetRect() ) - @target = Qt::Point.new( 200 + rand(190), + r = TQt::Region.new( targetRect() ) + @target = TQt::Point.new( 200 + rand(190), 10 + rand(255) ) - repaint( r.unite( Qt::Region.new(targetRect()) ) ) + repaint( r.unite( TQt::Region.new(targetRect()) ) ) end def setGameOver() @@ -108,7 +108,7 @@ class CannonField < Qt::Widget end def moveShot() - r = Qt::Region.new( shotRect() ) + r = TQt::Region.new( shotRect() ) @timerCount += 1 shotR = shotRect() @@ -122,7 +122,7 @@ class CannonField < Qt::Widget emit missed() emit canShoot(true) else - r = r.unite( Qt::Region.new( shotR ) ) + r = r.unite( TQt::Region.new( shotR ) ) end repaint( r ) @@ -130,11 +130,11 @@ class CannonField < Qt::Widget def paintEvent( e ) updateR = e.rect() - p = Qt::Painter.new( self ) + p = TQt::Painter.new( self ) if @gameEnded p.setPen( black ) - p.setFont( Qt::Font.new( "Courier", 48, QFont::Bold ) ) + p.setFont( TQt::Font.new( "Courier", 48, TQFont::Bold ) ) p.drawText( rect(), AlignCenter, "Game Over" ) end if updateR.intersects( cannonRect() ) @@ -151,7 +151,7 @@ class CannonField < Qt::Widget def paintShot( p ) p.setBrush( black ) - p.setPen( Qt::NoPen ) + p.setPen( TQt::NoPen ) p.drawRect( shotRect() ) end @@ -163,14 +163,14 @@ class CannonField < Qt::Widget def paintCannon(p) cr = cannonRect() - pix = Qt::Pixmap.new( cr.size() ) + pix = TQt::Pixmap.new( cr.size() ) pix.fill( self, cr.topLeft() ) - tmp = Qt::Painter.new( pix ) + tmp = TQt::Painter.new( pix ) tmp.setBrush( blue ) - tmp.setPen( Qt::NoPen ) + tmp.setPen( TQt::NoPen ) tmp.translate( 0, pix.height() - 1 ) - tmp.drawPie( Qt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) + tmp.drawPie( TQt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) tmp.rotate( - @ang ) tmp.drawRect( @barrelRect ) tmp.end() @@ -179,7 +179,7 @@ class CannonField < Qt::Widget end def cannonRect() - r = Qt::Rect.new( 0, 0, 50, 50) + r = TQt::Rect.new( 0, 0, 50, 50) r.moveBottomLeft( rect().bottomLeft() ) return r end @@ -198,14 +198,14 @@ class CannonField < Qt::Widget x = x0 + velx*time y = y0 + vely*time - 0.5*gravity*time*time - r = Qt::Rect.new( 0, 0, 6, 6 ); - r.moveCenter( Qt::Point.new( x.round, height() - 1 - y.round ) ) + r = TQt::Rect.new( 0, 0, 6, 6 ); + r.moveCenter( TQt::Point.new( x.round, height() - 1 - y.round ) ) return r end def targetRect() - r = Qt::Rect.new( 0, 0, 20, 10 ) - r.moveCenter( Qt::Point.new(@target.x(),height() - 1 - @target.y()) ); + r = TQt::Rect.new( 0, 0, 20, 10 ) + r.moveCenter( TQt::Point.new(@target.x(),height() - 1 - @target.y()) ); return r end @@ -214,6 +214,6 @@ class CannonField < Qt::Widget end def sizePolicy() - return Qt::SizePolicy.new( Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding ) + return TQt::SizePolicy.new( TQt::SizePolicy::Expanding, TQt::SizePolicy::Expanding ) end end diff --git a/qtruby/rubylib/tutorial/t13/gamebrd.rb b/qtruby/rubylib/tutorial/t13/gamebrd.rb index dc993927..46cc10c5 100644 --- a/qtruby/rubylib/tutorial/t13/gamebrd.rb +++ b/qtruby/rubylib/tutorial/t13/gamebrd.rb @@ -1,15 +1,15 @@ -require 'Qt' -require 'lcdrange.rb' -require 'cannon.rb' +retquire 'Qt' +retquire 'lcdrange.rb' +retquire 'cannon.rb' -class GameBoard < Qt::Widget +class GameBoard < TQt::Widget slots 'fire()', 'hit()', 'missed()', 'newGame()' def initialize() super - quit = Qt::PushButton.new('&Quit', self, 'quit') - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit = TQt::PushButton.new('&Quit', self, 'quit') + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) @@ -36,34 +36,34 @@ class GameBoard < Qt::Widget connect( @cannonField, SIGNAL('missed()'), self, SLOT('missed()') ) - shoot = Qt::PushButton.new( '&Shoot', self, 'shoot' ) - shoot.setFont( Qt::Font.new( 'Times', 18, Qt::Font::Bold ) ) + shoot = TQt::PushButton.new( '&Shoot', self, 'shoot' ) + shoot.setFont( TQt::Font.new( 'Times', 18, TQt::Font::Bold ) ) connect( shoot, SIGNAL('clicked()'), SLOT('fire()') ) connect( @cannonField, SIGNAL('canShoot(bool)'), shoot, SLOT('setEnabled(bool)') ) - restart = Qt::PushButton.new( '&New Game', self, 'newgame' ) - restart.setFont( Qt::Font.new( 'Times', 18, Qt::Font::Bold ) ) + restart = TQt::PushButton.new( '&New Game', self, 'newgame' ) + restart.setFont( TQt::Font.new( 'Times', 18, TQt::Font::Bold ) ) connect( restart, SIGNAL('clicked()'), self, SLOT('newGame()') ) - @hits = Qt::LCDNumber.new( 2, self, 'hits' ) - @shotsLeft = Qt::LCDNumber.new( 2, self, 'shotsleft' ) - hitsL = Qt::Label.new( 'HITS', self, 'hitsLabel' ) - shotsLeftL = Qt::Label.new( 'SHOTS LEFT', self, 'shotsleftLabel' ) + @hits = TQt::LCDNumber.new( 2, self, 'hits' ) + @shotsLeft = TQt::LCDNumber.new( 2, self, 'shotsleft' ) + hitsL = TQt::Label.new( 'HITS', self, 'hitsLabel' ) + shotsLeftL = TQt::Label.new( 'SHOTS LEFT', self, 'shotsleftLabel' ) - grid = Qt::GridLayout.new( self, 2, 2, 10 ) + grid = TQt::GridLayout.new( self, 2, 2, 10 ) grid.addWidget( quit, 0, 0 ) grid.addWidget( @cannonField, 1, 1 ) grid.setColStretch( 1, 10 ) - leftBox = Qt::VBoxLayout.new() + leftBox = TQt::VBoxLayout.new() grid.addLayout( leftBox, 1, 0 ) leftBox.addWidget( angle ) leftBox.addWidget( force ) - topBox = Qt::HBoxLayout.new() + topBox = TQt::HBoxLayout.new() grid.addLayout( topBox, 0, 1 ) topBox.addWidget( shoot ) topBox.addWidget( @hits ) diff --git a/qtruby/rubylib/tutorial/t13/lcdrange.rb b/qtruby/rubylib/tutorial/t13/lcdrange.rb index 03edb89c..a91cc384 100644 --- a/qtruby/rubylib/tutorial/t13/lcdrange.rb +++ b/qtruby/rubylib/tutorial/t13/lcdrange.rb @@ -1,6 +1,6 @@ -require 'Qt' +retquire 'Qt' -class LCDRange < Qt::Widget +class LCDRange < TQt::Widget signals 'valueChanged(int)' slots 'setValue(int)', 'setRange(int, int)', 'setText(const char*)' @@ -11,20 +11,20 @@ class LCDRange < Qt::Widget end def init() - @lcd = Qt::LCDNumber.new(2, self, 'lcd') - @slider = Qt::Slider.new(Qt::VBox::Horizontal, self, 'slider') + @lcd = TQt::LCDNumber.new(2, self, 'lcd') + @slider = TQt::Slider.new(TQt::VBox::Horizontal, self, 'slider') @slider.setRange(0, 99) @slider.setValue(0) - @label = Qt::Label.new( ' ', self, 'label' ) - @label.setAlignment( Qt::AlignCenter ) + @label = TQt::Label.new( ' ', self, 'label' ) + @label.setAlignment( TQt::AlignCenter ) connect(@slider, SIGNAL('valueChanged(int)'), @lcd, SLOT('display(int)')) connect(@slider, SIGNAL('valueChanged(int)'), SIGNAL('valueChanged(int)')) setFocusProxy(@slider) - l = Qt::VBoxLayout.new( self ) + l = TQt::VBoxLayout.new( self ) l.addWidget( @lcd, 1 ) l.addWidget( @slider ) l.addWidget( @label ) diff --git a/qtruby/rubylib/tutorial/t13/t13.rb b/qtruby/rubylib/tutorial/t13/t13.rb index 817dfe70..8e63bcd6 100755 --- a/qtruby/rubylib/tutorial/t13/t13.rb +++ b/qtruby/rubylib/tutorial/t13/t13.rb @@ -1,11 +1,11 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' -require 'gamebrd.rb' +retquire 'Qt' +retquire 'gamebrd.rb' -Qt::Application.setColorSpec( Qt::Application::CustomColor ) -a = Qt::Application.new(ARGV) +TQt::Application.setColorSpec( TQt::Application::CustomColor ) +a = TQt::Application.new(ARGV) gb = GameBoard.new gb.setGeometry( 100, 100, 500, 355 ) diff --git a/qtruby/rubylib/tutorial/t14/cannon.rb b/qtruby/rubylib/tutorial/t14/cannon.rb index b0f77d37..3c1d7663 100644 --- a/qtruby/rubylib/tutorial/t14/cannon.rb +++ b/qtruby/rubylib/tutorial/t14/cannon.rb @@ -1,7 +1,7 @@ -require 'Qt' +retquire 'Qt' include Math -class CannonField < Qt::Widget +class CannonField < TQt::Widget signals 'hit()', 'missed()', 'angleChanged(int)', 'forceChanged(int)', 'canShoot(bool)' @@ -14,17 +14,17 @@ class CannonField < Qt::Widget @ang = 45 @f = 0 @timerCount = 0; - @autoShootTimer = Qt::Timer.new( self, 'movement handler' ) + @autoShootTimer = TQt::Timer.new( self, 'movement handler' ) connect( @autoShootTimer, SIGNAL('timeout()'), self, SLOT('moveShot()') ) @shoot_ang = 0 @shoot_f = 0 - @target = Qt::Point.new(0, 0) + @target = TQt::Point.new(0, 0) @gameEnded = false @barrelPressed = false - setPalette( Qt::Palette.new( Qt::Color.new( 250, 250, 200) ) ) + setPalette( TQt::Palette.new( TQt::Color.new( 250, 250, 200) ) ) newTarget() - @barrelRect = Qt::Rect.new(33, -4, 15, 8) + @barrelRect = TQt::Rect.new(33, -4, 15, 8) end def angle() @@ -80,13 +80,13 @@ class CannonField < Qt::Widget def newTarget() if @@first_time @@first_time = false - midnight = Qt::Time.new( 0, 0, 0 ) - srand( midnight.secsTo(Qt::Time.currentTime()) ) + midnight = TQt::Time.new( 0, 0, 0 ) + srand( midnight.secsTo(TQt::Time.currentTime()) ) end - r = Qt::Region.new( targetRect() ) - @target = Qt::Point.new( 200 + rand(190), + r = TQt::Region.new( targetRect() ) + @target = TQt::Point.new( 200 + rand(190), 10 + rand(255) ) - repaint( r.unite( Qt::Region.new(targetRect()) ) ) + repaint( r.unite( TQt::Region.new(targetRect()) ) ) end def setGameOver() @@ -110,7 +110,7 @@ class CannonField < Qt::Widget end def moveShot() - r = Qt::Region.new( shotRect() ) + r = TQt::Region.new( shotRect() ) @timerCount += 1 shotR = shotRect() @@ -125,7 +125,7 @@ class CannonField < Qt::Widget emit missed() emit canShoot(true) else - r = r.unite( Qt::Region.new( shotR ) ) + r = r.unite( TQt::Region.new( shotR ) ) end repaint( r ) @@ -133,7 +133,7 @@ class CannonField < Qt::Widget private :moveShot def mousePressEvent( e ) - if e.button() != Qt::LeftButton + if e.button() != TQt::LeftButton return end if barrelHit( e.pos() ) @@ -157,19 +157,19 @@ class CannonField < Qt::Widget end def mouseReleaseEvent( e ) - if e.button() == Qt::LeftButton + if e.button() == TQt::LeftButton @barrelPressed = false end end def paintEvent( e ) updateR = e.rect() - p = Qt::Painter.new( self ) + p = TQt::Painter.new( self ) if @gameEnded p.setPen( black ) - p.setFont( Qt::Font.new( 'Courier', 48, Qt::Font::Bold ) ) - p.drawText( rect(), Qt::AlignCenter, 'Game Over' ) + p.setFont( TQt::Font.new( 'Courier', 48, TQt::Font::Bold ) ) + p.drawText( rect(), TQt::AlignCenter, 'Game Over' ) end if updateR.intersects( cannonRect() ) paintCannon( p ) @@ -189,7 +189,7 @@ class CannonField < Qt::Widget def paintShot( p ) p.setBrush( black ) - p.setPen( Qt::NoPen ) + p.setPen( TQt::NoPen ) p.drawRect( shotRect() ) end @@ -207,15 +207,15 @@ class CannonField < Qt::Widget def paintCannon(p) cr = cannonRect() - pix = Qt::Pixmap.new( cr.size() ) + pix = TQt::Pixmap.new( cr.size() ) pix.fill( self, cr.topLeft() ) - tmp = Qt::Painter.new( pix ) + tmp = TQt::Painter.new( pix ) tmp.setBrush( blue ) - tmp.setPen( Qt::NoPen ) + tmp.setPen( TQt::NoPen ) tmp.translate( 0, pix.height() - 1 ) - tmp.drawPie( Qt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) + tmp.drawPie( TQt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) tmp.rotate( - @ang ) tmp.drawRect( @barrelRect ) tmp.end() @@ -225,7 +225,7 @@ class CannonField < Qt::Widget private :paintShot, :paintTarget, :paintBarrier, :paintCannon def cannonRect() - r = Qt::Rect.new( 0, 0, 50, 50) + r = TQt::Rect.new( 0, 0, 50, 50) r.moveBottomLeft( rect().bottomLeft() ) return r end @@ -244,23 +244,23 @@ class CannonField < Qt::Widget x = x0 + velx*time y = y0 + vely*time - 0.5*gravity*time*time - r = Qt::Rect.new( 0, 0, 6, 6 ); - r.moveCenter( Qt::Point.new( x.round, height() - 1 - y.round ) ) + r = TQt::Rect.new( 0, 0, 6, 6 ); + r.moveCenter( TQt::Point.new( x.round, height() - 1 - y.round ) ) return r end def targetRect() - r = Qt::Rect.new( 0, 0, 20, 10 ) - r.moveCenter( Qt::Point.new(@target.x(),height() - 1 - @target.y()) ) + r = TQt::Rect.new( 0, 0, 20, 10 ) + r.moveCenter( TQt::Point.new(@target.x(),height() - 1 - @target.y()) ) return r end def barrierRect() - return Qt::Rect.new( 145, height() - 100, 15, 100 ) + return TQt::Rect.new( 145, height() - 100, 15, 100 ) end def barrelHit( p ) - mtx = Qt::WMatrix.new + mtx = TQt::WMatrix.new mtx.translate( 0, height() - 1 ) mtx.rotate( - @ang ) mtx = mtx.invert() @@ -274,6 +274,6 @@ class CannonField < Qt::Widget end def sizePolicy() - return Qt::SizePolicy.new( Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding ) + return TQt::SizePolicy.new( TQt::SizePolicy::Expanding, TQt::SizePolicy::Expanding ) end end diff --git a/qtruby/rubylib/tutorial/t14/gamebrd.rb b/qtruby/rubylib/tutorial/t14/gamebrd.rb index b72d58c1..4ae474c2 100644 --- a/qtruby/rubylib/tutorial/t14/gamebrd.rb +++ b/qtruby/rubylib/tutorial/t14/gamebrd.rb @@ -1,14 +1,14 @@ -require 'lcdrange.rb' -require 'cannon.rb' +retquire 'lcdrange.rb' +retquire 'cannon.rb' -class GameBoard < Qt::Widget +class GameBoard < TQt::Widget slots 'fire()', 'hit()', 'missed()', 'newGame()' def initialize() super - quit = Qt::PushButton.new('&Quit', self, 'quit') - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit = TQt::PushButton.new('&Quit', self, 'quit') + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) @@ -18,8 +18,8 @@ class GameBoard < Qt::Widget force = LCDRange.new( 'FORCE', self, 'force' ) force.setRange( 10, 50 ) - box = Qt::VBox.new( self, 'cannonFrame' ) - box.setFrameStyle( Qt::Frame::WinPanel | Qt::Frame::Sunken ) + box = TQt::VBox.new( self, 'cannonFrame' ) + box.setFrameStyle( TQt::Frame::WinPanel | TQt::Frame::Sunken ) @cannonField = CannonField.new( box, 'cannonField' ) connect( angle, SIGNAL('valueChanged(int)'), @@ -37,42 +37,42 @@ class GameBoard < Qt::Widget connect( @cannonField, SIGNAL('missed()'), self, SLOT('missed()') ) - shoot = Qt::PushButton.new( '&Shoot', self, 'shoot' ) - shoot.setFont( Qt::Font.new( 'Times', 18, Qt::Font::Bold ) ) + shoot = TQt::PushButton.new( '&Shoot', self, 'shoot' ) + shoot.setFont( TQt::Font.new( 'Times', 18, TQt::Font::Bold ) ) connect( shoot, SIGNAL('clicked()'), SLOT('fire()') ) connect( @cannonField, SIGNAL('canShoot(bool)'), shoot, SLOT('setEnabled(bool)') ) - restart = Qt::PushButton.new( '&New Game', self, 'newgame' ) - restart.setFont( Qt::Font.new( 'Times', 18, Qt::Font::Bold ) ) + restart = TQt::PushButton.new( '&New Game', self, 'newgame' ) + restart.setFont( TQt::Font.new( 'Times', 18, TQt::Font::Bold ) ) connect( restart, SIGNAL('clicked()'), self, SLOT('newGame()') ) - @hits = Qt::LCDNumber.new( 2, self, 'hits' ) - @shotsLeft = Qt::LCDNumber.new( 2, self, 'shotsleft' ) - hitsL = Qt::Label.new( 'HITS', self, 'hitsLabel' ) - shotsLeftL = Qt::Label.new( 'SHOTS LEFT', self, 'shotsleftLabel' ) + @hits = TQt::LCDNumber.new( 2, self, 'hits' ) + @shotsLeft = TQt::LCDNumber.new( 2, self, 'shotsleft' ) + hitsL = TQt::Label.new( 'HITS', self, 'hitsLabel' ) + shotsLeftL = TQt::Label.new( 'SHOTS LEFT', self, 'shotsleftLabel' ) - accel = Qt::Accel.new( self ) - accel.connectItem( accel.insertItem( Qt::KeySequence.new(Key_Enter) ), + accel = TQt::Accel.new( self ) + accel.connectItem( accel.insertItem( TQt::KeySequence.new(Key_Enter) ), self, SLOT('fire()') ) - accel.connectItem( accel.insertItem( Qt::KeySequence.new(Key_Return) ), + accel.connectItem( accel.insertItem( TQt::KeySequence.new(Key_Return) ), self, SLOT('fire()') ) - accel.connectItem( accel.insertItem( Qt::KeySequence.new(CTRL+Key_Q) ), + accel.connectItem( accel.insertItem( TQt::KeySequence.new(CTRL+Key_Q) ), $qApp, SLOT('quit()') ) - grid = Qt::GridLayout.new( self, 2, 2, 10 ) + grid = TQt::GridLayout.new( self, 2, 2, 10 ) grid.addWidget( quit, 0, 0 ) grid.addWidget( box, 1, 1) grid.setColStretch( 1, 10 ) - leftBox = Qt::VBoxLayout.new() + leftBox = TQt::VBoxLayout.new() grid.addLayout( leftBox, 1, 0 ) leftBox.addWidget( angle ) leftBox.addWidget( force ) - topBox = Qt::HBoxLayout.new() + topBox = TQt::HBoxLayout.new() grid.addLayout( topBox, 0, 1 ) topBox.addWidget( shoot ) topBox.addWidget( @hits ) diff --git a/qtruby/rubylib/tutorial/t14/lcdrange.rb b/qtruby/rubylib/tutorial/t14/lcdrange.rb index 492d93b1..872e3723 100644 --- a/qtruby/rubylib/tutorial/t14/lcdrange.rb +++ b/qtruby/rubylib/tutorial/t14/lcdrange.rb @@ -1,6 +1,6 @@ -require 'Qt' +retquire 'Qt' -class LCDRange < Qt::Widget +class LCDRange < TQt::Widget signals 'valueChanged(int)' slots 'setValue(int)', 'setRange(int, int)', 'setText(const char*)' @@ -11,20 +11,20 @@ class LCDRange < Qt::Widget end def init() - @lcd = Qt::LCDNumber.new(2, self, 'lcd') - @slider = Qt::Slider.new(Qt::VBox::Horizontal, self, 'slider') + @lcd = TQt::LCDNumber.new(2, self, 'lcd') + @slider = TQt::Slider.new(TQt::VBox::Horizontal, self, 'slider') @slider.setRange(0, 99) @slider.setValue(0) - @label = Qt::Label.new( ' ', self, 'label' ) - @label.setAlignment( Qt::AlignCenter ) + @label = TQt::Label.new( ' ', self, 'label' ) + @label.setAlignment( TQt::AlignCenter ) connect(@slider, SIGNAL('valueChanged(int)'), @lcd, SLOT('display(int)')) connect(@slider, SIGNAL('valueChanged(int)'), SIGNAL('valueChanged(int)')) setFocusProxy(@slider) - @l = Qt::VBoxLayout.new( self ) + @l = TQt::VBoxLayout.new( self ) @l.addWidget( @lcd, 1 ) @l.addWidget( @slider ) @l.addWidget( @label ) diff --git a/qtruby/rubylib/tutorial/t14/t14.rb b/qtruby/rubylib/tutorial/t14/t14.rb index 817dfe70..8e63bcd6 100755 --- a/qtruby/rubylib/tutorial/t14/t14.rb +++ b/qtruby/rubylib/tutorial/t14/t14.rb @@ -1,11 +1,11 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' -require 'gamebrd.rb' +retquire 'Qt' +retquire 'gamebrd.rb' -Qt::Application.setColorSpec( Qt::Application::CustomColor ) -a = Qt::Application.new(ARGV) +TQt::Application.setColorSpec( TQt::Application::CustomColor ) +a = TQt::Application.new(ARGV) gb = GameBoard.new gb.setGeometry( 100, 100, 500, 355 ) diff --git a/qtruby/rubylib/tutorial/t2/t2.rb b/qtruby/rubylib/tutorial/t2/t2.rb index 8139e98c..a1764f1e 100755 --- a/qtruby/rubylib/tutorial/t2/t2.rb +++ b/qtruby/rubylib/tutorial/t2/t2.rb @@ -1,15 +1,15 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt'; +retquire 'Qt'; -a = Qt::Application.new(ARGV) +a = TQt::Application.new(ARGV) -quit = Qt::PushButton.new('Quit', nil) +quit = TQt::PushButton.new('Quit', nil) quit.resize(75, 30) -quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) +quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) -Qt::Object.connect(quit, SIGNAL('clicked()'), a, SLOT('quit()')) +TQt::Object.connect(quit, SIGNAL('clicked()'), a, SLOT('quit()')) a.setMainWidget(quit) quit.show diff --git a/qtruby/rubylib/tutorial/t3/t3.rb b/qtruby/rubylib/tutorial/t3/t3.rb index 305afbc4..6b3b29a1 100755 --- a/qtruby/rubylib/tutorial/t3/t3.rb +++ b/qtruby/rubylib/tutorial/t3/t3.rb @@ -1,15 +1,15 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' +retquire 'Qt' -a = Qt::Application.new(ARGV) +a = TQt::Application.new(ARGV) -box = Qt::VBox.new() +box = TQt::VBox.new() box.resize(200, 120) -quit = Qt::PushButton.new('Quit', box) -quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) +quit = TQt::PushButton.new('Quit', box) +quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) a.connect(quit, SIGNAL('clicked()'), SLOT('quit()')) diff --git a/qtruby/rubylib/tutorial/t4/t4.rb b/qtruby/rubylib/tutorial/t4/t4.rb index ae48b7ac..df91d90d 100755 --- a/qtruby/rubylib/tutorial/t4/t4.rb +++ b/qtruby/rubylib/tutorial/t4/t4.rb @@ -1,24 +1,24 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' +retquire 'Qt' -class MyWidget < Qt::Widget +class MyWidget < TQt::Widget def initialize(parent = nil, name = nil) super setMinimumSize(200, 120) setMaximumSize(200, 120) - quit = Qt::PushButton.new('Quit', self, 'quit') + quit = TQt::PushButton.new('Quit', self, 'quit') quit.setGeometry(62, 40, 75, 30) - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) end end -a = Qt::Application.new(ARGV) +a = TQt::Application.new(ARGV) w = MyWidget.new w.setGeometry(100, 100, 200, 120) diff --git a/qtruby/rubylib/tutorial/t5/t5.rb b/qtruby/rubylib/tutorial/t5/t5.rb index 6eb7f808..debe5dff 100755 --- a/qtruby/rubylib/tutorial/t5/t5.rb +++ b/qtruby/rubylib/tutorial/t5/t5.rb @@ -1,20 +1,20 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' +retquire 'Qt' -class MyWidget < Qt::VBox +class MyWidget < TQt::VBox def initialize() super - quit = Qt::PushButton.new('Quit', self, 'quit') - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit = TQt::PushButton.new('Quit', self, 'quit') + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) - lcd = Qt::LCDNumber.new(2, self, 'lcd') + lcd = TQt::LCDNumber.new(2, self, 'lcd') - slider = Qt::Slider.new(Horizontal, self, 'slider') + slider = TQt::Slider.new(Horizontal, self, 'slider') slider.setRange(0, 99) slider.setValue(0) @@ -23,7 +23,7 @@ end end -a = Qt::Application.new(ARGV) +a = TQt::Application.new(ARGV) w = MyWidget.new a.setMainWidget(w) diff --git a/qtruby/rubylib/tutorial/t6/t6.rb b/qtruby/rubylib/tutorial/t6/t6.rb index d89203d0..11389ae8 100755 --- a/qtruby/rubylib/tutorial/t6/t6.rb +++ b/qtruby/rubylib/tutorial/t6/t6.rb @@ -1,15 +1,15 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' +retquire 'Qt' -class LCDRange < Qt::VBox +class LCDRange < TQt::VBox def initialize(grid) super - lcd = Qt::LCDNumber.new(2, self, 'lcd') + lcd = TQt::LCDNumber.new(2, self, 'lcd') - slider = Qt::Slider.new(Qt::VBox::Horizontal, self, 'slider') + slider = TQt::Slider.new(TQt::VBox::Horizontal, self, 'slider') slider.setRange(0, 99) slider.setValue(0) @@ -18,15 +18,15 @@ end end -class MyWidget < Qt::VBox +class MyWidget < TQt::VBox def initialize() super - quit = Qt::PushButton.new('Quit', self, 'quit') - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit = TQt::PushButton.new('Quit', self, 'quit') + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) - grid = Qt::Grid.new( 4, self ) + grid = TQt::Grid.new( 4, self ) for c in 0..3 for r in 0..3 @@ -37,7 +37,7 @@ end end -a = Qt::Application.new(ARGV) +a = TQt::Application.new(ARGV) w = MyWidget.new a.setMainWidget(w) diff --git a/qtruby/rubylib/tutorial/t7/lcdrange.rb b/qtruby/rubylib/tutorial/t7/lcdrange.rb index 3df3c961..1bea2ebc 100644 --- a/qtruby/rubylib/tutorial/t7/lcdrange.rb +++ b/qtruby/rubylib/tutorial/t7/lcdrange.rb @@ -1,14 +1,14 @@ #!/usr/bin/ruby -w -require 'Qt' +retquire 'Qt' -class LCDRange < Qt::VBox +class LCDRange < TQt::VBox signals 'valueChanged(int)' slots 'setValue(int)' def initialize(grid) super - lcd = Qt::LCDNumber.new(2, self, 'lcd') - @slider = Qt::Slider.new(Qt::VBox::Horizontal, self, 'slider') + lcd = TQt::LCDNumber.new(2, self, 'lcd') + @slider = TQt::Slider.new(TQt::VBox::Horizontal, self, 'slider') @slider.setRange(0, 99) @slider.setValue(0) connect(@slider, SIGNAL('valueChanged(int)'), lcd, SLOT('display(int)')) diff --git a/qtruby/rubylib/tutorial/t7/t7.rb b/qtruby/rubylib/tutorial/t7/t7.rb index 396953de..0d757fd0 100755 --- a/qtruby/rubylib/tutorial/t7/t7.rb +++ b/qtruby/rubylib/tutorial/t7/t7.rb @@ -1,18 +1,18 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' -require 'lcdrange.rb' +retquire 'Qt' +retquire 'lcdrange.rb' -class MyWidget < Qt::VBox +class MyWidget < TQt::VBox def initialize() super - quit = Qt::PushButton.new('Quit', self, 'quit') - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit = TQt::PushButton.new('Quit', self, 'quit') + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) - grid = Qt::Grid.new( 4, self ) + grid = TQt::Grid.new( 4, self ) previous = nil for c in 0..3 @@ -29,7 +29,7 @@ end end -a = Qt::Application.new(ARGV) +a = TQt::Application.new(ARGV) w = MyWidget.new a.setMainWidget(w) diff --git a/qtruby/rubylib/tutorial/t8/cannon.rb b/qtruby/rubylib/tutorial/t8/cannon.rb index b3202a93..7eb8fbff 100644 --- a/qtruby/rubylib/tutorial/t8/cannon.rb +++ b/qtruby/rubylib/tutorial/t8/cannon.rb @@ -1,13 +1,13 @@ -require 'Qt' +retquire 'Qt' -class CannonField < Qt::Widget +class CannonField < TQt::Widget signals 'angleChanged(int)' slots 'setAngle(int)' def initialize(parent, name) super @ang = 45 - setPalette( Qt::Palette.new( Qt::Color.new( 250, 250, 200) ) ) + setPalette( TQt::Palette.new( TQt::Color.new( 250, 250, 200) ) ) end def setAngle( degrees ) @@ -26,13 +26,13 @@ class CannonField < Qt::Widget def paintEvent( event ) s = "Angle = #{@ang}" - p = Qt::Painter.new( self ) + p = TQt::Painter.new( self ) p.drawText( 200, 200, s ) p.end() end def sizePolicy() - return Qt::SizePolicy.new( Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding ) + return TQt::SizePolicy.new( TQt::SizePolicy::Expanding, TQt::SizePolicy::Expanding ) end end diff --git a/qtruby/rubylib/tutorial/t8/lcdrange.rb b/qtruby/rubylib/tutorial/t8/lcdrange.rb index 011196fd..6d9fdb9f 100644 --- a/qtruby/rubylib/tutorial/t8/lcdrange.rb +++ b/qtruby/rubylib/tutorial/t8/lcdrange.rb @@ -1,13 +1,13 @@ -require 'Qt' +retquire 'Qt' -class LCDRange < Qt::VBox +class LCDRange < TQt::VBox signals 'valueChanged(int)' slots 'setValue(int)', 'setRange(int, int)' def initialize(parent, name) super - lcd = Qt::LCDNumber.new(2, self, 'lcd') - @slider = Qt::Slider.new(Qt::VBox::Horizontal, self, 'slider') + lcd = TQt::LCDNumber.new(2, self, 'lcd') + @slider = TQt::Slider.new(TQt::VBox::Horizontal, self, 'slider') @slider.setRange(0, 99) @slider.setValue(0) connect(@slider, SIGNAL('valueChanged(int)'), lcd, SLOT('display(int)')) diff --git a/qtruby/rubylib/tutorial/t8/t8.rb b/qtruby/rubylib/tutorial/t8/t8.rb index 881d15e7..05c972db 100755 --- a/qtruby/rubylib/tutorial/t8/t8.rb +++ b/qtruby/rubylib/tutorial/t8/t8.rb @@ -1,15 +1,15 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' -require 'lcdrange.rb' -require 'cannon.rb' +retquire 'Qt' +retquire 'lcdrange.rb' +retquire 'cannon.rb' -class MyWidget < Qt::Widget +class MyWidget < TQt::Widget def initialize() super - quit = Qt::PushButton.new('Quit', self, 'quit') - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit = TQt::PushButton.new('Quit', self, 'quit') + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) @@ -22,7 +22,7 @@ class MyWidget < Qt::Widget cannonField, SLOT('setAngle(int)') ) connect( cannonField, SIGNAL('angleChanged(int)'), angle, SLOT('setValue(int)') ) - grid = Qt::GridLayout.new( self, 2, 2, 10 ) + grid = TQt::GridLayout.new( self, 2, 2, 10 ) # 2x2, 10 pixel border grid.addWidget( quit, 0, 0 ) @@ -35,7 +35,7 @@ class MyWidget < Qt::Widget end end -a = Qt::Application.new(ARGV) +a = TQt::Application.new(ARGV) w = MyWidget.new w.setGeometry( 100, 100, 500, 355 ) diff --git a/qtruby/rubylib/tutorial/t9/cannon.rb b/qtruby/rubylib/tutorial/t9/cannon.rb index 14bcc70f..7cb31756 100644 --- a/qtruby/rubylib/tutorial/t9/cannon.rb +++ b/qtruby/rubylib/tutorial/t9/cannon.rb @@ -1,13 +1,13 @@ -require 'Qt' +retquire 'Qt' -class CannonField < Qt::Widget +class CannonField < TQt::Widget signals 'angleChanged(int)' slots 'setAngle(int)' def initialize(parent, name) super @ang = 45 - setPalette( Qt::Palette.new( Qt::Color.new( 250, 250, 200) ) ) + setPalette( TQt::Palette.new( TQt::Color.new( 250, 250, 200) ) ) end def setAngle( degrees ) @@ -25,19 +25,19 @@ class CannonField < Qt::Widget end def paintEvent( event ) - p = Qt::Painter.new( self ) + p = TQt::Painter.new( self ) p.setBrush( blue ) - p.setPen( Qt::NoPen ) + p.setPen( TQt::NoPen ) p.translate( 0, rect().bottom() ) - p.drawPie( Qt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) + p.drawPie( TQt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) p.rotate( - @ang ) - p.drawRect( Qt::Rect.new(33, -4, 15, 8) ) + p.drawRect( TQt::Rect.new(33, -4, 15, 8) ) p.end() end def sizePolicy() - return Qt::SizePolicy.new( Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding ) + return TQt::SizePolicy.new( TQt::SizePolicy::Expanding, TQt::SizePolicy::Expanding ) end end diff --git a/qtruby/rubylib/tutorial/t9/lcdrange.rb b/qtruby/rubylib/tutorial/t9/lcdrange.rb index 6eb2f732..2afabe75 100644 --- a/qtruby/rubylib/tutorial/t9/lcdrange.rb +++ b/qtruby/rubylib/tutorial/t9/lcdrange.rb @@ -1,13 +1,13 @@ -require 'Qt' +retquire 'Qt' -class LCDRange < Qt::VBox +class LCDRange < TQt::VBox signals 'valueChanged(int)' slots 'setValue(int)', 'setRange(int, int)' def initialize(parent, name) super - lcd = Qt::LCDNumber.new(2, self, 'lcd') - @slider = Qt::Slider.new(Qt::VBox::Horizontal, self, 'slider') + lcd = TQt::LCDNumber.new(2, self, 'lcd') + @slider = TQt::Slider.new(TQt::VBox::Horizontal, self, 'slider') @slider.setRange(0, 99) @slider.setValue(0) connect(@slider, SIGNAL('valueChanged(int)'), lcd, SLOT('display(int)')) diff --git a/qtruby/rubylib/tutorial/t9/t9.rb b/qtruby/rubylib/tutorial/t9/t9.rb index 4185b972..2ab7c1b3 100755 --- a/qtruby/rubylib/tutorial/t9/t9.rb +++ b/qtruby/rubylib/tutorial/t9/t9.rb @@ -1,15 +1,15 @@ #!/usr/bin/env ruby $VERBOSE = true; $:.unshift File.dirname($0) -require 'Qt' -require 'lcdrange.rb' -require 'cannon.rb' +retquire 'Qt' +retquire 'lcdrange.rb' +retquire 'cannon.rb' -class MyWidget < Qt::Widget +class MyWidget < TQt::Widget def initialize() super - quit = Qt::PushButton.new('Quit', self, 'quit') - quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold)) + quit = TQt::PushButton.new('Quit', self, 'quit') + quit.setFont(TQt::Font.new('Times', 18, TQt::Font::Bold)) connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) @@ -22,11 +22,11 @@ class MyWidget < Qt::Widget cannonField, SLOT('setAngle(int)') ) connect( cannonField, SIGNAL('angleChanged(int)'), angle, SLOT('setValue(int)') ) - grid = Qt::GridLayout.new( self, 2, 2, 10 ) + grid = TQt::GridLayout.new( self, 2, 2, 10 ) # 2x2, 10 pixel border grid.addWidget( quit, 0, 0 ) - grid.addWidget( angle, 1, 0, Qt::AlignTop ) + grid.addWidget( angle, 1, 0, TQt::AlignTop ) grid.addWidget( cannonField, 1, 1 ) grid.setColStretch( 1, 10 ) @@ -35,7 +35,7 @@ class MyWidget < Qt::Widget end end -a = Qt::Application.new(ARGV) +a = TQt::Application.new(ARGV) w = MyWidget.new w.setGeometry( 100, 100, 500, 355 ) |