#ifndef QT_BOARD_GUI_H
#define QT_BOARD_GUI_H

#include <QMainWindow>
#include <biwak/gpio.hpp>

#include <QLabel>
#include <QCheckBox>
#include <QPushButton>
#include <QEvent>
#include <QSlider>

namespace Ui {
   class CBoardGui;
}

class QCheckBox;
class QPushButton;
class QSpacerItem;
class QLabel;
class QSpinBox;
class QButton;

class CBoardGui : public QMainWindow
{
   Q_OBJECT

   private:

      QPixmap *pixmapGraphicDisplay;

   public:
      explicit CBoardGui(QWidget *parent = 0);
      ~CBoardGui();
      static CBoardGui *instance();
      static Ui::CBoardGui *uiInstance();
      QAbstractButton *createOutput();
      QAbstractButton *createInput();
      QAbstractSlider *createPwm(const char *labelText);
      QLabel *createDisplay();
      QSpinBox *createTimer(const char *labelText);
      int getAdc(int channel);
      /*
      bool doExit;
      virtual void 	closeEvent(QCloseEvent * event)
      {
         //lHint << "Exit!";
         doExit=true;
      }
      */
      Ui::CBoardGui *getUi();
      void handleInput(int extiIndex, int state);

      //QLabel *getGraphicDispay();
      //QPixmap *getGraphicDispayPixmap();

   private slots:
      void slotExited();

   signals:
      void signalInputChanged( int extiIndex, int state );

   private:
      Ui::CBoardGui *ui;
       
   public:
   public:
      
      virtual bool event(QEvent *event) override
      {
         // The quit event has to be catched to actually exit the main process.
         // Signal aboutToQuit() is not emitted when using
         // processEvents() in a loop instead of exit().
         if( event->type() == QEvent::WindowDeactivate )
         {
            slotExited();
         }
         return( QMainWindow::event(event) );
      }
};


#endif // QT_BOARD_GUI_H
