#ifndef LEGENDWIDGET_H
#define LEGENDWIDGET_H
/***************************************************************************
 *   Copyright (C) 2007 by Carsten Niehaus                                 *
 *   cniehaus@kde.org                                                      *
 *                                                                         *
 *   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.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/

#include <kdialog.h>

#include "kalziumpainter.h"
#include "kalziumschemetype.h"
#include "kalziumtabletype.h"

class LegendItem;
// class LegendLayout;

/**
 * @author Carsten Niehaus
 *
 * The LegendWidget displays the explanations of what the user is currently
 * seeing in the table
 */
class LegendWidget : public QWidget
{
    Q_OBJECT

public:
    LegendWidget( QWidget *parent );

    ~LegendWidget() {}

    void LockWidget();
    void UnLockWidget();

private:
    bool m_update;

    QPixmap m_pixmap;

    KalziumSchemeType * m_scheme;

    KalziumPainter::MODE m_mode;

    KalziumTableType * m_tableType;

    KalziumGradientType * m_gradientType;

    QList<LegendItem*> m_legendItemList;
    
    Qt::DockWidgetArea m_dockArea;

    void updateLegendItemLayout( const QList<legendPair>& list );

public slots:
    void updateContent();

    void setMode( KalziumPainter::MODE m );

    void setScheme( KalziumSchemeType * type );

    void setTableType( KalziumTableType * type );

    void setGradientType( KalziumGradientType * type );
    
    void setDockArea(Qt::DockWidgetArea newDockArea);
};

/**
 * A LegendItem is displayed as one small rectangle which represents the
 * color in the table with a short explanation for it.
 *
 * @author Carsten Niehaus
 */
class LegendItem : public QWidget
{
    Q_OBJECT

public:
    LegendItem( const QPair<QString, QColor>& pair, QWidget * parent = 0 );
    ~LegendItem() {}

};

#endif // LEGENDWIDGET_H
