emulkbd.h

Go to the documentation of this file.
00001 
00041 #if !defined(EMULKBD_H)
00042 #define EMULKBD_H
00043 
00044 #if defined (_MSC_VER) && (_MSC_VER > 1000)
00045 #pragma once
00046 #endif // _MSC_VER > 1000
00047 
00048 #include <QtGui/QFrame>
00049 
00050 // fwd decl
00051 class QGridLayout;
00052 class EmulKey;
00053 
00054 class EmulKbd : public QFrame
00055 {
00056     Q_OBJECT
00057 
00058 // Data members
00059 protected:
00060     QGridLayout *layout;
00061     int frame_width;
00062     int active_row;
00063 
00064 // Construction
00065 public:
00066     EmulKbd(QWidget *parent = 0, Qt::WFlags f = 0);
00067     virtual ~EmulKbd();
00068 
00069 // Public methods
00070     void addKey(const char *label, int keycode, int row, int col, int matrix_row = -1, int matrix_col = -1);
00071     void setRow(int row);
00072     int readCols(void);
00073 
00074 // Protected methods
00075 protected:
00076     void setKey(int row, int col, bool on);
00077 
00078 // Base class overrides
00079 protected:
00080     virtual QSizePolicy sizePolicy() const;
00081     virtual void resizeEvent(QResizeEvent *e);
00082     virtual bool event(QEvent *e);
00083 
00084 // Friends
00085     friend class EmulKey;
00086 };
00087 
00088 
00089 // Private helper class for EmulKbd
00090 // NOTE: with protected inheritance, dynamic_cast<> does not work (gcc 2.96)
00091 #include <QtGui/qpushbutton.h>
00092 class EmulKey : public QPushButton
00093 {
00094     Q_OBJECT
00095 
00096 // Data members
00097 protected:
00098     int row, col;
00099     int keycode;
00100 
00101 // Construction
00102 public:
00103     EmulKey(EmulKbd *parent, const char *label, int keycode, int _row, int _col);
00104     virtual ~EmulKey();
00105 
00106 // superclass overrides
00107     void setDown(bool enable);
00108 
00109 protected slots:
00110     void keyPressed(void);
00111     void keyReleased(void);
00112 
00113 // Friends
00114 public:
00115     friend class EmulKbd;
00116 };
00117 
00118 #endif // !defined(EMULKBD_H)
00119