/***************************************************************************
 *   Copyright (C) 2005 by Tavarez Arnaud Bakoula                          *
 *   tbakoula@yahoo.fr                                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef CELL_ROW_H
#define CELL_ROW_H

#include <qpoint.h>
#include <qsize.h>
#include <qrect.h>
#include <qpainter.h>

#include <vector>

class Cell;
class QPainter;

class CellRow
{
public:
    CellRow( uint idx, uint sz );
    virtual ~CellRow();

    virtual void draw( QPainter* painter );
    virtual void reset() = 0;
    virtual void ready() = 0;
    virtual void createCells() = 0;

    virtual void removeCells( uint rm );
    virtual void appendCells( uint ap ) = 0;

    void placeCells();
    void updateMe();

    Cell* getCellAt( uint idx );
    Cell* getCellAt( int x, int y );

    QRect& rect() { return bound; }
    uint getIndex() const { return index; }
    uint getDim() const { return dim; }

protected:
    void computePosition( Cell* cell, uint c );

protected:
    std::vector<Cell*> *cell_list;
    typedef std::vector<Cell*>::iterator cell_iterator;
    QRect bound;
    uint index;
    uint dim;

private:
    CellRow( const CellRow& );
    CellRow& operator=( const CellRow& );
};

#endif // CELL_ROW_H
