diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-12-05 15:55:57 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-12-05 15:55:57 -0600 |
commit | 9ba04742771370f59740e32e11c5f3a1e6a1b70a (patch) | |
tree | c81c34dae2b3b1ea73801bf18a960265dc4207f7 /qtruby/rubylib/examples/qt-examples/tictac/tictac.rb | |
parent | 1a96c45b22d01378202d9dc7ed9c47acd30f966e (diff) | |
download | tdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.tar.gz tdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.zip |
Initial TQt conversion
Diffstat (limited to 'qtruby/rubylib/examples/qt-examples/tictac/tictac.rb')
-rw-r--r-- | qtruby/rubylib/examples/qt-examples/tictac/tictac.rb | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/qtruby/rubylib/examples/qt-examples/tictac/tictac.rb b/qtruby/rubylib/examples/qt-examples/tictac/tictac.rb index 04ab8b9d..354e22ef 100644 --- a/qtruby/rubylib/examples/qt-examples/tictac/tictac.rb +++ b/qtruby/rubylib/examples/qt-examples/tictac/tictac.rb @@ -1,6 +1,6 @@ -require 'Qt' +retquire 'Qt' -class TicTacButton < Qt::PushButton +class TicTacButton < TQt::PushButton attr_accessor :btype @@ -13,18 +13,18 @@ class TicTacButton < Qt::PushButton def drawButtonLabel(p) r = rect() - p.setPen( Qt::Pen.new( Qt::white,2 ) ) # set fat pen + p.setPen( TQt::Pen.new( TQt::white,2 ) ) # set fat pen if (@btype == Circle) p.drawEllipse( r.left()+4, r.top()+4, r.width()-8, r.height()-8 ) elsif (@btype == Cross) # draw cross - p.drawLine( r.topLeft() +Qt::Point.new(4,4), r.bottomRight()-Qt::Point.new(4,4)) - p.drawLine( r.bottomLeft()+Qt::Point.new(4,-4),r.topRight() -Qt::Point.new(4,-4)) + p.drawLine( r.topLeft() +TQt::Point.new(4,4), r.bottomRight()-TQt::Point.new(4,4)) + p.drawLine( r.bottomLeft()+TQt::Point.new(4,-4),r.topRight() -TQt::Point.new(4,-4)) end super(p) end end -class TicTacGameBoard < Qt::Widget +class TicTacGameBoard < TQt::Widget signals 'finished()' slots 'buttonClicked()' @@ -41,8 +41,8 @@ class TicTacGameBoard < Qt::Widget @buttons = Array.new(n) @btArray = Array.new(n) - grid = Qt::GridLayout.new(self, n, n, 4) - p = Qt::Palette.new(Qt::blue) + grid = TQt::GridLayout.new(self, n, n, 4) + p = TQt::Palette.new(TQt::blue) for i in (0..n-1) ttb = TicTacButton.new(self) @@ -238,13 +238,13 @@ class TicTacGameBoard < Qt::Widget end -class TicTacToe < Qt::Widget +class TicTacToe < TQt::Widget slots 'newGameClicked()', 'gameOver()' def initialize (boardSize) super() - l = Qt::VBoxLayout.new(self, 6) + l = TQt::VBoxLayout.new(self, 6) @state_msg = [ 'Click Play to start', @@ -254,9 +254,9 @@ class TicTacToe < Qt::Widget 'It\'s a draw'] # Create a message label - @message = Qt::Label.new(self) - @message.setFrameStyle((Qt::Frame.WinPanel|Qt::Frame.Sunken)) - @message.setAlignment(Qt::AlignCenter) + @message = TQt::Label.new(self) + @message.setFrameStyle((TQt::Frame.WinPanel|TQt::Frame.Sunken)) + @message.setAlignment(TQt::AlignCenter) l.addWidget(@message) # Create the game board and connect the signal finished() @@ -266,23 +266,23 @@ class TicTacToe < Qt::Widget l.addWidget(@board) # Create a horizontal frame line - line = Qt::Frame.new(self) - line.setFrameStyle(Qt::Frame.HLine|Qt::Frame.Sunken) + line = TQt::Frame.new(self) + line.setFrameStyle(TQt::Frame.HLine|TQt::Frame.Sunken) l.addWidget(line) # Create the combo box for deciding who should start # and connect its clicked() signals to the buttonClicked() slot - @whoStarts = Qt::ComboBox.new(self) + @whoStarts = TQt::ComboBox.new(self) @whoStarts.insertItem('Computer starts') @whoStarts.insertItem('Human starts') l.addWidget(@whoStarts); # Create the push buttons and connect their signals to the right slots - @newGame = Qt::PushButton.new('Play!', self) + @newGame = TQt::PushButton.new('Play!', self) connect(@newGame, SIGNAL('clicked()'), self, SLOT('newGameClicked()')) - @quit = Qt::PushButton.new('Quit', self) + @quit = TQt::PushButton.new('Quit', self) connect(@quit, SIGNAL('clicked()'), $qApp, SLOT('quit()')) - b = Qt::HBoxLayout.new + b = TQt::HBoxLayout.new l.addLayout(b) b.addWidget(@newGame) b.addWidget(@quit) |