/**
* \file
* <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
* Copyright 2006 Develer S.r.l. (http://www.develer.com/)
* Copyright 2000, 2001 Bernardo Innocenti <bernie@codewiz.org>
- * This file is part of DevLib - See README.devlib for information.
+ *
* -->
*
* \version $Id$
/*#*
*#* $Log$
+ *#* Revision 1.6 2006/09/19 17:49:04 bernie
+ *#* Reindent.
+ *#*
+ *#* 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.
+ *#*
*#* 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)
+
+#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)
{
- // "File" menu
- QPopupMenu * file = new QPopupMenu(this);
- file->insertItem("&Quit", static_cast<QObject *>(e->emulApp), SLOT(closeAllWindows()), CTRL+Key_Q);
+ 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);
- // "Help" menu
- QPopupMenu * help = new QPopupMenu(this);
- help->insertItem("&About", this, SLOT(about()), Key_F1);
+ menuBar()->addSeparator();
- // Menu bar
- QMenuBar * menu = new QMenuBar(this);
- menu->insertItem("&File", file);
- menu->insertSeparator();
- menu->insertItem("&Help", help);
+ 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, 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);