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: Philippe Fremy
Subject: [Camino-devel] camino/src/client TilePresentation.h TilePresen...
Date: Thu, 27 Feb 2003 05:22:44 -0500

CVSROOT:        /cvsroot/camino
Module name:    camino
Changes by:     Philippe Fremy <address@hidden> 03/02/27 05:22:38

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

Log message:
        change tile selection method

Patches:
Index: camino/src/client/TilePresentation.cpp
diff -u camino/src/client/TilePresentation.cpp:1.4 
camino/src/client/TilePresentation.cpp:1.5
--- camino/src/client/TilePresentation.cpp:1.4  Tue Feb 18 18:16:06 2003
+++ camino/src/client/TilePresentation.cpp      Thu Feb 27 05:22:34 2003
@@ -2,7 +2,7 @@
 **
 ** Camino
 **
-** Version : $Id: TilePresentation.cpp,v 1.4 2003/02/18 23:16:06 pfremy Exp $
+** Version : $Id: TilePresentation.cpp,v 1.5 2003/02/27 10:22:34 pfremy Exp $
 **
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 28/01/2003
@@ -25,72 +25,70 @@
 
 // generic include files
 // include files for QT
-#include <qlayout.h>
+#include <qgrid.h>
+#include <qhbox.h>
+#include <qlabel.h>
 #include <qsignalmapper.h>
 // application specific include files
+#include "common/const.h"
 #include "client/Theme.h"
 #include "TilePresentation.h"
 
-extern Theme theme;
-
 TilePresentation::TilePresentation( QWidget * parent, const char * name )
-       : QWidget( parent, name )
+       : QVBox( parent, name )
 {
-       _toggled = -1;
+       _selected = -1;
        QSignalMapper * sigmap = new QSignalMapper( this );
 
-       QVBoxLayout * layout = new QVBoxLayout( this );
-       layout->addStretch( 1 );
+       setSpacing( 10 );
+
+       QGrid * grid = new QGrid( 1, Horizontal, this );
+       grid->setSpacing( 10 );
+
+       TileButton * button = 0L;
        for( int i = 0; i < 6; i++ ) {
-               _buttons[i] = new TileButton( this );
-               layout->addWidget( _buttons[i] );
-               layout->addStretch( 1 );
-               sigmap->setMapping( _buttons[i], i );
-               connect( _buttons[i], SIGNAL( clicked() ), sigmap, SLOT( map() 
) );
+               button = new TileButton( grid );
+               _buttonList.append( button );
+               sigmap->setMapping( button , i );
+               connect( button, SIGNAL( clicked() ), sigmap, SLOT( map() ) );
        }
-       layout->activate();
 
-       connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_toggle( int ) ) );
+       QWidget * w = new QWidget( this );
+       setStretchFactor( w, 10 );
+
+       QHBox * box = new QHBox( this );
+       new QLabel( "Selected tile :", box );
+       _selectedTile = new TileButton( box );
+
+       connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_selectTile( int ) 
) );
 }
 
 void TilePresentation::reupdate()
 {
-       for( int i = 0; i < 6; i++ ) {
-               _buttons[i]->reinit();
+       QPtrListIterator<TileButton> it( _buttonList );
+       for( ; it.current(); ++it) {
+               it.current()->reinit();
        }
 }
 
-void TilePresentation::slot_toggle( int num )
+void TilePresentation::slot_selectTile( int num )
 {
-       // untoggle previous toggled button
-       if( _toggled != -1 ) {
-               if( num != _toggled ) {
-                       _buttons[_toggled]->toggle();
-               }
-       }
-
-       if( num == _toggled ) {
-               _toggled = -1;
-       } else {
-               _toggled = num;
-       }
-
-       emit sig_tile( _toggled );
+       _selectedTile->setTile( _buttonList.at(num)->getTileType() );
+       _selected = num;
 }
 
-void TilePresentation::slot_recvTile( Tile::TileType tile )
+void TilePresentation::addTile( Tile::TileType tile )
 {
-       // XXX should not hardcode button number
-       for( int i=0; i<6; i++) {
-               if (_buttons[i]->_type == Tile::TILE_UNKNOWN) {
-                       _buttons[i]->setTile( tile );
-                       qDebug("TilePresentation::slot_recvTile() - update 
button %d", i );
+       QPtrListIterator<TileButton> it( _buttonList );
+       for( ; it.current(); ++it ) {
+               if (it.current()->_type == Tile::TILE_UNKNOWN) {
+                       it.current()->setTile( tile );
                        return;
                }
        }
        qDebug("TilePresentation::slot_recvTile() - Received a tile but all 
buttons are filled!");
        qDebug("TilePresentation::slot_recvTile() - I discard the first one 
then");
-       _buttons[0]->setTile( tile );
+       _buttonList.first()->setTile( tile );
 }
 
 //
@@ -101,17 +99,17 @@
 : QPushButton( parent, name )
 {
        _type = Tile::TILE_UNKNOWN;
-       setFlat( true );
-       setToggleButton( true );
+//     setFlat( true );
        reinit();
 }
 
 void TileButton::setTile( Tile::TileType type )
 {
        _type = type;
-       int size = theme.getZoomSize();
-       setFixedSize( size+2, size+2 );
-       setPixmap( theme.getTilePixmap( (int)type, 0 ) );
+       //int size = theme.getZoomSize();
+//     setPixmap( theme.getTilePixmap( (int)type, 0 ) );
+       setPixmap( Theme::getTheme()->pixmapForTile( type ) );
+       setFixedSize( pixmap()->width() + 2, pixmap()->height() + 2 );
 }
 
 void TileButton::reinit()
Index: camino/src/client/TilePresentation.h
diff -u camino/src/client/TilePresentation.h:1.4 
camino/src/client/TilePresentation.h:1.5
--- camino/src/client/TilePresentation.h:1.4    Tue Feb 18 18:16:06 2003
+++ camino/src/client/TilePresentation.h        Thu Feb 27 05:22:34 2003
@@ -5,7 +5,7 @@
 ** TilePresentation.h
 ** Displays tiles of the player
 **
-** Version : $Id: TilePresentation.h,v 1.4 2003/02/18 23:16:06 pfremy Exp $
+** Version : $Id: TilePresentation.h,v 1.5 2003/02/27 10:22:34 pfremy Exp $
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 28/01/2003
 ** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -32,6 +32,8 @@
 // include files for QT
 #include <qpushbutton.h>
 #include <qwidget.h>
+#include <qvbox.h>
+#include <qptrlist.h>
 // application specific include files
 #include "common/Tile.h"
 
@@ -45,25 +47,25 @@
 
 
 /** comment for the class */
-class TilePresentation : public QWidget
+class TilePresentation : public QVBox
 {
        Q_OBJECT
 public:
        /** Constructor */
        TilePresentation( QWidget * parent = 0, const char * name = 0 );
-
        void reupdate();
+       void addTile( Tile::TileType tile );
 
 public slots:
-       void slot_toggle( int num );
-       void slot_recvTile( Tile::TileType tile );
+       void slot_selectTile( int num );
 
 signals:
        void sig_tile( int num );
 
 protected:
-       TileButton * _buttons[6];
-       int _toggled;
+       QPtrList< TileButton > _buttonList;
+       TileButton * _selectedTile;
+       int _selected;
 };
 
 class TileButton : public QPushButton
@@ -72,6 +74,7 @@
        TileButton( QWidget * parent = 0, const char * name = 0 );
 
        void setTile( Tile::TileType type );
+       Tile::TileType getTileType() { return _type; }
 
        void reinit();
 




reply via email to

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