/*#*
*#* $Log$
+ *#* Revision 1.6 2006/02/20 02:00:40 bernie
+ *#* Port to Qt 4.1.
+ *#*
*#* Revision 1.5 2006/02/15 09:13:16 bernie
*#* Switch to BITMAP_FMT_PLANAR_V_LSB.
*#*
#include <cfg/debug.h>
#include <gfx/gfx.h> // CONFIG_BITMAP_FMT
-#include <qpainter.h>
-#include <qimage.h>
-#include <qsizepolicy.h>
-#include <qsize.h>
+#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
// Display colors
#define LCD_FG_COLOR 0x0, 0x0, 0x0
EmulLCD::EmulLCD(QWidget *parent, const char *name) :
- QFrame(parent, name, WRepaintNoErase | WResizeNoErase),
+ QFrame(parent, name, Qt::WRepaintNoErase | Qt::WResizeNoErase),
fg_color(LCD_FG_COLOR),
bg_color(LCD_BG_COLOR)
{
}
-void EmulLCD::drawContents(QPainter *p)
+void EmulLCD::paintEvent(QPaintEvent * /*event*/)
{
+ QPainter p(this);
QImage img(raster, WIDTH, HEIGHT, 1, NULL, 0, QImage::BigEndian);
- p->setBackgroundMode(OpaqueMode);
- p->setPen(fg_color);
- p->setBackgroundColor(bg_color);
- p->drawImage(frame_width, frame_width, img);
+ p.setBackgroundMode(Qt::OpaqueMode);
+ p.setPen(fg_color);
+ p.setBackgroundColor(bg_color);
+ p.drawImage(frame_width, frame_width, img);
}
void EmulLCD::writeRaster(uint8_t *new_raster)
#error Unsupported bitmap format
#endif
- QPainter p(this);
- drawContents(&p);
+ repaint();
}
/*#*
*#* $Log$
+ *#* Revision 1.4 2006/02/20 02:00:40 bernie
+ *#* Port to Qt 4.1.
+ *#*
*#* Revision 1.3 2006/02/15 09:13:16 bernie
*#* Switch to BITMAP_FMT_PLANAR_V_LSB.
*#*
#ifndef DRV_LCD_GFX_QT_H
#define DRV_LCD_GFX_QT_H
-#include <qframe.h>
-#include <qcolor.h>
+#if _QT < 4
+ #include <qframe.h>
+ #include <qcolor.h>
+#else
+ #include <QtGui/QColor>
+ #include <QtGui/QFrame>
+#endif
// fwd decls
class QSizePolicy;
protected:
virtual QSizePolicy sizePolicy() const;
virtual QSize sizeHint() const;
-// virtual void paintEvent(QPaintEvent *event);
- virtual void drawContents(QPainter *p);
+ virtual void paintEvent(QPaintEvent *event);
// Operations
public:
/*#*
*#* $Log$
+ *#* Revision 1.2 2006/02/20 02:01:35 bernie
+ *#* Port to Qt 4.1.
+ *#*
*#* Revision 1.1 2005/11/27 03:06:36 bernie
*#* Qt timer emulation.
*#*
#include <cfg/compiler.h> /* hptime.t */
// Qt headers
-#include <qdatetime.h>
-#include <qtimer.h>
+#if _QT < 4
+ #include <qdatetime.h>
+ #include <qtimer.h>
+#else
+ #include <QtCore/QDateTime>
+ #include <QtCore/QTimer>
+#endif
// The user interrupt server routine
/*#*
*#* $Log$
+ *#* Revision 1.8 2006/02/20 02:02:29 bernie
+ *#* Port to Qt 4.1.
+ *#*
*#* Revision 1.7 2005/11/27 03:58:40 bernie
*#* Add POSIX timer emulator.
*#*
#include <cfg/os.h>
#if OS_QT
- #include <qapplication.h>
+ #if _QT < 4
+ #include <qapplication.h>
+ #else
+ #include <QtGui/QApplication>
+ #endif
#elif OS_POSIX
#include <sys/select.h>
#elif CPU_AVR
/*#*
*#* $Log$
+ *#* Revision 1.3 2006/02/20 02:00:40 bernie
+ *#* Port to Qt 4.1.
+ *#*
*#* Revision 1.2 2006/01/16 03:51:51 bernie
*#* Fix boilerplate.
*#*
#include "emul.h"
#include "emulwin.h"
+#include <cfg/module.h>
-#include <qapplication.h>
#include <cstdlib> // std::exit()
+#if _QT < 4
+ #include <qapplication.h>
+#else
+ #include <QtGui/qapplication.h>
+#endif
+
+
/// The global emulator instance.
Emulator *emul;
emulApp(new QApplication(argc, argv)),
emulWin(new EmulWin(this))
{
- emulApp->setMainWidget(emulWin);
+ #if QT_VERSION < ((4 << 16) + (0 << 8) + 0)
+ emulApp->setMainWidget(emulWin);
+ #endif
emulWin->show();
}
}
-void Emulator::quit()
+NORETURN void Emulator::quit()
{
// WHAT A KLUDGE!
this->~Emulator();
exit(0);
}
+MOD_DEFINE(emul)
/// Main emulator entry point.
extern "C" void emul_init(int *argc, char *argv[])
{
- ASSERT(!emul);
-
// setup global emulator pointer
emul = new Emulator(*argc, argv);
+
+ MOD_INIT(emul);
}
extern "C" void emul_cleanup()
{
- ASSERT(emul);
+ MOD_CLEANUP(emul);
+
delete emul;
emul = NULL;
}
#include "emulkbd.h"
#include "emul.h"
-#include <qpainter.h>
-#include <qpixmap.h>
-#include <qsizepolicy.h>
-#include <qsize.h>
-#include <qrect.h>
-#include <qlayout.h>
-#include <qobjectlist.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
EmulKey::EmulKey(EmulKbd *kbd, const char *label, int _keycode, int _row, int _col) :
keycode(_keycode)
{
// don't let the widget get focus
- setFocusPolicy(QWidget::NoFocus);
+ setFocusPolicy(Qt::NoFocus);
// unused
connect(this, SIGNAL(pressed()), this, SLOT(keyPressed()));
}
-EmulKbd::EmulKbd(QWidget *parent, const char *name, WFlags f) :
- QFrame(parent, name, WRepaintNoErase | WResizeNoErase | f),
+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)),
active_row(0)
{
setFrameStyle(QFrame::Box | QFrame::Sunken);
setLineWidth(1);
- setFocusPolicy(StrongFocus);
+ setFocusPolicy(Qt::StrongFocus);
frame_width = frameWidth();
}
}
-void EmulKbd::resizeEvent(QResizeEvent * event)
+void EmulKbd::resizeEvent(QResizeEvent *event)
{
// Let our superclass process the event first
QFrame::resizeEvent(event);
// handle key presses for all keys in keyboard
-bool EmulKbd::event(QEvent * _e)
+bool EmulKbd::event(QEvent *_e)
{
switch (_e->type())
{
if (!e->isAutoRepeat())
{
// scan all children
- for (QObjectListIt it(*children()); *it; ++it)
+ for (QObjectList::const_iterator it(children().begin()); it != children().end(); ++it)
{
// only keys, not other children!
- if ((*it)->metaObject() == EmulKey::staticMetaObject())
+ if ((*it)->metaObject() == &EmulKey::staticMetaObject)
// if ((key = dynamic_cast<EmulKey *>(*it)))
{
key = static_cast<EmulKey *>(*it);
#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, WFlags f = 0);
+ EmulKbd(QWidget *parent = 0, const char *name = 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.4 2006/02/20 02:00:39 bernie
+ *#* Port to Qt 4.1.
+ *#*
*#* Revision 1.3 2006/02/15 09:11:17 bernie
*#* Add keyboard emulator.
*#*
#include <emul/emulkbd.h>
#include <cassert>
-#include <qlayout.h>
-#include <qlabel.h>
-#include <qslider.h>
-#include <qcheckbox.h>
-#include <qpopupmenu.h>
-#include <qmenubar.h>
-#include <qmessagebox.h>
-#include <qdatetime.h>
-#include <qtimer.h>
-#include <qapplication.h>
-
-EmulWin::EmulWin(Emulator *e) : QMainWindow(0, "DevLibEmul", WDestructiveClose)
+
+#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
+)
{
+ #if _QT >= 4
+ setAttribute(Qt::WA_DeleteOnClose);
+ #endif
+
// "File" menu
QPopupMenu * file = new QPopupMenu(this);
file->insertItem("&Quit", static_cast<QObject *>(e->emulApp), SLOT(closeAllWindows()), CTRL+Key_Q);
/*#*
*#* $Log$
+ *#* Revision 1.3 2006/02/20 02:00:39 bernie
+ *#* Port to Qt 4.1.
+ *#*
*#* Revision 1.2 2006/01/16 03:51:51 bernie
*#* Fix boilerplate.
*#*
#ifndef EMUL_EMULWIN_H
#define EMUL_EMULWIN_H
-#include <qmainwindow.h>
+#if _QT < 4
+ #include <qmainwindow.h>
+#else
+ #include <QtGui/QMainWindow>
+#endif
// fwd decls
class Emulator;