diff options
Diffstat (limited to 'qtruby/rubylib/examples/qtscribble/scribble.rb')
-rw-r--r-- | qtruby/rubylib/examples/qtscribble/scribble.rb | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/qtruby/rubylib/examples/qtscribble/scribble.rb b/qtruby/rubylib/examples/qtscribble/scribble.rb index 7c6e1ca5..2d931088 100644 --- a/qtruby/rubylib/examples/qtscribble/scribble.rb +++ b/qtruby/rubylib/examples/qtscribble/scribble.rb @@ -5,11 +5,11 @@ # window knows how to redraw itself. # -require 'Qt' +retquire 'Qt' - class ScribbleArea < Qt::Widget + class ScribbleArea < TQt::Widget - slots "setColor(QColor)", "slotLoad(const QString&)", "slotSave(const QString&)", "slotClearArea()" + slots "setColor(TQColor)", "slotLoad(const TQString&)", "slotSave(const TQString&)", "slotClearArea()" # # The constructor. Initializes the member variables. @@ -17,21 +17,21 @@ require 'Qt' def initialize() super # initialize member variables - @_buffer = Qt::Pixmap.new() - @_last = Qt::Point.new() + @_buffer = TQt::Pixmap.new() + @_last = TQt::Point.new() @_currentcolor = black # don't blank the window before repainting setBackgroundMode( NoBackground ) # create a pop-up menu - @_popupmenu = Qt::PopupMenu.new() + @_popupmenu = TQt::PopupMenu.new() @_popupmenu.insertItem( "&Clear", self, SLOT( "slotClearArea()" ) ) end # # This slot sets the curren color for the scribble area. It will be - # connected with the colorChanged( Qt::Color ) signal from the + # connected with the colorChanged( TQt::Color ) signal from the # ScribbleWindow. # def setColor( new_color ) @@ -52,12 +52,12 @@ require 'Qt' # - # This method does the actual loading. It relies on Qt::Pixmap (and the + # This method does the actual loading. It relies on TQt::Pixmap (and the # underlying I/O machinery) to determine the filetype. # def slotLoad( filename ) if !@_buffer.load( filename ) - Qt::MessageBox.warning( nil, "Load error", "Could not load file" ) + TQt::MessageBox.warning( nil, "Load error", "Could not load file" ) end repaint() # refresh the window @@ -70,7 +70,7 @@ require 'Qt' # def slotSave( filename ) if !@_buffer.save( filename, "BMP" ) - Qt::MessageBox.warning( nil, "Save error", "Could not save file" ) + TQt::MessageBox.warning( nil, "Save error", "Could not save file" ) end end @@ -82,7 +82,7 @@ require 'Qt' # def mousePressEvent(event) if event.button() == RightButton - @_popupmenu.exec( Qt::Cursor.pos() ) + @_popupmenu.exec( TQt::Cursor.pos() ) else @_last = event.pos() # retrieve the coordinates from the event end @@ -98,10 +98,10 @@ require 'Qt' # pressed. # def mouseMoveEvent(event) - # create a Qt::Painter object for drawing onto the window - windowpainter = Qt::Painter.new() - # and another Qt::Painter object for drawing int an off-screen pixmap - bufferpainter = Qt::Painter.new() + # create a TQt::Painter object for drawing onto the window + windowpainter = TQt::Painter.new() + # and another TQt::Painter object for drawing int an off-screen pixmap + bufferpainter = TQt::Painter.new() # start painting windowpainter.begin( self ) # This painter paints onto the window @@ -136,17 +136,17 @@ require 'Qt' # painting, for example, when it has been obscured and then revealed again. # def resizeEvent(event) - save = Qt::Pixmap.new( @_buffer ) + save = TQt::Pixmap.new( @_buffer ) @_buffer.resize( event.size() ) @_buffer.fill( white ) bitBlt( @_buffer, 0, 0, save ) end end -class ScribbleWindow < Qt::Widget +class ScribbleWindow < TQt::Widget slots "slotAbout()", "slotAboutQt()", "slotColorMenu(int)", "slotLoad()", "slotSave()" - signals "colorChanged(QColor)", "load(const QString&)", "save(const QString&)" + signals "colorChanged(TQColor)", "load(const TQString&)", "save(const TQString&)" COLOR_MENU_ID_BLACK = 0 COLOR_MENU_ID_RED = 1 @@ -158,44 +158,44 @@ class ScribbleWindow < Qt::Widget super # The next lines build the menu bar. We first create the menus # one by one, then add them to the menu bar. # - @_filemenu = Qt::PopupMenu.new() # create a file menu + @_filemenu = TQt::PopupMenu.new() # create a file menu @_filemenu.insertItem( "&Load", self, SLOT( "slotLoad()" ) ) @_filemenu.insertItem( "&Save", self, SLOT( "slotSave()" ) ) @_filemenu.insertSeparator() @_filemenu.insertItem( "&Quit", $qApp, SLOT( "quit()" ) ) - @_colormenu = Qt::PopupMenu.new() # create a color menu + @_colormenu = TQt::PopupMenu.new() # create a color menu @_colormenu.insertItem( "B&lack", COLOR_MENU_ID_BLACK) @_colormenu.insertItem( "&Red", COLOR_MENU_ID_RED) @_colormenu.insertItem( "&Blue", COLOR_MENU_ID_BLUE) @_colormenu.insertItem( "&Green", COLOR_MENU_ID_GREEN) @_colormenu.insertItem( "&Yellow", COLOR_MENU_ID_YELLOW) - Qt::Object.connect( @_colormenu, SIGNAL( "activated( int )" ), + TQt::Object.connect( @_colormenu, SIGNAL( "activated( int )" ), self, SLOT( "slotColorMenu( int )" ) ) - @_helpmenu = Qt::PopupMenu.new() # create a help menu + @_helpmenu = TQt::PopupMenu.new() # create a help menu @_helpmenu.insertItem( "&About QtScribble", self, SLOT( "slotAbout()" ) ) @_helpmenu.insertItem( "&About Qt", self, SLOT( "slotAboutQt()" ) ) - @_menubar = Qt::MenuBar.new( self, "" ) # create a menu bar + @_menubar = TQt::MenuBar.new( self, "" ) # create a menu bar @_menubar.insertItem( "&File", @_filemenu ) @_menubar.insertItem( "&Color", @_colormenu ) @_menubar.insertItem( "&Help", @_helpmenu ) - # We create a Qt::ScrollView and a ScribbleArea. The ScribbleArea will + # We create a TQt::ScrollView and a ScribbleArea. The ScribbleArea will # be managed by the scroll view.# - @_scrollview = Qt::ScrollView.new( self ) + @_scrollview = TQt::ScrollView.new( self ) @_scrollview.setGeometry( 0, @_menubar.height(), width(), height() - @_menubar.height() ) @_scribblearea = ScribbleArea.new() @_scribblearea.setGeometry( 0, 0, 1000, 1000 ) @_scrollview.addChild( @_scribblearea ) - Qt::Object.connect( self, SIGNAL( "colorChanged(QColor)" ), - @_scribblearea, SLOT( "setColor(QColor)" ) ) - Qt::Object.connect( self, SIGNAL( "save(const QString&)" ), - @_scribblearea, SLOT( "slotSave(const QString&)" ) ) - Qt::Object.connect( self, SIGNAL( "load(const QString&)" ), - @_scribblearea, SLOT( "slotLoad(const QString&)" ) ) + TQt::Object.connect( self, SIGNAL( "colorChanged(TQColor)" ), + @_scribblearea, SLOT( "setColor(TQColor)" ) ) + TQt::Object.connect( self, SIGNAL( "save(const TQString&)" ), + @_scribblearea, SLOT( "slotSave(const TQString&)" ) ) + TQt::Object.connect( self, SIGNAL( "load(const TQString&)" ), + @_scribblearea, SLOT( "slotLoad(const TQString&)" ) ) end def resizeEvent( event ) @@ -209,13 +209,13 @@ class ScribbleWindow < Qt::Widget def slotAbout() - Qt::MessageBox.information( self, "About QtScribble 5", + TQt::MessageBox.information( self, "About QtScribble 5", "This is the Scribble 5 application\n" + "Copyright 1998 by Mathias Kalle Dalheimer\n") end def slotAboutQt() - Qt::MessageBox.aboutQt( self, "About Qt" ) + TQt::MessageBox.aboutQt( self, "About Qt" ) end def slotColorMenu( item ) @@ -236,14 +236,14 @@ class ScribbleWindow < Qt::Widget # # This is the slot for the menu item File/Load. It opens a - # Qt::FileDialog to ask the user for a filename, then emits a save() + # TQt::FileDialog to ask the user for a filename, then emits a save() # signal with the filename as parameter. # def slotLoad() # Open a file dialog for loading. The default directory is the # current directory, the filter *.bmp. # - filename = Qt::FileDialog.getOpenFileName( ".", "*.bmp", self ) + filename = TQt::FileDialog.getOpenFileName( ".", "*.bmp", self ) if !filename.nil? emit load( filename ) end @@ -251,21 +251,21 @@ class ScribbleWindow < Qt::Widget # # This is the slot for the menu item File/Load. It opens a - # Qt::FileDialog to ask the user for a filename, then emits a save() + # TQt::FileDialog to ask the user for a filename, then emits a save() # signal with the filename as parameter. # def slotSave() # Open a file dialog for saving. The default directory is the # current directory, the filter *.bmp. # - filename = Qt::FileDialog.getSaveFileName( ".", "*.bmp", self ) + filename = TQt::FileDialog.getSaveFileName( ".", "*.bmp", self ) if !filename.nil? emit save( filename ) end end end -myapp = Qt::Application.new(ARGV) +myapp = TQt::Application.new(ARGV) mywidget = ScribbleWindow.new() mywidget.setGeometry(50, 500, 400, 400) |