/*#*
*#* $Log$
+ *#* Revision 1.8 2006/05/28 12:17:57 bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
*#* Revision 1.7 2006/04/27 05:43:08 bernie
*#* Fix naming conventions.
*#*
*#*
*#* Revision 1.1 2006/01/16 03:51:35 bernie
*#* Add LCD Qt emulator.
- *#*
*#*/
#include "lcd_gfx_qt.h"
#include <cfg/debug.h>
#include <gfx/gfx.h> // CONFIG_BITMAP_FMT
-#if _QT < 4
- #include <qpainter.h>
- #include <qimage.h>
- #include <qsizepolicy.h>
- #include <qsize.h>
-#else
- #include <QtGui/QPainter>
- #include <QtGui/QImage>
- #include <QtGui/QSizePolicy>
- #include <QtCore/QSize>
-#endif
+#include <QtGui/QPainter>
+#include <QtGui/QImage>
+#include <QtGui/QSizePolicy>
+#include <QtCore/QSize>
// Display colors
#define LCD_FG_COLOR 0x0, 0x0, 0x0
uint8_t v = 0;
for (int xbit = 0; xbit < 8; ++xbit)
v |= (new_raster[(xbyte * 8 + xbit) + (y / 8) * WIDTH] & (1 << (y%8)) )
- ? (1 << (7 - xbit)) : 0;
+ ? 0 : (1 << (7 - xbit));
raster[y * ((WIDTH + 7) / 8) + xbyte] = v;
}
#include <gfx/gfx.h>
#include <cfg/debug.h>
-/*!
+DECLARE_WALL(wall_before_raster, WALL_SIZE)
+/**
* Raster buffer to draw into.
*
* Bits in the bitmap bytes have vertical orientation,
* as required by the LCD driver.
*/
-DECLARE_WALL(wall_before_raster, WALL_SIZE)
static uint8_t lcd_raster[RASTER_SIZE(EmulLCD::WIDTH, EmulLCD::HEIGHT)];
DECLARE_WALL(wall_after_raster, WALL_SIZE)
/*#*
*#* $Log$
+ *#* Revision 1.5 2006/05/28 12:17:57 bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
*#* Revision 1.4 2006/02/20 02:00:40 bernie
*#* Port to Qt 4.1.
*#*
#ifndef DRV_LCD_GFX_QT_H
#define DRV_LCD_GFX_QT_H
-#if _QT < 4
- #include <qframe.h>
- #include <qcolor.h>
-#else
- #include <QtGui/QColor>
- #include <QtGui/QFrame>
-#endif
+#include <QtGui/QColor>
+#include <QtGui/QFrame>
// fwd decls
class QSizePolicy;
/*#*
*#* $Log$
+ *#* Revision 1.4 2006/05/28 12:17:57 bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
*#* Revision 1.3 2006/02/21 21:28:02 bernie
*#* New time handling based on TIMER_TICKS_PER_SEC to support slow timers with ticks longer than 1ms.
*#*
#include <cfg/compiler.h> /* hptime.t */
// Qt headers
-#if _QT < 4
- #include <qdatetime.h>
- #include <qtimer.h>
-#else
- #include <QtCore/QDateTime>
- #include <QtCore/QTimer>
-#endif
+#include <QtCore/QDateTime>
+#include <QtCore/QTimer>
// The user interrupt server routine
/*#*
*#* $Log$
+ *#* Revision 1.6 2006/05/28 12:17:57 bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
*#* Revision 1.5 2006/05/27 22:30:56 bernie
*#* Add some delay to slow things down.
*#*
#include <cstdlib> // std::exit()
-#if _QT < 4
- #include <qapplication.h>
-#else
- #include <QtGui/qapplication.h>
-#endif
+#include <QtGui/qapplication.h>
/// The global emulator instance.
emulApp(new QApplication(argc, argv)),
emulWin(new EmulWin(this))
{
- #if QT_VERSION < ((4 << 16) + (0 << 8) + 0)
- emulApp->setMainWidget(emulWin);
- #endif
emulWin->show();
}
#include "emulkbd.h"
#include "emul.h"
-#if _QT < 4
- #include <qpainter.h>
- #include <qpixmap.h>
- #include <qsizepolicy.h>
- #include <qsize.h>
- #include <qrect.h>
- #include <qlayout.h>
- #include <qobjectlist.h>
-#else
- #include <QtGui/QPainter>
- #include <QtGui/QPixmap>
- #include <QtGui/QSizePolicy>
- #include <QtGui/QLayout>
- #include <QtGui/QKeyEvent>
- #include <QtCore/QEvent>
- #include <QtCore/QSize>
- #include <QtCore/QRect>
-#endif
+#include <QtGui/QPainter>
+#include <QtGui/QPixmap>
+#include <QtGui/QSizePolicy>
+#include <QtGui/QLayout>
+#include <QtGui/QKeyEvent>
+#include <QtCore/QEvent>
+#include <QtCore/QSize>
+#include <QtCore/QRect>
EmulKey::EmulKey(EmulKbd *kbd, const char *label, int _keycode, int _row, int _col) :
}
-EmulKbd::EmulKbd(QWidget *parent, const char *name, Qt::WFlags f) :
- QFrame(parent, name, Qt::WRepaintNoErase | Qt::WResizeNoErase | f),
- layout(new QGridLayout(this, 4, 4, 4)),
+EmulKbd::EmulKbd(QWidget *parent, Qt::WFlags f) :
+ QFrame(parent, f),
+ layout(new QGridLayout(this)),
active_row(0)
{
setFrameStyle(QFrame::Box | QFrame::Sunken);
QSizePolicy EmulKbd::sizePolicy() const
{
- return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed, false);
+ return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
}
EmulKey *key;
int cols = 0;
+ // FIXME: QLayoutIterator is obsolete in Qt4
for(QLayoutIterator it(layout->iterator()); (item = it.current()); ++it)
{
key = static_cast<EmulKey *>(item->widget());
#pragma once
#endif // _MSC_VER > 1000
-#if _QT < 4
-#include <qframe.h>
-#else
#include <QtGui/QFrame>
-#endif
// fwd decl
class QGridLayout;
// Construction
public:
- EmulKbd(QWidget *parent = 0, const char *name = 0, Qt::WFlags f = 0);
+ EmulKbd(QWidget *parent = 0, Qt::WFlags f = 0);
virtual ~EmulKbd();
// Public methods
// Private helper class for EmulKbd
// NOTE: with protected inheritance, dynamic_cast<> does not work (gcc 2.96)
-#if _QT < 4
-#include <qpushbutton.h>
-#else
#include <QtGui/qpushbutton.h>
-#endif
class EmulKey : public QPushButton
{
Q_OBJECT
/*#*
*#* $Log$
+ *#* Revision 1.5 2006/05/28 12:17:56 bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
*#* Revision 1.4 2006/02/20 02:00:39 bernie
*#* Port to Qt 4.1.
*#*
#include <cassert>
-#if _QT < 4
- #include <qlayout.h>
- #include <qlabel.h>
- #include <qslider.h>
- #include <qcheckbox.h>
- #include <qmenubar.h>
- #include <qmessagebox.h>
- #include <qdatetime.h>
- #include <qtimer.h>
- #include <qapplication.h>
- #include <qpopupmenu.h>
- #include <qevent.h>
-#else
- #include <QtGui/QLayout>
- #include <QtGui/QLabel>
- #include <QtGui/QSlider>
- #include <QtGui/QCheckBox>
- #include <QtGui/QMenuBar>
- #include <QtGui/QMessageBox>
- #include <QtCore/QDateTime>
- #include <QtCore/QTimer>
- #include <QtGui/QApplication>
- #include <QtGui/QCloseEvent>
- //#include <Qt3Support/q3popupmenu.h>
- //#define QPopupMenu Q3PopupMenu
- #define QPopupMenu QMenu
- using namespace Qt;
-#endif
-
-EmulWin::EmulWin(Emulator *e) : QMainWindow(0, "DevLibEmul",
- #if _QT < 4
- Qt::WDestructiveClose
- #else
- 0
- #endif
-)
+#include <QtGui/QLayout>
+#include <QtGui/QLabel>
+#include <QtGui/QSlider>
+#include <QtGui/QCheckBox>
+#include <QtGui/QMenuBar>
+#include <QtGui/QMessageBox>
+#include <QtCore/QDateTime>
+#include <QtCore/QTimer>
+#include <QtGui/QApplication>
+#include <QtGui/QCloseEvent>
+using namespace Qt;
+
+EmulWin::EmulWin(Emulator *e)
{
- #if _QT >= 4
- setAttribute(Qt::WA_DeleteOnClose);
- #endif
+ setWindowTitle(tr("DevLib Emul Demo"));
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ // Create the menu bar
+ QMenu *file_menu = menuBar()->addMenu(tr("&File"));
+ file_menu->addAction(tr("&Quit"),
+ e->emulApp, SLOT(closeAllWindows()), CTRL+Key_Q);
- // "File" menu
- QPopupMenu * file = new QPopupMenu(this);
- file->insertItem("&Quit", static_cast<QObject *>(e->emulApp), SLOT(closeAllWindows()), CTRL+Key_Q);
+ menuBar()->addSeparator();
- // "Help" menu
- QPopupMenu * help = new QPopupMenu(this);
- help->insertItem("&About", this, SLOT(about()), Key_F1);
+ QMenu *help_menu = menuBar()->addMenu(tr("&Help"));
+ help_menu->addAction(tr("&About"),
+ this, SLOT(about()), Key_F1);
- // Menu bar
- QMenuBar * menu = new QMenuBar(this);
- menu->insertItem("&File", file);
- menu->insertSeparator();
- menu->insertItem("&Help", help);
// Make a central widget to contain the other widgets
QWidget *central = new QWidget(this);
setCentralWidget(central);
// Create a layout to position the widgets
- QHBoxLayout *box_main = new QHBoxLayout(central, 4);
+ QHBoxLayout *box_main = new QHBoxLayout(central);
// Main layout
- QVBoxLayout *box_right = new QVBoxLayout(box_main, 4);
+ QVBoxLayout *box_right = new QVBoxLayout();
+ box_main->addLayout(box_right);
// LCD
- QHBoxLayout *lay_lcd = new QHBoxLayout(box_right, 4);
- lay_lcd->addWidget(e->emulLCD = new EmulLCD(central));
+ QHBoxLayout *lay_lcd = new QHBoxLayout();
+ box_right->addLayout(lay_lcd);
+ lay_lcd->addStretch();
+ lay_lcd->addWidget(e->emulLCD = new EmulLCD(central));
+ lay_lcd->addStretch();
// Keyboard
- QHBoxLayout *lay_kbd = new QHBoxLayout(box_right, 4);
- lay_kbd->addWidget(e->emulKbd = new EmulKbd(central));
+ box_right->addWidget(e->emulKbd = new EmulKbd(central));
// Setup keyboard: Label Keycode Row Col MRow MCol
e->emulKbd->addKey("^", Key_Up, 0, 0, 0, 0);
/*#*
*#* $Log$
+ *#* Revision 1.4 2006/05/28 12:17:56 bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
*#* Revision 1.3 2006/02/20 02:00:39 bernie
*#* Port to Qt 4.1.
*#*
#ifndef EMUL_EMULWIN_H
#define EMUL_EMULWIN_H
-#if _QT < 4
- #include <qmainwindow.h>
-#else
- #include <QtGui/QMainWindow>
-#endif
+#include <QtGui/QMainWindow>
// fwd decls
class Emulator;