Search for verstag.h in app subdirs first.
[bertos.git] / emul / emulkbd.h
1 /**
2  * \file
3  * <!--
4  * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
5  * Copyright 2001 Bernardo Innocenti <bernie@codewiz.org>
6  * This file is part of DevLib - See README.devlib for information.
7  * -->
8  *
9  * \version $Id$
10  *
11  * \author Bernardo Innocenti <bernie@develer.com>
12  *
13  * \brief QT-based widget for leyboard emulation (interface)
14  */
15
16 #if !defined(EMULKBD_H)
17 #define EMULKBD_H
18
19 #if defined (_MSC_VER) && (_MSC_VER > 1000)
20 #pragma once
21 #endif // _MSC_VER > 1000
22
23 #if _QT < 4
24 #include <qframe.h>
25 #else
26 #include <QtGui/QFrame>
27 #endif
28
29 // fwd decl
30 class QGridLayout;
31 class EmulKey;
32
33 class EmulKbd : public QFrame
34 {
35         Q_OBJECT
36
37 // Data members
38 protected:
39         QGridLayout *layout;
40         int frame_width;
41         int active_row;
42
43 // Construction
44 public:
45         EmulKbd(QWidget *parent = 0, const char *name = 0, Qt::WFlags f = 0);
46         virtual ~EmulKbd();
47
48 // Public methods
49         void addKey(const char *label, int keycode, int row, int col, int matrix_row = -1, int matrix_col = -1);
50         void setRow(int row);
51         int readCols(void);
52
53 // Protected methods
54 protected:
55         void setKey(int row, int col, bool on);
56
57 // Base class overrides
58 protected:
59         virtual QSizePolicy sizePolicy() const;
60         virtual void resizeEvent(QResizeEvent *e);
61         virtual bool event(QEvent *e);
62
63 // Friends
64         friend class EmulKey;
65 };
66
67
68 // Private helper class for EmulKbd
69 // NOTE: with protected inheritance, dynamic_cast<> does not work (gcc 2.96)
70 #if _QT < 4
71 #include <qpushbutton.h>
72 #else
73 #include <QtGui/qpushbutton.h>
74 #endif
75 class EmulKey : public QPushButton
76 {
77         Q_OBJECT
78
79 // Data members
80 protected:
81         int row, col;
82         int keycode;
83
84 // Construction
85 public:
86         EmulKey(EmulKbd *parent, const char *label, int keycode, int _row, int _col);
87         virtual ~EmulKey();
88
89 // superclass overrides
90         void setDown(bool enable);
91
92 protected slots:
93         void keyPressed(void);
94         void keyReleased(void);
95
96 // Friends
97 public:
98         friend class EmulKbd;
99 };
100
101 #endif // !defined(EMULKBD_H)
102