/***************************************************************************
 *   Copyright (C) 2006 by Andreas Krumnow   *
 *   andreas@krumnow.de   *
 *                                                                         *
 *   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 TRAFFIX_H
#define TRAFFIX_H

#include <QApplication>
// #include <QWidget>
#include <QFrame>
#include <QGridLayout>
#include <QSpacerItem>
#include <QPushButton>
#include <QLabel>
#include <QCheckBox>
#include <QSlider>
#include <QTime>
#include <QTimer>
#include <QString>
#include <QMessageBox>
#include <QSettings>

#include "plotterfield.h"
#include "colorslider.h"
#include "nettraffix.h"

class Traffix: public QWidget
{
      Q_OBJECT

private:
    PlotterField *plotPane;
    NetTraffix  *netTraffics;
    ColorSlider *sld_bkCol, *sld_gridCol, *sld_plotCol1, *sld_plotCol2;

    QSlider     *sld_alpha,     *sld_clockInterval;
    QGridLayout *mainLayout,    *normalLayout,      *extensionLayout;
    QFrame *extension;
    QSpacerItem *spacerItem;
    QPushButton *btn_Quit,      *btn_Options,       *btn_ClockRun, 
                *btn_About,     *btn_saveSettings,  *btn_restoreSettings;
    QCheckBox   *cbx_Hlines,    *cbx_Vlines,
                *cbx_HTxt,      *cbx_VTxt;
    QLabel      *lbl_alpha,     *lbl_clockInterval,
                *lbl_gridCol,   *lbl_clockInterv_2,
                *lbl_bkcol,     *statusLine,
                *lbl_plotCol1,
                *lbl_plotCol2,  *Lbl_colorSliders;
    QTimer      *clock;
    QTime       *benchmark;
    QFile       *settingsIni;
    QString     version,        last_edited;
    QPainter    *pen_colorSliders;
    int         clockMsecs,     optionsHeight,      hz_genau,
                bytesRx,        diffRx,
                bytesTx,        diffTx;
    double      hz;
    bool        firstRTx;

    QSettings   *settings;
    QPoint      winPos;
    int         val_plotCol1,   val_gridCol,    val_alpha,
                val_plotCol2,   val_bkCol,
                val_clockRange, val_clockInterval ;
    bool        flg_Hlines,     flg_Vlines,
                flg_HTxt,       flg_VTxt,       flg_ClockRun;


protected:
    void resizeEvent ( QResizeEvent * );

public:
    Traffix();
    ~Traffix();

private slots:
    void about();
    void newSample();
    void saveSettings();
    void restoreSettings();
    void on_btn_Options(bool b);
    void on_cbx_Hlines(bool b);
    void on_cbx_Vlines(bool b);
    void on_cbx_HTxt(bool b);
    void on_cbx_VTxt(bool b);
    void on_sld_gridCol(int i);
    void on_sld_alpha(int i);
    void on_sld_plotCol1(int i);
    void on_sld_plotCol2(int i);
    void on_sld_bkCol(int i);

public slots:
    void on_clockRun(bool);
    void set_clockInterval(int);
};

#endif