Move unpack lwip ip address macro to macros module.
[bertos.git] / bertos / emul / emulkbd.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
30  * Copyright 2001 Bernie Innocenti <bernie@codewiz.org>
31  *
32  * -->
33  *
34  *
35  * \author Bernie Innocenti <bernie@codewiz.org>
36  *
37  * \brief QT-based widget for leyboard emulation (interface)
38  */
39
40 #if !defined(EMULKBD_H)
41 #define EMULKBD_H
42
43 #if defined (_MSC_VER) && (_MSC_VER > 1000)
44 #pragma once
45 #endif // _MSC_VER > 1000
46
47 #include <QtGui/QFrame>
48
49 // fwd decl
50 class QGridLayout;
51 class EmulKey;
52
53 class EmulKbd : public QFrame
54 {
55         Q_OBJECT
56
57 // Data members
58 protected:
59         QGridLayout *layout;
60         int frame_width;
61         int active_row;
62
63 // Construction
64 public:
65         EmulKbd(QWidget *parent = 0, Qt::WFlags f = 0);
66         virtual ~EmulKbd();
67
68 // Public methods
69         void addKey(const char *label, int keycode, int row, int col, int matrix_row = -1, int matrix_col = -1);
70         void setRow(int row);
71         int readCols(void);
72
73 // Protected methods
74 protected:
75         void setKey(int row, int col, bool on);
76
77 // Base class overrides
78 protected:
79         virtual QSizePolicy sizePolicy() const;
80         virtual void resizeEvent(QResizeEvent *e);
81         virtual bool event(QEvent *e);
82
83 // Friends
84         friend class EmulKey;
85 };
86
87
88 // Private helper class for EmulKbd
89 // NOTE: with protected inheritance, dynamic_cast<> does not work (gcc 2.96)
90 #include <QtGui/qpushbutton.h>
91 class EmulKey : public QPushButton
92 {
93         Q_OBJECT
94
95 // Data members
96 protected:
97         int row, col;
98         int keycode;
99
100 // Construction
101 public:
102         EmulKey(EmulKbd *parent, const char *label, int keycode, int _row, int _col);
103         virtual ~EmulKey();
104
105 // superclass overrides
106         void setDown(bool enable);
107
108 protected slots:
109         void keyPressed(void);
110         void keyReleased(void);
111
112 // Friends
113 public:
114         friend class EmulKbd;
115 };
116
117 #endif // !defined(EMULKBD_H)
118