Refactor BeRTOS to be in his own directory.
[bertos.git] / bertos / drv / lcd_lm44_qt.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 2000,2001 Bernardo Innocenti <bernie@codewiz.org>
31  *
32  * -->
33  *
34  * \version $Id$
35  *
36  * \author Bernardo Innocenti <bernie@develer.com>
37  *
38  * \brief Custom Qt widget for emulating a graphics LCD display (implementation)
39  */
40
41 /*#*
42  *#* $Log$
43  *#* Revision 1.1  2006/01/16 03:51:35  bernie
44  *#* Add LCD Qt emulator.
45  *#*
46  *#*/
47
48 #ifndef EMULLCD_H
49 #define EMULLCD_H
50
51 #include <qframe.h>
52 #include <qfont.h>
53 #include <qcolor.h>
54
55 // fwd decls
56 class QSizePolicy;
57 class QPaintEvent;
58 class QResizeEvent;
59
60 /**
61  * Qt widget to emulate a dot-matrix LCD display.
62  */
63 class EmulLCD : public QFrame
64 {
65         Q_OBJECT
66
67 public:
68 // Attributes
69         enum { COLS = 20, ROWS = 4 };
70
71 // Construction
72         EmulLCD(QWidget *parent = 0, const char *name = 0);
73         virtual ~EmulLCD();
74
75 // Base class overrides
76 protected:
77         virtual QSizePolicy sizePolicy() const;
78         virtual QSize sizeHint() const;
79         virtual void drawContents(QPainter *p);
80
81 // Operations
82 public:
83         void MoveCursor         (int col, int row);
84         void ShowCursor         (bool show = true);
85         void PutChar            (unsigned char c);
86         char GetChar            ();
87         void Clear                      ();
88         void SetCGRamAddr       (unsigned char addr);
89
90 // Implementation
91 protected:
92         void SetPainter(QPainter & p);
93         void RedrawText(QPainter & p);
94         void PrintChar(QPainter & p, int row, int col);
95         void AdvanceCursor();
96
97         QFont lcd_font;                                 ///< Display character font
98         QColor fg_color, bg_color;              ///< LCD colors
99         int font_width, font_height;    ///< Font dimensions
100         int frame_width;                                ///< Frame width (and height)
101         int     cr_row, cr_col;                         ///< Cursor position
102         int cgramaddr;                                  ///< CGRAM Address (-1 disabled)
103         unsigned char ddram[ROWS][COLS];///< Display data RAM
104         unsigned char cgram[8*8];               ///< CGRAM
105         bool show_cursor;                               ///< Cursor enabled?
106 };
107
108 #endif // !defined(EMULLCD_H)
109