Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/ui/ui-drv/qt
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/ui-drv/qt')
-rw-r--r--src/ui/ui-drv/qt/XaoS.icnsbin0 -> 223269 bytes
-rw-r--r--src/ui/ui-drv/qt/XaoS.pro29
-rw-r--r--src/ui/ui-drv/qt/XaoS.qrc5
-rw-r--r--src/ui/ui-drv/qt/aconfig.h63
-rw-r--r--src/ui/ui-drv/qt/config.h149
-rw-r--r--src/ui/ui-drv/qt/config.pri4
-rw-r--r--src/ui/ui-drv/qt/customdialog.cpp179
-rw-r--r--src/ui/ui-drv/qt/customdialog.h29
-rw-r--r--src/ui/ui-drv/qt/fractalwidget.cpp228
-rw-r--r--src/ui/ui-drv/qt/fractalwidget.h57
-rw-r--r--src/ui/ui-drv/qt/images/xaosbig.pngbin0 -> 27584 bytes
-rw-r--r--src/ui/ui-drv/qt/main.cpp180
-rw-r--r--src/ui/ui-drv/qt/mainwindow.cpp172
-rw-r--r--src/ui/ui-drv/qt/mainwindow.h43
-rw-r--r--src/ui/ui-drv/qt/ui_qt.c99
-rw-r--r--src/ui/ui-drv/qt/version.h23
-rw-r--r--src/ui/ui-drv/qt/xaos.icobin0 -> 120841 bytes
-rw-r--r--src/ui/ui-drv/qt/xaos.rc1
18 files changed, 1261 insertions, 0 deletions
diff --git a/src/ui/ui-drv/qt/XaoS.icns b/src/ui/ui-drv/qt/XaoS.icns
new file mode 100644
index 0000000..e03d0cb
--- /dev/null
+++ b/src/ui/ui-drv/qt/XaoS.icns
Binary files differ
diff --git a/src/ui/ui-drv/qt/XaoS.pro b/src/ui/ui-drv/qt/XaoS.pro
new file mode 100644
index 0000000..1fddca6
--- /dev/null
+++ b/src/ui/ui-drv/qt/XaoS.pro
@@ -0,0 +1,29 @@
+# -------------------------------------------------
+# Project created by QtCreator 2009-10-29T19:21:55
+# -------------------------------------------------
+macx {
+ TARGET = XaoS
+ ICON = XaoS.icns
+}
+else:TARGET = xaos
+win32:RC_FILE = xaos.rc
+DESTDIR = $PWD/../../../../../bin
+TEMPLATE = app
+INCLUDEPATH += $$PWD \
+ $$PWD/../../../include
+SOURCES += main.cpp \
+ mainwindow.cpp \
+ fractalwidget.cpp \
+ customdialog.cpp
+HEADERS += mainwindow.h \
+ fractalwidget.h \
+ customdialog.h
+include($$PWD/../../../engine/engine.pri)
+include($$PWD/../../../filter/filter.pri)
+include($$PWD/../../../ui/ui.pri)
+include($$PWD/../../../ui/ui-drv/qt/qt.pri)
+include($$PWD/../../../ui-hlp/ui-hlp.pri)
+include($$PWD/../../../util/util.pri)
+include($$PWD/config.pri)
+include($$PWD/../../../sffe/sffe.pri)
+include($$PWD/../../../include/include.pri)
diff --git a/src/ui/ui-drv/qt/XaoS.qrc b/src/ui/ui-drv/qt/XaoS.qrc
new file mode 100644
index 0000000..1940908
--- /dev/null
+++ b/src/ui/ui-drv/qt/XaoS.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>images/xaosbig.png</file>
+ </qresource>
+</RCC>
diff --git a/src/ui/ui-drv/qt/aconfig.h b/src/ui/ui-drv/qt/aconfig.h
new file mode 100644
index 0000000..cb61b1d
--- /dev/null
+++ b/src/ui/ui-drv/qt/aconfig.h
@@ -0,0 +1,63 @@
+/* src/include/aconfig.h. Generated from aconfig.h.in by configure. */
+#ifndef ACONFIG_H
+#define ACONFIG_H
+/* #undef HAVE_PTHREAD_SIGHANDLER */
+#define DATAPATH "/usr/local/share/XaoS"
+/* #undef C_ALLOCA */
+/* #undef const */
+/* #undef USE_PTHREAD */
+/*Avoid stack frame explosion on Windoze*/
+#ifndef _WIN32
+/*BeOS crashes badly when large amounts of stack are consumed */
+#ifndef __BEOS__
+#define HAVE_ALLOCA 1
+/* #undef HAVE_ALLOCA_H */
+#endif
+#endif
+#define HAVE_FABSL 1
+/* #undef HAVE__FABSL */
+/* #undef HAVE___FABSL */
+#define HAVE_FTIME 1
+#define USE_PNG 1
+#define HAVE_FINITE 1
+/* #undef HAVE_SELECT */
+#define HAVE_LONG_DOUBLE 1
+/* #undef HAVE_REDRAWWIN */
+/* #undef HAVE_WREDRAWLN */
+/* #undef USE_NCURSES */
+/* #undef inline */
+/* #undef _POSIX_SOURCE */
+#define STDC_HEADERS 1
+/* Define if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+#define HAVE_GETTIMEOFDAY 1
+/* #undef HAVE_USLEEP */
+/* #undef HAVE_TERMATTRS */
+/* #undef HAVE_MOUSEMASK */
+/* #undef HAVE_SETITIMER */
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+/* Define if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+/* #undef MITSHM */
+/* #undef CURSES_DRIVER */
+/* #undef BEOS_DRIVER */
+/* #undef AA_DRIVER */
+/* #undef GTK_DRIVER */
+#define QT_DRIVER 1
+/* #undef GGI_DRIVER */
+/* #undef X11_DRIVER */
+/* #undef DGA_DRIVER */
+/* #undef SVGA_DRIVER */
+/* #undef WIN32_DRIVER */
+/* #undef DDRAW_DRIVER */
+/* #undef HTML_HELP */
+#define SIZEOF_SHORT 2
+#define SIZEOF_INT 4
+#define SIZEOF_LONG 4
+/* #undef HAVE_GETTEXT */
+#define NO_MALLOC_H 1
+#define MAIN_FUNCTION ui_main
+#endif
diff --git a/src/ui/ui-drv/qt/config.h b/src/ui/ui-drv/qt/config.h
new file mode 100644
index 0000000..b358144
--- /dev/null
+++ b/src/ui/ui-drv/qt/config.h
@@ -0,0 +1,149 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+#define HOMEDIR
+
+#ifdef __BEOS__
+#define MAIN_FUNCTION be_main
+#ifdef __POWERPC__
+# define SLOWCACHESYNC
+# ifdef __MWERKS__
+# define INLINEFABS(x) __fabs(x)
+# endif
+#endif
+#endif
+
+#ifdef _WIN32
+#define CONFIGFILE "XaoS.cfg"
+#else
+#define CONFIGFILE ".XaoSrc"
+#endif
+
+/*For compilers that don't support nameless unions, do a
+#define NONAMELESSUNION
+before #include <ddraw.h>*/
+#ifdef _WIN32
+#define NONAMELESSUNION
+#endif
+
+/*#define I_WAS_HERE */ /*uncoment this to disable changing of parameters by atoconf */
+
+#define FPOINT_TYPE long double
+ /*floating point math type on computers
+ with medium speed floating point math should
+ use float instead */
+#include <aconfig.h>
+#define USE_STDIO
+#if !defined(HAVE_LONG_DOUBLE)&&!defined(I_WAS_HERE)
+#undef FPOINT_TYPE
+#define FPOINT_TYPE double
+#endif
+#define CONST const
+#define INLINE inline
+
+/* BeOS have broken long double IO routines on i386. Use our replacements */
+#ifdef __BEOS__
+#ifdef __i386__
+#define USE_XLDIO
+#endif
+#endif
+
+/* Win32 don't support long double IO. Use our replacements if possible */
+#ifdef _WIN32
+#ifndef __GNUC__
+1
+/* You need to solve long double IO problems to compile XaoS on non-gcc
+ * compiler */
+#endif
+#define USE_XLDIO
+#endif
+
+#include "gccaccel.h"
+#ifdef HAVE_MOUSEMASK
+#define NCURSESMOUSE
+#endif
+#ifndef HAVE_LIMITS_H
+#define INT_MAX 2127423647
+#endif
+#ifdef SVGA_DRIVER
+#define DESTICKY
+#endif
+#ifdef COCOA_DRIVER
+#define SFIXEDCOLOR
+#define STRUECOLOR
+#define STRUECOLOR16
+#define STRUECOLOR24
+#define SMBITMAPS
+#define SLBITMAPS
+#endif
+#ifdef QT_DRIVER
+#define SFIXEDCOLOR
+#define STRUECOLOR
+#define STRUECOLOR16
+#define STRUECOLOR24
+#define SMBITMAPS
+#define SLBITMAPS
+#endif
+#ifdef GTK_DRIVER
+#define SFIXEDCOLOR
+#define STRUECOLOR
+#define STRUECOLOR16
+#define STRUECOLOR24
+#define SMBITMAPS
+#define SLBITMAPS
+#endif
+#ifdef X11_DRIVER
+#define SFIXEDCOLOR
+#define STRUECOLOR
+#define STRUECOLOR16
+#define STRUECOLOR24
+#define SMBITMAPS
+#define SLBITMAPS
+#endif
+#ifdef SVGA_DRIVER
+#undef STRUECOLOR16
+#define STRUECOLOR16
+#undef STRUECOLOR24
+#define STRUECOLOR24
+#endif
+#ifdef GGI_DRIVER
+#undef STRUECOLOR16
+#define STRUECOLOR16
+#undef STRUECOLOR24
+#define STRUECOLOR24
+#undef SLBITMAPS
+#define SLBITMAPS
+#endif
+#ifdef BEOS_DRIVER
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef __GNUC__
+void be_exit_xaos(int i) __attribute__ ((__noreturn__));
+#else
+void be_exit_xaos(int i);
+#endif
+#ifdef __cplusplus
+}
+#endif
+#define exit_xaos(i) be_exit_xaos(i)
+#undef STRUECOLOR16
+#define STRUECOLOR16
+#undef SFIXEDCOLOR
+#define SFIXEDCOLOR
+#undef SMBITMAPS
+#define SMBITMAPS
+#undef SLBITMAPS
+#define SLBITMAPS
+#endif
+#ifdef WIN32_DRIVER
+#define MAIN_FUNCTION XaoS_main
+#undef STRUECOLOR16
+#define STRUECOLOR16
+#undef STRUECOLOR24
+#define STRUECOLOR24
+#endif
+#ifdef HAVE_SELECT
+#define COMPILE_PIPE
+#endif
+#endif /*CONFIG_H */
+
diff --git a/src/ui/ui-drv/qt/config.pri b/src/ui/ui-drv/qt/config.pri
new file mode 100644
index 0000000..f666345
--- /dev/null
+++ b/src/ui/ui-drv/qt/config.pri
@@ -0,0 +1,4 @@
+HEADERS += \
+ $$PWD/config.h \
+ $$PWD/aconfig.h \
+ $$PWD/version.h
diff --git a/src/ui/ui-drv/qt/customdialog.cpp b/src/ui/ui-drv/qt/customdialog.cpp
new file mode 100644
index 0000000..d25a7d4
--- /dev/null
+++ b/src/ui/ui-drv/qt/customdialog.cpp
@@ -0,0 +1,179 @@
+#include <QtGui>
+
+
+#include "customdialog.h"
+
+#include "ui.h"
+
+CustomDialog::CustomDialog(struct uih_context *uih, const menuitem *item, const menudialog *dialog, QWidget *parent)
+ : QDialog(parent)
+{
+ m_menuitem = item;
+ m_dialog = dialog;
+ m_parameters = 0;
+
+ setWindowTitle(item->name);
+
+ QBoxLayout *dialogLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
+ QFormLayout *formLayout = new QFormLayout();
+
+ for (int i = 0; dialog[i].question; i++) {
+
+ QString label(dialog[i].question);
+ if (dialog[i].type == DIALOG_COORD) {
+
+ QLineEdit *real = new QLineEdit(QString::number(dialog[i].deffloat, 'g'), this);
+ real->setObjectName(label + "real");
+ real->setValidator(new QDoubleValidator(real));
+
+ QLineEdit *imag = new QLineEdit(QString::number(dialog[i].deffloat2, 'g'), this);
+ imag->setObjectName(label + "imag");
+ imag->setValidator(new QDoubleValidator(imag));
+
+ QBoxLayout *layout = new QBoxLayout(QBoxLayout::LeftToRight);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(real);
+ layout->addWidget(new QLabel("+", this));
+ layout->addWidget(imag);
+ layout->addWidget(new QLabel("i", this));
+
+ formLayout->addRow(label, layout);
+
+ } else if (dialog[i].type == DIALOG_IFILE || dialog[i].type == DIALOG_OFILE) {
+
+ QLineEdit *filename = new QLineEdit(dialog[i].defstr, this);
+ filename->setObjectName(label);
+
+ QToolButton *chooser = new QToolButton(this);
+ chooser->setObjectName(label);
+ chooser->setText("...");
+
+ if (dialog[i].type == DIALOG_IFILE)
+ connect(chooser, SIGNAL(clicked()), this, SLOT(chooseInputFile()));
+ else
+ connect(chooser, SIGNAL(clicked()), this, SLOT(chooseOutputFile()));
+
+ QBoxLayout *layout = new QBoxLayout(QBoxLayout::LeftToRight);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(filename);
+ layout->addWidget(chooser);
+
+ formLayout->addRow(label, layout);
+
+ } else if (dialog[i].type == DIALOG_CHOICE) {
+
+ QComboBox *combo = new QComboBox(this);
+ combo->setObjectName(label);
+
+ const char **str = (const char **)dialog[i].defstr;
+ for (int j = 0; str[j] != NULL; j++)
+ combo->addItem(str[j]);
+ combo->setCurrentIndex(dialog[i].defint);
+
+ formLayout->addRow(label, combo);
+
+ } else {
+
+ QLineEdit *field = new QLineEdit(this);
+ field->setObjectName(label);
+
+ if (dialog[i].type == DIALOG_INT) {
+ field->setText(QString::number(dialog[i].defint));
+ field->setValidator(new QIntValidator(field));
+ }
+ else if (dialog[i].type == DIALOG_FLOAT) {
+ field->setText(QString::number(dialog[i].deffloat, 'g'));
+ field->setValidator(new QDoubleValidator(field));
+ } else {
+ field->setText(dialog[i].defstr);
+ }
+
+ formLayout->addRow(label, field);
+
+ }
+ }
+
+ dialogLayout->addLayout(formLayout);
+
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(
+ (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help),
+ Qt::Horizontal, this);
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(showHelp()));
+ dialogLayout->addWidget(buttonBox);
+
+ setLayout(dialogLayout);
+}
+
+void CustomDialog::accept()
+{
+ int nitems;
+ for (nitems = 0; m_dialog[nitems].question; nitems++);
+ m_parameters = (dialogparam *)malloc(sizeof (*m_parameters) * nitems);
+
+ for (int i = 0; i < nitems; i++) {
+ QString label(m_dialog[i].question);
+
+ if (m_dialog[i].type == DIALOG_COORD) {
+
+ QLineEdit *real = findChild<QLineEdit *>(label + "real");
+ QLineEdit *imag = findChild<QLineEdit *>(label + "imag");
+
+ m_parameters[i].dcoord[0] = real->text().toFloat();
+ m_parameters[i].dcoord[1] = imag->text().toFloat();
+
+ } else if (m_dialog[i].type == DIALOG_CHOICE) {
+
+ QComboBox *field = findChild<QComboBox *>(label);
+ m_parameters[i].dint = field->currentIndex();
+
+ } else {
+
+ QLineEdit *field = findChild<QLineEdit *>(label);
+
+ if (m_dialog[i].type == DIALOG_INT)
+ m_parameters[i].dint = field->text().toInt();
+ else if (m_dialog[i].type == DIALOG_FLOAT)
+ m_parameters[i].number = field->text().toFloat();
+ else
+ m_parameters[i].dstring = strdup(field->text().toUtf8());
+ }
+ }
+
+ QDialog::accept();
+}
+
+dialogparam *CustomDialog::parameters()
+{
+ return m_parameters;
+}
+
+void CustomDialog::chooseInputFile()
+{
+ QLineEdit *field = findChild<QLineEdit *>(sender()->objectName());
+
+ QString filter = "XaoS Files (*.xpf *.xaf)";
+ QString directory = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
+
+ QString fileName = QFileDialog::getOpenFileName(this, sender()->objectName(), directory, filter);
+ if (!fileName.isNull())
+ {
+ field->setText(fileName);
+ }
+}
+
+void CustomDialog::chooseOutputFile()
+{
+ QLineEdit *field = findChild<QLineEdit *>(sender()->objectName());
+ QString directory = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
+
+ QString fileName = QFileDialog::getSaveFileName(this, sender()->objectName(), directory);
+ if (!fileName.isNull())
+ field->setText(fileName);
+}
+
+void CustomDialog::showHelp()
+{
+ ui_help(m_menuitem->shortname);
+}
diff --git a/src/ui/ui-drv/qt/customdialog.h b/src/ui/ui-drv/qt/customdialog.h
new file mode 100644
index 0000000..168e24f
--- /dev/null
+++ b/src/ui/ui-drv/qt/customdialog.h
@@ -0,0 +1,29 @@
+#ifndef CUSTOMDIALOG_H
+#define CUSTOMDIALOG_H
+
+#include <QDialog>
+
+#include "ui.h"
+
+class CustomDialog : public QDialog
+{
+ Q_OBJECT
+
+private:
+ const menuitem *m_menuitem;
+ const menudialog *m_dialog;
+ dialogparam *m_parameters;
+
+private slots:
+ void chooseInputFile();
+ void chooseOutputFile();
+ void showHelp();
+
+public:
+ CustomDialog(struct uih_context *uih, const menuitem *item, const menudialog *dialog, QWidget *parent = 0);
+
+ void accept();
+ dialogparam *parameters();
+};
+
+#endif // CUSTOMDIALOG_H
diff --git a/src/ui/ui-drv/qt/fractalwidget.cpp b/src/ui/ui-drv/qt/fractalwidget.cpp
new file mode 100644
index 0000000..0fa1141
--- /dev/null
+++ b/src/ui/ui-drv/qt/fractalwidget.cpp
@@ -0,0 +1,228 @@
+#include "fractalwidget.h"
+
+#include "ui.h"
+
+#include <QtGui>
+
+FractalWidget::FractalWidget()
+{
+ m_mouseButtons = 0;
+ m_mousePosition = QPoint(0, 0);
+ m_keyCombination = 0;
+ m_activeImage = 0;
+ m_image[0] = m_image[1] = 0;
+
+ setFocusPolicy(Qt::WheelFocus);
+ setMouseTracking(true);
+}
+
+void FractalWidget::updateMouse(QMouseEvent *event)
+{
+ m_mousePosition = event->pos();
+ m_mouseButtons = event->buttons();
+ m_keyboardModifiers = event->modifiers();
+}
+
+void FractalWidget::mousePressEvent(QMouseEvent *event)
+{
+ updateMouse(event);
+}
+
+void FractalWidget::mouseReleaseEvent(QMouseEvent *event)
+{
+ updateMouse(event);
+}
+
+void FractalWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ updateMouse(event);
+}
+
+void FractalWidget::wheelEvent(QWheelEvent *event)
+{
+}
+
+void FractalWidget::keyPressEvent(QKeyEvent *event)
+{
+ m_keyboardModifiers = event->modifiers();
+
+ switch (event->key()) {
+ case Qt::Key_Left:
+ m_keyCombination |= 1;
+ ui_key(UIKEY_LEFT);
+ break;
+ case Qt::Key_Right:
+ m_keyCombination |= 2;
+ ui_key(UIKEY_RIGHT);
+ break;
+ case Qt::Key_Up:
+ m_keyCombination |= 4;
+ ui_key(UIKEY_UP);
+ break;
+ case Qt::Key_Down:
+ m_keyCombination |= 8;
+ ui_key(UIKEY_DOWN);
+ break;
+ case Qt::Key_PageUp:
+ ui_key(UIKEY_PGUP);
+ break;
+ case Qt::Key_PageDown:
+ ui_key(UIKEY_PGDOWN);
+ break;
+ case Qt::Key_Backspace:
+ ui_key(UIKEY_BACKSPACE);
+ break;
+ case Qt::Key_Escape:
+ ui_key(UIKEY_ESC);
+ break;
+ case Qt::Key_Home:
+ ui_key(UIKEY_HOME);
+ break;
+ case Qt::Key_End:
+ ui_key(UIKEY_END);
+ break;
+ case Qt::Key_Tab:
+ ui_key(UIKEY_TAB);
+ break;
+ default:
+ if (!event->text().isEmpty())
+ ui_key(event->text().toAscii()[0]);
+ else
+ event->ignore();
+ }
+}
+
+void FractalWidget::keyReleaseEvent(QKeyEvent *event)
+{
+ m_keyboardModifiers = event->modifiers();
+
+ switch (event->key()) {
+ case Qt::Key_Left:
+ m_keyCombination &= ~1;
+ break;
+ case Qt::Key_Right:
+ m_keyCombination &= ~2;
+ break;
+ case Qt::Key_Up:
+ m_keyCombination &= ~4;
+ break;
+ case Qt::Key_Down:
+ m_keyCombination &= ~8;
+ break;
+ default:
+ event->ignore();
+ }
+}
+
+void FractalWidget::resizeEvent(QResizeEvent *event)
+{
+ if (m_image[0] && m_image[1])
+ ui_call_resize();
+}
+
+void FractalWidget::paintEvent (QPaintEvent *event)
+{
+ if (m_image[m_activeImage]) {
+ QPainter painter(this);
+ painter.drawImage(0, 0, *m_image[m_activeImage]);
+ }
+}
+
+void FractalWidget::createImages()
+{
+ m_image[0] = new QImage(width(), height(), QImage::Format_RGB32);
+ m_image[1] = new QImage(width(), height(), QImage::Format_RGB32);
+ m_activeImage = 0;
+}
+
+void FractalWidget::destroyImages()
+{
+ delete m_image[0];
+ delete m_image[1];
+}
+
+char *FractalWidget::imageBuffer1()
+{
+ return (char *)m_image[0]->bits();
+}
+
+char *FractalWidget::imageBuffer2()
+{
+ return (char *)m_image[1]->bits();
+}
+
+int FractalWidget::imageBytesPerLine()
+{
+ return m_image[0]->bytesPerLine();
+}
+
+void FractalWidget::switchActiveImage()
+{
+ m_activeImage ^= 1;
+}
+
+QPoint FractalWidget::mousePosition()
+{
+ return m_mousePosition;
+}
+
+int FractalWidget::mouseButtons()
+{
+
+ // Qt::MetaModifier maps to control key on Macs
+ Qt::KeyboardModifier controlModifier =
+#ifdef Q_WS_MAC
+ Qt::MetaModifier;
+#else
+ Qt::ControlModifier;
+#endif
+
+ int mouseButtons = 0;
+
+ // Modifier keys change behavior of left and right mouse buttons
+ if (m_keyboardModifiers & controlModifier) {
+ // Control key swaps left and right buttons
+ if (m_mouseButtons & Qt::LeftButton)
+ mouseButtons |= BUTTON3;
+ if (m_mouseButtons & Qt::RightButton)
+ mouseButtons |= BUTTON1;
+ } else if (m_keyboardModifiers & Qt::ShiftModifier) {
+ // Shift key makes left and right buttons emulate middle button
+ mouseButtons |= BUTTON2;
+ } else {
+ // Otherwise, mouse buttons map normally
+ if (m_mouseButtons & Qt::LeftButton)
+ mouseButtons |= BUTTON1;
+ if (m_mouseButtons & Qt::RightButton)
+ mouseButtons |= BUTTON3;
+ }
+
+ // Middle button is unaffected by modifier keys
+ if (m_mouseButtons & Qt::MidButton)
+ mouseButtons |= BUTTON2;
+
+ return mouseButtons;
+}
+
+int FractalWidget::keyCombination()
+{
+ return m_keyCombination;
+}
+
+void FractalWidget::setCursorType(int type)
+{
+ if (type == WAITMOUSE || type == REPLAYMOUSE)
+ setCursor(Qt::WaitCursor);
+ else
+ setCursor(Qt::ArrowCursor);
+}
+
+QSize FractalWidget::sizeHint() const
+{
+ return m_sizeHint;
+}
+
+void FractalWidget::setSizeHint(const QSize &size)
+{
+ m_sizeHint = size;
+}
diff --git a/src/ui/ui-drv/qt/fractalwidget.h b/src/ui/ui-drv/qt/fractalwidget.h
new file mode 100644
index 0000000..8fcdd8f
--- /dev/null
+++ b/src/ui/ui-drv/qt/fractalwidget.h
@@ -0,0 +1,57 @@
+#ifndef FRACTALWIDGET_H
+#define FRACTALWIDGET_H
+
+#include <QWidget>
+
+class QImage;
+class QPoint;
+
+class FractalWidget : public QWidget
+{
+ Q_OBJECT
+
+private:
+ QImage *m_image[2];
+ int m_activeImage;
+ QPoint m_mousePosition;
+ Qt::MouseButtons m_mouseButtons;
+ Qt::KeyboardModifiers m_keyboardModifiers;
+ int m_keyCombination;
+ QSize m_sizeHint;
+
+ void updateMouse(QMouseEvent *event);
+
+protected:
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void wheelEvent(QWheelEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *event);
+ void paintEvent (QPaintEvent *event);
+ void resizeEvent(QResizeEvent *event);
+
+public:
+ FractalWidget();
+
+ void createImages();
+ void destroyImages();
+
+ char *imageBuffer1();
+ char *imageBuffer2();
+ int imageBytesPerLine();
+ QSize imageSize();
+
+ void switchActiveImage();
+
+ QPoint mousePosition();
+ int mouseButtons();
+ int keyCombination();
+
+ void setCursorType(int type);
+
+ QSize sizeHint() const;
+ void setSizeHint(const QSize &size);
+};
+
+#endif // FRACTALWIDGET_H
diff --git a/src/ui/ui-drv/qt/images/xaosbig.png b/src/ui/ui-drv/qt/images/xaosbig.png
new file mode 100644
index 0000000..ce38dc3
--- /dev/null
+++ b/src/ui/ui-drv/qt/images/xaosbig.png
Binary files differ
diff --git a/src/ui/ui-drv/qt/main.cpp b/src/ui/ui-drv/qt/main.cpp
new file mode 100644
index 0000000..5100312
--- /dev/null
+++ b/src/ui/ui-drv/qt/main.cpp
@@ -0,0 +1,180 @@
+#include <QtGui/QApplication>
+
+#include "mainwindow.h"
+#include "fractalwidget.h"
+
+#include "ui.h"
+#include "filter.h"
+#include "ui_helper.h"
+#include "version.h"
+
+
+MainWindow *window;
+FractalWidget *widget;
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setApplicationName("XaoS");
+ QCoreApplication::setApplicationVersion(XaoS_VERSION);
+ QCoreApplication::setOrganizationName("XaoS Project");
+ QCoreApplication::setOrganizationDomain("xaos.sourceforge.net");
+
+ QApplication a(argc, argv);
+ MAIN_FUNCTION(argc, argv);
+ //return a.exec();
+}
+
+static int
+qt_initDriver ()
+{
+ window = new MainWindow();
+ widget = window->fractalWidget();
+ window->show();
+ return 1;
+}
+
+static void
+qt_uninitDriver ()
+{
+ delete window;
+}
+
+static int
+qt_allocBuffers (char **b1, char **b2)
+{
+ widget->createImages();
+ *b1 = widget->imageBuffer1();
+ *b2 = widget->imageBuffer2();
+ return widget->imageBytesPerLine();
+}
+
+static void
+qt_freeBuffers (char *b1, char *b2)
+{
+ widget->destroyImages();
+}
+
+static void
+qt_getImageSize (int *w, int *h)
+{
+ *w = widget->size().width();
+ *h = widget->size().height();
+}
+
+static void
+qt_flipBuffers ()
+{
+ widget->switchActiveImage();
+}
+
+static void
+qt_redrawImage()
+{
+ widget->update();
+}
+
+static void
+qt_processEvents (int wait, int *mx, int *my, int *mb, int *k)
+{
+ QCoreApplication::processEvents(wait ? QEventLoop::WaitForMoreEvents : QEventLoop::AllEvents);
+
+ *mx = widget->mousePosition().x();
+ *my = widget->mousePosition().y();
+ *mb = widget->mouseButtons();
+ *k = widget->keyCombination();
+}
+
+static void
+qt_getMouse (int *x, int *y, int *b)
+{
+ *x = widget->mousePosition().x();
+ *y = widget->mousePosition().y();
+ *b = widget->mouseButtons();
+}
+
+static void
+qt_printText(int x, int y, CONST char *text)
+{
+ window->showMessage(text);
+}
+
+static void
+qt_setCursorType (int type)
+{
+ widget->setCursorType(type);
+}
+
+static void
+qt_buildMenu (struct uih_context *uih, CONST char *name)
+{
+ window->buildMenu(uih, name);
+}
+
+static void
+qt_popupMenu (struct uih_context *uih, CONST char *name)
+{
+ window->popupMenu(uih, name);
+}
+
+static void
+qt_toggleMenu (struct uih_context *uih, CONST char *name)
+{
+ window->toggleMenu(uih, name);
+}
+
+static void
+qt_showDialog (struct uih_context *c, CONST char *name)
+{
+ window->showDialog(c, name);
+}
+
+static void
+qt_showHelp (struct uih_context *c, CONST char *name)
+{
+}
+
+struct gui_driver qt_gui_driver = {
+/* setrootmenu */ qt_buildMenu,
+/* enabledisable */ qt_toggleMenu,
+/* menu */ qt_popupMenu,
+/* dialog */ qt_showDialog,
+/* help */ NULL
+};
+
+static struct params qt_params[] = {
+{NULL, 0, NULL, NULL}
+};
+
+struct ui_driver qt_driver = {
+/* name */ "Qt Driver",
+/* init */ qt_initDriver,
+/* getsize */ qt_getImageSize,
+/* processevents */ qt_processEvents,
+/* getmouse */ qt_getMouse,
+/* uninit */ qt_uninitDriver,
+/* set_color */ NULL,
+/* set_range */ NULL,
+/* print */ qt_printText,
+/* display */ qt_redrawImage,
+/* alloc_buffers */ qt_allocBuffers,
+/* free_buffers */ qt_freeBuffers,
+/* filp_buffers */ qt_flipBuffers,
+/* mousetype */ qt_setCursorType,
+/* flush */ NULL,
+/* textwidth */ 12,
+/* textheight */ 12,
+/* params */ qt_params,
+/* flags */ PIXELSIZE,
+/* width */ 0.01,
+/* height */ 0.01,
+/* maxwidth */ 0,
+/* maxheight */ 0,
+/* imagetype */ UI_TRUECOLOR,
+/* palettestart */ 0,
+/* paletteend */ 256,
+/* maxentries */ 255,
+/* rmask */ 0xff0000,
+/* gmask */ 0x00ff00,
+/* bmask */ 0x0000ff,
+/* gui_driver */ &qt_gui_driver
+};
diff --git a/src/ui/ui-drv/qt/mainwindow.cpp b/src/ui/ui-drv/qt/mainwindow.cpp
new file mode 100644
index 0000000..aa03e66
--- /dev/null
+++ b/src/ui/ui-drv/qt/mainwindow.cpp
@@ -0,0 +1,172 @@
+#include "mainwindow.h"
+#include "fractalwidget.h"
+#include "customdialog.h"
+
+#include "ui.h"
+
+#include <QtGui>
+
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setWindowTitle(QCoreApplication::applicationName());
+
+ statusBar()->show();
+
+ m_fractalWidget = new FractalWidget();
+ setCentralWidget(m_fractalWidget);
+
+ readSettings();
+}
+
+MainWindow::~MainWindow()
+{
+}
+
+FractalWidget *MainWindow::fractalWidget()
+{
+ return m_fractalWidget;
+}
+
+void MainWindow::readSettings()
+{
+ QSettings settings;
+ QPoint pos = settings.value("windowPosition", QPoint(200, 200)).toPoint();
+ QSize size = settings.value("imageSize", QSize(640, 480)).toSize();
+ m_fractalWidget->setSizeHint(size);
+ move(pos);
+}
+
+void MainWindow::writeSettings()
+{
+ QSettings settings;
+ settings.setValue("windowPosition", pos());
+ settings.setValue("imageSize", size());
+}
+
+void MainWindow::closeEvent(QCloseEvent *event)
+{
+ writeSettings();
+ ui_quit();
+}
+
+void MainWindow::showMessage(const QString &message)
+{
+ statusBar()->showMessage(message, 5000);
+}
+
+QKeySequence::StandardKey MainWindow::keyForItem(const QString &name)
+{
+ if (name =="initstate") return QKeySequence::New;
+ if (name =="loadpos") return QKeySequence::Open;
+ if (name =="savepos") return QKeySequence::Save;
+ if (name =="undo") return QKeySequence::Undo;
+ if (name =="redo") return QKeySequence::Redo;
+ if (name =="recalculate") return QKeySequence::Refresh;
+ if (name =="help") return QKeySequence::HelpContents;
+
+ return QKeySequence::UnknownKey;
+}
+
+void MainWindow::buildMenu(struct uih_context *uih, const char *name)
+{
+ menuBar()->clear();
+
+ const menuitem *item;
+ for (int i = 0; (item = menu_item(name, i)) != NULL; i++) {
+ if (item->type == MENU_SUBMENU) {
+ QMenu *menu = menuBar()->addMenu(QString(item->name));
+ buildMenu(uih, item->shortname, menu);
+ }
+ }
+}
+
+void MainWindow::buildMenu(struct uih_context *uih, const char *name, QMenu *parent)
+{
+ QActionGroup *group = new QActionGroup(parent);
+
+ const menuitem *item;
+ for (int i = 0; (item = menu_item(name, i)) != NULL; i++) {
+
+ QString itemName(item->name);
+ if (item->type == MENU_DIALOG || item->type == MENU_CUSTOMDIALOG)
+ itemName += "...";
+
+ if (item->type == MENU_SEPARATOR) {
+ parent->addSeparator();
+ } else if (item->type == MENU_SUBMENU) {
+ QMenu *menu = parent->addMenu(item->name);
+ buildMenu(uih, item->shortname, menu);
+ } else {
+ QAction *action = new QAction(itemName, parent);
+ action->setShortcuts(keyForItem(item->shortname));
+ action->setObjectName(item->shortname);
+ if (item->flags & (MENUFLAG_RADIO | MENUFLAG_CHECKBOX)) {
+ action->setCheckable(true);
+ action->setChecked(menu_enabled(item, uih));
+ if (item->flags & MENUFLAG_RADIO)
+ action->setActionGroup(group);
+ }
+ connect(action, SIGNAL(triggered()), this, SLOT(activateMenuItem()));
+ parent->addAction(action);
+ }
+ }
+}
+
+void MainWindow::popupMenu(struct uih_context *uih, const char *name)
+{
+ QMenu *menu = new QMenu(this);
+ buildMenu(uih, name, menu);
+ menu->exec(QCursor::pos());
+ delete menu;
+}
+
+void MainWindow::toggleMenu(struct uih_context *uih, const char *name)
+{
+ const menuitem *item = menu_findcommand(name);
+ QAction *action = menuBar()->findChild<QAction *>(name);
+ if (action)
+ action->setChecked(menu_enabled(item, uih));
+}
+
+void MainWindow::activateMenuItem()
+{
+ QAction *action = qobject_cast<QAction *>(sender());
+ const menuitem *item = menu_findcommand(action->objectName().toAscii());
+ ui_menuactivate(item, NULL);
+}
+
+void MainWindow::showDialog(struct uih_context *uih, const char *name)
+{
+ const menuitem *item = menu_findcommand(name);
+ if (!item) return;
+
+ const menudialog *dialog = menu_getdialog(uih, item);
+ if (!dialog) return;
+
+ int nitems;
+ for (nitems = 0; dialog[nitems].question; nitems++);
+
+ if (nitems == 1 && (dialog[0].type == DIALOG_IFILE || dialog[0].type == DIALOG_OFILE)) {
+ QString filter = QString("*.%1").arg(QFileInfo(dialog[0].defstr).completeSuffix());
+ QString directory;// = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
+
+ QString fileName;
+ if (dialog[0].type == DIALOG_IFILE)
+ fileName = QFileDialog::getOpenFileName(this, item->name, directory, filter);
+ else if (dialog[0].type == DIALOG_OFILE)
+ fileName = QFileDialog::getSaveFileName(this, item->name, directory, filter);
+
+
+ if (!fileName.isNull()) {
+ dialogparam *param = (dialogparam *)malloc(sizeof(dialogparam));
+ param->dstring = strdup(fileName.toUtf8());
+ ui_menuactivate(item, param);
+ }
+ } else {
+ CustomDialog customDialog(uih, item, dialog, this);
+ if (customDialog.exec() == QDialog::Accepted)
+ ui_menuactivate(item, customDialog.parameters());
+ }
+}
diff --git a/src/ui/ui-drv/qt/mainwindow.h b/src/ui/ui-drv/qt/mainwindow.h
new file mode 100644
index 0000000..ffead6d
--- /dev/null
+++ b/src/ui/ui-drv/qt/mainwindow.h
@@ -0,0 +1,43 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QtGui/QMainWindow>
+
+class QImage;
+class FractalWidget;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+private:
+ FractalWidget *m_fractalWidget;
+
+ void readSettings();
+ void writeSettings();
+
+ static QKeySequence::StandardKey keyForItem(const QString &name);
+
+protected:
+ void closeEvent(QCloseEvent *event);
+
+private slots:
+ void activateMenuItem();
+
+ public:
+ MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+ FractalWidget *fractalWidget();
+
+ void showMessage(const QString &message);
+
+ void buildMenu(struct uih_context *uih, const char *name);
+ void buildMenu(struct uih_context *uih, const char *name, QMenu *parent);
+ void popupMenu(struct uih_context *uih, const char *name);
+ void toggleMenu(struct uih_context *uih, const char *name);
+
+ void showDialog(struct uih_context *uih, const char *name);
+};
+
+#endif // MAINWINDOW_H
diff --git a/src/ui/ui-drv/qt/ui_qt.c b/src/ui/ui-drv/qt/ui_qt.c
new file mode 100644
index 0000000..1ac3b0a
--- /dev/null
+++ b/src/ui/ui-drv/qt/ui_qt.c
@@ -0,0 +1,99 @@
+#include "aconfig.h"
+#ifdef TEMPLATE_DRIVER
+/*includes */
+#include <ui.h>
+
+static int template_set_color(int r, int g, int b, int init)
+{
+ return ( /*pixel value or -1 for full palette */ -1);
+}
+
+static void template_setpalette(ui_palette pal, int start, int end)
+{
+}
+
+static void template_print(int x, int y, CONST char *text)
+{
+}
+
+static void template_display()
+{
+}
+
+static void template_flip_buffers()
+{
+}
+
+void template_free_buffers(char *b1, char *b2)
+{
+}
+
+int template_alloc_buffers(char **b1, char **b2)
+{
+ return 1; /* bytes per scanline */
+}
+
+static void template_getsize(int *w, int *h)
+{
+}
+
+static void
+template_processevents(int wait, int *mx, int *my, int *mb, int *k)
+{
+}
+
+static int template_init()
+{
+ return ( /*1 for sucess 0 for fail */ 1);
+}
+
+static void template_uninitialise()
+{
+}
+
+static void template_getmouse(int *x, int *y, int *b)
+{
+}
+
+
+static void template_mousetype(int type)
+{
+}
+
+static struct params params[] = {
+ {"", P_HELP, NULL, "Template driver options:"},
+ {"-flag", P_SWITCH, &variable, "Example flag..."},
+ {NULL, 0, NULL, NULL}
+};
+
+struct ui_driver template_driver = {
+ "Template",
+ template_init,
+ template_getsize,
+ template_processevents,
+ template_getmouse,
+ template_uninitialise,
+ template_set_color, /*You should implement just one */
+ template_set_palette, /*of these and add NULL as second */
+ template_print,
+ template_display,
+ template_alloc_buffers,
+ template_free_buffers,
+ template_flip_buffers,
+ template_mousetype, /*This should be NULL */
+ NULL, /*flush */
+ 8, /*text width */
+ 8, /*text height */
+ UGLYTEXTSIZE,
+ params,
+ 0, /*flags...see ui.h */
+ 0.0, 0.0, /*width/height of screen in centimeters */
+ 0, 0, /*resolution of screen for windowed systems */
+ UI_C256, /*Image type */
+ 0, 255, 255 /*start, end of palette and maximum allocatable */
+ /*entries */
+};
+
+/* DONT FORGET TO ADD DOCUMENTATION ABOUT YOUR DRIVER INTO xaos.hlp FILE!*/
+
+#endif
diff --git a/src/ui/ui-drv/qt/version.h b/src/ui/ui-drv/qt/version.h
new file mode 100644
index 0000000..94cd83e
--- /dev/null
+++ b/src/ui/ui-drv/qt/version.h
@@ -0,0 +1,23 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996,1997 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * This program 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define XaoS_VERSION "4.0"
diff --git a/src/ui/ui-drv/qt/xaos.ico b/src/ui/ui-drv/qt/xaos.ico
new file mode 100644
index 0000000..12347f5
--- /dev/null
+++ b/src/ui/ui-drv/qt/xaos.ico
Binary files differ
diff --git a/src/ui/ui-drv/qt/xaos.rc b/src/ui/ui-drv/qt/xaos.rc
new file mode 100644
index 0000000..6235fef
--- /dev/null
+++ b/src/ui/ui-drv/qt/xaos.rc
@@ -0,0 +1 @@
+IDI_ICON1 ICON DISCARDABLE "xaos.ico"