X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Femul%2Femulwin.cpp;fp=bertos%2Femul%2Femulwin.cpp;h=b5f57cd455a61fd328355a7418cb8ea99e6a35ad;hb=791e167e053bdd9250d34a9a5ccae6ccde4d6679;hp=0000000000000000000000000000000000000000;hpb=faf2f6bfd5933ff75e6cc01e3d48f9277f731d8f;p=bertos.git diff --git a/bertos/emul/emulwin.cpp b/bertos/emul/emulwin.cpp new file mode 100644 index 00000000..b5f57cd4 --- /dev/null +++ b/bertos/emul/emulwin.cpp @@ -0,0 +1,130 @@ +/** + * \file + * + * + * \version $Id$ + * + * \author Bernardo Innocenti + * + * \brief Main Qt window for embedded applications emulator (implementation) + */ + +#include "emulwin.h" + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace Qt; + +EmulWin::EmulWin(Emulator *e) +{ + setWindowTitle(tr("BeRTOS 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); + + menuBar()->addSeparator(); + + QMenu *help_menu = menuBar()->addMenu(tr("&Help")); + help_menu->addAction(tr("&About"), + this, SLOT(about()), Key_F1); + + // 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); + + // Main layout + QVBoxLayout *box_right = new QVBoxLayout(); + box_main->addLayout(box_right); + + // LCD + 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 + 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); + e->emulKbd->addKey("v", Key_Down, 1, 0, 0, 1); + e->emulKbd->addKey("OK", Key_Return, 0, 1, 0, 2); + e->emulKbd->addKey("ESC", Key_Escape, 1, 1, 0, 3); +} + + +EmulWin::~EmulWin() +{ + emul->quit(); +} + + +void EmulWin::closeEvent(QCloseEvent *ce) +{ + emul->quit(); + ce->accept(); +} + + +void EmulWin::about() +{ + QMessageBox::about(this, + "BeRTOS Embedded Application Emulator", + "Version 0.1\n" + "Copyright 2006, 2008 Develer S.r.l. (http://www.develer.com/)\n" + "Copyright 2001, 2002, 2003, 2005 Bernardo Innocenti \n" + "All rights reserved." + ); +} + +#include "emulwin_moc.cpp"