--- /dev/null
+/**
+ * \file
+ * <!--
+ * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000, 2001 Bernardo Innocenti <bernie@codewiz.org>
+ * All Rights Reserved.
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ *
+ * \brief Qt-based emulator framework for embedded applications (implementation)
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2006/01/16 03:37:12 bernie
+ *#* Add emulator skeleton.
+ *#*
+ *#*/
+
+#include "emul.h"
+#include "emulwin.h"
+
+#include <qapplication.h>
+#include <cstdlib> // std::exit()
+
+/// The global emulator instance.
+Emulator *emul;
+
+Emulator::Emulator(int &argc, char **argv) :
+ emulApp(new QApplication(argc, argv)),
+ emulWin(new EmulWin(this))
+{
+ emulApp->setMainWidget(emulWin);
+ emulWin->show();
+}
+
+
+Emulator::~Emulator()
+{
+ // we don't delete emulWin because it automatically
+ // deletes itself when closed
+ delete emulApp;
+}
+
+
+void Emulator::quit()
+{
+ // WHAT A KLUDGE!
+ this->~Emulator();
+ emul = NULL;
+
+ // do we have a better way to shut down the emulation?
+ exit(0);
+}
+
+
+/// Main emulator entry point.
+extern "C" void emul_init(int *argc, char *argv[])
+{
+ ASSERT(!emul);
+
+ // setup global emulator pointer
+ emul = new Emulator(*argc, argv);
+}
+
+extern "C" void emul_cleanup()
+{
+ ASSERT(emul);
+ delete emul;
+ emul = NULL;
+}
+
+extern "C" void emul_idle()
+{
+ // We process GUI events when the application is idle.
+ emul->emulApp->processEvents();
+}
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000, 2001 Bernardo Innocenti <bernie@codewiz.org>
+ * All Rights Reserved.
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ *
+ * \brief Qt-based emulator framework for embedded applications (interface)
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2006/01/16 03:37:12 bernie
+ *#* Add emulator skeleton.
+ *#*
+ *#*/
+
+#ifndef EMUL_EMUL_H
+#define EMUL_EMUL_H
+
+#include <cfg/compiler.h>
+
+#ifdef __cplusplus
+
+// fwd decls
+class QApplication;
+class EmulWin;
+class EmulPRT;
+class EmulLCD;
+class EmulKBD;
+class QCheckBox;
+class QSlider;
+class QLabel;
+
+class Emulator
+{
+// data members
+public:
+ QApplication *emulApp; ///< QT Application.
+ EmulWin *emulWin; ///< Main window.
+
+ EmulLCD *emulLCD; ///< Display emulator.
+ EmulKBD *emulKBD; ///< Keyboard emulator.
+
+// construction
+ Emulator(int &argc, char **argv);
+ ~Emulator();
+
+// public methods
+ int exec(void (*entry)(void));
+ void quit();
+};
+
+extern Emulator *emul;
+
+#endif /* __cplusplus */
+
+EXTERN_C void emul_init(int *argc, char *argv[]);
+EXTERN_C void emul_cleanup();
+EXTERN_C void emul_idle();
+
+#endif /* EMUL_EMUL_H */
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000, 2001 Bernardo Innocenti <bernie@codewiz.org>
+ * All Rights Reserved.
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ *
+ * \brief Main Qt window for embedded applications emulator (implementation)
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2006/01/16 03:37:12 bernie
+ *#* Add emulator skeleton.
+ *#*
+ *#*/
+
+#include "emulwin.h"
+
+#include <drv/lcd_gfx_qt.h>
+#include <emul/emul.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, "SarfEmul", WDestructiveClose)
+{
+ // "File" menu
+ QPopupMenu * file = new QPopupMenu(this);
+ file->insertItem("&Quit", static_cast<QObject *>(e->emulApp), SLOT(closeAllWindows()), CTRL+Key_Q);
+
+ // "Help" menu
+ QPopupMenu * help = new QPopupMenu(this);
+ help->insertItem("&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);
+
+ // Main layout
+ QVBoxLayout *box_right = new QVBoxLayout(box_main, 4);
+
+ // LCD
+ QHBoxLayout *lay_lcd = new QHBoxLayout(box_right, 4);
+ lay_lcd->addWidget(e->emulLCD = new EmulLCD(central));
+}
+
+
+EmulWin::~EmulWin()
+{
+ emul->quit();
+}
+
+
+void EmulWin::closeEvent(QCloseEvent *ce)
+{
+ ce->accept();
+}
+
+
+void EmulWin::about()
+{
+ QMessageBox::about(this,
+ "Embedded Application Emulator",
+ "Version 0.1\n"
+ "Copyright 2006 Develer S.r.l. (http://www.develer.com/)\n"
+ "Copyright 2001, 2002, 2003, 2005 Bernardo Innocenti <bernie@codewiz.org>\n"
+ "All rights reserved."
+ );
+}
+
+#include "emulwin_moc.cpp"
--- /dev/null
+/**
+ * \file
+ * <!--
+ * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000, 2001 Bernardo Innocenti <bernie@codewiz.org>
+ * All Rights Reserved.
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ *
+ * \brief Main Qt window for embedded applications emulator (interface)
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2006/01/16 03:37:12 bernie
+ *#* Add emulator skeleton.
+ *#*
+ *#*/
+
+#ifndef EMUL_EMULWIN_H
+#define EMUL_EMULWIN_H
+
+#include <qmainwindow.h>
+
+// fwd decls
+class Emulator;
+
+class EmulWin : public QMainWindow
+{
+ Q_OBJECT
+
+// construction
+public:
+ EmulWin(Emulator *emul);
+ ~EmulWin();
+
+protected:
+ void closeEvent(QCloseEvent *);
+
+private slots:
+ void about();
+};
+
+#endif // EMUL_EMULWIN_H
+