/** * \file * * * * \author Bernie Innocenti * * \brief Custom Qt widget for emulating a graphics LCD display (implementation) */ #ifndef EMULLCD_H #define EMULLCD_H #include #include #include // fwd decls class QSizePolicy; class QPaintEvent; class QResizeEvent; /** * Qt widget to emulate a dot-matrix LCD display. */ class EmulLCD : public QFrame { Q_OBJECT public: // Attributes enum { COLS = 20, ROWS = 4 }; // Construction EmulLCD(QWidget *parent = 0, const char *name = 0); virtual ~EmulLCD(); // Base class overrides protected: virtual QSizePolicy sizePolicy() const; virtual QSize sizeHint() const; virtual void drawContents(QPainter *p); // Operations public: void MoveCursor (int col, int row); void ShowCursor (bool show = true); void PutChar (unsigned char c); char GetChar (); void Clear (); void SetCGRamAddr (unsigned char addr); // Implementation protected: void SetPainter(QPainter & p); void RedrawText(QPainter & p); void PrintChar(QPainter & p, int row, int col); void AdvanceCursor(); QFont lcd_font; ///< Display character font QColor fg_color, bg_color; ///< LCD colors int font_width, font_height; ///< Font dimensions int frame_width; ///< Frame width (and height) int cr_row, cr_col; ///< Cursor position int cgramaddr; ///< CGRAM Address (-1 disabled) unsigned char ddram[ROWS][COLS];///< Display data RAM unsigned char cgram[8*8]; ///< CGRAM bool show_cursor; ///< Cursor enabled? }; #endif // !defined(EMULLCD_H)