camino-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Camino-devel] camino/src/client TilePresentation.h TilePresen...


From: Pascal Audoux
Subject: [Camino-devel] camino/src/client TilePresentation.h TilePresen...
Date: Mon, 03 Mar 2003 15:17:29 -0500

CVSROOT:        /cvsroot/camino
Module name:    camino
Changes by:     Pascal Audoux <address@hidden>  03/03/03 15:17:28

Modified files:
        src/client     : TilePresentation.h TilePresentation.cpp 

Log message:
        implement rotation of the tile

Patches:
Index: camino/src/client/TilePresentation.cpp
diff -u camino/src/client/TilePresentation.cpp:1.10 
camino/src/client/TilePresentation.cpp:1.11
--- camino/src/client/TilePresentation.cpp:1.10 Sun Mar  2 12:07:18 2003
+++ camino/src/client/TilePresentation.cpp      Mon Mar  3 15:17:28 2003
@@ -2,7 +2,7 @@
 **
 ** Camino
 **
-** Version : $Id: TilePresentation.cpp,v 1.10 2003/03/02 17:07:18 pfremy Exp $
+** Version : $Id: TilePresentation.cpp,v 1.11 2003/03/03 20:17:28 Audoux Exp $
 **
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 28/01/2003
@@ -62,11 +62,10 @@
        vbox->setSpacing( 10 );
        new QLabel( "Selected tile :", vbox );
        _rotateButton = new QPushButton( "rotate", vbox );
-       _selectedTileButton = new TileButton( hbox );
-       _selectedTileButton->setFlat( true );
-       _selectedTileButton->setAlwaysShow( true );
+       _selectedTileLabel = new RotateLabel( hbox );
 
        connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_selectTile( int ) 
) );
+       connect( _rotateButton, SIGNAL( clicked() ), _selectedTileLabel, SLOT( 
slot_rotate() ) );
 }
 
 void TilePresentation::reupdate()
@@ -79,7 +78,11 @@
 
 void TilePresentation::slot_selectTile( int num )
 {
-       _selectedTileButton->setTile( _buttonList.at(num)->getTile() );
+       Tile * tile = _buttonList.at(num)->getTile();
+       if( tile ) {
+               tile->setRotation( 0 );
+       }
+       _selectedTileLabel->setTile( tile );
        _selectedIndex = num;
 }
 
@@ -104,8 +107,8 @@
        for( ; it.current(); ++it ) {
                if (it.current()->getTile() == tile ) {
                        it.current()->setTile( 0L );
-                       if (_selectedTileButton->getTile() == tile) {
-                               _selectedTileButton->setTile( 0L );
+                       if( _selectedTileLabel->getTile() == tile ) {
+                               _selectedTileLabel->setTile( 0L );
                        }
                        return;
                }
@@ -115,19 +118,20 @@
 
 void TilePresentation::removeSelectedTile()
 {
-       removeTile( _selectedTileButton->getTile() );
-       _selectedTileButton->setTile( 0L );
+       removeTile( _selectedTileLabel->getTile() );
+       _selectedTileLabel->setTile( 0L );
 }
 
 Tile * TilePresentation::getSelected()
 {
-       return _selectedTileButton->getTile(); 
+       return _selectedTileLabel->getTile(); 
 }
 
 void TilePresentation::setSelected( Tile * tile )
 {
-       _selectedTileButton->setTile( tile );
+       _selectedTileLabel->setTile( tile );
 }
+
 //
 // ----- TileButton -----
 //
@@ -146,11 +150,9 @@
        _tile = tile;
 
        if (tile != 0L) {
-               //int size = theme.getZoomSize();
-       //      setPixmap( theme.getTilePixmap( (int)type, 0 ) );
-               setPixmap( Theme::getTheme()->pixmapForTile( tile->getType() ) 
);
+               setPixmap( Theme::getTheme()->getTilePixmap( tile->getType(), 0 
) );
        } else {
-               setPixmap( Theme::getTheme()->pixmapForTile( Tile::TILE_UNKNOWN 
) );
+               setPixmap( Theme::getTheme()->getTilePixmap( 
Tile::TILE_UNKNOWN, 0 ) );
        }
        setFixedSize( pixmap()->width() + 2, pixmap()->height() + 2 );
        if ( _alwaysShow == true) {
@@ -173,4 +175,40 @@
 {
        _alwaysShow = as;
        setTile( _tile );
+}
+
+//
+// ----- RotateLabel -----
+//
+
+RotateLabel::RotateLabel( QWidget * parent, const char * name )
+: QLabel( parent, name )
+{
+       setTile( 0L );
+       reinit();
+}
+
+void RotateLabel::setTile( Tile * tile )
+{
+       _tile = tile;
+
+       if (tile != 0L) {
+               setPixmap( Theme::getTheme()->getTilePixmap( tile->getType(), 
tile->getRotation() ) );
+       } else {
+               setPixmap( Theme::getTheme()->getTilePixmap( 
Tile::TILE_UNKNOWN, 0 ) );
+       }
+       setFixedSize( pixmap()->width() + 2, pixmap()->height() + 2 );
+}
+
+void RotateLabel::reinit()
+{
+       setTile( _tile );
+}
+
+void RotateLabel::slot_rotate()
+{
+       if( _tile ) {
+               _tile->rotate();
+               reinit();
+       }
 }
Index: camino/src/client/TilePresentation.h
diff -u camino/src/client/TilePresentation.h:1.9 
camino/src/client/TilePresentation.h:1.10
--- camino/src/client/TilePresentation.h:1.9    Sun Mar  2 12:07:18 2003
+++ camino/src/client/TilePresentation.h        Mon Mar  3 15:17:28 2003
@@ -5,7 +5,7 @@
 ** TilePresentation.h
 ** Displays tiles of the player
 **
-** Version : $Id: TilePresentation.h,v 1.9 2003/03/02 17:07:18 pfremy Exp $
+** Version : $Id: TilePresentation.h,v 1.10 2003/03/03 20:17:28 Audoux Exp $
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 28/01/2003
 ** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -30,15 +30,17 @@
 
 // generic include files
 // include files for QT
+#include <qlabel.h>
+#include <qptrlist.h>
 #include <qpushbutton.h>
-#include <qwidget.h>
 #include <qvbox.h>
-#include <qptrlist.h>
+#include <qwidget.h>
 // application specific include files
 #include "common/Tile.h"
 
 
 class TileButton;
+class RotateLabel;
 
 /*              ------------------------------
  *                      TilePresentation
@@ -68,7 +70,7 @@
 
 protected:
        QPtrList< TileButton > _buttonList;
-       TileButton * _selectedTileButton;
+       RotateLabel * _selectedTileLabel;
        QPushButton * _rotateButton;
        int _selectedIndex;
 };
@@ -85,7 +87,28 @@
        void reinit();
 
 protected:
-       bool _alwaysShow;       
+       bool _alwaysShow;
+       Tile* _tile;
+
+friend class TilePresentation;
+};
+
+class RotateLabel : public QLabel
+{
+       Q_OBJECT
+public:
+       RotateLabel( QWidget * parent = 0, const char * name = 0 );
+
+       void setTile( Tile * tile );
+
+       Tile * getTile() { return _tile; }
+
+       void reinit();
+
+public slots:
+       void slot_rotate();
+
+protected:
        Tile* _tile;
 
 friend class TilePresentation;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]