/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KDEVMON_H
#define KDEVMON_H

#include <Qt3Support/Q3MemArray>
#include <qframe.h>
#include <kapplication.h>

#include "resources.h"

class SelectMenu;
class InputDialog;
class KdevmonConfig;
class ProcParser;
class PrefsDialogImpl;
class MainFrame;
class DockFrame;
class BpsFrame;
class BarFrame;
class StatsFrame;
class Q3PopupMenu;
class QFrame;
class QBoxLayout;

class Kdevmon : public QFrame
{
	Q_OBJECT
public:
	Kdevmon(KApplication *parent, QWidget* parentWidget = 0, const char *name = 0 );
	~Kdevmon();
	
	void initFromConfig();
	
	void setClear();
	void setDockFrameVisible(bool);
	void setStatsFrameVisible(bool);
	void setMainFrameVisible(bool);
	void save();
	void saveAs();
	void load();
	void preferences();
	void about();
	void aboutkde();
	void help();


private:
	MainFrame *m_mainFrame;
	DockFrame *m_dockFrame;
	BpsFrame *m_bpsOutFrame;
	BpsFrame *m_bpsInFrame;
	BarFrame *m_barFrame;
	StatsFrame *m_statsFrame;
	ProcParser *m_parser;
	PrefsDialogImpl *m_prefsDialog;
	QTimer *m_timer;
	QFrame *m_topFrame;
	Q3PopupMenu *m_popupMenu;
	QBoxLayout *m_mainLayout;
	
	KdevmonConfig *m_config;
	
	Q3MemArray< double > m_bytesIn;
	Q3MemArray< double > m_bytesOut;
	double m_lastBytesIn, m_lastBytesOut;
	double m_maxByteRateIn, m_maxByteRateOut;
	Q3MemArray< double > m_packetsIn;
	Q3MemArray< double > m_packetsOut;
	double m_lastPacketsIn, m_lastPacketsOut;
	double m_maxPacketRateIn, m_maxPacketRateOut;
	
	Q3PopupMenu *initPopupMenu();
	PrefsDialogImpl *initPrefsDialog();
	
	void showPopupMenu( const QPoint& pos );

protected slots:
	void processTimerEvent();

	void commandCallback(int id);
	void statusCallback(int id);


	bool eventFilter( QObject *, QEvent * );
	void closeEvent(QCloseEvent *event);
	void resizeEvent( QResizeEvent * );

	void quit();


};

#endif
