Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/Makefile.in51
-rw-r--r--src/ui/dialog.c1521
-rw-r--r--src/ui/drivers.c89
-rw-r--r--src/ui/filesel.c677
-rw-r--r--src/ui/fparams.c112
-rw-r--r--src/ui/param.c172
-rw-r--r--src/ui/pipecmd.c113
-rw-r--r--src/ui/ui-drv/aa/Makefile.in39
-rw-r--r--src/ui/ui-drv/aa/ui_aa.c724
-rw-r--r--src/ui/ui-drv/cocoa/AppController.h59
-rw-r--r--src/ui/ui-drv/cocoa/AppController.m542
-rw-r--r--src/ui/ui-drv/cocoa/CustomDialog.h38
-rw-r--r--src/ui/ui-drv/cocoa/CustomDialog.m433
-rw-r--r--src/ui/ui-drv/cocoa/English.lproj/Credits.html26
-rw-r--r--src/ui/ui-drv/cocoa/English.lproj/InfoPlist.stringsbin0 -> 420 bytes
-rw-r--r--src/ui/ui-drv/cocoa/English.lproj/MainMenu.nib/designable.nib498
-rw-r--r--src/ui/ui-drv/cocoa/English.lproj/MainMenu.nib/keyedobjects.nibbin0 -> 4197 bytes
-rw-r--r--src/ui/ui-drv/cocoa/FractalView.h70
-rw-r--r--src/ui/ui-drv/cocoa/FractalView.m347
-rw-r--r--src/ui/ui-drv/cocoa/HowToBuild.txt47
-rw-r--r--src/ui/ui-drv/cocoa/Info.plist69
-rw-r--r--src/ui/ui-drv/cocoa/Japanese.lproj/InfoPlist.stringsbin0 -> 208 bytes
-rw-r--r--src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/classes.nib4
-rw-r--r--src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/info.nib17
-rw-r--r--src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/keyedobjects.nibbin0 -> 10793 bytes
-rw-r--r--src/ui/ui-drv/cocoa/Read Me.rtf193
-rw-r--r--src/ui/ui-drv/cocoa/Readme Cocoa390
-rw-r--r--src/ui/ui-drv/cocoa/VideatorProxy.h42
-rw-r--r--src/ui/ui-drv/cocoa/VideatorProxy.m157
-rw-r--r--src/ui/ui-drv/cocoa/XaoS.icnsbin0 -> 223269 bytes
-rw-r--r--src/ui/ui-drv/cocoa/XaoS.xcodeproj/project.pbxproj831
-rw-r--r--src/ui/ui-drv/cocoa/XaoSDocument.icnsbin0 -> 127993 bytes
-rw-r--r--src/ui/ui-drv/cocoa/XaoS_Prefix.pch7
-rw-r--r--src/ui/ui-drv/cocoa/aconfig.h123
-rw-r--r--src/ui/ui-drv/cocoa/grlib_cocoa.m142
-rw-r--r--src/ui/ui-drv/cocoa/performanceCursor.tiffbin0 -> 4478 bytes
-rw-r--r--src/ui/ui-drv/cocoa/ui_cocoa.m267
-rw-r--r--src/ui/ui-drv/cocoa/version.h22
-rw-r--r--src/ui/ui-drv/gtk/Makefile.in39
-rw-r--r--src/ui/ui-drv/gtk/ui_gtk.c764
-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
-rw-r--r--src/ui/ui-drv/template/Makefile.in39
-rw-r--r--src/ui/ui-drv/template/ui_template.c99
-rw-r--r--src/ui/ui-drv/win32/Makefile.in43
-rw-r--r--src/ui/ui-drv/win32/about.c239
-rw-r--r--src/ui/ui-drv/win32/about.h20
-rw-r--r--src/ui/ui-drv/win32/about.rc19
-rw-r--r--src/ui/ui-drv/win32/dxguid.c1102
-rw-r--r--src/ui/ui-drv/win32/installer/XaoS Installer.nsi138
-rw-r--r--src/ui/ui-drv/win32/installer/XaoS.bmpbin0 -> 25818 bytes
-rw-r--r--src/ui/ui-drv/win32/resource.h3
-rw-r--r--src/ui/ui-drv/win32/small.icobin0 -> 2294 bytes
-rw-r--r--src/ui/ui-drv/win32/ui_win32.c1886
-rw-r--r--src/ui/ui-drv/win32/ui_win32.h20
-rw-r--r--src/ui/ui-drv/win32/version.rc39
-rw-r--r--src/ui/ui-drv/win32/windialo.c471
-rw-r--r--src/ui/ui-drv/win32/winmenu.c243
-rw-r--r--src/ui/ui-drv/win32/xaos.dlg228
-rw-r--r--src/ui/ui-drv/win32/xaos.exe.manifest10
-rw-r--r--src/ui/ui-drv/win32/xaos.icobin0 -> 135286 bytes
-rw-r--r--src/ui/ui-drv/win32/xaos.rc16
-rw-r--r--src/ui/ui-drv/x11/Makefile.in40
-rw-r--r--src/ui/ui-drv/x11/ui_x11.c597
-rw-r--r--src/ui/ui-drv/x11/xlib.c663
-rw-r--r--src/ui/ui-drv/x11/xlib.h139
-rw-r--r--src/ui/ui.c1761
-rw-r--r--src/ui/ui.pri10
-rw-r--r--src/ui/uihelp.c486
-rw-r--r--src/ui/uiint.h75
-rw-r--r--src/ui/uimenu.c572
87 files changed, 18844 insertions, 0 deletions
diff --git a/src/ui/Makefile.in b/src/ui/Makefile.in
new file mode 100644
index 0000000..0db3230
--- /dev/null
+++ b/src/ui/Makefile.in
@@ -0,0 +1,51 @@
+CC = @CC@
+CFLAGS = @CFLAGS@
+LIBS = @LIBS@ -lm
+LFLAGS = @LDFLAGS@
+AR = @AR@
+RANLIB = @RANLIB@
+
+SRCS = \
+ drivers.c \
+ ui.c \
+ uihelp.c \
+ param.c \
+ fparams.c \
+ filesel.c \
+ uimenu.c \
+ pipecmd.c \
+ dialog.c
+
+OBJS = $(SRCS:.c=.o)
+
+TLIB = ../lib/libui.a
+
+
+all: $(TLIB)
+
+$(TLIB):$(OBJS)
+ rm -f $@
+ $(AR) rc $@ $(OBJS)
+ $(RANLIB) $@
+
+keywords.c: keywords.gperf
+ gperf -t -p -D -C -a keywords.gperf > keywords.c
+
+clean:
+ rm -f $(TLIB)
+ rm -f *.[oas]
+ rm -f *~
+ rm -f core
+
+distclean:clean
+ rm Makefile
+
+#dep:
+# rm -f .depend
+# make .depend
+#
+#.depend:
+# echo '# Program dependencies' >.depend
+# gcc -I svgalib $(DEFINES) -MM $(patsubst %.o,%.c,$(OBJS)) >>.depend
+#
+#include .depend
diff --git a/src/ui/dialog.c b/src/ui/dialog.c
new file mode 100644
index 0000000..d5c6aae
--- /dev/null
+++ b/src/ui/dialog.c
@@ -0,0 +1,1521 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 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.
+ */
+#undef _EFENCE_
+#include <config.h>
+#ifdef _plan9_
+#include <u.h>
+#include <libc.h>
+#include <ctype.h>
+#else
+#include <aconfig.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <math.h>
+#ifndef _MAC
+#include <sys/stat.h>
+#endif
+#endif
+#include <fconfig.h>
+#ifndef _plan9_
+#include <assert.h>
+#endif
+#include <filter.h>
+#include <fractal.h>
+#include <ui_helper.h>
+#include <ui.h>
+#include <xmenu.h>
+#include <grlib.h>
+#include "uiint.h"
+#include <xldio.h>
+#include <misc-f.h>
+
+#ifdef HAVE_GETTEXT
+#include <libintl.h>
+#else
+#define gettext(STRING) STRING
+#endif
+
+struct dialogitem;
+struct dialogtype {
+ void (*build) (struct dialogitem * item, CONST menudialog * entry);
+ int (*key) (struct dialogitem * item, int key);
+ void (*mouse) (struct dialogitem * item, int x, int y, int buttons,
+ int flags);
+ void (*destroy) (struct dialogitem * item, dialogparam * param);
+ void (*draw) (struct dialogitem * item);
+ void (*unselect) (struct dialogitem * item);
+};
+struct dialogitem {
+ int y;
+ int width, width1, height;
+ CONST menudialog *dialog;
+ void *data;
+ CONST struct dialogtype *type;
+};
+static struct opendialog {
+ int x, y, width, height;
+ int half;
+ int nitems;
+ CONST menudialog *dialog;
+ int mousereleased;
+ int mousegrab;
+ CONST menuitem *item;
+ int current;
+ struct dialogitem *items;
+ struct uih_window *window;
+} dialog;
+
+static dialogparam *qparam;
+static CONST menuitem *qitem;
+
+int dialogvisible;
+
+int yesnodialogvisible;
+static struct yesnodialog {
+ int width;
+ int questionwidth;
+ int mousereleased;
+ char *question;
+ void (*handler) (int yes);
+ int selected;
+ int pressed;
+ struct uih_window *window;
+} yesnodialog;
+
+// These 3 definitions are no longer used:
+static CONST char *CONST oktext = "OK";
+static CONST char *CONST canceltext = "Cancel";
+static CONST char *CONST helptext = "Help";
+
+static int okwidth;
+static int cancelwidth;
+#define SELECTED(item) ((item-dialog.items)==dialog.current)
+static void NEXT(void)
+{
+ dialog.items[dialog.current].type->unselect(dialog.items +
+ dialog.current);
+ dialog.current = (dialog.current + 1) % dialog.nitems;
+ uih->display = 1;
+}
+
+static void PREV(void)
+{
+ dialog.items[dialog.current].type->unselect(dialog.items +
+ dialog.current);
+ dialog.current =
+ dialog.current ? (dialog.current - 1) : dialog.nitems - 1;
+ uih->display = 1;
+}
+
+struct okdata {
+ int pressed;
+ int selected;
+};
+
+CONST char *CONST yestext = "Yes";
+CONST char *CONST notext = "No";
+#define YESNOX ((uih->image->width-yesnodialog.width)/2)
+#define YESNOHEIGHT (2*BUTTONHEIGHT+2*BORDERHEIGHT)
+#define YESNOY ((uih->image->height-YESNOHEIGHT)/2)
+void
+ui_drawbutton(CONST char *text, int pressed, int selected, int x1, int x2,
+ int y)
+{
+ int width = xtextwidth(uih->font, text);
+ /*printf("%s %i %i\n",text,pressed,selected); */
+ if (uih->palette->type & BITMAPS) {
+ uih_drawborder(uih, x1, y, x2 - x1, BUTTONHEIGHT,
+ (pressed != 0
+ || selected != 0) * BORDER_PRESSED | BORDER_LIGHT);
+ xprint(uih->image, uih->font, (x1 + x2 - width) / 2 + pressed,
+ y + BORDERHEIGHT + pressed, text, selected
+ || pressed ? BGCOLOR(uih) : FGCOLOR(uih), BGCOLOR(uih),
+ TEXT_PRESSED);
+ } else {
+ uih_drawborder(uih, x1, y, x2 - x1, BUTTONHEIGHT,
+ (pressed != 0) * BORDER_PRESSED | BORDER_LIGHT);
+ xprint(uih->image, uih->font, (x1 + x2 - width) / 2 + pressed,
+ y + BORDERHEIGHT + pressed, text,
+ selected ? SELCOLOR(uih) : FGCOLOR(uih), BGCOLOR(uih),
+ /*TEXT_PRESSED */ 0);
+ }
+}
+
+static void
+ui_yesnopos(struct uih_context *c, int *x, int *y, int *w, int *h,
+ void *data)
+{
+#ifdef _plan9_
+#define filevisible 0
+#endif
+ if (filevisible || helpvisible) {
+ *x = *y = *w = *h = 0;
+ return;
+ }
+ *w = yesnodialog.width;
+ *h = YESNOHEIGHT;
+ *x = YESNOX;
+ *y = YESNOY;
+}
+
+static void ui_drawyesno(struct uih_context *c, void *data)
+{
+ xprint(uih->image, uih->font,
+ YESNOX + (yesnodialog.width - yesnodialog.questionwidth) / 2,
+ YESNOY + BORDERHEIGHT, yesnodialog.question,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ ui_drawbutton(yestext, yesnodialog.pressed == 0,
+ yesnodialog.selected == 0, YESNOX + BORDERWIDTH + 1,
+ YESNOX + (yesnodialog.width) / 2 - 1,
+ YESNOY + BUTTONHEIGHT + BORDERHEIGHT);
+ ui_drawbutton(notext, yesnodialog.pressed == 1,
+ yesnodialog.selected == 1,
+ YESNOX + (yesnodialog.width) / 2 + 1,
+ YESNOX + yesnodialog.width - BORDERWIDTH - 1,
+ YESNOY + BUTTONHEIGHT + BORDERHEIGHT);
+}
+
+static void ui_closeyesno(int success)
+{
+ if (!yesnodialogvisible)
+ return;
+ free(yesnodialog.question);
+ yesnodialog.handler(success);
+ yesnodialogvisible = 0;
+ uih_removew(uih, yesnodialog.window);
+ uih->display = 1;
+}
+
+void ui_buildyesno(CONST char *question, void (*handler) (int yes))
+{
+ if (yesnodialogvisible)
+ ui_closeyesno(0);
+ yesnodialogvisible = 1;
+ yesnodialog.questionwidth = xtextwidth(uih->font, question);
+ yesnodialog.question = mystrdup(question);
+ yesnodialog.mousereleased = 0;
+ yesnodialog.width =
+ xtextwidth(uih->font, yestext) + xtextwidth(uih->font,
+ notext) +
+ 8 * BORDERWIDTH + 2;
+ if (yesnodialog.width < yesnodialog.questionwidth)
+ yesnodialog.width = yesnodialog.questionwidth;
+ yesnodialog.width += 2 * BORDERWIDTH;
+ yesnodialog.handler = handler;
+ yesnodialog.selected = 0;
+ yesnodialog.pressed = -1;
+ yesnodialog.window =
+ uih_registerw(uih, ui_yesnopos, ui_drawyesno, NULL, DRAWBORDER);
+ uih->display = 1;
+}
+
+static int ui_keyyesno(int key)
+{
+ if (!yesnodialogvisible)
+ return 0;
+ switch (key) {
+ case UIKEY_LEFT:
+ yesnodialog.selected ^= 1;
+ uih->display = 1;
+ return 1;
+ case UIKEY_UP:
+ return 1;
+ case UIKEY_RIGHT:
+ case UIKEY_TAB:
+ yesnodialog.selected ^= 1;
+ uih->display = 1;
+ return 1;
+ case UIKEY_DOWN:
+ return 1;
+ case 13:
+ case '\n':
+ ui_closeyesno(!yesnodialog.selected);
+ return 1;
+ case UIKEY_ESC:
+ ui_closeyesno(0);
+ return 1;
+ }
+ return 1;
+}
+
+static int ui_mouseyesno(int x, int y, int buttons, int flags)
+{
+ int mouseat = 0;
+ if (!yesnodialogvisible)
+ return 0;
+ if (!yesnodialog.mousereleased && (flags & MOUSE_RELEASE)) {
+ yesnodialog.mousereleased = 1;
+ return 1;
+ }
+ if (!yesnodialog.mousereleased && (flags & MOUSE_DRAG)) {
+ return 1;
+ }
+ yesnodialog.mousereleased = 1;
+ if (x < YESNOX || y < YESNOY || x > YESNOX + yesnodialog.width
+ || y > YESNOY + YESNOHEIGHT) {
+ if (flags & MOUSE_PRESS) {
+ ui_closeyesno(0);
+ } else {
+ if (yesnodialog.pressed != -1)
+ uih->display = 1;
+ yesnodialog.pressed = -1;
+ }
+ return 1;
+ }
+ if (x > YESNOX + yesnodialog.width / 2)
+ mouseat = 1;
+ if (flags & MOUSE_DRAG) {
+ if (yesnodialog.pressed != mouseat)
+ uih->display = 1;
+ if (yesnodialog.selected != mouseat)
+ uih->display = 1;
+ yesnodialog.selected = mouseat;
+ yesnodialog.pressed = mouseat;
+ } else {
+ if ((flags & MOUSE_MOVE) && yesnodialog.selected != mouseat)
+ uih->display = 1, yesnodialog.selected = mouseat;
+ if (yesnodialog.pressed != -1)
+ uih->display = 1;
+ yesnodialog.pressed = -1;
+ }
+ if (flags & MOUSE_RELEASE) {
+ ui_closeyesno(!mouseat);
+ }
+ return 1;
+}
+
+static void ui_buildok(struct dialogitem *item, CONST menudialog * entry)
+{
+ struct okdata *ok;
+ item->height = BUTTONHEIGHT;
+ okwidth = xtextwidth(uih->font, gettext("OK"));
+ cancelwidth = xtextwidth(uih->font, gettext("Cancel"));
+ item->width = okwidth + 2 * BORDERWIDTH + 2;
+ item->width1 = cancelwidth + 2 * BORDERWIDTH + 2;
+ if (item->width < item->width1)
+ item->width = item->width1;
+ if (item->width > item->width1)
+ item->width1 = item->width;
+ item->data = ok = (struct okdata *) malloc(sizeof(struct okdata));
+ ok->pressed = -1;
+ ok->selected = 0;
+}
+
+static void ui_destroyok(struct dialogitem *item, dialogparam * param)
+{
+ free(item->data);
+}
+
+static int ui_keyok(struct dialogitem *item, int key)
+{
+ struct okdata *ok = (struct okdata *) item->data;
+ switch (key) {
+ case UIKEY_LEFT:
+ if (ok->selected >= 1) {
+ ok->selected--;
+ uih->display = 1;
+ return 1;
+ }
+ case UIKEY_UP:
+ PREV();
+ return 1;
+ case UIKEY_RIGHT:
+ case UIKEY_TAB:
+ if (ok->selected < 2) {
+ ok->selected++;
+ uih->display = 1;
+ return 1;
+ }
+ case UIKEY_DOWN:
+ NEXT();
+ return 1;
+ case 13:
+ case '\n':
+ if (ok->selected <= 1)
+ ui_closedialog(!ok->selected);
+ else
+ ui_help(dialog.item->shortname);
+ return 1;
+ }
+ return 0;
+}
+
+static void
+ui_mouseok(struct dialogitem *item, int x, int y, int buttons, int flags)
+{
+ struct okdata *ok = (struct okdata *) item->data;
+ int mouseat = 0;
+ if (x > dialog.x + dialog.width / 3)
+ mouseat = 1;
+ if (x > dialog.x + 2 * dialog.width / 3)
+ mouseat = 2;
+ if (flags & MOUSE_DRAG) {
+ if (ok->pressed != mouseat)
+ uih->display = 1;
+ if (ok->selected != mouseat)
+ uih->display = 1;
+ ok->selected = mouseat;
+ ok->pressed = mouseat;
+ } else {
+ if ((flags & MOUSE_MOVE) && ok->selected != mouseat)
+ uih->display = 1, ok->selected = mouseat;
+ if (ok->pressed != -1)
+ uih->display = 1;
+ ok->pressed = -1;
+ }
+ if (flags & MOUSE_RELEASE) {
+ if (mouseat < 2)
+ ui_closedialog(!mouseat);
+ else
+ ui_help(dialog.item->shortname);
+ }
+}
+
+static void ui_drawok(struct dialogitem *item)
+{
+ struct okdata *ok = (struct okdata *) item->data;
+ ui_drawbutton(gettext("OK"), ok->pressed == 0, SELECTED(item)
+ && ok->selected == 0, dialog.x + BORDERWIDTH + 1,
+ dialog.x + (dialog.width) / 3 - 1, item->y);
+ ui_drawbutton(gettext("Cancel"), ok->pressed == 1, SELECTED(item)
+ && ok->selected == 1, dialog.x + (dialog.width) / 3 + 1,
+ dialog.x + 2 * dialog.width / 3 - BORDERWIDTH, item->y);
+ ui_drawbutton(gettext("Help"), ok->pressed == 2, SELECTED(item)
+ && ok->selected == 2, dialog.x + 2 * (dialog.width) / 3,
+ dialog.x + dialog.width - BORDERWIDTH - 1, item->y);
+}
+
+static void ui_unselectok(struct dialogitem *item)
+{
+ struct okdata *ok = (struct okdata *) item->data;
+ ok->pressed = -1;
+ ok->selected = 0;
+ uih->display = 1;
+}
+
+CONST static struct dialogtype okdialog = {
+ ui_buildok,
+ ui_keyok,
+ ui_mouseok,
+ ui_destroyok,
+ ui_drawok,
+ ui_unselectok
+};
+
+void ui_updatetext(struct ui_textdata *d)
+{
+ int again = 1;
+ int i;
+ int wi;
+ int len = (int) strlen(d->text);
+ if (d->start >= len)
+ d->start = 0;
+ if (d->cursor > len)
+ d->cursor = len;
+ if (d->cursor < d->start)
+ d->start = d->cursor;
+ do {
+ wi = 0;
+ for (i = 0; d->text[d->start + i]; i++) {
+ if (d->start + i == d->cursor)
+ d->cursorpos = wi;
+ wi += xtextcharw(uih->font, d->text[d->start + i]);
+ if (wi >= d->width) {
+ break;
+ }
+ }
+ if (d->start + i == d->cursor && wi < d->width)
+ d->cursorpos = wi;
+ if (d->start + i < d->cursor)
+ d->start++;
+ else
+ again = 0;
+ }
+ while (again);
+ d->ndisplayed = i;
+ while (again);
+}
+
+struct ui_textdata *ui_opentext(int x, int y, int width, CONST char *def)
+{
+ struct ui_textdata *d = (struct ui_textdata *) malloc(sizeof(*d));
+ char *text;
+ int size = 100;
+ if ((int) strlen(def) > size)
+ size = (int) strlen(def) * 2;
+ d->x = x;
+ d->y = y;
+ d->width = width;
+ text = (char *) malloc(size);
+ strcpy(text, def);
+ d->text = text;
+ d->cursor = 0;
+ d->cursorpos = 0;
+ d->start = 0;
+ d->ndisplayed = 0;
+ d->clear = 1;
+ d->size = size;
+ ui_updatetext(d);
+ return (d);
+}
+
+void ui_drawtext(struct ui_textdata *d, int active)
+{
+ char *c = (char *) malloc(d->ndisplayed + 2);
+ strncpy(c, d->text + d->start, d->ndisplayed);
+ c[d->ndisplayed] = 0;
+ xprint(uih->image, uih->font, d->x, d->y, c,
+ (uih->palette->type & BITMAPS) ? BGCOLOR(uih) : ((active
+ && d->clear) ?
+ SELCOLOR(uih) :
+ FGCOLOR(uih)),
+ BGCOLOR(uih),
+ (uih->palette->type & BITMAPS) ? TEXT_PRESSED : 0);
+ if (active) {
+ xdrawcursor(uih->image, d->x + d->cursorpos, d->y,
+ (uih->palette->
+ type & BITMAPS) ? BGCOLOR(uih) : SELCOLOR(uih),
+ xtextheight(uih->font));
+ }
+ free(c);
+}
+
+void ui_textmouse(struct ui_textdata *d, int x, int y)
+{
+ if (y > d->y && y < d->y + xtextheight(uih->font) && x > d->x) {
+ int w = 0;
+ int i;
+ int xp = d->x;
+ for (i = 0; i < d->ndisplayed + 1 && xp - w / 2 < x; i++) {
+ w = xtextcharw(uih->font, d->text[i + d->start]);
+ xp += w;
+ }
+ d->cursor = i + d->start - 1;
+ if (d->cursor < 0)
+ d->cursor = 0;
+ d->clear = 0;
+ ui_updatetext(d);
+ uih->display = 1;
+ }
+}
+
+void ui_closetext(struct ui_textdata *d)
+{
+ free(d->text);
+ free(d);
+}
+
+int ui_textkey(struct ui_textdata *d, int key)
+{
+ switch (key) {
+ case UIKEY_LEFT:
+ if (d->clear)
+ d->clear = 0;
+ if (d->cursor)
+ d->cursor--;
+ else
+ return 0;
+ ui_updatetext(d);
+ uih->display = 1;
+ return 1;
+ case UIKEY_RIGHT:
+ if (d->clear)
+ d->clear = 0;
+ if (d->cursor < (int) strlen(d->text))
+ d->cursor++;
+ else
+ return 0;
+ ui_updatetext(d);
+ uih->display = 1;
+ return 1;
+ case UIKEY_HOME:
+ if (d->clear)
+ d->clear = 0;
+ d->cursor = 0;
+ ui_updatetext(d);
+ uih->display = 1;
+ return 1;
+ case UIKEY_END:
+ if (d->clear)
+ d->clear = 0;
+ d->cursor = (int) strlen(d->text);
+ ui_updatetext(d);
+ uih->display = 1;
+ return 1;
+ case UIKEY_BACKSPACE:
+ if (d->clear)
+ d->text[0] = 0, d->clear = 0;
+ else if (d->cursor) {
+ int len, i;
+ len = (int) strlen(d->text);
+ for (i = d->cursor; i <= len; i++) {
+ d->text[i - 1] = d->text[i];
+ }
+ d->cursor--;
+ }
+ ui_updatetext(d);
+ uih->display = 1;
+ return 1;
+ }
+ if (isprint(key)) {
+ int i;
+ int len;
+ if (d->clear)
+ d->text[0] = 0, d->clear = 0;
+ if ((len = (int) strlen(d->text)) > d->size - 2) {
+ d->text = (char *) realloc(d->text, d->size * 2);
+ }
+ for (i = len; i >= d->cursor; i--) {
+ d->text[i + 1] = d->text[i];
+ }
+ d->text[d->cursor] = key;
+ d->cursor++;
+ ui_updatetext(d);
+ uih->display = 1;
+ return 1;
+ }
+ return 0;
+}
+
+static void
+ui_buildstring(struct dialogitem *item, CONST menudialog * entry)
+{
+ item->height = BUTTONHEIGHT;
+ item->width = xtextwidth(uih->font, item->dialog->question);
+ item->width1 = xtextcharw(uih->font, 'w') * 20;
+ item->data = ui_opentext(0, 0, 2043, item->dialog->defstr);
+}
+
+static void ui_destroystring(struct dialogitem *item, dialogparam * param)
+{
+ struct ui_textdata *text = (struct ui_textdata *) item->data;
+ param->dstring = mystrdup(text->text);
+ ui_closetext(text);
+}
+
+static void ui_drawquestion(struct dialogitem *item)
+{
+ if (uih->palette->type & BITMAPS) {
+ if (SELECTED(item))
+ xrectangle(uih->image, dialog.x + BORDERWIDTH, item->y,
+ dialog.half - dialog.x - 2 * BORDERWIDTH,
+ BUTTONHEIGHT, FGCOLOR(uih));
+ xprint(uih->image, uih->font, dialog.half - item->width,
+ item->y + BORDERHEIGHT, item->dialog->question,
+ SELECTED(item) ? BGCOLOR(uih) : FGCOLOR(uih),
+ BGCOLOR(uih), TEXT_PRESSED);
+ } else {
+ xprint(uih->image, uih->font, dialog.half - item->width,
+ item->y + BORDERHEIGHT, item->dialog->question,
+ SELECTED(item) ? SELCOLOR(uih) : FGCOLOR(uih), BGCOLOR(uih),
+ 0);
+ }
+}
+
+static void ui_drawstring(struct dialogitem *item)
+{
+ struct ui_textdata *text = (struct ui_textdata *) item->data;
+ if (text->width == 2043)
+ text->x = dialog.half + BORDERWIDTH, text->width =
+ dialog.width + dialog.x - dialog.half - 2 * BORDERWIDTH,
+ text->y = item->y + BORDERHEIGHT, ui_updatetext(text);
+ uih_drawborder(uih, dialog.half, item->y,
+ dialog.width - dialog.half + dialog.x - BORDERWIDTH,
+ BUTTONHEIGHT, BORDER_PRESSED | BORDER_LIGHT);
+ ui_drawtext(text, SELECTED(item));
+ ui_drawquestion(item);
+}
+
+static int ui_keystring(struct dialogitem *item, int key)
+{
+ struct ui_textdata *text = (struct ui_textdata *) item->data;
+ return (ui_textkey(text, key));
+}
+
+static void
+ui_mousestring(struct dialogitem *item, int x, int y, int buttons,
+ int flags)
+{
+ struct ui_textdata *text = (struct ui_textdata *) item->data;
+ if (flags & MOUSE_DRAG) {
+ ui_textmouse(text, x, y);
+ }
+}
+
+static void ui_unselectstring(struct dialogitem *item)
+{
+}
+
+CONST static struct dialogtype stringdialog = {
+ ui_buildstring,
+ ui_keystring,
+ ui_mousestring,
+ ui_destroystring,
+ ui_drawstring,
+ ui_unselectstring
+};
+
+static void ui_buildint(struct dialogitem *item, CONST menudialog * entry)
+{
+ char s[50];
+ item->height = BUTTONHEIGHT;
+ item->width = xtextwidth(uih->font, item->dialog->question);
+ item->width1 = xtextcharw(uih->font, 'w') * 5;
+ sprintf(s, "%i", item->dialog->defint);
+ item->data = ui_opentext(0, 0, 2043, s);
+}
+
+static void ui_destroyint(struct dialogitem *item, dialogparam * param)
+{
+ struct ui_textdata *text = (struct ui_textdata *) item->data;
+ param->dint = (int) atol(text->text);
+ ui_closetext(text);
+}
+
+CONST static struct dialogtype intdialog = {
+ ui_buildint,
+ ui_keystring,
+ ui_mousestring,
+ ui_destroyint,
+ ui_drawstring,
+ ui_unselectstring
+};
+
+static CONST char *ui_getextension(CONST char *ch)
+{
+ int i = 0;
+ while (ch[i]) {
+ if (ch[i] == '*')
+ return (ch + i + 1);
+ i++;
+ }
+ return ch + i;
+}
+
+number_t ui_getfloat(CONST char *c)
+{
+#ifdef HAVE_LONG_DOUBLE
+ long double param;
+#else
+ double param;
+#endif
+#ifdef HAVE_LONG_DOUBLE
+#ifndef USE_ATOLD
+#ifdef USE_XLDIO
+ param = x_strtold(c, NULL);
+ if (0)
+#else
+ if (sscanf(c, "%LG", &param) == 0)
+#endif
+#else
+ param = _atold(c);
+ if (0)
+#endif
+ {
+#else
+ if (sscanf(c, "%lG", &param) == 0) {
+#endif
+ return 0;
+ }
+ return (param);
+}
+
+#define BROWSEWIDTH /*(2*BORDERWIDTH+xtextcharw(uih->font,'B'))*/BUTTONHEIGHT
+struct ui_filedata {
+ struct ui_textdata *text;
+ int active;
+ int pressed;
+};
+
+static struct dialogitem *curritem;
+static void filecallback(CONST char *name, int succ)
+{
+ struct ui_filedata *text = (struct ui_filedata *) curritem->data;
+ if (succ) {
+ ui_closetext(text->text);
+ uih->display = 1;
+ text->text = ui_opentext(0, 0, 2043, name);
+ dialog.mousereleased = 0;
+ }
+ if (dialog.nitems == 2)
+ ui_closedialog(succ);
+}
+
+static void ui_buildfile(struct dialogitem *item, CONST menudialog * entry)
+{
+ char str[256];
+ struct ui_filedata *data =
+ (struct ui_filedata *) malloc(sizeof(*data));
+ int i = 0;
+ item->height = BUTTONHEIGHT;
+ item->width = xtextwidth(uih->font, item->dialog->question);
+ item->width1 = xtextcharw(uih->font, 'w') * 20;
+ while (item->dialog->defstr[i] != '*' && item->dialog->defstr[i] != 0)
+ str[i] = item->dialog->defstr[i], i++;
+ str[i] = 0;
+ item->data = data;
+ if (entry->type == DIALOG_OFILE)
+ data->text =
+ ui_opentext(0, 0, 2043,
+ ui_getfile(str,
+ ui_getextension(item->dialog->defstr)));
+ else
+ data->text = ui_opentext(0, 0, 2043, item->dialog->defstr);
+ data->active = 0;
+ data->pressed = 0;
+#ifndef _plan9_
+ if (dialog.nitems == 2) {
+ curritem = item;
+ ui_buildfilesel(data->text->text, "", filecallback);
+ }
+#endif
+}
+
+static void ui_destroyfile(struct dialogitem *item, dialogparam * param)
+{
+ struct ui_filedata *text = (struct ui_filedata *) item->data;
+#ifndef _plan9_
+ if (filevisible)
+ ui_closefilesel(0);
+#endif
+ param->dpath = mystrdup(text->text->text);
+ ui_closetext(text->text);
+ free(text);
+}
+
+static void ui_drawfile(struct dialogitem *item)
+{
+ struct ui_filedata *data = (struct ui_filedata *) item->data;
+ int wholesize =
+ dialog.width + dialog.x - dialog.half - 2 * BORDERWIDTH;
+ if (data->text->width == 2043) {
+ data->text->x = dialog.half + BORDERWIDTH,
+ data->text->width = wholesize - BROWSEWIDTH - 2 * BORDERWIDTH,
+ data->text->y = item->y + BORDERHEIGHT;
+ ui_updatetext(data->text);
+ }
+ uih_drawborder(uih, dialog.half, item->y, wholesize - BROWSEWIDTH,
+ BUTTONHEIGHT, BORDER_PRESSED | BORDER_LIGHT);
+ ui_drawtext(data->text, SELECTED(item) && !data->active);
+ xprint(uih->image, uih->font, dialog.half - item->width,
+ item->y + BORDERHEIGHT, item->dialog->question,
+ SELECTED(item) ? SELCOLOR(uih) : FGCOLOR(uih), BGCOLOR(uih), 0);
+ ui_drawquestion(item);
+ ui_drawbutton("B", data->pressed && SELECTED(item), SELECTED(item)
+ && data->active,
+ dialog.x + dialog.width - BROWSEWIDTH - BORDERWIDTH,
+ dialog.x + dialog.width - BORDERWIDTH, item->y);
+}
+
+static int ui_keyfile(struct dialogitem *item, int key)
+{
+ struct ui_filedata *text = (struct ui_filedata *) item->data;
+ int i = 0;
+ if (!text->active)
+ i = ui_textkey(text->text, key);
+ if (!i) {
+ if (key == '\t' || key == UIKEY_RIGHT) {
+ text->active++;
+ if (text->active > 1) {
+ text->active = 0;
+ return 0;
+ }
+ uih->display = 1;
+ return 1;
+ }
+ if (key == UIKEY_LEFT) {
+ text->active--;
+ if (text->active < 0) {
+ text->active = 1;
+ return 0;
+ }
+ return 1;
+ }
+#ifndef _plan9_
+ if ((key == 13 || key == '\n') && text->active) {
+ curritem = item;
+ ui_buildfilesel(text->text->text, "", filecallback);
+ return 1;
+ }
+#endif
+ }
+ return (i);
+}
+
+static void
+ui_mousefile(struct dialogitem *item, int x, int y, int buttons, int flags)
+{
+ struct ui_filedata *text = (struct ui_filedata *) item->data;
+ int i;
+ if (flags & MOUSE_MOVE) {
+ if (x < dialog.x + dialog.width - BORDERWIDTH - BROWSEWIDTH)
+ i = 0;
+ else
+ i = 1;
+ if (text->active != i)
+ text->active = i, uih->display = 1;
+ }
+#ifndef _plan9_
+ if ((flags & MOUSE_RELEASE) && text->pressed) {
+ text->pressed = 0;
+ uih->display = 1;
+ curritem = item;
+ ui_buildfilesel(text->text->text, "", filecallback);
+ return;
+ }
+#endif
+ if (flags & MOUSE_DRAG) {
+ if (x < dialog.x + dialog.width - BORDERWIDTH - BROWSEWIDTH) {
+ text->active = 0, ui_textmouse(text->text, x, y);
+ if (text->pressed)
+ text->pressed = 0, uih->display = 1;
+ } else if (!text->pressed) {
+ text->pressed = 1;
+ uih->display = 1;
+ }
+ }
+}
+
+static void ui_unselectfile(struct dialogitem *item)
+{
+ struct ui_filedata *text = (struct ui_filedata *) item->data;
+ if (text->active)
+ text->active = 0, uih->display = 1;
+ if (text->pressed)
+ text->pressed = 0, uih->display = 1;
+}
+
+CONST static struct dialogtype filedialog = {
+ ui_buildfile,
+ ui_keyfile,
+ ui_mousefile,
+ ui_destroyfile,
+ ui_drawfile,
+ ui_unselectfile
+};
+
+static void
+ui_buildfloat(struct dialogitem *item, CONST menudialog * entry)
+{
+ char s[50];
+ item->height = BUTTONHEIGHT;
+ item->width = xtextwidth(uih->font, item->dialog->question);
+ item->width1 = xtextcharw(uih->font, 'w') * 10;
+ sprintf(s, "%g", (double) item->dialog->deffloat);
+ item->data = ui_opentext(0, 0, 2043, s);
+}
+
+static void ui_destroyfloat(struct dialogitem *item, dialogparam * param)
+{
+ struct ui_textdata *text = (struct ui_textdata *) item->data;
+ param->number = ui_getfloat(text->text);
+ ui_closetext(text);
+}
+
+CONST static struct dialogtype floatdialog = {
+ ui_buildfloat,
+ ui_keystring,
+ ui_mousestring,
+ ui_destroyfloat,
+ ui_drawstring,
+ ui_unselectstring
+};
+
+struct ui_coorddata {
+ struct ui_textdata *text[2];
+ int active;
+};
+static void
+ui_buildcoord(struct dialogitem *item, CONST menudialog * entry)
+{
+ char s[50];
+ struct ui_coorddata *data =
+ (struct ui_coorddata *) malloc(sizeof(*data));
+ item->height = BUTTONHEIGHT;
+ item->width = xtextwidth(uih->font, item->dialog->question);
+ item->width1 = xtextcharw(uih->font, 'w') * 20;
+ item->data = data;
+ data->active = 0;
+ sprintf(s, "%g", (double) item->dialog->deffloat);
+ data->text[0] = ui_opentext(0, 0, 2043, s);
+ sprintf(s, "%g", (double) item->dialog->deffloat2);
+ data->text[1] = ui_opentext(0, 0, 2043, s);
+}
+
+static void ui_destroycoord(struct dialogitem *item, dialogparam * param)
+{
+ struct ui_coorddata *data = (struct ui_coorddata *) item->data;
+ param->dcoord[0] = ui_getfloat(data->text[0]->text);
+ param->dcoord[1] = ui_getfloat(data->text[1]->text);
+ ui_closetext(data->text[0]);
+ ui_closetext(data->text[1]);
+ free(data);
+}
+
+#define SPACESIZE xtextwidth(uih->font,"+")
+#define ENDSIZE xtextwidth(uih->font,"i")
+static void ui_drawcoord(struct dialogitem *item)
+{
+ struct ui_coorddata *data = (struct ui_coorddata *) item->data;
+ int wholesize =
+ dialog.width + dialog.x - dialog.half - 2 * BORDERWIDTH - ENDSIZE;
+ int half = (wholesize - SPACESIZE) / 2;
+ if (data->text[0]->width == 2043) {
+ data->text[0]->x = dialog.half + BORDERWIDTH,
+ data->text[0]->width = half - BORDERWIDTH,
+ data->text[0]->y = item->y + BORDERHEIGHT;
+ data->text[1]->x = dialog.half + half + SPACESIZE + BORDERWIDTH,
+ data->text[1]->width = half - BORDERWIDTH,
+ data->text[1]->y = item->y + BORDERHEIGHT;
+ ui_updatetext(data->text[0]);
+ ui_updatetext(data->text[1]);
+ }
+ uih_drawborder(uih, dialog.half, item->y, half, BUTTONHEIGHT,
+ BORDER_PRESSED | BORDER_LIGHT);
+ uih_drawborder(uih, dialog.half + half + SPACESIZE, item->y, half,
+ BUTTONHEIGHT, BORDER_PRESSED | BORDER_LIGHT);
+ ui_drawtext(data->text[0], SELECTED(item) && !data->active);
+ ui_drawtext(data->text[1], SELECTED(item) && data->active);
+ xprint(uih->image, uih->font, dialog.half + half,
+ item->y + BORDERHEIGHT, "+", FGCOLOR(uih),
+ BGCOLOR(uih), 0);
+ xprint(uih->image, uih->font,
+ dialog.x + dialog.width - BORDERWIDTH - ENDSIZE,
+ item->y + BORDERHEIGHT, "i", FGCOLOR(uih),
+ BGCOLOR(uih), 0);
+ ui_drawquestion(item);
+}
+
+static int ui_keycoord(struct dialogitem *item, int key)
+{
+ struct ui_coorddata *text = (struct ui_coorddata *) item->data;
+ int i = ui_textkey(text->text[text->active], key);
+ if (!i) {
+ if (key == '\t' || key == UIKEY_RIGHT) {
+ text->active++;
+ if (text->active > 1) {
+ text->active = 0;
+ return 0;
+ }
+ uih->display = 1;
+ if (key == UIKEY_RIGHT) {
+ text->text[1]->cursor = 0;
+ ui_updatetext(text->text[1]);
+ uih->display = 1;
+ }
+ return 1;
+ }
+ if (key == UIKEY_LEFT) {
+ text->active--;
+ if (text->active < 0) {
+ text->active = 1;
+ return 0;
+ }
+ text->text[0]->cursor = (int) strlen(text->text[0]->text);
+ ui_updatetext(text->text[0]);
+ uih->display = 1;
+ return 1;
+ }
+ }
+ return (i);
+}
+
+static void
+ui_mousecoord(struct dialogitem *item, int x, int y, int buttons,
+ int flags)
+{
+ struct ui_coorddata *text = (struct ui_coorddata *) item->data;
+ int i;
+ if (flags & MOUSE_MOVE) {
+ if (x < text->text[1]->x)
+ i = 0;
+ else
+ i = 1;
+ if (text->active != i)
+ text->active = i, uih->display = 1;
+ }
+ if (flags & MOUSE_DRAG) {
+ if (x < text->text[1]->x)
+ text->active = 0, ui_textmouse(text->text[0], x, y);
+ else
+ text->active = 1, ui_textmouse(text->text[1], x, y);
+ }
+}
+
+static void ui_unselectcoord(struct dialogitem *item)
+{
+ struct ui_coorddata *text = (struct ui_coorddata *) item->data;
+ text->active = 0;
+}
+
+CONST static struct dialogtype coorddialog = {
+ ui_buildcoord,
+ ui_keycoord,
+ ui_mousecoord,
+ ui_destroycoord,
+ ui_drawcoord,
+ ui_unselectcoord
+};
+
+struct ui_choicedata {
+ CONST char **texts;
+ int selected;
+ int n;
+
+ struct uih_window *menu;
+ int x, y, width, height;
+ int active;
+};
+static void
+ui_choicemenupos(struct uih_context *uih, int *x, int *y, int *width,
+ int *height, void *data)
+{
+ struct ui_choicedata *choice = (struct ui_choicedata *) data;
+ if (filevisible || helpvisible) {
+ *x = *y = *width = *height = 0;
+ return;
+ }
+ *x = choice->x;
+ *y = choice->y;
+ *width = choice->width;
+ *height = choice->height;
+}
+
+static void ui_drawchoicemenu(uih_context * uih, void *data)
+{
+ struct ui_choicedata *choice = (struct ui_choicedata *) data;
+ int i;
+ for (i = 0; i < choice->n; i++) {
+ xprint(uih->image, uih->font, choice->x + BORDERWIDTH,
+ choice->y + BORDERHEIGHT + i * xtextheight(uih->font),
+ choice->texts[i],
+ i == choice->active ? SELCOLOR(uih) : FGCOLOR(uih),
+ BGCOLOR(uih), 0);
+ }
+}
+
+static void
+ui_buildchoicemenu(struct uih_context *uih, struct ui_choicedata *choice,
+ int x, int y, int width)
+{
+ if (choice->menu != NULL)
+ return;
+ choice->width = width + 2 * BORDERWIDTH;
+ choice->x = x;
+ choice->height = xtextheight(uih->font) * choice->n + 2 * BORDERHEIGHT;
+ choice->active = choice->selected;
+ choice->y = y - choice->active * xtextheight(uih->font);
+ dialog.mousegrab = 1;
+ if (choice->x + choice->width > uih->image->width)
+ choice->x = uih->image->width - choice->width;
+ if (choice->y + choice->height > uih->image->height)
+ choice->y = uih->image->height - choice->height;
+ if (choice->x < 0)
+ choice->x = 0;
+ if (choice->y < 0)
+ choice->y = 0;
+ choice->menu =
+ uih_registerw(uih, ui_choicemenupos, ui_drawchoicemenu, choice,
+ DRAWBORDER);
+ uih->display = 1;
+}
+
+static void
+ui_closechoicemenu(struct uih_context *uih, struct ui_choicedata *choice)
+{
+ if (choice->menu == NULL)
+ return;
+ uih_removew(uih, choice->menu);
+ choice->menu = NULL;
+ uih->display = 1;
+ dialog.mousegrab = 0;
+ dialog.mousereleased = 0;
+}
+
+static void
+ui_buildchoice(struct dialogitem *item, CONST menudialog * entry)
+{
+ int i;
+ struct ui_choicedata *data =
+ (struct ui_choicedata *) malloc(sizeof(*data));
+ item->height = BUTTONHEIGHT;
+ item->width = xtextwidth(uih->font, item->dialog->question);
+ item->width1 = 0;
+ data->menu = NULL;
+
+ data->texts = (CONST char **) entry->defstr;
+ for (i = 0; data->texts[i] != NULL; i++) {
+ int w = xtextwidth(uih->font, data->texts[i]);
+ if (w > item->width1)
+ item->width1 = w;
+ }
+ item->width1 += 2 * BORDERWIDTH;
+ data->n = i;
+ data->selected = entry->defint;
+ item->data = data;
+}
+
+static void ui_destroychoice(struct dialogitem *item, dialogparam * param)
+{
+ struct ui_choicedata *data = (struct ui_choicedata *) item->data;
+ param->dint = data->selected;
+ ui_closechoicemenu(uih, data);
+ free(data);
+}
+
+static void ui_drawchoice(struct dialogitem *item)
+{
+ struct ui_choicedata *data = (struct ui_choicedata *) item->data;
+ uih_drawborder(uih, dialog.half, item->y, item->width1,
+ BUTTONHEIGHT | BORDER_LIGHT, 0);
+ xprint(uih->image, uih->font, dialog.half + BORDERWIDTH,
+ item->y + BORDERHEIGHT, data->texts[data->selected],
+ SELECTED(item) ? SELCOLOR(uih) : FGCOLOR(uih),
+ BGCOLOR(uih), 0);
+ ui_drawquestion(item);
+}
+
+static int ui_keychoice(struct dialogitem *item, int key)
+{
+ struct ui_choicedata *data = (struct ui_choicedata *) item->data;
+ if (!data->menu) {
+ switch (key) {
+ case ' ':
+ case '\n':
+ case 13:
+ case UIKEY_UP:
+ case UIKEY_DOWN:
+ case UIKEY_RIGHT:
+ ui_buildchoicemenu(uih, data, dialog.half, item->y,
+ item->width1);
+ return (1);
+ }
+ } else {
+ switch (key) {
+ case ' ':
+ case 13:
+ case '\n':
+ data->selected = data->active;
+ ui_closechoicemenu(uih, data);
+ return (1);
+ case UIKEY_DOWN:
+ data->active++;
+ data->active %= data->n;
+ uih->display = 1;
+ return (1);
+ case UIKEY_UP:
+ data->active--;
+ if (data->active < 0)
+ data->active = data->n - 1;
+ uih->display = 1;
+ return (1);
+ case UIKEY_ESC:
+ ui_closechoicemenu(uih, data);
+ return (1);
+ }
+ }
+ return 0;
+}
+
+static void
+ui_mousechoice(struct dialogitem *item, int x, int y, int buttons,
+ int flags)
+{
+ struct ui_choicedata *data = (struct ui_choicedata *) item->data;
+ int in;
+ if (data->menu != NULL) {
+ in = 0;
+ if (x > data->x && y > data->y && x < data->x + data->width
+ && y < data->y + data->height)
+ in = 1;
+ if ((flags & MOUSE_PRESS) && !in) {
+ ui_closechoicemenu(uih, data);
+ return;
+ }
+ if ((flags & MOUSE_MOVE) && in) {
+ in = (y - data->y) / xtextheight(uih->font);
+ if (in < 0)
+ in = 0;
+ if (in >= data->n)
+ in = data->n - 1;
+ if (data->active != in)
+ data->active = in, uih->display = 1;
+ }
+ if (flags & MOUSE_RELEASE) {
+ data->selected = data->active;
+ ui_closechoicemenu(uih, data);
+ return;
+ }
+ } else {
+ if (flags & MOUSE_PRESS && x > dialog.half)
+ ui_buildchoicemenu(uih, data, dialog.half, item->y,
+ item->width1);
+ }
+}
+
+static void ui_unselectchoice(struct dialogitem *item)
+{
+ struct ui_choicedata *data = (struct ui_choicedata *) item->data;
+ ui_closechoicemenu(uih, data);
+}
+
+CONST static struct dialogtype choicedialog = {
+ ui_buildchoice,
+ ui_keychoice,
+ ui_mousechoice,
+ ui_destroychoice,
+ ui_drawchoice,
+ ui_unselectchoice
+};
+
+static void
+ui_dialogpos(struct uih_context *c, int *x, int *y, int *width,
+ int *height, void *data)
+{
+ *x = dialog.x;
+ *y = dialog.y;
+ if (filevisible || helpvisible) {
+ *x = *y = *width = *height = 0;
+ return;
+ }
+ *width = dialog.width;
+ *height = dialog.height;
+}
+
+static void ui_dialogdraw(struct uih_context *c, void *data)
+{
+ int n;
+ for (n = 0; n < dialog.nitems; n++)
+ dialog.items[n].type->draw(dialog.items + n);
+}
+
+#define YSKIP 2
+void ui_builddialog(CONST menuitem * item)
+{
+ int n = 2;
+ int ypos;
+ int width1 = 0;
+ if (ui_nogui) {
+ printf("dialog \"%s\"\n", item->shortname);
+ return;
+ }
+ if (driver->gui_driver && driver->gui_driver->dialog) {
+ driver->gui_driver->dialog(uih, item->shortname);
+ return;
+ }
+ dialogvisible = 1;
+ dialog.width = 0;
+ dialog.height = 0;
+ dialog.dialog = menu_getdialog(uih, item);
+ dialog.item = item;
+ for (n = 0; dialog.dialog[n].question != NULL; n++);
+ n++;
+ dialog.nitems = n;
+ dialog.items =
+ (struct dialogitem *) malloc(sizeof(struct dialogitem) *
+ dialog.nitems);
+ dialog.mousereleased = 0;
+ dialog.items[dialog.nitems - 1].type = &okdialog;
+ for (n = 0; n < dialog.nitems; n++) {
+ if (n < dialog.nitems - 1) {
+ switch (dialog.dialog[n].type) {
+ case DIALOG_STRING:
+ case DIALOG_KEYSTRING:
+ dialog.items[n].type = &stringdialog;
+ break;
+ case DIALOG_INT:
+ dialog.items[n].type = &intdialog;
+ break;
+ case DIALOG_IFILE:
+ case DIALOG_OFILE:
+ dialog.items[n].type = &filedialog;
+ break;
+ case DIALOG_FLOAT:
+ dialog.items[n].type = &floatdialog;
+ break;
+ case DIALOG_COORD:
+ dialog.items[n].type = &coorddialog;
+ break;
+ case DIALOG_CHOICE:
+ dialog.items[n].type = &choicedialog;
+ break;
+ default:
+ printf("uidialog:unknown type!\n");
+ exit(1);
+ }
+ }
+ dialog.items[n].dialog = dialog.dialog + n;
+ dialog.items[n].type->build(dialog.items + n, dialog.dialog + n);
+ dialog.height += dialog.items[n].height;
+ if (width1 < dialog.items[n].width1)
+ width1 = dialog.items[n].width1;
+ if (dialog.width < dialog.items[n].width)
+ dialog.width = dialog.items[n].width;
+ }
+ dialog.height += YSKIP * (n - 1);
+ n = xtextwidth(uih->font, gettext("OK")) + xtextwidth(uih->font,
+ gettext
+ ("Cancel")) +
+ xtextwidth(uih->font, gettext("Help")) + 10;
+ if (dialog.width < n)
+ dialog.width = n;
+ dialog.half = dialog.width + 2 * BORDERWIDTH;
+ dialog.width += 2 * BORDERWIDTH + width1;
+ dialog.height += 2 * BORDERHEIGHT;
+ dialog.current = 0;
+ dialog.x = (uih->image->width - dialog.width) / 2;
+ dialog.half += dialog.x;
+ dialog.y = (uih->image->height - dialog.height) / 2;
+ ypos = dialog.y + BORDERHEIGHT;
+ for (n = 0; n < dialog.nitems; n++) {
+ dialog.items[n].y = ypos;
+ ypos += dialog.items[n].height + YSKIP;
+ }
+ dialog.window =
+ uih_registerw(uih, ui_dialogpos, ui_dialogdraw, NULL, DRAWBORDER);
+ uih->display = 1;
+}
+
+static void ui_dialogquestion(int succesfull)
+{
+ if (succesfull)
+ ui_menuactivate(qitem, qparam);
+ else
+ menu_destroydialog(qitem, qparam, uih);
+}
+
+void ui_closedialog(int succesfull)
+{
+ int n = 2;
+ if (dialogvisible) {
+ dialogparam *param =
+ (dialogparam *) malloc(sizeof(dialogparam) * (dialog.nitems));
+ dialogvisible = 0;
+ uih_removew(uih, dialog.window);
+ uih->display = 1;
+ for (n = 0; n < dialog.nitems; n++) {
+ dialog.items[n].type->destroy(dialog.items + n, param + n);
+ }
+ free(dialog.items);
+ if (succesfull) {
+ for (n = 0; n < dialog.nitems - 1; n++)
+ if (dialog.dialog[n].type == DIALOG_OFILE
+ && xio_exist(param[n].dpath)) {
+ qparam = param;
+ qitem = dialog.item;
+ ui_buildyesno("File exist. Overwrite?",
+ ui_dialogquestion);
+ return;
+ }
+ ui_menuactivate(dialog.item, param);
+ } else
+ menu_destroydialog(dialog.item, param, uih);
+ }
+}
+
+int ui_dialogmouse(int x, int y, int mousebuttons, int flags)
+{
+ int i;
+ if (ui_mouseyesno(x, y, mousebuttons, flags))
+ return 1;
+ if (!dialogvisible)
+ return 0;
+ if (!dialog.mousereleased && (flags & MOUSE_RELEASE)) {
+ dialog.mousereleased = 1;
+ return 1;
+ }
+ if (!dialog.mousereleased && (flags & MOUSE_DRAG)) {
+ return 1;
+ }
+ dialog.mousereleased = 1;
+ if (dialog.mousegrab) {
+ dialog.items[dialog.current].type->mouse(dialog.items +
+ dialog.current, x, y,
+ mousebuttons, flags);
+ return 1;
+ }
+ if (dialog.x > x || dialog.y > y || dialog.x + dialog.width < x
+ || dialog.y + dialog.height < y) {
+ if (flags & MOUSE_PRESS) {
+ ui_closedialog(0);
+ return 1;
+ }
+ dialog.items[dialog.current].type->mouse(dialog.items +
+ dialog.current, x, y, 0,
+ 0);
+ return 1;
+ }
+ for (i = dialog.nitems - 1; i >= 0; i--)
+ if (dialog.items[i].y < y)
+ break;
+ if (i == -1) {
+ dialog.items[dialog.current].type->mouse(dialog.items +
+ dialog.current, x, y, 0,
+ 0);
+ return 1;
+ }
+ if (((flags & MOUSE_PRESS) || (flags & MOUSE_MOVE))
+ && dialog.current != i) {
+ dialog.items[dialog.current].type->unselect(dialog.items +
+ dialog.current);
+ dialog.current = i;
+ uih->display = 1;
+ }
+ dialog.items[i].type->mouse(dialog.items + i, x, y, mousebuttons,
+ flags);
+ return 1;
+}
+
+int ui_dialogkeys(int key)
+{
+ if (ui_keyyesno(key))
+ return 1;
+ if (!dialogvisible)
+ return 0;
+ if (key == UIKEY_ESC) {
+ ui_closedialog(0);
+ return 1;
+ }
+ if (!dialog.items[dialog.current].type->
+ key(dialog.items + dialog.current, key)) {
+ switch (key) {
+ case 'h':
+ ui_help(dialog.item->shortname);
+ return 1;
+ case UIKEY_TAB:
+ case UIKEY_DOWN:
+ case UIKEY_RIGHT:
+ NEXT();
+ break;
+ case UIKEY_UP:
+ case UIKEY_LEFT:
+ PREV();
+ break;
+ case 13:
+ case '\n':
+ ui_closedialog(1);
+ }
+ }
+ return 1;
+}
diff --git a/src/ui/drivers.c b/src/ui/drivers.c
new file mode 100644
index 0000000..f4954c6
--- /dev/null
+++ b/src/ui/drivers.c
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+/*drivers registry */
+#include <config.h>
+#include <ui.h>
+extern CONST struct ui_driver svga_driver, x11_driver, dog_driver,
+ plan9_driver, plan9_driver, mac_driver, mac_full_driver, osx_driver,
+ osx_fullscreen_driver, os2vio_driver, cocoa_driver, qt_driver,
+ cocoa_fullscreen_driver, be_driver, be_direct_driver, be_screen_driver,
+ aalib_driver, gtk_driver, ggi_driver, win32_driver, dxw_driver,
+ dxf_driver, DGA_driver;
+CONST struct ui_driver *CONST drivers[] = {
+#ifdef WIN32_DRIVER
+ &win32_driver,
+#endif
+#ifdef DDRAW_DRIVER
+ &dxw_driver,
+ &dxf_driver,
+#endif
+#ifdef SVGA_DRIVER
+ &svga_driver,
+#endif
+#ifdef X11_DRIVER
+ &x11_driver,
+#endif
+#ifdef DGA_DRIVER
+ &DGA_driver,
+#endif
+#ifdef GTK_DRIVER
+ &gtk_driver,
+#endif
+#ifdef GGI_DRIVER
+ &ggi_driver,
+#endif
+#ifdef OS2VIO_DRIVER
+ &os2vio_driver,
+#endif
+#ifdef DOG_DRIVER
+ &dog_driver,
+#endif
+#ifdef PLAN9_DRIVER
+ &plan9_driver,
+#endif
+#ifdef AA_DRIVER
+ &aalib_driver,
+#endif
+#ifdef _MAC
+ &mac_driver,
+ &mac_full_driver,
+#endif
+#ifdef OSX_DRIVER
+ &osx_driver,
+ &osx_fullscreen_driver,
+#endif
+#ifdef COCOA_DRIVER
+ &cocoa_driver,
+ &cocoa_fullscreen_driver,
+#endif
+#ifdef QT_DRIVER
+ &qt_driver,
+#endif
+#ifdef BEOS_DRIVER
+ &be_driver,
+ &be_direct_driver,
+ &be_screen_driver,
+#endif
+ NULL
+};
+
+CONST int ndrivers = (sizeof(drivers) / sizeof(*drivers) - 1);
diff --git a/src/ui/filesel.c b/src/ui/filesel.c
new file mode 100644
index 0000000..24c1c83
--- /dev/null
+++ b/src/ui/filesel.c
@@ -0,0 +1,677 @@
+#ifndef _plan9_
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+#include <config.h>
+#include <filter.h>
+#include <fractal.h>
+#include <ui_helper.h>
+#include <xmenu.h>
+#include <grlib.h>
+#include <ui.h>
+#include <xerror.h>
+#include <misc-f.h>
+#include "uiint.h"
+
+#ifdef HAVE_GETTEXT
+#include <libintl.h>
+#else
+#define gettext(STRING) STRING
+#endif
+
+static char **dirs;
+static char **sdirs;
+static int ndirs;
+static char **names;
+static char **snames;
+static int nnames;
+
+struct ui_textdata *dir, *filename;
+static char lastdir[256];
+static char *currdir;
+
+static struct uih_window *filew;
+static CONST char *mask;
+static void (*callback) (CONST char *name, int succ);
+int filevisible;
+static int filex, filey, filewidth, fileheight;
+
+#define ADIR 0
+#define AFILELIST 1
+#define ADIRLIST 2
+#define AFILE 3
+#define AOK 4
+
+#define DIRSTART (filey+BORDERHEIGHT)
+#define LISTSTART (DIRSTART+BUTTONHEIGHT+BORDERHEIGHT)
+#define LISTEND (FILESTART-BORDERHEIGHT)
+#define FILESTART (OKSTART-BORDERHEIGHT-BUTTONHEIGHT)
+#define OKSTART (filey+fileheight-BORDERHEIGHT-BUTTONHEIGHT)
+#define SCROLLWIDTH 10
+
+#define LISTWIDTH ((filewidth-10*BORDERWIDTH-2*SCROLLWIDTH)/2)
+
+#define NVISIBLE ((LISTEND-LISTSTART-2*BORDERHEIGHT)/xtextheight(uih->font))
+
+static int selectedname;
+static int selecteddir;
+static int namestart;
+static int dirstart;
+
+static int pressedbutton;
+static int activebutton;
+static int active;
+
+static void ui_freenames(void)
+{
+ int i;
+ selectedname = 0;
+ selecteddir = 0;
+ if (nnames) {
+ for (i = 0; i < nnames; i++)
+ free(names[i]), free(snames[i]);
+ free(names);
+ nnames = 0;
+ }
+ if (ndirs) {
+ for (i = 0; i < ndirs; i++)
+ free(dirs[i]), free(sdirs[i]);
+ free(dirs);
+ ndirs = 0;
+ }
+ if (snames)
+ free(snames), snames = NULL;
+ if (sdirs)
+ free(sdirs), sdirs = NULL;
+}
+
+static int compar(CONST void *a, CONST void *b)
+{
+ return (strcmp(*(CONST char **) a, *(CONST char **) b));
+}
+
+static char **ui_mksnames(int nnames, char **names, int width)
+{
+ char **snames = NULL;
+ int i;
+ if (nnames) {
+ qsort(names, nnames, sizeof(*names), /*(int (*)(CONST void *, CONST
+ void *))strcmp */ compar);
+ snames = (char **) malloc(sizeof(*snames) * nnames);
+ for (i = 0; i < nnames; i++) {
+ if (xtextwidth(uih->font, names[i]) <= width)
+ snames[i] = mystrdup(names[i]);
+ else {
+ int y;
+ int swidth = 0;
+ int len = (int) strlen(names[i]);
+ snames[i] = (char *) malloc(strlen(names[i]) + 2);
+ for (y = len - 4; y < len; y++)
+ swidth += xtextcharw(uih->font, names[i][y]);
+ swidth += xtextcharw(uih->font, '|');
+ y = 0;
+ while (swidth < width) {
+ snames[i][y] = names[i][y];
+ swidth += xtextcharw(uih->font, names[i][y]);
+ y++;
+ }
+ snames[i][y - 1] = '|';
+ snames[i][y] = 0;
+ strcat(snames[i], names[i] + len - 4);
+ }
+ }
+ }
+ return (snames);
+}
+
+static void ui_buildnames(int width)
+{
+ ui_freenames();
+ xio_getfiles(currdir, &names, &dirs, &nnames, &ndirs);
+ if (snames)
+ free(snames), snames = NULL;
+ if (sdirs)
+ free(sdirs), sdirs = NULL;
+ snames = ui_mksnames(nnames, names, width);
+ sdirs = ui_mksnames(ndirs, dirs, width);
+}
+
+void ui_closefilesel(int success)
+{
+ char *text =
+ (char *) malloc((int) strlen(filename->text) +
+ (int) strlen(currdir) + 3);
+ filevisible = 0;
+ uih_removew(uih, filew);
+ ui_freenames();
+ sprintf(text, "%s" XIO_PATHSEPSTR "%s", currdir, filename->text);
+ ui_closetext(dir);
+ ui_closetext(filename);
+ strcpy(lastdir, currdir);
+ free(currdir);
+ callback(text, success);
+ free(text);
+ uih->display = 1;
+ ui_freenames();
+}
+
+static void
+filepos(uih_context * c, int *x, int *y, int *w, int *h, void *data)
+{
+ *x = filex;
+ *y = filey;
+ *w = filewidth;
+ *h = fileheight;
+}
+
+static void drawfile(uih_context * c, void *data)
+{
+ int i;
+ int ypos;
+ int h = xtextheight(uih->font);
+ uih_drawborder(uih, filex + BORDERWIDTH, DIRSTART,
+ filewidth - 2 * BORDERWIDTH, BUTTONHEIGHT,
+ BORDER_PRESSED | BORDER_LIGHT);
+ uih_drawborder(uih, filex + BORDERWIDTH, FILESTART,
+ filewidth - 2 * BORDERWIDTH, BUTTONHEIGHT,
+ BORDER_PRESSED | BORDER_LIGHT);
+
+ ui_drawbutton("OK", (pressedbutton == 0), active == AOK
+ && activebutton == 0, filex + BORDERWIDTH,
+ filex + filewidth / 2 - BORDERWIDTH, OKSTART);
+ ui_drawbutton(gettext("Cancel"), (pressedbutton == 1), active == AOK
+ && activebutton == 1,
+ filex + filewidth / 2 + BORDERWIDTH,
+ filex + filewidth - BORDERWIDTH, OKSTART);
+
+ uih_drawborder(uih, filex + BORDERWIDTH, LISTSTART,
+ LISTWIDTH + 3 * BORDERWIDTH + SCROLLWIDTH,
+ LISTEND - LISTSTART, BORDER_PRESSED);
+ uih_drawborder(uih, filex + filewidth / 2 + BORDERWIDTH, LISTSTART,
+ LISTWIDTH + 3 * BORDERWIDTH + SCROLLWIDTH,
+ LISTEND - LISTSTART, BORDER_PRESSED);
+ ypos = LISTSTART + BORDERHEIGHT;
+ for (i = 0; ypos + h < LISTEND && i + namestart < nnames; i++) {
+ if (i + namestart == selectedname) {
+ xrectangle(uih->image, filex + 2 * BORDERWIDTH, ypos,
+ LISTWIDTH, h,
+ (uih->palette->
+ type & BITMAPS) ? BGCOLOR(uih) :
+ LIGHTGRAYCOLOR(uih));
+ }
+ if (uih->palette->type & BITMAPS)
+ xprint(uih->image, uih->font, filex + 2 * BORDERWIDTH, ypos,
+ snames[i + namestart],
+ i + namestart ==
+ selectedname ? FGCOLOR(uih) : BGCOLOR(uih),
+ BGCOLOR(uih), TEXT_PRESSED);
+ else
+ xprint(uih->image, uih->font, filex + 2 * BORDERWIDTH, ypos,
+ snames[i + namestart],
+ (i + namestart) == selectedname
+ && active == AFILELIST ? SELCOLOR(uih) : FGCOLOR(uih),
+ BGCOLOR(uih), 0);
+ ypos += h;
+ }
+ if (nnames) {
+ int xstart = (namestart) * (LISTEND - LISTSTART) / nnames;
+ int xend = (namestart + NVISIBLE) * (LISTEND - LISTSTART) / nnames;
+ if (xstart > (LISTEND - LISTSTART - 2 * BORDERHEIGHT))
+ xstart = LISTEND - LISTSTART - 2 * BORDERHEIGHT;
+ if (xend > (LISTEND - LISTSTART - 2 * BORDERHEIGHT))
+ xend = LISTEND - LISTSTART - 2 * BORDERHEIGHT;
+ uih_drawborder(uih, filex + LISTWIDTH + 3 * BORDERWIDTH, LISTSTART + xstart + BORDERHEIGHT, SCROLLWIDTH, xend - xstart, /*1|BORDER_LIGHT */
+ 0);
+ }
+
+ ypos = LISTSTART + BORDERHEIGHT;
+ for (i = 0; ypos + h < LISTEND && i + dirstart < ndirs; i++) {
+ if (i + dirstart == selecteddir) {
+ xrectangle(uih->image, filex + filewidth / 2 + 2 * BORDERWIDTH,
+ ypos, LISTWIDTH, h,
+ (uih->palette->type & BITMAPS) ? BGCOLOR(uih) :
+ LIGHTGRAYCOLOR(uih));
+ }
+ if (uih->palette->type & BITMAPS)
+ xprint(uih->image, uih->font,
+ filex + filewidth / 2 + 2 * BORDERWIDTH, ypos,
+ sdirs[i + dirstart],
+ i + dirstart ==
+ selecteddir ? FGCOLOR(uih) : BGCOLOR(uih), BGCOLOR(uih),
+ TEXT_PRESSED);
+ else
+ xprint(uih->image, uih->font,
+ filex + filewidth / 2 + 2 * BORDERWIDTH, ypos,
+ sdirs[i + dirstart],
+ (i + dirstart) == selecteddir
+ && active == ADIRLIST ? SELCOLOR(uih) : FGCOLOR(uih),
+ BGCOLOR(uih), 0);
+ ypos += h;
+ }
+ if (ndirs) {
+ int xstart = (dirstart) * (LISTEND - LISTSTART) / ndirs;
+ int xend = (dirstart + NVISIBLE) * (LISTEND - LISTSTART) / ndirs;
+ if (xstart > (LISTEND - LISTSTART - 2 * BORDERHEIGHT))
+ xstart = LISTEND - LISTSTART - 2 * BORDERHEIGHT;
+ if (xend > (LISTEND - LISTSTART - 2 * BORDERHEIGHT))
+ xend = LISTEND - LISTSTART - 2 * BORDERHEIGHT;
+ uih_drawborder(uih, filex + filewidth / 2 + LISTWIDTH + 3 * BORDERWIDTH, LISTSTART + xstart + BORDERHEIGHT, SCROLLWIDTH, xend - xstart, /*1|BORDER_LIGHT */
+ 0);
+ }
+ ui_drawtext(filename, active == AFILE);
+ ui_drawtext(dir, active == ADIR);
+}
+
+static void setname(int name)
+{
+ ui_closetext(filename);
+ filename =
+ ui_opentext(filex + 2 * BORDERWIDTH, FILESTART + BORDERHEIGHT,
+ filewidth - 4 * BORDERWIDTH, names[name]);
+}
+
+#ifdef _WIN32
+#define DRIVES
+#endif
+#ifdef DJGPP
+#define DRIVES
+#endif
+static void setdir(int name)
+{
+ char *dirstring = dirs[name];
+ char *s = NULL;
+ if (dirstring[0] == '.' && !dirstring[1]) {
+ /*do nothing */
+ s = mystrdup(currdir);
+ } else if (dirstring[0] && dirstring[1] && dirstring[0] == '.'
+ && dirstring[1] == '.' && !dirstring[2]) {
+ int i = (int) strlen(currdir);
+ s = (char *) malloc((int) strlen(dirstring) +
+ (int) strlen(currdir) + 2);
+ strcpy(s, currdir);
+ for (;
+ i >= 0 && s[i] != '/' && s[i] != '\\' && s[i] != XIO_PATHSEP;
+ i--);
+ if (i < 0)
+ free(s), s = NULL;
+ else
+ s[i] = 0;
+ }
+ if (s == NULL) {
+ int i = (int) strlen(currdir);
+ s = (char *) malloc((int) strlen(dirstring) +
+ (int) strlen(currdir) + 2);
+ strcpy(s, currdir);
+ if (currdir[i - 1] != '/' && currdir[i - 1] != '\\'
+ && currdir[i - 1] != XIO_PATHSEP)
+ strcat(s, XIO_PATHSEPSTR);
+ strcat(s, dirstring);
+ if (!s[0])
+ s[0] = XIO_PATHSEP, s[1] = 0;
+ }
+ free(currdir);
+#ifdef DRIVES
+ if (strlen(s) == 2
+ && ((s[0] >= 'a' && s[0] <= 'z') || (s[0] >= 'A' && s[0] <= 'Z'))
+ && s[1] == ':')
+ s[2] = XIO_PATHSEP, s[3] = 0;
+#endif
+ currdir = s;
+ ui_closetext(dir);
+ dir =
+ ui_opentext(filex + 2 * BORDERWIDTH, DIRSTART + BORDERHEIGHT,
+ filewidth - 4 * BORDERWIDTH, currdir);
+ ui_freenames();
+ ui_buildnames(LISTWIDTH);
+ dirstart = 0;
+ selecteddir = 0;
+ namestart = 0;
+ selectedname = 0;
+ uih->display = 1;
+}
+
+static void setexactdir(CONST char *dirstring)
+{
+ free(currdir);
+ currdir = mystrdup(dirstring);
+ ui_closetext(dir);
+ dir =
+ ui_opentext(filex + 2 * BORDERWIDTH, DIRSTART + BORDERHEIGHT,
+ filewidth - 4 * BORDERWIDTH, currdir);
+ ui_freenames();
+ ui_buildnames(LISTWIDTH);
+ dirstart = 0;
+ selecteddir = 0;
+ namestart = 0;
+ selectedname = 0;
+ uih->display = 1;
+}
+
+int ui_keyfilesel(int k)
+{
+ if (!filevisible)
+ return 0;
+ if (k == UIKEY_ESC)
+ ui_closefilesel(0);
+ else
+ switch (active) {
+ default:
+ active = AFILE;
+ uih->display = 1;
+ break;
+ case ADIR:
+ if (ui_textkey(dir, k))
+ break;
+ if (k == '\n' || k == 13) {
+ active = AFILE;
+ setexactdir(dir->text);
+ uih->display = 1;
+ }
+ if (k == UIKEY_UP) {
+ active = AOK;
+ uih->display = 1;
+ activebutton = 1;
+ }
+ if (k == '\t' || k == UIKEY_DOWN) {
+ active++;
+ uih->display = 1;
+ }
+ break;
+ case AFILELIST:
+ switch (k) {
+ case '\t':
+ case UIKEY_RIGHT:
+ uih->display = 1;
+ active = ADIRLIST;
+ break;
+ case UIKEY_LEFT:
+ uih->display = 1;
+ active = ADIR;
+ break;
+ case UIKEY_UP:
+ if (selectedname) {
+ uih->display = 1;
+ selectedname--;
+ if (selectedname < namestart)
+ namestart = selectedname;
+ }
+ break;
+ case UIKEY_DOWN:
+ if (selectedname < nnames - 1) {
+ uih->display = 1;
+ selectedname++;
+ if (selectedname >= namestart + NVISIBLE)
+ namestart = selectedname - NVISIBLE + 1;
+ }
+ break;
+ case UIKEY_HOME:
+ if (selectedname) {
+ uih->display = 1;
+ selectedname = namestart = 0;
+ }
+ break;
+ case UIKEY_END:
+ if (selectedname < nnames - 1) {
+ uih->display = 1;
+ selectedname = nnames - 1;;
+ if (selectedname >= namestart + NVISIBLE)
+ namestart = selectedname - NVISIBLE + 1;
+ }
+ break;
+ case '\n':
+ case 13:
+ setname(selectedname);
+ uih->display = 1;
+ active = AFILE;
+ break;
+ }
+ break;
+ case ADIRLIST:
+ switch (k) {
+ case '\t':
+ case UIKEY_RIGHT:
+ uih->display = 1;
+ active = AFILE;
+ break;
+ case UIKEY_LEFT:
+ uih->display = 1;
+ active = AFILELIST;
+ break;
+ case UIKEY_UP:
+ if (selecteddir) {
+ uih->display = 1;
+ selecteddir--;
+ if (selecteddir < dirstart)
+ dirstart = selecteddir;
+ }
+ break;
+ case UIKEY_DOWN:
+ if (selecteddir < ndirs - 1) {
+ uih->display = 1;
+ selecteddir++;
+ if (selecteddir >= dirstart + NVISIBLE)
+ dirstart = selecteddir - NVISIBLE + 1;
+ }
+ break;
+ case UIKEY_HOME:
+ if (selecteddir) {
+ uih->display = 1;
+ selecteddir = dirstart = 0;
+ }
+ break;
+ case UIKEY_END:
+ if (selecteddir < ndirs - 1) {
+ uih->display = 1;
+ selecteddir = ndirs - 1;;
+ if (selecteddir >= dirstart + NVISIBLE)
+ dirstart = selecteddir - NVISIBLE + 1;
+ }
+ break;
+ case '\n':
+ case 13:
+ setdir(selecteddir);
+ uih->display = 1;
+ break;
+ }
+ break;
+ case AFILE:
+ if (ui_textkey(filename, k))
+ break;
+ if (k == '\t' || k == UIKEY_DOWN) {
+ active++;
+ uih->display = 1;
+ activebutton = 0;
+ }
+ if (k == UIKEY_UP) {
+ active--;
+ uih->display = 1;
+ }
+
+ if (k == '\n' || k == 13) {
+ ui_closefilesel(1);
+ }
+ break;
+ case AOK:
+ if (k == '\n' || k == 13)
+ ui_closefilesel(!activebutton);
+ if (k == '\t' || k == UIKEY_RIGHT || k == UIKEY_DOWN) {
+ uih->display = 1;
+ activebutton++;
+ if (activebutton > 2) {
+ activebutton = 0;
+ active = ADIR;
+ }
+ }
+ if (k == UIKEY_LEFT || k == UIKEY_UP) {
+ uih->display = 1;
+ activebutton--;
+ if (activebutton < 0) {
+ activebutton = 0;
+ active = AFILE;
+ }
+ }
+ }
+ return 1;
+}
+
+int ui_mousefilesel(int x, int y, int buttons, int flags)
+{
+ static int grabbed = -1;
+ if (!filevisible)
+ return 0;
+ if (grabbed >= 0 && (flags & MOUSE_DRAG)) {
+ if (!grabbed) {
+ int pos;
+ pos =
+ (y - LISTSTART) * nnames / (LISTEND - LISTSTART -
+ 2 * BORDERHEIGHT);
+ if (pos >= nnames - NVISIBLE)
+ pos = nnames - NVISIBLE;
+ if (pos < 0)
+ pos = 0;
+ if (pos != namestart) {
+ namestart = pos;
+ uih->display = 1;
+ if (selectedname < pos)
+ selectedname = pos;
+ if (selectedname >= pos + NVISIBLE)
+ selectedname = pos + NVISIBLE - 1;
+ }
+ } else {
+ int pos;
+ pos =
+ (y - LISTSTART) * ndirs / (LISTEND - LISTSTART -
+ 2 * BORDERHEIGHT);
+ if (pos >= ndirs - NVISIBLE)
+ pos = ndirs - NVISIBLE;
+ if (pos < 0)
+ pos = 0;
+ if (pos != dirstart) {
+ dirstart = pos;
+ uih->display = 1;
+ if (selecteddir < pos)
+ selecteddir = pos;
+ if (selecteddir >= pos + NVISIBLE)
+ selecteddir = pos + NVISIBLE - 1;
+ }
+ }
+ } else
+ grabbed = -1;
+ if (x < filex || y < filey || x > filex + filewidth
+ || y > filex + fileheight) {
+ if (flags & MOUSE_PRESS)
+ ui_closefilesel(0);
+ return 1;
+ }
+ if (y < LISTSTART) {
+ if (pressedbutton != -1)
+ pressedbutton = -1, uih->display = 1;
+ if ((flags & MOUSE_MOVE) && active != ADIR)
+ active = ADIR, uih->display = 1;
+ if (flags & MOUSE_PRESS)
+ ui_textmouse(dir, x, y);
+ } else if (y < LISTEND) {
+ int mouseat = 0;
+ if (pressedbutton != -1)
+ pressedbutton = -1, uih->display = 1;
+ if (x > filex + filewidth / 2)
+ mouseat = 1, x -= filewidth / 2;
+ x -= filex;
+ if (flags & MOUSE_MOVE) {
+ if (!mouseat && active != AFILELIST)
+ active = AFILELIST, uih->display = 1;
+ if (mouseat && active != ADIRLIST)
+ active = ADIRLIST, uih->display = 1;
+ }
+ if (x > LISTWIDTH && (flags & MOUSE_PRESS))
+ grabbed = mouseat;
+ else {
+ if (flags & MOUSE_PRESS) {
+ int atitem =
+ (y - LISTSTART -
+ BORDERHEIGHT) / xtextheight(uih->font);
+ if (atitem < 0)
+ atitem = 0;
+ if (!mouseat) {
+ atitem += namestart;
+ if (atitem < nnames) {
+ if (atitem == selectedname
+ && !strcmp(names[selectedname],
+ filename->text)) {
+ ui_closefilesel(1);
+ } else {
+ selectedname = atitem;
+ uih->display = 1;
+ setname(selectedname);
+ }
+ }
+ } else {
+ atitem += dirstart;
+ if (atitem < ndirs) {
+ selecteddir = atitem;
+ uih->display = 1;
+ setdir(selecteddir);
+ }
+ }
+ }
+ }
+ } else if (y < OKSTART) {
+ if (pressedbutton != -1)
+ pressedbutton = -1, uih->display = 1;
+ /*exit(1); */
+ if ((flags & MOUSE_MOVE) && active != AFILE)
+ active = AFILE, uih->display = 1;
+ if (flags & MOUSE_PRESS)
+ ui_textmouse(filename, x, y);
+ } else {
+ int mouseat = 0;
+ if (x > filex + filewidth / 2)
+ mouseat = 1;
+ if (flags & MOUSE_PRESS) {
+ if (active != AOK)
+ active = AOK, uih->display = 1;
+ if (activebutton != mouseat || pressedbutton != mouseat)
+ activebutton = pressedbutton = mouseat, uih->display = 1;
+ }
+ if ((flags & MOUSE_MOVE) && pressedbutton != mouseat)
+ uih->display = 1, pressedbutton = -1, active =
+ AOK, activebutton = mouseat;
+ if ((flags & MOUSE_RELEASE) && pressedbutton == mouseat)
+ ui_closefilesel(!mouseat);
+ }
+ return 1;
+}
+
+void
+ui_buildfilesel(CONST char *f, CONST char *m,
+ void (*c) (CONST char *, int))
+{
+ if (filevisible) {
+ x_fatalerror("Internal error!");
+ }
+ pressedbutton = activebutton = active = -1;
+ if (lastdir[0] == 0)
+ getcwd(lastdir, 256);
+ lastdir[255] = 0;
+ currdir = mystrdup(lastdir);
+ callback = c;
+ active = AFILE;
+ filex = 0;
+ filey = 0;
+ filewidth = uih->image->width;
+ fileheight = uih->image->height;
+ namestart = dirstart = 0;
+ mask = m;
+ dir =
+ ui_opentext(filex + 2 * BORDERWIDTH, DIRSTART + BORDERHEIGHT,
+ filewidth - 4 * BORDERWIDTH, lastdir);
+ filename =
+ ui_opentext(filex + 2 * BORDERWIDTH, FILESTART + BORDERHEIGHT,
+ filewidth - 4 * BORDERWIDTH, f);
+ filevisible = 1;
+ ui_buildnames(LISTWIDTH);
+ filew = uih_registerw(uih, filepos, drawfile, 0, DRAWBORDER);
+}
+#endif
diff --git a/src/ui/fparams.c b/src/ui/fparams.c
new file mode 100644
index 0000000..0befa7a
--- /dev/null
+++ b/src/ui/fparams.c
@@ -0,0 +1,112 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 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.
+ */
+
+#include <config.h>
+#ifndef _plan9_
+#include <fconfig.h>
+#include <string.h>
+#include <stdlib.h>
+#ifdef DESTICKY
+#include <unistd.h>
+#endif
+#else
+#include <u.h>
+#include <libc.h>
+#endif
+#include <filter.h>
+#include <ui_helper.h>
+#include <ui.h>
+#include <param.h>
+#include <xmenu.h>
+#include <plane.h>
+#include <xerror.h>
+#include "uiint.h"
+
+
+static char *defrender = NULL;
+static CONST char *rbasename = "anim";
+static int alias = 0;
+static int slowmode = 0;
+static char *imgtype;
+static char *defsize;
+static float framerate;
+static int letterspersec = 20;
+static int defvectors;
+static int iframedist;
+CONST struct params ui_fractal_params[] = {
+
+ {"", P_HELP, NULL, "Animation rendering:"},
+ {"-render", P_STRING, &defrender,
+ "Render animation into seqence of .png files"},
+ {"-basename", P_STRING, &rbasename,
+ "Name for .png files (XaoS will add 4 digit number and extension"},
+ {"-size", P_STRING, &defsize, "widthxheight"},
+ {"-renderimage", P_STRING, &imgtype, "256 or truecolor"},
+ {"-renderframerate", P_FLOAT, &framerate, "framerate"},
+ {"-antialiasing", P_SWITCH, &alias,
+ "Perform antialiasing (slow, requires quite lot of memory)"},
+ {"-alwaysrecalc", P_SWITCH, &slowmode,
+ "Always recalculate whole image (slowes down rendering, increases quality)"},
+ {"-rendervectors", P_SWITCH, &defvectors,
+ "Render motion vectors (should be used for MPEG encoding)"},
+ {"-iframedist", P_NUMBER, &iframedist,
+ "Recommended distance between I frames in pat file (should be used for MPEG encoding)"},
+ {NULL, 0, NULL, NULL}
+};
+
+int ui_dorender_params(void)
+{
+ if (defrender != NULL) {
+ int imagetype = TRUECOLOR24;
+ int width = 640, height = 480;
+#ifdef DESTICKY
+ seteuid(getuid()); /* Don't need supervisor rights anymore. */
+ setegid(getgid());
+#endif
+#ifndef STRUECOLOR24
+ if (imagetype == TRUECOLOR24)
+ imagetype = TRUECOLOR;
+#endif
+ if (imgtype != NULL) {
+ if (!strcmp("256", imgtype))
+ imagetype = C256;
+ else if (!strcmp("truecolor", imgtype)) {
+ x_fatalerror("Unknown image type:%s", imgtype);
+ }
+ }
+ if (defsize != NULL &&
+ !sscanf(defsize, "%ix%i", &width, &height) &&
+ (width <= 0 || height <= 0)) {
+ x_fatalerror("Invalid size (use for example 320x200");
+ }
+ if (framerate <= 0)
+ framerate = 30;
+ uih_renderanimation(NULL, rbasename, defrender, width, height,
+ ui_get_windowwidth(width) / width,
+ ui_get_windowheight(height) / height,
+ (int) (1000000 / framerate), imagetype, alias,
+ slowmode, letterspersec, NULL, defvectors,
+ iframedist);
+ return 1;
+ }
+ return 0;
+}
diff --git a/src/ui/param.c b/src/ui/param.c
new file mode 100644
index 0000000..eb10a9d
--- /dev/null
+++ b/src/ui/param.c
@@ -0,0 +1,172 @@
+/*
+ * 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.
+ */
+#ifdef _plan9_
+#include <u.h>
+#include <libc.h>
+#else
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#endif
+#include <config.h>
+#include <param.h>
+#include <xmenu.h>
+#include <version.h>
+#include <xerror.h>
+#define MAXPARAMS 40
+static CONST struct params *params[40];
+int nparams;
+
+int params_parser(int argc, char **argv)
+{
+ int i, p = 0, d;
+ int ie = 0;
+ int is;
+ CONST struct params *par = NULL;
+ int error = 0;
+ int found;
+ for (i = 1; i < argc && !error; i++) {
+ found = 0;
+#ifdef MACOSX
+ if (strncmp("-psn", argv[i], 4) == 0)
+ continue;
+#endif
+ if (!strcmp("-help", argv[i])) {
+ error = 1;
+ break;
+ }
+ for (d = 0; d < nparams; d++) {
+ par = params[d];
+ for (p = 0; par[p].name != NULL && !error; p++) {
+ if (!strcmp(par[p].name, argv[i])) {
+ found = 1;
+ is = i;
+ switch (par[p].type) {
+ case P_SWITCH:
+ *((int *) par[p].value) = 1;
+ break;
+ case P_NUMBER:
+ {
+ int n;
+ if (i == argc - 1) {
+ x_error
+ ("parameter %s requires numeric value.",
+ argv[i]);
+ error = 1;
+ break;
+ }
+ if (sscanf(argv[i + 1], "%i", &n) != 1) {
+ x_error("parameter for %s is not number.",
+ argv[i]);
+ error = 1;
+ break;
+ }
+ *((int *) par[p].value) = n;
+ i++;
+ }
+ break;
+ case P_FLOAT:
+ {
+ float n;
+ if (i == argc - 1) {
+ x_error
+ ("parameter %s requires floating point numeric value.",
+ argv[i]);
+ error = 1;
+ break;
+ }
+ if (sscanf(argv[i + 1], "%f", &n) != 1) {
+ x_error
+ ("parameter for %s is not floating point number.",
+ argv[i]);
+ error = 1;
+ break;
+ }
+ *((float *) par[p].value) = n;
+ i++;
+ }
+ break;
+ case P_STRING:
+ {
+ if (i == argc - 1) {
+ x_error
+ ("parameter %s requires string value.",
+ argv[i]);
+ error = 1;
+ break;
+ }
+ i++;
+ *((char **) par[p].value) = *(argv + i);
+ }
+ }
+ ie = i;
+ i = is;
+ }
+ }
+ }
+ if (d == nparams && !found) {
+ i = menu_processargs(i, argc, argv);
+ if (i < 0) {
+ error = 1;
+ break;
+ } else
+ i++;
+ } else
+ i = ie;
+ }
+ if (error) {
+ const char *name[] = {
+ "",
+ "number",
+ "string",
+ "f.point"
+ };
+#ifndef _plan9_
+ printf(" XaoS" XaoS_VERSION " help text\n");
+ printf
+ (" (This help is genereated automagically. I am sorry for all inconvencies)\n\n");
+#endif
+ printf("option string param description\n\n");
+ for (d = 0; d < nparams; d++) {
+ par = params[d];
+ for (p = 0; par[p].name != NULL; p++) {
+ if (par[p].type == P_HELP)
+ printf("\n%s\n\n", par[p].help);
+ else if (!par[p].type)
+ printf(" %-14s %s\n", par[p].name, par[p].help);
+ else
+ printf(" %-14s %s\n%14s %s\n", par[p].name,
+ name[par[p].type], "", par[p].help);
+ }
+ if (p == 0)
+ printf(" No options avaiable for now\n");
+ }
+ menu_printhelp();
+ return 0;
+ }
+ return (1);
+}
+
+void params_register(CONST struct params *par)
+{
+ params[nparams++] = par;
+}
diff --git a/src/ui/pipecmd.c b/src/ui/pipecmd.c
new file mode 100644
index 0000000..f0f4c66
--- /dev/null
+++ b/src/ui/pipecmd.c
@@ -0,0 +1,113 @@
+#include <config.h>
+#ifndef _plan9
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#ifndef _MAC
+#include <sys/types.h>
+#endif
+#include <fconfig.h>
+#include <filter.h>
+#include <fractal.h>
+#include <string.h>
+#include <ui_helper.h>
+#include <ui.h>
+#include <timers.h>
+#include <xmenu.h>
+#include "uiint.h"
+#ifdef COMPILE_PIPE
+static int pipefd = -1;
+tl_timer *pipetimer;
+static char pipecommand[256];
+static int commandpos;
+static int textmode = 0;
+static int backslash = 0;
+static int nest = -1;
+#define add(cmd) (pipecommand[commandpos++]=cmd)
+static void ui_pipe_handler(void *data, int q)
+{
+#ifdef O_NONBLOCK
+ char buf[100];
+ int n = (int) read(pipefd, buf, 100);
+ int i;
+ if (n > 0) {
+ buf[n] = 0;
+ }
+ for (i = 0; i < n; i++) {
+ if (backslash) {
+ add(buf[i]);
+ continue;
+ }
+ if (textmode) {
+ if (buf[i] == '\\') {
+ add(buf[i]);
+ backslash = 1;
+ continue;
+ }
+ if (buf[i] == '"') {
+ add(buf[i]);
+ textmode = 0;
+ continue;
+ }
+ add(buf[i]);
+ } else {
+ add(buf[i]);
+ if (buf[i] == '"')
+ textmode = 1;
+ if (buf[i] == ')')
+ nest--;
+ if (buf[i] == '(') {
+ if (nest == -1)
+ nest = 1;
+ else
+ nest++;
+ }
+ if (!nest) {
+ add(0);
+ uih_command(uih, pipecommand);
+ nest = -1;
+ commandpos = 0;
+ }
+ }
+ }
+#endif
+}
+
+void ui_pipe_init(CONST char *name)
+{
+#ifdef O_NONBLOCK
+ if ((int) strlen(name) == 1 && name[0] == '-') {
+ pipefd = 0;
+ fcntl(pipefd, F_SETFL, O_NONBLOCK);
+ } else {
+ pipefd = open(name, O_NONBLOCK);
+ if (pipefd == -1) {
+ perror(name);
+ exit(1);
+ }
+ }
+ pipetimer = tl_create_timer();
+ tl_set_multihandler(pipetimer, ui_pipe_handler, NULL);
+ tl_reset_timer(pipetimer);
+ tl_set_interval(pipetimer, 100000);
+ tl_add_timer(syncgroup, pipetimer);
+#else
+ printf
+ ("Fatal error - constant O_NONBLOCK used for non-blocking IO in the pipe handling"
+ "is unknown at the moment of compilation. The non-blocking IO will not work. "
+ "Please ask authors...\n");
+ exit(0);
+#endif
+}
+
+static void ui_pipe_close(void)
+{
+#ifdef O_NONBLOCK
+ if (pipefd == -1)
+ return;
+ close(pipefd);
+ tl_remove_timer(pipetimer);
+#endif
+}
+#endif
+#endif
diff --git a/src/ui/ui-drv/aa/Makefile.in b/src/ui/ui-drv/aa/Makefile.in
new file mode 100644
index 0000000..c49da4a
--- /dev/null
+++ b/src/ui/ui-drv/aa/Makefile.in
@@ -0,0 +1,39 @@
+CC = @CC@
+CFLAGS = @CFLAGS@
+LIBS = @LIBS@ -lm
+LFLAGS = @LDFLAGS@
+AR = @AR@
+RANLIB = @RANLIB@
+
+SRCS = ui_aa.c
+
+OBJS = $(SRCS:.c=.o)
+
+TLIB = @LIBPATH@/libuiaa.a
+
+
+all: $(TLIB)
+
+$(TLIB):$(OBJS)
+ rm -f $@
+ $(AR) rc $@ $(OBJS)
+ $(RANLIB) $@
+
+clean:
+ rm -f $(TLIB)
+ rm -f *.[oas]
+ rm -f *~
+ rm -f core
+
+distclean:clean
+ rm Makefile
+
+#dep:
+# rm -f .depend
+# make .depend
+#
+#.depend:
+# echo '# Program dependencies' >.depend
+# gcc -I svgalib $(DEFINES) -MM $(patsubst %.o,%.c,$(OBJS)) >>.depend
+#
+#include .depend
diff --git a/src/ui/ui-drv/aa/ui_aa.c b/src/ui/ui-drv/aa/ui_aa.c
new file mode 100644
index 0000000..22aa0fc
--- /dev/null
+++ b/src/ui/ui-drv/aa/ui_aa.c
@@ -0,0 +1,724 @@
+#include "aconfig.h"
+#ifdef AA_DRIVER
+#include <string.h>
+#include <malloc.h>
+#include <aalib.h>
+#include <ui.h>
+#include <unistd.h>
+#include <xmenu.h>
+#include <archaccel.h>
+struct ui_driver aalib_driver;
+static aa_palette palette;
+static aa_palette aapalette;
+static int useaapalette;
+#define c context
+static aa_context *c;
+static unsigned char *secondary;
+static int mouse;
+static int nomouse;
+static void aa_build_menus (void);
+static void aa_remove_menus (void);
+extern unsigned char *aa_chardata;
+extern unsigned char *aa_colordata;
+extern int aa_cursorx, aa_cursory;
+
+
+
+static void
+aa_print (int x, int y, CONST char *text)
+{
+ aa_puts (c, x / 2, y / 2, AA_SPECIAL, text);
+}
+
+static void
+aa_display (void)
+{
+ int i;
+ aa_renderpalette (c, useaapalette ? aapalette : palette,
+ &aa_defrenderparams, 0, 0, aa_scrwidth (c),
+ aa_scrheight (c));
+ for (i = 0; i < aa_scrwidth (c) * aa_scrheight (c); i++)
+ {
+ if (aa_colordata[i] != 255)
+ aa_text (c)[i] = aa_chardata[i], aa_attrs (c)[i] = aa_colordata[i];
+ }
+}
+static void
+aa_set_palette (ui_palette pal, int start, int end)
+{
+ int i;
+ for (i = start; i <= end; i++)
+ aa_setpalette (palette, i, pal[i - start][0], pal[i - start][1],
+ pal[i - start][2]);
+ aa_display ();
+ aa_flush (c);
+}
+
+static void
+aa_flip_buffers (void)
+{
+ unsigned char *tmp;
+ tmp = secondary;
+ secondary = c->imagebuffer;
+ c->imagebuffer = tmp;
+}
+
+static void
+aa_free_buffers (char *b1, char *b2)
+{
+ free (aa_chardata);
+ free (aa_colordata);
+ free (secondary);
+}
+
+static int
+aa_alloc_buffers (char **b1, char **b2)
+{
+ secondary = malloc (aa_imgwidth (c) * aa_imgheight (c));
+ *(unsigned char **) b2 = secondary;
+ *(unsigned char **) b1 = c->imagebuffer;
+ aa_chardata = malloc (aa_scrwidth (c) * aa_scrheight (c));
+ aa_colordata = malloc (aa_scrwidth (c) * aa_scrheight (c));
+ return aa_imgwidth (c); /* bytes per scanline */
+}
+
+static void
+aa_getsize (int *w, int *h)
+{
+ aa_resize (c);
+ *w = aa_imgwidth (c);
+ *h = aa_imgheight (c);
+}
+
+static int mousex, mousey, mouseb;
+static void
+aa_processevents (int wait, int *mx, int *my, int *mb, int *k)
+{
+ int ch;
+ static int keys;
+ do
+ {
+ if ((ch = aa_getevent (c, wait)) != AA_NONE && ch != AA_MOUSE
+ && ch != AA_RESIZE && ch < 256)
+ ui_key (ch);
+ switch (ch)
+ {
+ case AA_BACKSPACE:
+ ui_key (UIKEY_BACKSPACE);
+ break;
+ case AA_ESC:
+ ui_key (UIKEY_ESC);
+ break;
+ case AA_RESIZE:
+ ui_resize ();
+ break;
+ case AA_MOUSE:
+ aa_getmouse (c, &mousex, &mousey, &mouseb);
+ break;
+ case AA_LEFT:
+ ui_key (UIKEY_LEFT);
+ if (c->kbddriver->flags & AA_SENDRELEASE)
+ keys |= 1;
+ break;
+ case AA_LEFT | AA_RELEASE:
+ keys &= ~1;
+ break;
+ case AA_RIGHT:
+ ui_key (UIKEY_RIGHT);
+ if (c->kbddriver->flags & AA_SENDRELEASE)
+ keys |= 2;
+ break;
+ case AA_RIGHT | AA_RELEASE:
+ keys &= ~2;
+ break;
+ case AA_UP:
+ ui_key (UIKEY_UP);
+ if (c->kbddriver->flags & AA_SENDRELEASE)
+ keys |= 4;
+ break;
+ case AA_UP | AA_RELEASE:
+ keys &= ~4;
+ break;
+ case AA_DOWN:
+ ui_key (UIKEY_DOWN);
+ if (c->kbddriver->flags & AA_SENDRELEASE)
+ keys |= 8;
+ break;
+ case AA_DOWN | AA_RELEASE:
+ keys &= ~8;
+ break;
+ }
+ wait = 0;
+ }
+ while (ch != AA_NONE);
+ *mx = mousex * 2;
+ *my = mousey * 2;
+ *k = keys;
+ *mb = 0;
+ if (mouseb & AA_BUTTON1)
+ *mb |= BUTTON1;
+ if (mouseb & AA_BUTTON2)
+ *mb |= BUTTON2;
+ if (mouseb & AA_BUTTON3)
+ *mb |= BUTTON3;
+ return;
+}
+
+#define NATTRS 7
+static char *aadriver = NULL;
+static char *kbddriver = NULL;
+static char *mousedriver = NULL;
+static char *deffont = NULL;
+static int width, height, minwidth, minheight, maxwidth, maxheight, recwidth,
+ recheight;
+static int enable[NATTRS + 2], disable[NATTRS + 2];
+static int extended, inverse, bright = 0, contrast = 0;
+static float aa_gamma, dimmul, boldmul;
+static int dithering[3];
+static int randomval = 0;
+static int masks[] =
+ { AA_NORMAL_MASK, AA_DIM_MASK, AA_BOLD_MASK, AA_BOLDFONT_MASK,
+ AA_REVERSE_MASK, AA_ALL, AA_EIGHT
+};
+
+#ifdef DESTICKY
+extern int euid, egid;
+#endif
+static int
+aa_initialize (void)
+{
+ int i, y;
+ aa_parseoptions (NULL, NULL, NULL, NULL); /*parse environment first */
+
+ if (deffont != NULL)
+ {
+ for (y = 0; aa_fonts[y] != NULL; y++)
+ {
+ if (!strcmp (deffont, aa_fonts[y]->name)
+ || !strcmp (deffont, aa_fonts[y]->shortname))
+ {
+ aa_defparams.font = aa_fonts[y];
+ break;
+ }
+ }
+ }
+
+ if (extended)
+ aa_defparams.supported |= AA_EXTENDED;
+
+ for (i = 0; i < NATTRS; i++)
+ {
+ if (enable[i])
+ aa_defparams.supported |= masks[i];
+ if (disable[i])
+ aa_defparams.supported &= ~masks[i];
+ }
+
+ for (i = 0; i < 3; i++)
+ if (dithering[i])
+ aa_defrenderparams.dither = i;
+ if (randomval)
+ aa_defrenderparams.randomval = randomval;
+ if (bright)
+ aa_defrenderparams.bright = bright;
+ if (contrast)
+ aa_defrenderparams.contrast = contrast;
+ if (aa_gamma)
+ aa_defrenderparams.gamma = aa_gamma;
+
+ if (width)
+ aa_defparams.width = width;
+ if (height)
+ aa_defparams.height = height;
+ if (minwidth)
+ aa_defparams.minwidth = minwidth;
+ if (minheight)
+ aa_defparams.minheight = minheight;
+ if (maxwidth)
+ aa_defparams.maxwidth = maxwidth;
+ if (maxheight)
+ aa_defparams.maxheight = maxheight;
+ if (recwidth)
+ aa_defparams.recwidth = recwidth;
+ if (recheight)
+ aa_defparams.recheight = recheight;
+
+ if (aadriver != NULL)
+ aa_recommendhidisplay (aadriver);
+ if (kbddriver != NULL)
+ aa_recommendhikbd (kbddriver);
+ if (mousedriver != NULL)
+ aa_recommendhimouse (mousedriver);
+ if (dimmul)
+ aa_defparams.dimmul = dimmul;
+ if (boldmul)
+ aa_defparams.boldmul = boldmul;
+ if (inverse)
+ aa_defrenderparams.inversion = 1;
+
+#ifdef DESTICKY
+ seteuid (euid); /* We need supervisor rights to open mouse. */
+ setegid (egid);
+#endif
+ c = aa_autoinit (&aa_defparams);
+#ifdef DESTICKY
+ seteuid (getuid ()); /* Don't need supervisor rights anymore. */
+ setegid (getgid ());
+#endif
+
+ if (c == NULL)
+ return 0;
+ aa_autoinitkbd (c, AA_SENDRELEASE);
+ if (!nomouse)
+ mouse = aa_autoinitmouse (c, AA_MOUSEALLMASK);
+
+ aalib_driver.width = aa_mmwidth (c) / 10.0;
+ aalib_driver.height = aa_mmheight (c) / 10.0;
+ aa_build_menus ();
+ return (1);
+}
+
+static void
+aa_uninitialise (void)
+{
+ aa_close (c);
+ aa_remove_menus ();
+}
+
+static void
+aa_get_mouse (int *x, int *y, int *b)
+{
+ if (mouse)
+ aa_getmouse (c, &mousex, &mousey, &mouseb);
+ *x = mousex * 2;
+ *y = mousey * 2;
+ *b = 0;
+ if (mouseb & AA_BUTTON1)
+ *b |= BUTTON1;
+ if (mouseb & AA_BUTTON2)
+ *b |= BUTTON2;
+ if (mouseb & AA_BUTTON3)
+ *b |= BUTTON3;
+}
+
+static void
+aa_mousetype (int type)
+{
+#if (AA_LIB_VERSION>1||AA_LIB_MINNOR>0)
+ if (type == REPLAYMOUSE)
+ aa_hidemouse (c);
+ else
+ aa_showmouse (c);
+#endif
+}
+
+
+#if AA_LIB_VERSION==1 && AA_LIB_MINNOR==0
+#define SUPPORTED c->driver->params.supported
+#else
+#define SUPPORTED c->driverparams.supported
+#endif
+
+
+static int driver;
+static int font;
+static int mask;
+
+static void
+aa_save5 (void)
+{
+ struct aa_hardware_params p = aa_defparams;
+ struct aa_context *sc;
+ struct aa_savedata data;
+ int i;
+ char *name;
+ char extension[100];
+ if (aa_formats[driver]->flags & AA_USE_PAGES)
+ strcpy (extension, "_0_0");
+ else
+ extension[0] = 0;
+ strcat (extension, aa_formats[driver]->extension);
+
+#ifdef DJGPP
+ name = ui_getfile ("fr", extension);
+ /*fit into ugly 8char. limit */
+#else
+ name = ui_getfile ("fract", extension);
+#endif
+
+ if (name == NULL)
+ {
+ aa_print (0, 0, "Save driver initialization failed");
+ aa_flush (c);
+ sleep (3);
+ return;
+ }
+ for (i = 0; name[i] != '.' && name[i] != '_'; i++);
+ name[i] = 0;
+ strcat (name, "%c%e");
+
+ p.minwidth = p.maxwidth = 0;
+ p.minheight = p.maxheight = 0;
+ p.width = aa_scrwidth (c);
+ p.height = aa_scrheight (c);
+ p.supported = mask;
+ if (aa_formats[driver]->font == NULL)
+ p.font = aa_fonts[font];
+
+ data.format = aa_formats[driver];
+ data.name = name;
+ sc = aa_init (&save_d, &p, &data);
+ if (sc == NULL)
+ {
+ aa_print (0, 0, "Save driver initialization failed");
+ aa_flush (c);
+ sleep (3);
+ return;
+ }
+ memcpy (sc->imagebuffer, c->imagebuffer,
+ (aa_imgwidth (c) - 1) * aa_imgheight (c));
+ aa_renderpalette (sc, useaapalette ? aapalette : palette,
+ &aa_defrenderparams, 0, 0, aa_scrwidth (c),
+ aa_scrheight (c));
+ aa_flush (sc);
+ aa_close (sc);
+}
+
+static void
+aa_swinversion (struct uih_context *c)
+{
+ aa_defrenderparams.inversion ^= 1;
+}
+static int
+aa_inversion (struct uih_context *c)
+{
+ return (aa_defrenderparams.inversion);
+}
+static int aacurpalette = 0;
+static void
+aa_setXpalette (struct uih_context *c, int m)
+{
+ int i, s;
+ if (!m)
+ {
+ useaapalette = 0;
+ aa_display ();
+ return;
+ }
+ useaapalette = 1;
+ aacurpalette = m;
+ s = 1 << m;
+ s--;
+ for (i = 0; i < 255; i++)
+ {
+ aapalette[i] = (i & (s)) * 255 / s;
+ }
+}
+static int
+aa_getpalette (struct uih_context *c, int m)
+{
+ if (!useaapalette)
+ return (!m);
+ return (m == aacurpalette);
+}
+static void
+aa_dither (struct uih_context *c, int m)
+{
+ aa_defrenderparams.dither = m;
+}
+static int
+aa_getdither (struct uih_context *c, int mode)
+{
+ return ((int) aa_defrenderparams.dither == (int) mode);
+}
+
+
+static void
+aa_sfont (struct uih_context *co, int i)
+{
+ aa_setfont (c, aa_fonts[i]);
+}
+CONST static char *CONST name[] = {
+ "normal characters ",
+ "half bright(dim) ",
+ "double bright(bold) ",
+ "bold font ",
+ "reversed ",
+ "reserved characters ",
+ "non ascii characters ",
+ "leave menu",
+};
+CONST static char *CONST ttext[] = {
+ "Use XaoS palette",
+ "Black and white stripes",
+ "4 gray palette",
+ "16 gray palette",
+ "32 gray palette",
+ "64 gray palette",
+ "128 gray palette",
+ "256 gray palette"
+};
+static CONST int attribs[] = {
+ AA_NORMAL_MASK,
+ AA_DIM_MASK,
+ AA_BOLD_MASK,
+ AA_BOLDFONT_MASK,
+ AA_REVERSE_MASK,
+ AA_ALL,
+ AA_EIGHT,
+ 0
+};
+
+#define MYNATTRS (sizeof(name)/sizeof(char *))
+static void
+aa_swattr (struct uih_context *co, int m)
+{
+ int mask;
+ if (m < (int) MYNATTRS - 1)
+ {
+ mask = c->params.supported;
+ mask ^= attribs[m];
+ aa_setsupported (c, mask);
+ ui_menu ("aa_attr");
+ }
+}
+static int
+aa_getattr (struct uih_context *co, int m)
+{
+ return (c->params.supported & attribs[m]);
+}
+static int
+aa_getsave3 (struct uih_context *c, int m)
+{
+ return (mask & attribs[m]);
+}
+static void
+aa_save3 (struct uih_context *co, int m)
+{
+ if (m < (int) MYNATTRS - 1)
+ {
+ mask ^= attribs[m];
+ mask &= aa_formats[driver]->supported;
+ ui_menu ("aa_save3");
+ }
+ else
+ aa_save5 ();
+}
+static void
+aa_save2 (struct uih_context *cc, int m)
+{
+ aa_display ();
+ font = m;
+ mask = aa_formats[driver]->supported & c->params.supported;
+ if (!mask)
+ mask = aa_formats[driver]->supported;
+ ui_menu ("aa_save3");
+}
+static void
+aa_save (struct uih_context *c, int m)
+{
+ driver = m;
+ if (aa_formats[m]->font != NULL)
+ aa_save3 (NULL, 0);
+ else
+ ui_menu ("aa_save2");
+}
+
+#define UI (MENUFLAG_NOOPTION|MENUFLAG_NOPLAY)
+static CONST menuitem menuitems[] = {
+ SUBMENU ("file", NULL, "Save as text file", "aa_format"),
+ SUBMENU ("ui", NULL, "Attributes", "aa_attr"),
+ SUBMENU ("ui", NULL, "Font", "aa_font"),
+ MENUNOPCB ("ui", NULL, "Inversion", "aainversion", UI, aa_swinversion,
+ aa_inversion),
+ SUBMENU ("ui", NULL, "Dithering mode", "aa_dithering"),
+ SUBMENU ("", NULL, "Font for saved file", "aa_save2"),
+ SUBMENU ("", NULL, "Save attributes", "aa_save3"),
+ SUBMENU ("palettemenu", NULL, "Text palette", "aa_palette"),
+};
+
+static menuitem *fontmenus;
+static menuitem *fontmenus2;
+static menuitem *formatmenus;
+static int nfonts, nformats;
+static void
+aa_build_menus ()
+{
+ int i;
+ menu_add (menuitems, NITEMS (menuitems));
+ menu_genernumbered (sizeof (ttext) / sizeof (char *), "aa_palette", ttext,
+ NULL, MENU_INT, MENUFLAG_RADIO, aa_setXpalette,
+ aa_getpalette, "palettemenu");
+ menu_genernumbered (AA_DITHERTYPES, "aa_dithering",
+ (CONST char *CONST * CONST) aa_dithernames, NULL,
+ MENU_INT, MENUFLAG_RADIO, aa_dither, aa_getdither,
+ "dither");
+ menu_genernumbered (MYNATTRS, "aa_attr", name, NULL, MENU_INT,
+ MENUFLAG_RADIO, aa_swattr, aa_getattr, "attribute");
+ menu_genernumbered (MYNATTRS, "aa_save3", name, NULL, MENU_INT,
+ MENUFLAG_RADIO, aa_save3, aa_getsave3, "save");
+ for (i = 0; aa_fonts[i] != NULL; i++);
+ nfonts = i;
+ fontmenus = malloc (sizeof (menuitem) * i);
+ fontmenus2 = malloc (sizeof (menuitem) * i);
+ for (i = 0; aa_fonts[i] != NULL; i++)
+ {
+ char s[256];
+ sprintf (s, "font%i%s", i, aa_fonts[i]->shortname);
+ fontmenus[i].name = aa_fonts[i]->name;
+ fontmenus[i].shortname = strdup (s);
+ fontmenus[i].menuname = "aa_font";
+ fontmenus[i].key = NULL;
+ fontmenus[i].type = MENU_INT;
+ fontmenus[i].flags = UI;
+ fontmenus[i].iparam = i;
+ fontmenus[i].function = (void (*)(void)) aa_sfont;
+ fontmenus2[i].name = aa_fonts[i]->name;
+ fontmenus2[i].shortname = fontmenus[i].shortname;
+ fontmenus2[i].menuname = "aa_save2";
+ fontmenus2[i].key = NULL;
+ fontmenus2[i].type = MENU_INT;
+ fontmenus2[i].flags = UI;
+ fontmenus2[i].iparam = i;
+ fontmenus2[i].function = (void (*)(void)) aa_save2;
+ }
+ menu_add (fontmenus, nfonts);
+ menu_add (fontmenus2, nfonts);
+ for (i = 0; aa_formats[i] != NULL; i++);
+ nformats = i;
+ formatmenus = malloc (sizeof (menuitem) * i);
+ for (i = 0; aa_formats[i] != NULL; i++)
+ {
+ formatmenus[i].name = aa_formats[i]->formatname;
+ formatmenus[i].shortname = aa_formats[i]->formatname;
+ formatmenus[i].menuname = "aa_format";
+ formatmenus[i].key = NULL;
+ formatmenus[i].type = MENU_INT;
+ formatmenus[i].flags = UI;
+ formatmenus[i].iparam = i;
+ formatmenus[i].function = (void (*)(void)) aa_save;
+ }
+ menu_add (formatmenus, nformats);
+}
+static void
+aa_remove_menus ()
+{
+ int i;
+ menu_delnumbered (sizeof (ttext) / sizeof (char *), "palettemenu");
+ menu_delnumbered (AA_DITHERTYPES, "dither");
+ menu_delnumbered (MYNATTRS, "attribute");
+ menu_delnumbered (MYNATTRS, "save");
+ menu_delete (menuitems, NITEMS (menuitems));
+ menu_delete (fontmenus, nfonts);
+ menu_delete (fontmenus2, nfonts);
+ free (fontmenus2);
+ menu_delete (formatmenus, nformats);
+ free (formatmenus);
+ for (i = 0; aa_fonts[i] != NULL; i++)
+ {
+ free ((char *) fontmenus[i].shortname);
+ }
+ free (fontmenus);
+}
+static int cursorvisible = 1;
+static void
+aa_fflush (void)
+{
+ if (aa_cursorx < 0)
+ {
+ if (cursorvisible)
+ {
+ aa_gotoxy (c, 0, 0);
+ aa_hidecursor (c);
+ cursorvisible = 0;
+ }
+ }
+ else
+ {
+ aa_gotoxy (c, aa_cursorx, aa_cursory);
+ if (!cursorvisible)
+ aa_showcursor (c), cursorvisible = 1;
+ }
+ aa_flush (c);
+}
+
+static CONST struct params params[] = {
+ {"", P_HELP, NULL, "AA driver options:"},
+ {"-aadriver", P_STRING, &aadriver, "Select display driver used by aa-lib"},
+ {"-kbddriver", P_STRING, &kbddriver,
+ "Select keyboard driver used by aa-lib"},
+ {"-mousedriver", P_STRING, &mousedriver,
+ "Select keyboard driver used by aa-lib"},
+ {"-font", P_STRING, &deffont, "Select font"},
+ {"-width", P_NUMBER, &width, "Set width"},
+ {"-height", P_NUMBER, &height, "Set height"},
+ {"-minwidth", P_NUMBER, &minwidth, "Set minimal allowed width"},
+ {"-minheight", P_NUMBER, &minheight, "Set minimal allowed height"},
+ {"-maxwidth", P_NUMBER, &maxwidth, "Set maximal allowed width"},
+ {"-maxheight", P_NUMBER, &maxheight, "Set maximal allowed height"},
+ {"-recwidth", P_NUMBER, &recwidth, "Set recommended width"},
+ {"-recheight", P_NUMBER, &recheight, "Set recommended height"},
+ {"-normal", P_SWITCH, enable, "enable usage of narmal characters"},
+ {"-nonormal", P_SWITCH, disable, "disable usage of narmal characters"},
+ {"-dim", P_SWITCH, enable + 1,
+ "enable usage of dim(half bright) characters"},
+ {"-nodim", P_SWITCH, disable + 1,
+ "disable usage of dim(half bright) characters"},
+ {"-bold", P_SWITCH, enable + 2,
+ "enable usage of bold(double bright) characters"},
+ {"-nobold", P_SWITCH, disable + 2,
+ "disable usage of bold(double bright) characters"},
+ {"-boldfont", P_SWITCH, enable + 3, "enable usage of boldfont characters"},
+ {"-noboldfont", P_SWITCH, disable + 3,
+ "disable usage of boldfont characters"},
+ {"-reverse", P_SWITCH, enable + 4, "enable usage of reversed characters"},
+ {"-noreverse", P_SWITCH, disable + 4,
+ "disable usage of reversed characters"},
+ {"-all", P_SWITCH, enable + 5, "enable usage of reserved characters"},
+ {"-eight", P_SWITCH, enable + 6, "enable usage of non ansii characters"},
+ {"-extended", P_SWITCH, &extended,
+ "enable usage of extended character set"},
+ {"-inverse", P_SWITCH, &inverse, "enable inverse"},
+ {"-bright", P_NUMBER, &bright, "set bright (0-255)"},
+ {"-contrast", P_NUMBER, &contrast, "set contrast (0-255)"},
+ {"-gamma", P_FLOAT, &aa_gamma, "set famma (0-1)"},
+ {"-nodither", P_SWITCH, dithering, "Disable dithering"},
+ {"-floyd_steinberg", P_SWITCH, dithering + 2,
+ "Enable floyd steinberg dithering"},
+ {"-error_distribution", P_SWITCH, dithering + 1,
+ "Enable error distribution dithering"},
+ {"-random", P_NUMBER, &randomval, "Set random dithering value"},
+ {"-dimmul", P_FLOAT, &dimmul, "Multiply factor for dim color (5.3)"},
+ {"-boldmul", P_FLOAT, &boldmul, "Multiply factor for bold color (5.3)"},
+ {"-nomouse", P_SWITCH, &nomouse, "Disable mouse"},
+ {NULL, 0, NULL, NULL}
+};
+
+struct ui_driver aalib_driver = {
+ "aa",
+ aa_initialize,
+ aa_getsize,
+ aa_processevents,
+ aa_get_mouse,
+ aa_uninitialise,
+ NULL, /*You should implement just one */
+ aa_set_palette, /*of these and add NULL as second */
+ aa_print,
+ aa_display,
+ aa_alloc_buffers,
+ aa_free_buffers,
+ aa_flip_buffers,
+ aa_mousetype,
+ aa_fflush,
+ 2, /*text width */
+ 2, /*text height */
+ params,
+ PALETTE_REDISPLAYS | SCREENSIZE | UPDATE_AFTER_RESIZE | AALIB, /*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 */
+};
+
+#endif
diff --git a/src/ui/ui-drv/cocoa/AppController.h b/src/ui/ui-drv/cocoa/AppController.h
new file mode 100644
index 0000000..324eaff
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/AppController.h
@@ -0,0 +1,59 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * Cocoa Driver by J.B. Langston III (jb-langston@austin.rr.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.
+ */
+#import <Cocoa/Cocoa.h>
+#import <Carbon/Carbon.h>
+
+#import "FractalView.h"
+#include "ui.h"
+@ class VideatorProxy;
+
+@interface AppController:NSObject {
+ FractalView *view;
+ NSWindow *window;
+ BOOL applicationIsLaunched;
+}
+
+#pragma mark Accessors
+-(FractalView *) view;
+
+#pragma mark Driver Initialization
+-(void) initLocale;
+-(int) initDriver:(struct ui_driver *)driver fullscreen:(BOOL) fullscreen;
+-(void) uninitDriver;
+
+#pragma mark Menus
+-(void) localizeApplicationMenu;
+-(void) performMenuAction:(NSMenuItem *) sender;
+-(NSString *) keyEquivalentForName:(NSString *) name;
+-(void) buildMenuWithContext:(struct uih_context *)context name:(CONST char *) name;
+-(void) buildMenuWithContext:(struct uih_context *)context name:(CONST char *)menuName parent:(NSMenu *) parentMenu;
+-(void) buildMenuWithContext:(struct uih_context *)context name:(CONST char *)menuName parent:(NSMenu *)parentMenu isNumbered:(BOOL) isNumbered;
+-(void) showPopUpMenuWithContext:(struct uih_context *)context name:(CONST char *) name;
+
+#pragma mark Dialogs
+-(void) showDialogWithContext:(struct uih_context *)context name:(CONST char *) name;
+
+#pragma mark Help
+-(void) showHelpWithContext:(struct uih_context *)context name:(CONST char *) name;
+@end extern AppController *controller;
diff --git a/src/ui/ui-drv/cocoa/AppController.m b/src/ui/ui-drv/cocoa/AppController.m
new file mode 100644
index 0000000..6f03b97
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/AppController.m
@@ -0,0 +1,542 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * Cocoa Driver by J.B. Langston III (jb-langston@austin.rr.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.
+ */
+#import "AppController.h"
+#import "CustomDialog.h"
+#import "VideatorProxy.h"
+#import "ui.h"
+
+#ifdef HAVE_GETTEXT
+#include <libintl.h>
+#include <locale.h>
+#define _(string) gettext(string)
+#else
+#define _(string) (string)
+#endif
+
+/*
+ * This category overrides standard NSWindow behavior which prevents a window
+ * from receiving keyboard events unless it has a titlebar. Without this, the
+ * keyboard doesn't work in full screen mode.
+ */
+@implementation NSWindow (CanBecomeKeyWindowOverride)
+- (BOOL)canBecomeKeyWindow {
+ return YES;
+}
+@end
+
+
+AppController *controller;
+
+@implementation AppController
+
+
+#pragma mark Initialization
+- (id)init {
+ self = [super init];
+ if (self) {
+ applicationIsLaunched = NO;
+ [self initLocale];
+ }
+ return self;
+}
+
+#pragma mark Accessors
+
+- (FractalView *)view {
+ return view;
+}
+
+#pragma mark Driver Initialization
+
+- (void)initLocale {
+ /*
+ * The LANG environment variables used by gettext to determine the locale
+ * are not normally set on Mac OS X, so we use the Cocoa API to retrieve
+ * the list of preferred languages and set the LANG variable accordingly.
+ */
+
+ NSString *myLocalePath = [[[NSBundle mainBundle] resourcePath]
+ stringByAppendingPathComponent:@"locale"];
+
+#ifdef USE_LOCALEPATH
+ /*
+ * This is a global variable defined in ui.h, which the main function uses
+ * to locate the locale files when USE_LOCALEPATH is defined. If it is
+ * undefined, the main function will use the hard coded locale path instead.
+ */
+ localepath = (char *)[myLocalePath UTF8String];
+#endif
+
+ /*
+ * Each of the locales we support is stored in its own subdirectory in the
+ * Resources/locale directory. The name of the directory corresponds to the
+ * ISO code for the locale. Therefore, a list of the files in this
+ * directory conveniently serves as a list of supported locales.
+ */
+ NSMutableArray *supportedLanguages = [[[NSFileManager defaultManager]
+ directoryContentsAtPath:myLocalePath]
+ mutableCopy];
+
+ /* English is supported by default, so there isn't a locale directory for
+ * it. But in order to match it with the user's preferred languages, it
+ * still has to be in the array of supported languages.
+ */
+ [supportedLanguages addObject:@"en"];
+
+ /*
+ * The AppleLanguages user default returns an array of languages sorted
+ * according to the User's settings in the International Preference Panel.
+ * We find the best match between the supported and preferred locales
+ * and set the LANG variable to that.
+ */
+ NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
+ NSArray *preferredLanguages = [defaults objectForKey:@"AppleLanguages"];
+ NSString *lang = [preferredLanguages firstObjectCommonWithArray:supportedLanguages];
+ if (lang) setenv("LANG", [lang UTF8String], /*overwrite? */ 0);
+
+ [supportedLanguages release];
+}
+
+- (int)initDriver:(struct ui_driver *)driver
+ fullscreen:(BOOL)fullscreen {
+ /*
+ * Calculate the pixel size in cm. userSpaceScaleFactor returns:
+ * pixels per per point
+ * pixels per inch = pixels per point * 72.0
+ * inches per pixel = 1 / pixels per inch
+ * cm per pixel = inches per pixel * 2.54
+ */
+ CGDirectDisplayID displayID = (CGDirectDisplayID)[[[[NSScreen mainScreen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
+ CGSize displaySize = CGDisplayScreenSize(displayID);
+ NSSize displayResolution = [[NSScreen mainScreen] frame].size;
+ driver->width = (displaySize.width/displayResolution.width)/10;
+ driver->height = (displaySize.height/displayResolution.height)/10;
+
+ if (fullscreen) {
+ /*
+ * SetSystemUIMode is the easiest way to make a full screen application.
+ * It's Carbon, but it should be 64-bit safe. kUIModeAllHidden hides
+ * the dock and menuBar and kUIOptionAutoShowMenuBar causes the menubar
+ * to automatically slide in when the user moves the mouse to the top
+ * edge of the screen.
+ */
+ SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
+ window = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame]
+ styleMask:NSBorderlessWindowMask
+ backing:NSBackingStoreBuffered
+ defer:YES];
+ } else {
+ window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50, 50, 640, 480)
+ styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
+ backing:NSBackingStoreBuffered
+ defer:YES];
+ [window setFrameAutosaveName:@"XaoSWindow"];
+ }
+
+ view = [[FractalView alloc] initWithFrame:[[window contentView] frame]];
+ [view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
+ [[window contentView] addSubview:view];
+ [window makeFirstResponder:view];
+ [window setDelegate:self];
+ [window setTitle:@"XaoS"];
+ [window makeKeyAndOrderFront:self];
+ [NSApp setDelegate:self];
+
+ /*
+ * These tasks should only be done once, when the application first launches
+ * but for various reasons, they can't be done until after the main run
+ * loop has started. That's why we put them in the driver init code.
+ */
+ if (!applicationIsLaunched) {
+ [self localizeApplicationMenu];
+ [NSApp finishLaunching];
+ applicationIsLaunched = YES;
+ }
+
+ return 1; // 1 for success; 0 for failure
+}
+
+- (void)uninitDriver {
+ SetSystemUIMode(kUIModeNormal, 0);
+ [view release];
+ [window release];
+}
+
+#pragma mark Menus
+
+- (void)localizeApplicationMenu {
+ /*
+ * Internationalize XaoS application menu. We do this via code instead
+ * of within the nib because this allows all i18n to be cross-platform and
+ * self-contained within the po file instead of spread across many places.
+ */
+ NSMenu *appMenu = [[[NSApp mainMenu] itemAtIndex:0] submenu];
+
+ [[appMenu itemWithTitle:@"About XaoS"]
+ setTitle:[NSString stringWithUTF8String:_("About XaoS")]];
+
+ [[appMenu itemWithTitle:@"Services"]
+ setTitle:[NSString stringWithUTF8String:_("Services")]];
+
+ [[appMenu itemWithTitle:@"Hide XaoS"]
+ setTitle:[NSString stringWithUTF8String:_("Hide XaoS")]];
+
+ [[appMenu itemWithTitle:@"Hide Others"]
+ setTitle:[NSString stringWithUTF8String:_("Hide Others")]];
+
+ [[appMenu itemWithTitle:@"Show All"]
+ setTitle:[NSString stringWithUTF8String:_("Show All")]];
+
+ [[appMenu itemWithTitle:@"Quit XaoS"]
+ setTitle:[NSString stringWithUTF8String:_("Quit XaoS")]];
+}
+
+- (void)performMenuAction:(NSMenuItem *)sender {
+ /*
+ * Find the XaoS menu item associated with the sending Cocoa menu item
+ * then invoke the callback to perform that action.
+ */
+ NSString *name = [sender representedObject];
+ CONST menuitem *item = menu_findcommand([name UTF8String]);
+
+ ui_menuactivate(item, NULL);
+}
+
+- (NSString *)keyEquivalentForName:(NSString *)name {
+ // If you want more command-keys, just add them here based on their name:
+ if ([name isEqualToString:@"undo"]) return @"z";
+ if ([name isEqualToString:@"redo"]) return @"Z";
+ if ([name isEqualToString:@"loadpos"]) return @"o";
+ if ([name isEqualToString:@"savepos"]) return @"s";
+ return @"";
+}
+
+- (void)buildMenuWithContext:(struct uih_context *)context
+ name:(CONST char *)name {
+ NSMenu *menu = [NSApp mainMenu];
+ while ([menu numberOfItems] > 1)
+ [menu removeItemAtIndex:1];
+ [self buildMenuWithContext:context name:name parent:menu];
+}
+
+- (void)buildMenuWithContext:(struct uih_context *)context
+ name:(CONST char *)menuName
+ parent:(NSMenu *)parentMenu {
+ [self buildMenuWithContext:context
+ name:menuName
+ parent:parentMenu
+ isNumbered:NO];
+}
+
+- (void)buildMenuWithContext:(struct uih_context *)context
+ name:(CONST char *)menuName
+ parent:(NSMenu *)parentMenu
+ isNumbered:(BOOL)isNumbered {
+ int i, n;
+ CONST menuitem *item;
+ for (i=0,n=1; (item = menu_item(menuName, i)) != NULL; i++) {
+ if (item->type == MENU_SEPARATOR) {
+ [parentMenu addItem:[NSMenuItem separatorItem]];
+ } else {
+ NSString *menuTitle = [NSString stringWithUTF8String:item->name];
+
+ /*
+ * Add elipses to menu items that open dialogs in order to conform
+ * with the Apple Human Interface Guidelines.
+ */
+ if (item->type == MENU_CUSTOMDIALOG || item->type == MENU_DIALOG)
+ menuTitle = [menuTitle stringByAppendingString:@"..."];
+
+ NSString *menuShortName = [NSString stringWithUTF8String:item->shortname];
+ NSString *keyEquiv = [self keyEquivalentForName:menuShortName];
+
+ /*
+ * Add classic XaoS key accelerator to name in parenthesis, unless
+ * this is the main menu. This allows both Mac-style and Xaos-style
+ * key equivalents to co-exist.
+ */
+ if (item->key && parentMenu != [NSApp mainMenu])
+ menuTitle = [NSString stringWithFormat:@"%@ (%s)", menuTitle, item->key];
+
+ NSMenuItem *newItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:menuTitle action:nil keyEquivalent:keyEquiv];
+
+ /*
+ * If this is a numbered pop-up menu, override the default key
+ * accelerator with a number or letter based on the position in
+ * the menu.
+ */
+ if (isNumbered && item->type != MENU_SUBMENU) {
+ if (n < 10)
+ keyEquiv = [NSString stringWithFormat:@"%d", n];
+ else if (n == 10)
+ keyEquiv = @"0";
+ else if (n < 36)
+ keyEquiv = [NSString stringWithFormat:@"%c", 'a' + n - 11];
+
+ [newItem setKeyEquivalent:keyEquiv];
+ [newItem setKeyEquivalentModifierMask:0];
+ n++;
+ }
+
+ if (item->type == MENU_SUBMENU) {
+ /* Recursively build submenus */
+ NSMenu *newMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:menuTitle];
+ [newMenu setDelegate:self];
+ [newItem setSubmenu:newMenu];
+ [self buildMenuWithContext:context name:item->shortname parent:newMenu];
+
+ /* Conditionally add special items to certain menus */
+
+ /*
+ * These items are necessary to provide the expected keyboard
+ * equivalents for cut & paste operations in custom dialogs
+ * and to conform to the human interface guidelines
+ */
+ if ([menuShortName isEqualToString:@"edit"]) {
+ [newMenu addItem:[NSMenuItem separatorItem]];
+ [newMenu addItemWithTitle:[NSString stringWithUTF8String:_("Cut")]
+ action:@selector(cut:) keyEquivalent:@"x"];
+
+ [newMenu addItemWithTitle:[NSString stringWithUTF8String:_("Copy")]
+ action:@selector(copy:) keyEquivalent:@"c"];
+
+ [newMenu addItemWithTitle:[NSString stringWithUTF8String:_("Paste")]
+ action:@selector(paste:) keyEquivalent:@"v"];
+
+ [newMenu addItemWithTitle:[NSString stringWithUTF8String:_("Delete")]
+ action:@selector(delete:) keyEquivalent:@""];
+
+ [newMenu addItemWithTitle:[NSString stringWithUTF8String:_("Select All")]
+ action:@selector(selectAll:) keyEquivalent:@"a"];
+ }
+
+ /*
+ * These items in the window menu are necessary to provide expected
+ * keyboard equivalents for menu operations such as minimizing and
+ * to conform with the human interface guidelnes.
+ */
+ if ([menuShortName isEqualToString:@"window"]) {
+ [newMenu addItemWithTitle:[NSString stringWithUTF8String:_("Minimize")]
+ action:@selector(performMiniaturize:) keyEquivalent:@"m"];
+
+ [newMenu addItemWithTitle:[NSString stringWithUTF8String:_("Zoom")]
+ action:@selector(performZoom:) keyEquivalent:@""];
+
+ [newMenu addItem:[NSMenuItem separatorItem]];
+
+ [newMenu addItemWithTitle:[NSString stringWithUTF8String:_("Bring All to Front")]
+ action:@selector(arrangeInFront:) keyEquivalent:@""];
+ }
+
+ /*
+ * The close menu item in the File menu is necessary to provide
+ * the expected Command-W close window keyboard equivalent and
+ * to conform with the human interface guidelines.
+ */
+ if ([menuShortName isEqualToString:@"file"]) {
+ int i = [newMenu indexOfItemWithRepresentedObject:@"savepos"];
+ [newMenu insertItemWithTitle:[NSString stringWithUTF8String:_("Close")]
+ action:@selector(performClose:)
+ keyEquivalent:@"w"
+ atIndex:i];
+ [newMenu insertItem:[NSMenuItem separatorItem] atIndex:i];
+ }
+
+ /*
+ * Add Videator Output menu item in the UI menu just below
+ * VJ Mode. This will toggle sending video feed to Videator.
+ */
+#ifdef VIDEATOR_SUPPORT
+ if ([menuShortName isEqualToString:@"ui"]) {
+ int i = [newMenu indexOfItemWithRepresentedObject:@"inhibittextoutput"]+1;
+ NSMenuItem *item = [newMenu insertItemWithTitle:[NSString stringWithUTF8String:_("Videator Output")]
+ action:@selector(toggleVideator:)
+ keyEquivalent:@""
+ atIndex:i];
+ [item setTarget:[view videatorProxy]];
+ [item setRepresentedObject:@"videator"];
+ }
+#endif
+
+ [newMenu release];
+ } else {
+ /*
+ * Set action for leaf menu items to generic callback function
+ * and save the short name as the item's represented object. When
+ * the callback is activated, it will find the XaoS menu item
+ * to activate based on the represented object.
+ */
+ [newItem setTarget:self];
+ [newItem setAction:@selector(performMenuAction:)];
+ [newItem setRepresentedObject:menuShortName];
+ if (item->flags & (MENUFLAG_RADIO | MENUFLAG_CHECKBOX) && menu_enabled (item, context))
+ [newItem setState:NSOnState];
+ }
+
+ [parentMenu addItem:newItem];
+ [newItem release];
+ }
+ }
+}
+
+- (void)menuNeedsUpdate:(NSMenu *)menu {
+ CONST struct menuitem *xaosItem;
+ NSMenuItem *menuItem;
+ NSEnumerator *itemEnumerator = [[menu itemArray] objectEnumerator];
+ while (menuItem = [itemEnumerator nextObject]) {
+ if ([menuItem representedObject]) {
+ xaosItem = menu_findcommand([[menuItem representedObject] UTF8String]);
+ if (xaosItem)
+ [menuItem setState:(menu_enabled(xaosItem, globaluih) ? NSOnState : NSOffState)];
+#ifdef VIDEATOR_SUPPORT
+ else if ([[menuItem representedObject] isEqualToString:@"videator"])
+ [menuItem setState:([[view videatorProxy] videatorEnabled] ? NSOnState : NSOffState)];
+#endif
+ }
+ }
+}
+
+- (void)showPopUpMenuWithContext:(struct uih_context *)context
+ name:(CONST char *)name {
+ NSMenu *popUpMenu = [[NSMenu alloc] initWithTitle:@"Popup Menu"];
+ NSPopUpButtonCell *popUpButtonCell = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO];
+ NSRect frame = {{0.0, 0.0}, {0.0, 0.0}};
+ frame.origin = [window mouseLocationOutsideOfEventStream];
+ [self buildMenuWithContext:context name:name parent:popUpMenu isNumbered:YES];
+ int state = [[popUpMenu itemAtIndex:0] state];
+ [popUpButtonCell setMenu:popUpMenu];
+ [[popUpMenu itemAtIndex:0] setState:state];
+ [popUpButtonCell performClickWithFrame:frame inView:view];
+ [popUpButtonCell release];
+ [popUpMenu release];
+}
+
+#pragma mark Dialogs
+
+- (void)showDialogWithContext:(struct uih_context *)context
+ name:(CONST char *)name {
+ CONST menuitem *item = menu_findcommand (name);
+ if (!item) return;
+
+ CONST menudialog *dialog = menu_getdialog (context, 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)) {
+ NSString *extension = [[NSString stringWithUTF8String:dialog[0].defstr] pathExtension];
+
+ NSString *fileName = nil;
+ switch(dialog[0].type) {
+ case DIALOG_IFILE:
+ {
+ NSOpenPanel *oPanel = [NSOpenPanel openPanel];
+
+ int result = [oPanel runModalForDirectory:nil
+ file:nil
+ types:[NSArray arrayWithObject:extension]];
+
+ if (result == NSOKButton)
+ fileName = [oPanel filename];
+ break;
+ }
+ case DIALOG_OFILE:
+ {
+ NSSavePanel *sPanel = [NSSavePanel savePanel];
+ [sPanel setRequiredFileType:extension];
+
+ int result = [sPanel runModalForDirectory:nil file:@"untitled"];
+
+ if (result == NSOKButton)
+ fileName = [sPanel filename];
+ break;
+ }
+ }
+
+ [window makeKeyAndOrderFront:self];
+
+ if (fileName) {
+ dialogparam *param = malloc (sizeof (dialogparam));
+ param->dstring = strdup([fileName UTF8String]);
+ ui_menuactivate (item, param);
+ }
+
+ } else {
+ CustomDialog *customDialog = [[CustomDialog alloc] initWithContext:context
+ menuItem:item
+ dialog:dialog];
+ [NSApp beginSheet:customDialog
+ modalForWindow:window
+ modalDelegate:nil
+ didEndSelector:nil
+ contextInfo:nil];
+ [NSApp runModalForWindow:customDialog];
+ [NSApp endSheet:customDialog];
+ [customDialog orderOut:self];
+ [window makeKeyAndOrderFront:self];
+
+ if ([customDialog params])
+ ui_menuactivate(item, [customDialog params]);
+
+ [customDialog release];
+ }
+}
+
+#pragma mark Help
+
+- (void)showHelpWithContext:(struct uih_context *)context
+ name:(CONST char *)name {
+ NSString *anchor = [NSString stringWithUTF8String:name];
+ [[NSHelpManager sharedHelpManager] openHelpAnchor:anchor inBook:@"XaoS Help"];
+}
+
+#pragma mark Window Delegates
+
+- (void)windowWillClose:(NSNotification *)notification {
+ [NSApp terminate:self];
+}
+
+- (void)windowDidResize:(NSNotification *)notification {
+ // Handle maximize/zoom, but ignore live resizing
+ if (![view inLiveResize])
+ ui_resize();
+}
+
+#pragma mark Application Delegates
+
+- (BOOL)application:(NSApplication *)theApplication
+ openFile:(NSString *)filename {
+ if ([[filename pathExtension] isEqualToString:@"xpf"]) {
+ uih_loadfile(globaluih, [filename UTF8String]);
+ return YES;
+ } else if ([[filename pathExtension] isEqualToString:@"xaf"]) {
+ uih_playfile(globaluih, [filename UTF8String]);
+ return YES;
+ } else {
+ return NO;
+ }
+}
+
+@end \ No newline at end of file
diff --git a/src/ui/ui-drv/cocoa/CustomDialog.h b/src/ui/ui-drv/cocoa/CustomDialog.h
new file mode 100644
index 0000000..2821022
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/CustomDialog.h
@@ -0,0 +1,38 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * Cocoa Driver by J.B. Langston III (jb-langston@austin.rr.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.
+ */
+#import <Cocoa/Cocoa.h>
+#include "ui.h"
+
+@ interface CustomDialog:NSWindow {
+ struct uih_context *context;
+ CONST menuitem *item;
+ CONST menudialog *dialog;
+ dialogparam *params;
+ NSMutableDictionary *controls;
+}
+
+-(id) initWithContext:(struct uih_context *)context menuItem:(CONST menuitem *)item dialog:(CONST menudialog *) dialog;
+-(dialogparam *) params;
+
+@end
diff --git a/src/ui/ui-drv/cocoa/CustomDialog.m b/src/ui/ui-drv/cocoa/CustomDialog.m
new file mode 100644
index 0000000..5cac7df
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/CustomDialog.m
@@ -0,0 +1,433 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * Cocoa Driver by J.B. Langston III (jb-langston@austin.rr.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.
+ */
+#import "CustomDialog.h"
+
+#ifdef HAVE_GETTEXT
+#include <libintl.h>
+#include <locale.h>
+#define _(string) gettext(string)
+#else
+#define _(string) (string)
+#endif
+
+#define MARGIN 20
+#define SPACING 8
+
+@implementation CustomDialog
+
+#pragma mark Initialization
+
+- (id)initWithContext:(struct uih_context *)myContext
+ menuItem:(CONST menuitem *)myItem
+ dialog:(CONST menudialog *)myDialog {
+
+ NSRect windowRect = NSMakeRect(200, 200, 300, 107);
+ NSRect helpButtonRect = NSMakeRect(20, 20, 25, 25);
+ NSRect cancelButtonRect = NSMakeRect(128, 20, 75, 25);
+ NSRect okButtonRect = NSMakeRect(210, 20, 75, 25);
+ NSRect labelRect = NSMakeRect(20, 67, 62, 17);
+ NSRect controlRect = NSMakeRect(90, 65, 190, 22);
+ NSRect coordRect = NSMakeRect(90, 65, 85, 22);
+
+ self = [super initWithContentRect:windowRect
+ styleMask:NSTitledWindowMask
+ backing:NSBackingStoreBuffered
+ defer:YES];
+
+ if (self) {
+ context = myContext;
+ item = myItem;
+ dialog = myDialog;
+
+ [self setTitle:[NSString stringWithUTF8String:item->name]];
+
+ controls = [[NSMutableDictionary alloc] initWithCapacity:10];
+
+ NSMutableArray *labels = [[NSMutableArray alloc] initWithCapacity:10];
+
+ int maxLabelWidth = 0, maxControlWidth = 0, nitems = 0, i = 0;
+
+ for (nitems = 0; dialog[nitems].question; nitems++);
+
+ for (i = 0; i < nitems; i++) {
+ NSTextField *label = [[NSTextField alloc] initWithFrame:labelRect];
+ NSString *question = [NSString stringWithUTF8String:dialog[i].question];
+ [label setEditable:NO];
+ [label setBezeled:NO];
+ [label setDrawsBackground:NO];
+ [label setStringValue:question];
+
+ [label sizeToFit];
+ if ([label frame].size.width > maxLabelWidth)
+ maxLabelWidth = [label frame].size.width;
+
+ [[self contentView] addSubview:label];
+ [labels addObject:label];
+ [label release];
+
+ switch (dialog[i].type) {
+ case DIALOG_INT:
+ case DIALOG_FLOAT:
+ case DIALOG_STRING:
+ case DIALOG_KEYSTRING:
+ {
+ NSTextField *textField = [[NSTextField alloc] initWithFrame:controlRect];
+ [textField setEditable:YES];
+ [textField setBezeled:YES];
+ [textField setBezelStyle:NSTextFieldSquareBezel];
+ [[textField cell] setScrollable:YES];
+ switch (dialog[i].type) {
+ case DIALOG_INT:
+ [textField setIntValue:dialog[i].defint];
+ break;
+ case DIALOG_FLOAT:
+ [textField setDoubleValue:dialog[i].deffloat];
+ break;
+ case DIALOG_STRING:
+ [textField setStringValue:[NSString stringWithUTF8String:dialog[i].defstr]];
+ break;
+ case DIALOG_KEYSTRING:
+ [textField setStringValue:[NSString stringWithUTF8String:dialog[i].defstr]];
+ break;
+ }
+
+ if ([textField frame].size.width > maxControlWidth)
+ maxControlWidth = [textField frame].size.width;
+
+ [[self contentView] addSubview:textField];
+ [controls setValue:textField forKey:question];
+ [textField release];
+
+ break;
+ }
+ case DIALOG_IFILE:
+ case DIALOG_OFILE:
+ {
+ NSTextField *textField = [[NSTextField alloc] initWithFrame:controlRect];
+ [textField setEditable:NO];
+ [textField setBezeled:YES];
+ [textField setBezelStyle:NSTextFieldSquareBezel];
+ [[textField cell] setScrollable:YES];
+ [textField setStringValue:[NSString stringWithUTF8String:dialog[i].defstr]];
+ [[textField cell] setRepresentedObject:[NSString stringWithUTF8String:dialog[i].defstr]];
+
+ if ([textField frame].size.width > maxControlWidth)
+ maxControlWidth = [textField frame].size.width;
+
+ [[self contentView] addSubview:textField];
+ [controls setValue:textField forKey:question];
+
+ NSButton *chooseButton = [[NSButton alloc] initWithFrame:okButtonRect];
+ [chooseButton setTitle:[NSString stringWithUTF8String:_("Choose")]];
+ [chooseButton setButtonType:NSMomentaryPushInButton];
+ [chooseButton setBezelStyle:NSRoundedBezelStyle];
+ [chooseButton setTarget:self];
+ if (dialog[i].type == DIALOG_IFILE)
+ [chooseButton setAction:@selector(chooseInput:)];
+ else
+ [chooseButton setAction:@selector(chooseOutput:)];
+ [[chooseButton cell] setRepresentedObject:textField];
+
+ [[self contentView] addSubview:chooseButton];
+ [controls setValue:chooseButton forKey:[question stringByAppendingString:@"choose"]];
+
+ if ([textField frame].size.width + SPACING + [chooseButton frame].size.width > maxControlWidth)
+ maxControlWidth = [textField frame].size.width + SPACING + [chooseButton frame].size.width;
+
+ [chooseButton release];
+ [textField release];
+ break;
+ }
+ case DIALOG_CHOICE:
+ {
+
+ NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:controlRect];
+
+ NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
+ CONST char **str = (CONST char **) dialog[i].defstr;
+ int y;
+ for (y = 0; str[y] != NULL; y++)
+ {
+ NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:str[y]] action:nil keyEquivalent:@""];
+ [menu addItem:menuItem];
+ [menuItem release];
+ }
+ [popupButton setMenu:menu];
+ [menu release];
+ [popupButton selectItemAtIndex:dialog[i].defint];
+
+ [popupButton sizeToFit];
+ if ([popupButton frame].size.width > maxControlWidth)
+ maxControlWidth = [popupButton frame].size.width;
+
+ [[self contentView] addSubview:popupButton];
+ [controls setValue:popupButton forKey:question];
+ [popupButton release];
+
+ break;
+ }
+ case DIALOG_ONOFF:
+ {
+ break;
+ }
+ case DIALOG_COORD:
+ {
+ int coordWidth = 0;
+ NSTextField *textField = [[NSTextField alloc] initWithFrame:coordRect];
+ [textField setEditable:YES];
+ [textField setBezeled:YES];
+ [textField setBezelStyle:NSTextFieldSquareBezel];
+ [[textField cell] setScrollable:YES];
+ [textField setDoubleValue:dialog[i].deffloat];
+
+ coordWidth += [textField frame].size.width;
+
+ [[self contentView] addSubview:textField];
+ [controls setValue:textField forKey:question];
+ [textField release];
+
+ textField = [[NSTextField alloc] initWithFrame:labelRect];
+ [textField setEditable:NO];
+ [textField setBezeled:NO];
+ [textField setDrawsBackground:NO];
+ [textField setStringValue:@"+"];
+
+ [textField sizeToFit];
+ coordWidth += [textField frame].size.width;
+
+ [[self contentView] addSubview:textField];
+ [controls setValue:textField forKey:[question stringByAppendingString:@"+"]];
+ [textField release];
+
+ textField = [[NSTextField alloc] initWithFrame:coordRect];
+ [textField setEditable:YES];
+ [textField setBezeled:YES];
+ [textField setBezelStyle:NSTextFieldSquareBezel];
+ [[textField cell] setScrollable:YES];
+ [textField setDoubleValue:dialog[i].deffloat2];
+
+ coordWidth += [textField frame].size.width;
+
+ [[self contentView] addSubview:textField];
+ [controls setValue:textField forKey:[question stringByAppendingString:@"2"]];
+ [textField release];
+
+ textField = [[NSTextField alloc] initWithFrame:labelRect];
+ [textField setEditable:NO];
+ [textField setBezeled:NO];
+ [textField setDrawsBackground:NO];
+ [textField setStringValue:@"i"];
+
+ [textField sizeToFit];
+ coordWidth += [textField frame].size.width;
+
+ [[self contentView] addSubview:textField];
+ [controls setValue:textField forKey:[question stringByAppendingString:@"i"]];
+ [textField release];
+
+ if (coordWidth > maxControlWidth)
+ maxControlWidth = coordWidth;
+ }
+ }
+ if (MARGIN + maxLabelWidth + SPACING + maxControlWidth + MARGIN > windowRect.size.width)
+ windowRect.size.width = MARGIN + maxLabelWidth + SPACING + maxControlWidth + MARGIN;
+ }
+
+ controlRect.origin.x = labelRect.origin.x + maxLabelWidth + SPACING;
+
+ for (i = nitems-1; i >= 0; i--) {
+ NSTextField *label = [labels objectAtIndex:i];
+ NSControl *control = [controls objectForKey:[label stringValue]];
+ [label setFrameOrigin:labelRect.origin];
+
+ [control setFrameOrigin:controlRect.origin];
+
+ switch (dialog[i].type) {
+ case DIALOG_IFILE:
+ case DIALOG_OFILE:
+ {
+ NSButton *chooseButton = [controls objectForKey:[[label stringValue] stringByAppendingString:@"choose"]];
+ [chooseButton setFrameOrigin:NSMakePoint([control frame].origin.x + [control frame].size.width + SPACING, [control frame].origin.y - 2)];
+ break;
+ }
+ case DIALOG_COORD:
+ {
+ NSRect controlRect2 = controlRect;
+ controlRect2.origin.x += [control frame].size.width;
+ control = [controls objectForKey:[[label stringValue] stringByAppendingString:@"+"]];
+ [control setFrameOrigin:controlRect2.origin];
+ controlRect2.origin.x += [control frame].size.width;
+ control = [controls objectForKey:[[label stringValue] stringByAppendingString:@"2"]];
+ [control setFrameOrigin:controlRect2.origin];
+ controlRect2.origin.x += [control frame].size.width;
+ control = [controls objectForKey:[[label stringValue] stringByAppendingString:@"i"]];
+ [control setFrameOrigin:controlRect2.origin];
+ control = [controls objectForKey:[label stringValue]];
+ }
+ }
+
+ labelRect.origin.y += SPACING + [control frame].size.height;
+ controlRect.origin.y += SPACING + [control frame].size.height;
+ }
+
+ controlRect.origin.y += MARGIN;
+
+ windowRect.size.height = controlRect.origin.y;
+
+ okButtonRect.origin.x += windowRect.size.width - [self frame].size.width;
+ cancelButtonRect.origin.x += windowRect.size.width - [self frame].size.width;
+
+ NSButton *okButton = [[NSButton alloc] initWithFrame:okButtonRect];
+ [okButton setTitle:[NSString stringWithUTF8String:_("OK")]];
+ [okButton setButtonType:NSMomentaryPushInButton];
+ [okButton setBezelStyle:NSRoundedBezelStyle];
+ [okButton setKeyEquivalent:@"\r"];
+ [okButton setTarget:self];
+ [okButton setAction:@selector(execute:)];
+ [okButton sizeToFit];
+ [[self contentView] addSubview:okButton];
+
+ NSButton *cancelButton = [[NSButton alloc] initWithFrame:cancelButtonRect];
+ [cancelButton setTitle:[NSString stringWithUTF8String:_("Cancel")]];
+ [cancelButton setButtonType:NSMomentaryPushInButton];
+ [cancelButton setBezelStyle:NSRoundedBezelStyle];
+ [cancelButton setTarget:self];
+ [cancelButton setAction:@selector(cancel:)];
+ [cancelButton sizeToFit];
+ [[self contentView] addSubview:cancelButton];
+
+ NSButton *helpButton = [[NSButton alloc] initWithFrame:helpButtonRect];
+ [helpButton setTitle:@""];
+ [helpButton setButtonType:NSMomentaryPushInButton];
+ [helpButton setBezelStyle:NSHelpButtonBezelStyle];
+ [helpButton setTarget:self];
+ [helpButton setAction:@selector(help:)];
+ [[self contentView] addSubview:helpButton];
+ [helpButton release];
+
+ okButtonRect.size.width = MAX([okButton frame].size.width + 2, [cancelButton frame].size.width) + 2 * SPACING;
+ cancelButtonRect.size.width = okButtonRect.size.width;
+
+ okButtonRect.origin.x = windowRect.size.width - MARGIN - okButtonRect.size.width;
+ cancelButtonRect.origin.x = okButtonRect.origin.x - SPACING - cancelButtonRect.size.width;
+
+ [okButton setFrame:okButtonRect];
+ [cancelButton setFrame:cancelButtonRect];
+
+ [cancelButton release];
+ [okButton release];
+
+ [self setContentSize:windowRect.size];
+ }
+ return self;
+}
+
+# pragma mark Targets
+
+- (IBAction)execute:(id)sender {
+ int nitems;
+ for (nitems = 0; dialog[nitems].question; nitems++);
+ params = malloc (sizeof (*params) * nitems);
+
+ int i;
+ for (i = 0; i < nitems; i++) {
+ NSString *question = [NSString stringWithUTF8String:dialog[i].question];
+ NSControl *control;
+ switch (dialog[i].type) {
+ case DIALOG_IFILE:
+ case DIALOG_OFILE:
+ case DIALOG_STRING:
+ case DIALOG_KEYSTRING:
+ control = [controls objectForKey:question];
+ params[i].dstring = strdup ([[control stringValue] UTF8String]);
+ break;
+ case DIALOG_INT:
+ control = [controls objectForKey:question];
+ params[i].dint = [control intValue];
+ break;
+ case DIALOG_FLOAT:
+ control = [controls objectForKey:question];
+ params[i].number = [control floatValue];
+ break;
+ case DIALOG_COORD:
+ control = [controls objectForKey:question];
+ params[i].dcoord[0] = [control floatValue];
+ control = [controls objectForKey:[question stringByAppendingString:@"2"]];
+ params[i].dcoord[1] = [control floatValue];
+ break;
+ case DIALOG_CHOICE:
+ control = [controls objectForKey:question];
+ params[i].dint = [(NSPopUpButtonCell *)control indexOfSelectedItem];
+ break;
+ }
+ }
+ [NSApp stopModal];
+}
+
+- (IBAction)cancel:(id)sender {
+ params = NULL;
+ [NSApp stopModal];
+}
+
+- (IBAction)help:(id)sender {
+ ui_help(item->shortname);
+}
+
+- (IBAction)chooseInput:(id)sender {
+ NSTextField *target = [[sender cell] representedObject];
+ NSString *extension = [[[target cell] representedObject] pathExtension];
+ NSOpenPanel *oPanel = [NSOpenPanel openPanel];
+
+ int result = [oPanel runModalForDirectory:nil
+ file:nil
+ types:[NSArray arrayWithObject:extension]];
+
+ if (result == NSOKButton)
+ [target setStringValue:[oPanel filename]];
+}
+
+- (IBAction)chooseOutput:(id)sender {
+ NSTextField *target = [[sender cell] representedObject];
+ NSString *extension = [[[target cell] representedObject] pathExtension];
+ NSSavePanel *sPanel = [NSSavePanel savePanel];
+ [sPanel setRequiredFileType:extension];
+
+ int result = [sPanel runModalForDirectory:nil file:[target stringValue]];
+ if (result == NSOKButton)
+ [target setStringValue:[sPanel filename]];
+}
+
+#pragma mark Accessors
+
+- (dialogparam *)params {
+ return params;
+}
+
+#pragma mark Deallocation
+
+- (void)dealloc {
+ [controls release];
+ [super dealloc];
+}
+@end
diff --git a/src/ui/ui-drv/cocoa/English.lproj/Credits.html b/src/ui/ui-drv/cocoa/English.lproj/Credits.html
new file mode 100644
index 0000000..d38d9cd
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/English.lproj/Credits.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+ <title></title>
+ <meta name="Generator" content="Cocoa HTML Writer">
+ <meta name="CocoaVersion" content="824.41">
+ <style type="text/css">
+ body {
+ font-family: "Lucida Grande", Arial, sans-serif;
+ font-size: 8pt;
+ text-align: center;
+ }
+ </style>
+</head>
+<body>
+<p>XaoS is free software; you can redistribute it and/or modify it under the
+terms of the<br>
+<a href="help:anchor=gpl%20bookID=XaoS%20Help">GNU General Public License</a>.
+</p>
+<p><a href="help:anchor=about%20bookID=XaoS%20Help">Credits</a></p>
+<p><a href="help:anchor=devel%20bookID=XaoS%20Help">How to Help</a></p>
+<p><a href="http://xaos.sourceforge.net/">XaoS Website</a></p>
+</body>
+</html>
diff --git a/src/ui/ui-drv/cocoa/English.lproj/InfoPlist.strings b/src/ui/ui-drv/cocoa/English.lproj/InfoPlist.strings
new file mode 100644
index 0000000..42b5784
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/English.lproj/InfoPlist.strings
Binary files differ
diff --git a/src/ui/ui-drv/cocoa/English.lproj/MainMenu.nib/designable.nib b/src/ui/ui-drv/cocoa/English.lproj/MainMenu.nib/designable.nib
new file mode 100644
index 0000000..5d0aa75
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/English.lproj/MainMenu.nib/designable.nib
@@ -0,0 +1,498 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.01">
+ <data>
+ <int key="IBDocument.SystemTarget">0</int>
+ <string key="IBDocument.SystemVersion">9C7010</string>
+ <string key="IBDocument.InterfaceBuilderVersion">629</string>
+ <string key="IBDocument.AppKitVersion">949.26</string>
+ <string key="IBDocument.HIToolboxVersion">352.00</string>
+ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="29"/>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string id="617114957">com.apple.InterfaceBuilderKit</string>
+ <string id="578961457">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSCustomObject" id="1021">
+ <string key="NSClassName" id="1039455869">NSApplication</string>
+ </object>
+ <object class="NSCustomObject" id="1014">
+ <string key="NSClassName">FirstResponder</string>
+ </object>
+ <object class="NSCustomObject" id="1050">
+ <reference key="NSClassName" ref="1039455869"/>
+ </object>
+ <object class="NSMenu" id="649796088">
+ <string key="NSTitle">AMainMenu</string>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMenuItem" id="694149608">
+ <reference key="NSMenu" ref="649796088"/>
+ <string key="NSTitle" id="163516152">XaoS</string>
+ <string key="NSKeyEquiv" id="1003"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <object class="NSCustomResource" key="NSOnImage" id="621373611">
+ <string key="NSClassName" id="963292957">NSImage</string>
+ <string key="NSResourceName">NSMenuCheckmark</string>
+ </object>
+ <object class="NSCustomResource" key="NSMixedImage" id="481733502">
+ <reference key="NSClassName" ref="963292957"/>
+ <string key="NSResourceName">NSMenuMixedState</string>
+ </object>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="110575045">
+ <reference key="NSTitle" ref="163516152"/>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMenuItem" id="238522557">
+ <reference key="NSMenu" ref="110575045"/>
+ <string key="NSTitle">About XaoS</string>
+ <reference key="NSKeyEquiv" ref="1003"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="621373611"/>
+ <reference key="NSMixedImage" ref="481733502"/>
+ </object>
+ <object class="NSMenuItem" id="304266470">
+ <reference key="NSMenu" ref="110575045"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <reference key="NSTitle" ref="1003"/>
+ <reference key="NSKeyEquiv" ref="1003"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="621373611"/>
+ <reference key="NSMixedImage" ref="481733502"/>
+ </object>
+ <object class="NSMenuItem" id="1046388886">
+ <reference key="NSMenu" ref="110575045"/>
+ <string key="NSTitle" id="487627014">Services</string>
+ <reference key="NSKeyEquiv" ref="1003"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="621373611"/>
+ <reference key="NSMixedImage" ref="481733502"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="752062318">
+ <reference key="NSTitle" ref="487627014"/>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <string key="NSName">_NSServicesMenu</string>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="646227648">
+ <reference key="NSMenu" ref="110575045"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <reference key="NSTitle" ref="1003"/>
+ <reference key="NSKeyEquiv" ref="1003"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="621373611"/>
+ <reference key="NSMixedImage" ref="481733502"/>
+ </object>
+ <object class="NSMenuItem" id="755159360">
+ <reference key="NSMenu" ref="110575045"/>
+ <string key="NSTitle">Hide XaoS</string>
+ <string key="NSKeyEquiv" id="712247123">h</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="621373611"/>
+ <reference key="NSMixedImage" ref="481733502"/>
+ </object>
+ <object class="NSMenuItem" id="342932134">
+ <reference key="NSMenu" ref="110575045"/>
+ <string key="NSTitle">Hide Others</string>
+ <reference key="NSKeyEquiv" ref="712247123"/>
+ <int key="NSKeyEquivModMask">1572864</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="621373611"/>
+ <reference key="NSMixedImage" ref="481733502"/>
+ </object>
+ <object class="NSMenuItem" id="908899353">
+ <reference key="NSMenu" ref="110575045"/>
+ <string key="NSTitle">Show All</string>
+ <reference key="NSKeyEquiv" ref="1003"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="621373611"/>
+ <reference key="NSMixedImage" ref="481733502"/>
+ </object>
+ <object class="NSMenuItem" id="1056857174">
+ <reference key="NSMenu" ref="110575045"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <reference key="NSTitle" ref="1003"/>
+ <reference key="NSKeyEquiv" ref="1003"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="621373611"/>
+ <reference key="NSMixedImage" ref="481733502"/>
+ </object>
+ <object class="NSMenuItem" id="632727374">
+ <reference key="NSMenu" ref="110575045"/>
+ <string key="NSTitle">Quit XaoS</string>
+ <string key="NSKeyEquiv">q</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="621373611"/>
+ <reference key="NSMixedImage" ref="481733502"/>
+ </object>
+ </object>
+ <string key="NSName">_NSAppleMenu</string>
+ </object>
+ </object>
+ </object>
+ <string key="NSName">_NSMainMenu</string>
+ </object>
+ </object>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <object class="NSMutableArray" key="connectionRecords">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">orderFrontStandardAboutPanel:</string>
+ <reference key="source" ref="1021"/>
+ <reference key="destination" ref="238522557"/>
+ </object>
+ <int key="connectionID">142</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">hide:</string>
+ <reference key="source" ref="1014"/>
+ <reference key="destination" ref="755159360"/>
+ </object>
+ <int key="connectionID">367</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">hideOtherApplications:</string>
+ <reference key="source" ref="1014"/>
+ <reference key="destination" ref="342932134"/>
+ </object>
+ <int key="connectionID">368</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">terminate:</string>
+ <reference key="source" ref="1014"/>
+ <reference key="destination" ref="632727374"/>
+ </object>
+ <int key="connectionID">369</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">unhideAllApplications:</string>
+ <reference key="source" ref="1014"/>
+ <reference key="destination" ref="908899353"/>
+ </object>
+ <int key="connectionID">370</int>
+ </object>
+ </object>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <object class="NSArray" key="orderedObjects">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <object class="NSArray" key="object" id="1049">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="children" ref="1048"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="1021"/>
+ <reference key="parent" ref="1049"/>
+ <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="1014"/>
+ <reference key="parent" ref="1049"/>
+ <string key="objectName">First Responder</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-3</int>
+ <reference key="object" ref="1050"/>
+ <reference key="parent" ref="1049"/>
+ <string key="objectName">Application</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">29</int>
+ <reference key="object" ref="649796088"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="694149608"/>
+ </object>
+ <reference key="parent" ref="1049"/>
+ <string key="objectName">MainMenu</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">56</int>
+ <reference key="object" ref="694149608"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="110575045"/>
+ </object>
+ <reference key="parent" ref="649796088"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">57</int>
+ <reference key="object" ref="110575045"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="238522557"/>
+ <reference ref="755159360"/>
+ <reference ref="908899353"/>
+ <reference ref="632727374"/>
+ <reference ref="646227648"/>
+ <reference ref="304266470"/>
+ <reference ref="1046388886"/>
+ <reference ref="1056857174"/>
+ <reference ref="342932134"/>
+ </object>
+ <reference key="parent" ref="694149608"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">58</int>
+ <reference key="object" ref="238522557"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">134</int>
+ <reference key="object" ref="755159360"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">150</int>
+ <reference key="object" ref="908899353"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">136</int>
+ <reference key="object" ref="632727374"/>
+ <reference key="parent" ref="110575045"/>
+ <string key="objectName">1111</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">144</int>
+ <reference key="object" ref="646227648"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">236</int>
+ <reference key="object" ref="304266470"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">131</int>
+ <reference key="object" ref="1046388886"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="752062318"/>
+ </object>
+ <reference key="parent" ref="110575045"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">149</int>
+ <reference key="object" ref="1056857174"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">145</int>
+ <reference key="object" ref="342932134"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">130</int>
+ <reference key="object" ref="752062318"/>
+ <reference key="parent" ref="1046388886"/>
+ </object>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="flattenedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>-1.IBPluginDependency</string>
+ <string>-2.IBPluginDependency</string>
+ <string>-3.IBPluginDependency</string>
+ <string>130.IBPluginDependency</string>
+ <string>130.ImportedFromIB2</string>
+ <string>130.editorWindowContentRectSynchronizationRect</string>
+ <string>131.IBPluginDependency</string>
+ <string>131.ImportedFromIB2</string>
+ <string>134.IBPluginDependency</string>
+ <string>134.ImportedFromIB2</string>
+ <string>136.IBPluginDependency</string>
+ <string>136.ImportedFromIB2</string>
+ <string>144.IBPluginDependency</string>
+ <string>144.ImportedFromIB2</string>
+ <string>145.IBPluginDependency</string>
+ <string>145.ImportedFromIB2</string>
+ <string>149.IBPluginDependency</string>
+ <string>149.ImportedFromIB2</string>
+ <string>150.IBPluginDependency</string>
+ <string>150.ImportedFromIB2</string>
+ <string>236.IBPluginDependency</string>
+ <string>236.ImportedFromIB2</string>
+ <string>29.IBPluginDependency</string>
+ <string>29.ImportedFromIB2</string>
+ <string>29.WindowOrigin</string>
+ <string>29.editorWindowContentRectSynchronizationRect</string>
+ <string>56.IBPluginDependency</string>
+ <string>56.ImportedFromIB2</string>
+ <string>57.IBPluginDependency</string>
+ <string>57.ImportedFromIB2</string>
+ <string>57.editorWindowContentRectSynchronizationRect</string>
+ <string>58.IBPluginDependency</string>
+ <string>58.ImportedFromIB2</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="578961457"/>
+ <reference ref="617114957"/>
+ <reference ref="617114957"/>
+ <reference ref="578961457"/>
+ <integer value="1" id="9"/>
+ <string>{{436, 809}, {64, 6}}</string>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <string>{74, 862}</string>
+ <string>{{6, 836}, {77, 20}}</string>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ <string>{{18, 683}, {174, 153}}</string>
+ <reference ref="578961457"/>
+ <reference ref="9"/>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="activeLocalization"/>
+ <object class="NSMutableDictionary" key="localizations">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="sourceID"/>
+ <int key="maxID">374</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.LastKnownRelativeProjectPath">../../XaoS.xcodeproj</string>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <object class="NSMutableData" key="IBDocument.RunnableNib">
+ <bytes key="NS.bytes">YnBsaXN0MDDUAAEAAgADAAQABQAGAAkAClgkdmVyc2lvblQkdG9wWSRhcmNoaXZlclgkb2JqZWN0cxIA
+AYag0QAHAAhdSUIub2JqZWN0ZGF0YYABXxAPTlNLZXllZEFyY2hpdmVyrxBuAAsADAAxADUANgA8AD0A
+QQBFAE0AUwBjAGoAawBsAHEAcgBzAHYAegB7AH4AfwCDAIkAkACRAJIAkwCXAJ4AnwCgAKQArACtAK4A
+rwCzALoAuwC8AMAA0QDWANcA2wDmAOcA6AD0AP8BCADnAQkBDgERARIBFAEdASYBJwEoASsBLQE+AVAB
+YgFjAWQBZQFmAWcBaAFpAWoBawFsAW0BbgFvAXABcQF0AXcBjgGlAaYBpwGoAakBqgGrAawBrQGuAa8B
+sAGxAbIBswG0AbUBtgG3AbgBuQG8Ab8BwlUkbnVsbN8QEgANAA4ADwAQABEAEgATABQAFQAWABcAGAAZ
+ABoAGwAcAB0AHgAfACAAIQAiACMAJAAlACYAJwAoACkAKgArACwALQAuAC8AMFZOU1Jvb3RWJGNsYXNz
+XU5TT2JqZWN0c0tleXNfEA9OU0NsYXNzZXNWYWx1ZXNfEBlOU0FjY2Vzc2liaWxpdHlPaWRzVmFsdWVz
+XU5TQ29ubmVjdGlvbnNbTlNOYW1lc0tleXNbTlNGcmFtZXdvcmtdTlNDbGFzc2VzS2V5c1pOU09pZHNL
+ZXlzXU5TTmFtZXNWYWx1ZXNfEBlOU0FjY2Vzc2liaWxpdHlDb25uZWN0b3JzXU5TRm9udE1hbmFnZXJf
+EBBOU1Zpc2libGVXaW5kb3dzXxAPTlNPYmplY3RzVmFsdWVzXxAXTlNBY2Nlc3NpYmlsaXR5T2lkc0tl
+eXNZTlNOZXh0T2lkXE5TT2lkc1ZhbHVlc4ACgG2AKoBTgGyACIBBgAWAUoBUgEKAaoAAgAaAQIBrEQF4
+gFXSAA4AMgAzADRbTlNDbGFzc05hbWWABIADXU5TQXBwbGljYXRpb27SADcAOAA5ADpYJGNsYXNzZXNa
+JGNsYXNzbmFtZaIAOgA7Xk5TQ3VzdG9tT2JqZWN0WE5TT2JqZWN0XxAQSUJDb2NvYUZyYW1ld29ya9IA
+DgA+AD8AQFpOUy5vYmplY3RzgAeg0gA3ADgAQgBDowBDAEQAO1xOU011dGFibGVTZXRVTlNTZXTSAA4A
+PgBGAEeAKaUASABJAEoASwBMgAmAF4AcgCCAJdMADgBOAE8AUABRAFJYTlNTb3VyY2VXTlNMYWJlbIAW
+gAqAFdgADgBUAFUAVgBXAFgAWQBaAFsAXABdAF4AXwBgAGEAYldOU1RpdGxlXxARTlNLZXlFcXVpdk1v
+ZE1hc2taTlNLZXlFcXVpdl1OU01uZW1vbmljTG9jWU5TT25JbWFnZVxOU01peGVkSW1hZ2VWTlNNZW51
+gBSADBIAEAAAgA0Sf////4AOgBKAC9QADgBUAGQAZQBmAGcAaABpVk5TTmFtZVtOU01lbnVJdGVtc4A5
+gC+APIAxWVF1aXQgWGFvU1Fx0wAOADIAbQBuAG8AcF5OU1Jlc291cmNlTmFtZYARgA+AEFdOU0ltYWdl
+XxAPTlNNZW51Q2hlY2ttYXJr0gA3ADgAdAB1ogB1ADtfEBBOU0N1c3RvbVJlc291cmNl0wAOADIAbQBu
+AG8AeYARgA+AE18QEE5TTWVudU1peGVkU3RhdGXSADcAOAB8AH2iAH0AO1pOU01lbnVJdGVtWnRlcm1p
+bmF0ZTrSADcAOACAAIGjAIEAggA7XxAVTlNOaWJDb250cm9sQ29ubmVjdG9yXk5TTmliQ29ubmVjdG9y
+1AAOAIQATgBPAFAAHwCHAIhdTlNEZXN0aW5hdGlvboAWgAKAGIAb1wAOAFQAVgBXAFgAWQBaAFsAiwCM
+AF8AYABhAGKAFIAZgBqADoASgAtaQWJvdXQgWGFvU1BfEB1vcmRlckZyb250U3RhbmRhcmRBYm91dFBh
+bmVsOtMADgBOAE8AUACVAJaAFoAdgB/YAA4AVABVAFYAVwBYAFkAWgBbAJkAXQCMAF8AYABhAGKAFIAe
+gBqADoASgAtYU2hvdyBBbGxfEBZ1bmhpZGVBbGxBcHBsaWNhdGlvbnM60wAOAE4ATwBQAKIAo4AWgCGA
+JNgADgBUAFUAVgBXAFgAWQBaAFsApgCnAKgAXwBgAGEAYoAUgCISABgAAIAjgA6AEoALW0hpZGUgT3Ro
+ZXJzUWhfEBZoaWRlT3RoZXJBcHBsaWNhdGlvbnM60wAOAE4ATwBQALEAsoAWgCaAKNgADgBUAFUAVgBX
+AFgAWQBaAFsAtQBdAKgAXwBgAGEAYoAUgCeAI4AOgBKAC1lIaWRlIFhhb1NVaGlkZTrSADcAOAC9AL6j
+AL4AvwA7Xk5TTXV0YWJsZUFycmF5V05TQXJyYXnSAA4APgDBAMKAP64AlQBRAIcAxgDHAGIAyQDKALEA
+ogDNAM4AzwDQgB2ACoAYgCuAMoALgDOAPoAmgCGAOoA7gDaALtQADgBUAGQAZQBmANMA1ADVgDmALIA9
+gC1ZQU1haW5NZW510gAOAD4ARgDZgCmhANCALtoADgDcAFQAVQBWAFcAWABZAFoA3QBbAGIAZwBdAIwA
+XwBgAGEAxgDlWU5TU3VibWVudVhOU0FjdGlvboAUgAuAL4AagA6AEoArgDBUWGFvU15zdWJtZW51QWN0
+aW9uOtIADgA+AEYA6oApqQCHAMcAyQDNALEAogCVAM4AUYAYgDKAM4A6gCaAIYAdgDuACtoADgBUAFUA
+9QBWAPYAVwBYAFkAWgBbAIwAXQD5AIwA+QBfAGAAYQBiXU5TSXNTZXBhcmF0b3JcTlNJc0Rpc2FibGVk
+gBSAGgmAGgmADoASgAvaAA4A3ABUAFUAVgBXAFgAWQBaAN0AWwDPAQIAXQCMAF8AYABhAGIBB4AUgDaA
+NIAagA6AEoALgDVYU2VydmljZXPUAA4AVABkAGUAZgECAQwBDYA5gDSAOIA30gAOAD4ARgEQgCmgXxAP
+X05TU2VydmljZXNNZW510gA3ADgBEwBaogBaADvaAA4AVABVAPUAVgD2AFcAWABZAFoAWwCMAF0A+QCM
+APkAXwBgAGEAYoAUgBoJgBoJgA6AEoAL2gAOAFQAVQD1AFYA9gBXAFgAWQBaAFsAjABdAPkAjAD5AF8A
+YABhAGKAFIAaCYAaCYAOgBKAC1xfTlNBcHBsZU1lbnVbX05TTWFpbk1lbnXSAA4AMgAzADSABIAD0gA3
+ADgBLAC/ogC/ADvSAA4APgDBAS+AP64AYgBiAGIAHwBiANAAYgAfAGIAYgBiAGIAyQDGgAuAC4ALgAKA
+C4AugAuAAoALgAuAC4ALgDOAK9IADgA+AMEBQIA/rxAPANAAUQCHAMYAxwBiAMkAHwDKALEAogDNAM4A
+zwCVgC6ACoAYgCuAMoALgDOAAoA+gCaAIYA6gDuANoAd0gAOAD4AwQFSgD+vEA8BUwFUAVUBVgFXAVgB
+WQFaAVsBXAFdAV4BXwFgAWGAQ4BEgEWARoBHgEiASYBKgEuATIBNgE6AT4BQgFFfEBBNZW51IEl0ZW0g
+KFhhb1MpVDExMTFfEBZNZW51IEl0ZW0gKEFib3V0IFhhb1MpWE1haW5NZW51WVNlcGFyYXRvcltNZW51
+IChYYW9TKV8QFE1lbnUgSXRlbSAoU2VydmljZXMpXEZpbGUncyBPd25lcltBcHBsaWNhdGlvbl8QFU1l
+bnUgSXRlbSAoSGlkZSBYYW9TKV8QF01lbnUgSXRlbSAoSGlkZSBPdGhlcnMpW1NlcGFyYXRvci0xW1Nl
+cGFyYXRvci0yXxAPTWVudSAoU2VydmljZXMpXxAUTWVudSBJdGVtIChTaG93IEFsbCnSAA4APgDBAXOA
+P6DSAA4APgDBAXaAP6DSAA4APgDBAXmAP68QFACVAEkAUQBKAIcAxgDHAEsAYgDJAB8AygCxAKIAzQDO
+AEgAzwBMANCAHYAXgAqAHIAYgCuAMoAggAuAM4ACgD6AJoAhgDqAO4AJgDaAJYAu0gAOAD4AwQGQgD+v
+EBQBkQGSAZMBlAGVAZYBlwGYAZkBmgGbAZwBnQGeAZ8BoAGhAaIBowGkgFaAV4BYgFmAWoBbgFyAXYBe
+gF+AYIBhgGKAY4BkgGWAZoBngGiAaRCWEI4QiBEBchA6EB0Q7BEBcBA5EIMRAXcT//////////0QhhCR
+EJAQlREBcRCCEQFvEDjSAA4APgBGAbuAKaDSAA4APgDBAb6AP6DSAA4APgDBAcGAP6DSADcAOAHDAcSi
+AcQAO15OU0lCT2JqZWN0RGF0YQAIABkAIgAnADEAOgA/AEQAUgBUAGYBRQFLAZYBnQGkAbIBxAHgAe4B
++gIGAhQCHwItAkkCVwJqAnwClgKgAq0CrwKxArMCtQK3ArkCuwK9Ar8CwQLDAsUCxwLJAssCzQLQAtIC
+2wLnAukC6wL5AwIDCwMWAxsDKgMzA0YDTwNaA1wDXQNmA20DegOAA4kDiwOWA5gDmgOcA54DoAOtA7YD
+vgPAA8IDxAPlA+0EAQQMBBoEJAQxBDgEOgQ8BEEEQwRIBEoETAROBF8EZgRyBHQEdgR4BHoEhASGBJME
+ogSkBKYEqASwBMIEywTQBOME8ATyBPQE9gUJBRIFFwUiBS0FNgU9BVUFZAV1BYMFhQWHBYkFiwWoBaoF
+rAWuBbAFsgW0Bb8FwAXgBe0F7wXxBfMGFAYWBhgGGgYcBh4GIAYpBkIGTwZRBlMGVQZ2BngGegZ/BoEG
+gwaFBocGkwaVBq4Guwa9Br8GwQbiBuQG5gboBuoG7AbuBvgG/gcHBw4HHQclBy4HMAdNB08HUQdTB1UH
+VwdZB1sHXQdfB2EHYwdlB2cHaQd6B3wHfgeAB4IHjAeVB5cHmgecB8UHzwfYB9oH3AfeB+AH4gfkB+YH
+6AftB/wIBQgHCBoIHAgeCCAIIggkCCYIKAgqCCwIVQhjCHAIcgh0CHUIdwh4CHoIfAh+CKcIqQirCK0I
+rwixCLMItQi3CMAI0QjTCNUI1wjZCOII5AjlCPcJAAkFCS4JMAkyCTMJNQk2CTgJOgk8CWUJZwlpCWoJ
+bAltCW8JcQlzCYAJjAmVCZcJmQmiCacJsAmyCc8J0QnTCdUJ1wnZCdsJ3QnfCeEJ4wnlCecJ6QnrCfQJ
+9goXChkKGwodCh8KIQojCiUKJwopCisKLQovCjEKMwo1Cj4KQAphCmMKZQpnCmkKawptCm8KcQpzCnUK
+dwp5CnsKfQp/CpIKlwqwCrkKwwrPCuYK8wr/CxcLMQs9C0kLWwtyC3sLfQt+C4cLiQuKC5MLlQvAC8IL
+xAvGC8gLygvMC84L0AvSC9QL1gvYC9oL3AveC+AL4gvkC+YL6AvxC/MMHgwgDCIMJAwmDCgMKgwsDC4M
+MAwyDDQMNgw4DDoMPAw+DEAMQgxEDEYMSAxKDEwMTwxRDFMMVQxYDFoMXAxfDGgMagxsDG4McAxzDHUM
+eAx6DIMMhQyGDI8MkQySDJsMnQyeDKcMrAAAAAAAAAICAAAAAAAAAcUAAAAAAAAAAAAAAAAAAAy7A</bytes>
+ </object>
+ </data>
+</archive>
diff --git a/src/ui/ui-drv/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib b/src/ui/ui-drv/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib
new file mode 100644
index 0000000..8659a00
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib
Binary files differ
diff --git a/src/ui/ui-drv/cocoa/FractalView.h b/src/ui/ui-drv/cocoa/FractalView.h
new file mode 100644
index 0000000..34957ab
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/FractalView.h
@@ -0,0 +1,70 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * Cocoa Driver by J.B. Langston III (jb-langston@austin.rr.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.
+ */
+#import <Cocoa/Cocoa.h>
+
+#include "ui.h"
+
+#ifdef VIDEATOR_SUPPORT
+@ class VideatorProxy;
+#endif
+
+@interface FractalView:NSView {
+ int mouseX, mouseY;
+ int mouseButton, rightMouseButton, otherMouseButton, mouseScrollWheel;
+ int keysDown;
+ int cursorType;
+
+ int currentBuffer;
+ NSBitmapImageRep *imageRep[2];
+
+ NSString *messageText;
+ NSPoint messageLocation;
+
+#ifdef VIDEATOR_SUPPORT
+ VideatorProxy *videatorProxy;
+#endif
+}
+
+#pragma mark Buffers
+-(int) allocBuffer1:(char **)b1 buffer2:(char **) b2;
+-(void) freeBuffers;
+-(void) flipBuffers;
+
+#pragma mark Accessors
+
+#ifdef VIDEATOR_SUPPORT
+-(VideatorProxy *) videatorProxy;
+#endif
+-(void) getWidth:(int *)w height:(int *) h;
+-(void) getMouseX:(int *)mx mouseY:(int *)my mouseButton:(int *) mb;
+-(void) getMouseX:(int *)mx mouseY:(int *)my mouseButton:(int *)mb keys:(int *) k;
+
+#pragma mark Cursor
+-(void) setCursorType:(int) type;
+
+#pragma mark Text
+-(void) printText:(CONST char *)text atX:(int)x y:(int) y;
+- (NSDictionary *) textAttributes;
+
+@end
diff --git a/src/ui/ui-drv/cocoa/FractalView.m b/src/ui/ui-drv/cocoa/FractalView.m
new file mode 100644
index 0000000..6a3b458
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/FractalView.m
@@ -0,0 +1,347 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * Cocoa Driver by J.B. Langston III (jb-langston@austin.rr.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.
+ */
+#import "FractalView.h"
+#ifdef VIDEATOR_SUPPORT
+#import "VideatorProxy.h"
+#endif
+
+@interface NSObject(AppDelegateStuff)
+
+- (void)keyPressed:(NSString *)key;
+
+@end
+
+@implementation FractalView
+
+#pragma mark Initialization
+
+- (id)initWithFrame:(NSRect)frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+#ifdef VIDEATOR_SUPPORT
+ videatorProxy = [[VideatorProxy alloc] init];
+#endif
+ }
+ return self;
+}
+
+- (void)dealloc {
+#ifdef VIDEATOR_SUPPORT
+ [videatorProxy release];
+#endif
+ [super dealloc];
+}
+
+#pragma mark Drawing
+
+- (BOOL)isOpaque {
+ return YES;
+}
+
+- (void)drawRect:(NSRect)rect {
+ if (imageRep[currentBuffer]) {
+ [imageRep[currentBuffer] drawInRect:[self bounds]];
+ }
+
+ if (messageText) {
+ [messageText drawAtPoint:messageLocation withAttributes:[self textAttributes]];
+ [messageText release];
+ messageText = nil;
+ }
+
+#ifdef VIDEATOR_SUPPORT
+ [videatorProxy sendImageRep:imageRep[currentBuffer]];
+#endif
+}
+
+#pragma mark Resize Handling
+
+- (void)viewDidEndLiveResize {
+ ui_resize();
+}
+
+#pragma mark Mouse Event Handling
+
+- (void)calculateMouseLocationFromEvent:(NSEvent *)theEvent {
+ NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ mouseX = mouseLoc.x;
+ mouseY = [self bounds].size.height - mouseLoc.y;
+}
+
+- (void)mouseDown:(NSEvent *)theEvent {
+ [self calculateMouseLocationFromEvent:theEvent];
+
+ // Emulate 3 buttons based on modifier keys
+ mouseScrollWheel = 0;
+ if ([theEvent modifierFlags] & NSControlKeyMask) {
+ mouseButton = BUTTON3;
+ } else if ([theEvent modifierFlags] & NSShiftKeyMask) {
+ mouseButton = BUTTON2;
+ } else {
+ mouseButton = BUTTON1;
+ }
+}
+
+- (void)mouseUp:(NSEvent *)theEvent {
+ mouseButton = 0;
+}
+
+- (void)mouseDragged:(NSEvent *)theEvent {
+ [self calculateMouseLocationFromEvent:theEvent];
+}
+
+- (void)rightMouseDown:(NSEvent *)theEvent {
+ [self calculateMouseLocationFromEvent:theEvent];
+ mouseScrollWheel = 0;
+ rightMouseButton = BUTTON3;
+}
+
+- (void)rightMouseUp:(NSEvent *)theEvent {
+ rightMouseButton = 0;
+}
+
+- (void)rightMouseDragged:(NSEvent *)theEvent {
+ [self calculateMouseLocationFromEvent:theEvent];
+}
+
+- (void)otherMouseDown:(NSEvent *)theEvent {
+ [self calculateMouseLocationFromEvent:theEvent];
+ mouseScrollWheel = 0;
+ otherMouseButton = BUTTON2;
+}
+
+- (void)otherMouseUp:(NSEvent *)theEvent {
+ otherMouseButton = 0;
+}
+
+- (void)otherMouseDragged:(NSEvent *)theEvent {
+ [self calculateMouseLocationFromEvent:theEvent];
+}
+
+- (void)scrollWheel:(NSEvent *)theEvent {
+ // Only scroll if no mouse buttons are held
+ if ((mouseButton | rightMouseButton | otherMouseButton) == 0) {
+ mouseScrollWheel = BUTTON2;
+ mouseX += [theEvent deltaX];
+ mouseY += [theEvent deltaY];
+ }
+}
+
+#pragma mark Keyboard Event Handling
+
+- (void)flagsChanged:(NSEvent *)theEvent {
+ // Emulate 3 buttons based on modifier keys
+ if (mouseButton) {
+ if ([theEvent modifierFlags] & NSControlKeyMask) {
+ mouseButton = BUTTON3;
+ } else if ([theEvent modifierFlags] & NSShiftKeyMask) {
+ mouseButton = BUTTON2;
+ } else {
+ mouseButton = BUTTON1;
+ }
+ }
+}
+
+- (void)keyDown:(NSEvent *)e {
+ NSString *characters = [e characters];
+ if ([characters length] == 0) return;
+
+ unichar keyChar = [characters characterAtIndex:0];
+ switch(keyChar) {
+ case NSLeftArrowFunctionKey:
+ keysDown |= 1;
+ ui_key(UIKEY_LEFT);
+ break;
+ case NSRightArrowFunctionKey:
+ keysDown |= 2;
+ ui_key(UIKEY_RIGHT);
+ break;
+ case NSUpArrowFunctionKey:
+ keysDown |= 4;
+ ui_key(UIKEY_UP);
+ break;
+ case NSDownArrowFunctionKey:
+ keysDown |= 8;
+ ui_key(UIKEY_DOWN);
+ break;
+ case NSBackspaceCharacter:
+ ui_key(UIKEY_BACKSPACE);
+ break;
+ case NSEndFunctionKey:
+ ui_key(UIKEY_END);
+ break;
+ case '\033': // Escape
+ ui_key(UIKEY_ESC);
+ break;
+ case NSHomeFunctionKey:
+ ui_key(UIKEY_HOME);
+ break;
+ case NSPageDownFunctionKey:
+ ui_key(UIKEY_PGDOWN);
+ break;
+ case NSPageUpFunctionKey:
+ ui_key(UIKEY_PGUP);
+ break;
+ case NSTabCharacter:
+ ui_key(UIKEY_TAB);
+ break;
+ default:
+ ui_key(keyChar);
+ }
+}
+
+- (void)keyUp:(NSEvent *)e {
+ NSString *characters = [e characters];
+ if ([characters length] == 0) return;
+
+ unichar keyChar = [characters characterAtIndex:0];
+ switch(keyChar) {
+ case NSLeftArrowFunctionKey:
+ keysDown &= ~1;
+ break;
+ case NSRightArrowFunctionKey:
+ keysDown &= ~2;
+ break;
+ case NSUpArrowFunctionKey:
+ keysDown &= ~4;
+ break;
+ case NSDownArrowFunctionKey:
+ keysDown &= ~8;
+ break;
+ }
+}
+
+#pragma mark Accessors
+
+#ifdef VIDEATOR_SUPPORT
+- (VideatorProxy *)videatorProxy {
+ return videatorProxy;
+}
+#endif
+
+- (void)getWidth:(int *)w height:(int *)h {
+ NSRect bounds = [self bounds];
+ *w = bounds.size.width;
+ *h = bounds.size.height;
+}
+
+- (void)getMouseX:(int *)mx mouseY:(int *)my mouseButton:(int *)mb {
+ *mx = mouseX;
+ *my = mouseY;
+ *mb = mouseButton | rightMouseButton | otherMouseButton | mouseScrollWheel;
+}
+
+- (void)getMouseX:(int *)mx mouseY:(int *)my mouseButton:(int *)mb keys:(int *)k
+{
+ [self getMouseX:mx mouseY:my mouseButton:mb];
+ *k = keysDown;
+}
+
+#pragma mark Cursor
+
+- (void)setCursorType:(int)type {
+ cursorType = type;
+ [[self window] invalidateCursorRectsForView:self];
+}
+
+- (void)resetCursorRects {
+ /* BUG - cursor changes back to arrow when mouse is clicked
+ if (cursorType == VJMOUSE) {
+ NSCursor *cursor = [[NSCursor alloc] initWithImage:[NSImage imageNamed:@"performanceCursor"] hotSpot:NSMakePoint(1.0,1.0)];
+ [cursor setOnMouseEntered:YES];
+ [self addCursorRect:[self bounds] cursor:cursor];
+ [cursor release];
+ } */
+}
+
+
+#pragma mark Text
+
+- (NSDictionary *)textAttributes {
+
+ NSMutableDictionary *attrsDictionary = [NSMutableDictionary dictionaryWithObject:[NSColor whiteColor]
+ forKey:NSForegroundColorAttributeName];
+
+ NSShadow *dockStyleTextShadow = [[NSShadow alloc] init];
+ [dockStyleTextShadow setShadowOffset:NSMakeSize(2, -2)];
+ [dockStyleTextShadow setShadowBlurRadius:1];
+ [dockStyleTextShadow setShadowColor:[NSColor blackColor]];
+ [attrsDictionary setValue:[NSFont boldSystemFontOfSize:12.0] forKey:NSFontAttributeName];
+ [attrsDictionary setValue:dockStyleTextShadow forKey:NSShadowAttributeName];
+ [dockStyleTextShadow autorelease];
+
+ return attrsDictionary;
+}
+
+
+- (void)printText:(CONST char *)text atX:(int)x y:(int)y {
+ messageText = [[NSString stringWithUTF8String:text] retain];
+ messageLocation = NSMakePoint(x + 15, [self bounds].size.height - y);
+ [self setNeedsDisplay:YES];
+}
+
+#pragma mark Buffers
+
+- (int)allocBuffer1:(char **)b1 buffer2:(char **)b2 {
+ currentBuffer = 0;
+ NSRect bounds = [self bounds];
+ imageRep[0] = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
+ pixelsWide:bounds.size.width
+ pixelsHigh:bounds.size.height
+ bitsPerSample:8
+ samplesPerPixel:3
+ hasAlpha:NO
+ isPlanar:NO
+ colorSpaceName:NSDeviceRGBColorSpace
+ bytesPerRow:0
+ bitsPerPixel:32];
+
+ *b1 = (char *)[imageRep[0] bitmapData];
+
+ imageRep[1] = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
+ pixelsWide:bounds.size.width
+ pixelsHigh:bounds.size.height
+ bitsPerSample:8
+ samplesPerPixel:3
+ hasAlpha:NO
+ isPlanar:NO
+ colorSpaceName:NSDeviceRGBColorSpace
+ bytesPerRow:0
+ bitsPerPixel:32];
+
+ *b2 = (char *)[imageRep[1] bitmapData];
+ NSLog(@"bytesPerRow = %d", [imageRep[0] bytesPerRow]);
+ return [imageRep[0] bytesPerRow];
+}
+
+- (void)freeBuffers {
+ [imageRep[0] release];
+ [imageRep[1] release];
+}
+
+- (void)flipBuffers {
+ currentBuffer ^= 1;
+}
+
+@end
diff --git a/src/ui/ui-drv/cocoa/HowToBuild.txt b/src/ui/ui-drv/cocoa/HowToBuild.txt
new file mode 100644
index 0000000..90209f1
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/HowToBuild.txt
@@ -0,0 +1,47 @@
+XaoS for Mac OS X (Cocoa)
+Build Instructions
+
+By J.B. Langston III
+
+Here are instructions for getting the XaoS Xcode project to build successfully
+assuming you have downloaded a released source tarball or gotten the source
+from CVS:
+
+A) Build dependencies
+
+ 1) Download the latest libpng from
+
+ ftp://ftp.simplesystems.org/pub/libpng/png/src/
+
+ 2) Configure libpng for universal binaries with the following command:
+
+ env CFLAGS="-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -mmacosx-version-min=10.4" \
+ LDFLAGS="-arch i386 -arch ppc" \
+ ./configure --prefix=$XAOS_ROOT/src/ui/ui-drv/cocoa/thirdparty --disable-dependency-tracking
+
+ Be sure to replace $XAOS_ROOT with the root of your XaoS source folder.
+
+ For more information about building open source libraries as universal binaries:
+ http://developer.apple.com/technotes/tn2005/tn2137.html
+
+ 3) Make and install libpng:
+
+ make && make install
+
+ 4) Download the latest gsl from
+
+ ftp://ftp.gnu.org/gnu/gsl/
+
+ 5) Repeat steps 2 and 3 for gsl
+
+ 6) Download the latest gettext from
+
+ ftp://ftp.gnu.org/gnu/gettext/
+
+ 7) Repeat steps 2 and 3 for gettext
+
+B) Build XaoS
+
+ You should now be able to build XaoS from the Xcode project.
+
+Have fun! If you have questions, feel free to e-mail me: jb-langston at austin dot rr dot com \ No newline at end of file
diff --git a/src/ui/ui-drv/cocoa/Info.plist b/src/ui/ui-drv/cocoa/Info.plist
new file mode 100644
index 0000000..7dc86fd
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/Info.plist
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>xaf</string>
+ </array>
+ <key>CFBundleTypeIconFile</key>
+ <string>XaoSDocument</string>
+ <key>CFBundleTypeName</key>
+ <string>XaoS Animation File</string>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>LSTypeIsPackage</key>
+ <false/>
+ <key>NSPersistentStoreTypeKey</key>
+ <string>XML</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>xpf</string>
+ </array>
+ <key>CFBundleTypeIconFile</key>
+ <string>XaoSDocument</string>
+ <key>CFBundleTypeName</key>
+ <string>XaoS Position File</string>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>LSTypeIsPackage</key>
+ <false/>
+ <key>NSPersistentStoreTypeKey</key>
+ <string>XML</string>
+ </dict>
+ </array>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleHelpBookFolder</key>
+ <string>XaoSHelp</string>
+ <key>CFBundleHelpBookName</key>
+ <string>XaoSHelp</string>
+ <key>CFBundleIconFile</key>
+ <string>XaoS</string>
+ <key>CFBundleIdentifier</key>
+ <string>net.sourceforge.xaos.XaoS</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>3.5</string>
+ <key>NSAppleScriptEnabled</key>
+ <string>YES</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
diff --git a/src/ui/ui-drv/cocoa/Japanese.lproj/InfoPlist.strings b/src/ui/ui-drv/cocoa/Japanese.lproj/InfoPlist.strings
new file mode 100644
index 0000000..8a78ff4
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/Japanese.lproj/InfoPlist.strings
Binary files differ
diff --git a/src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/classes.nib b/src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 0000000..b9b4b09
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,4 @@
+{
+ IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; });
+ IBVersion = 1;
+} \ No newline at end of file
diff --git a/src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/info.nib b/src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/info.nib
new file mode 100644
index 0000000..4c74210
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/info.nib
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IBDocumentLocation</key>
+ <string>94 103 356 240 0 0 1280 1002 </string>
+ <key>IBEditorPositions</key>
+ <dict>
+ <key>29</key>
+ <string>93 343 318 44 0 0 1280 1002 </string>
+ </dict>
+ <key>IBFramework Version</key>
+ <string>403.0</string>
+ <key>IBSystem Version</key>
+ <string>8A278</string>
+</dict>
+</plist>
diff --git a/src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/keyedobjects.nib b/src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/keyedobjects.nib
new file mode 100644
index 0000000..ee1187e
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/Japanese.lproj/MainMenu.nib/keyedobjects.nib
Binary files differ
diff --git a/src/ui/ui-drv/cocoa/Read Me.rtf b/src/ui/ui-drv/cocoa/Read Me.rtf
new file mode 100644
index 0000000..b005745
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/Read Me.rtf
@@ -0,0 +1,193 @@
+{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf270
+{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
+{\colortbl;\red255\green255\blue255;}
+{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid1}
+{\list\listtemplateid2\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid2}
+{\list\listtemplateid3\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid3}
+{\list\listtemplateid4\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid4}
+{\list\listtemplateid5\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid5}
+{\list\listtemplateid6\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid6}
+{\list\listtemplateid7\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid7}
+{\list\listtemplateid8\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid1\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid8}
+{\list\listtemplateid9\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid9}
+{\list\listtemplateid10\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid10}}
+{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}{\listoverride\listid3\listoverridecount0\ls3}{\listoverride\listid4\listoverridecount0\ls4}{\listoverride\listid5\listoverridecount0\ls5}{\listoverride\listid6\listoverridecount0\ls6}{\listoverride\listid7\listoverridecount0\ls7}{\listoverride\listid8\listoverridecount0\ls8}{\listoverride\listid9\listoverridecount0\ls9}{\listoverride\listid10\listoverridecount0\ls10}}
+\vieww9000\viewh8400\viewkind0
+\deftab720
+\pard\pardeftab720\sa80\ql\qnatural
+
+\f0\b\fs24 \cf0 XaoS Real-Time Fractal Zoomer for Mac OS X, Version 3.4\
+\pard\pardeftab720\ql\qnatural
+
+\b0 \cf0 \
+Originally written by Jan Hubicka and Thomas Marsh\
+Currently maintained by Zoltan Kovacs (kovzol@math.u-szeged.hu)\
+Ported to Mac OS X By J.B. Langston III (jb-langston@austin.rr.com)\
+\'a0\
+Current version: \
+XaoS Homepage: {\field{\*\fldinst{HYPERLINK "http://xaos.sf.net/"}}{\fldrslt http://xaos.sf.net/}}\
+\'a0\
+\pard\pardeftab720\sa80\ql\qnatural
+
+\b \cf0 About\
+\pard\pardeftab720\sa80\ql\qnatural
+
+\b0 \cf0 XaoS is an incredible program that lets you explore fractals by zooming in and out in real time.\'a0 If you\'92ve only used static fractal viewers like Fractint or UltraFractal before, zooming into a fractal as a real time animation is incredible.\'a0 XaoS was originally written by Jan Hubicka and Thomas Marsh, and is currently maintained by Zoltan Kovacs. I contributed the Mac OS X user interface and made binaries available for ease of use. XaoS is free software available under the terms of the GNU General Public License.\
+\pard\pardeftab720\ql\qnatural
+\cf0 \
+\pard\pardeftab720\sa80\ql\qnatural
+
+\b \cf0 Installation and Usage\
+\pard\pardeftab720\ql\qnatural
+
+\b0 \cf0 After downloading the XaoS binary, just copy it to your applications folder and run the program. Basic usage is really pretty simple.\'a0\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\ql\qnatural
+\ls1\ilvl0\cf0 {\listtext \'95 }Point your mouse at the part of the image you want to zoom in on, and hold down the mouse button.\'a0 Away you go!\'a0\
+{\listtext \'95 }To zoom back out, hold down the control key and click.\'a0 Or, right click with a two-button mouse.\'a0\
+{\listtext \'95 }To pan, hold down the shift key and drag. On a three-button mouse, drag with the center button.\'a0 If you have a mouse with a scroll wheel, pressing down on the scroll wheel usually works like the center button.\
+{\listtext \'95 }To go full-screen, select UI->Drivers->Mac OS X Fullscreen Driver from the menu. In full screen mode, the menu is only displayed when you move the mouse near the top of the screen. After going full screen, you can quit by pressing \uc0\u8984 Q, or you can go back to windowed mode by selecting UI->Drivers->Mac OS X Windowed Driver.\
+\pard\pardeftab720\ql\qnatural
+\cf0 \'a0\
+To learn more, check out the tutorials from the Help menu.\'a0 They are really informative and a lot of fun to watch.\'a0 For more in-depth information, use the online help.\
+\'a0\
+\pard\pardeftab720\ql\qnatural
+
+\b \cf0 Known Issues\
+\pard\pardeftab720\ql\qnatural
+
+\b0 \cf0 The following are known issues with the current version of XaoS for Mac OS X.\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\ql\qnatural
+\ls2\ilvl0\cf0 {\listtext \'95 }Catseye fractal does not render properly.\'a0 \uc0\u8232 Workaround: Set the bailout to just over 4 (e.g., 4.000000001). After changing this setting, the fractal renders as expected.\
+\pard\pardeftab720\ql\qnatural
+\cf0 \
+\pard\pardeftab720\sa80\ql\qnatural
+
+\b \cf0 Revision History\
+\pard\pardeftab720\sa80\ql\qnatural
+
+\b0 \cf0 3.4\
+Release Date: 6/1/2008\
+\pard\tx560\pardeftab720\ql\qnatural
+\cf0 \
+This is a huge release for Mac users. The Mac user interface has been completely rewritten in Cocoa and improved in a number of ways:\
+\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\sa80\ql\qnatural
+\ls3\ilvl0\cf0 {\listtext \'95 }Standard Aqua dialog boxes instead of the strange-looking Unixy things in previous versions. Fields in dialog boxes now support cut and paste as you would expect.\
+{\listtext \'95 }Pop-up menus are now displayed using standard Aqua menus\
+{\listtext \'95 }Menu bar in full-screen mode is now the standard Mac OS X menu bar. It automatically slides into view when you move your mouse to the top of the screen and slides out when you move away from it.\
+{\listtext \'95 }XaoS now has a standard Aqua about dialog box, which displays links to license and credits in help file.\
+{\listtext \'95 }Help is now displayed via Mac OS X's standard help viewer. Tutorials can still be launched via links in the help viewer.\
+{\listtext \'95 }Support for opening xpf (Saved Position) and xaf (Saved Animation) files directly from Finder via drag and drop and by double-clicking. XaoS now includes its own document icon for these files as well.\
+{\listtext \'95 }Support for basic AppleScriptability via the standard script dictionary. Includes things like opening files and manipulating the window, but no XaoS-specific functionality.\
+{\listtext \'95 }Support for panning the fractal with the mouse scroll wheel or trackpad two-finger gestures.\
+\pard\tx560\pardeftab720\ql\qnatural
+\cf0 \
+In addition to the user interface improvements, XaoS for Mac has the following improvements:\
+\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\sa80\ql\qnatural
+\ls4\ilvl0\cf0 {\listtext \'95 }Now uses greater precision (long double) for calculations to enable much deeper zooms.\
+{\listtext \'95 }In addition to English, XaoS for Mac OS X now supports the following languages: Czech, French, German, Hungarian, Italian, Romanian, and Spanish.\
+{\listtext \'95 }Integration with Stone Design's Videator (http://stone.com/Videator/). XaoS can now send live a live video stream to Videator, which can then do post-processing using Mac OS X's core video technology. This is great for VJing (live video performance art). See http://stone.com/Videator/VJ.html for more details.\
+{\listtext \'95 }New Italian translation courtesy of Sergio Zanchetta\
+{\listtext \'95 }Updated German translation by Andreas Madritsch\
+{\listtext \'95 }Bug fix to prevent Edge Detection and Pseudo 3D filter from rendering the image completely black.\
+{\listtext \'95 }Bug fix to prevent garbled characters when using non-English languages on modern systems using UTF-8\
+{\listtext \'95 }Bug fix to prevent XaoS from crashing after using the Render Animation functionality\
+{\listtext \'95 }Bug fix to prevent incorrect colors on smooth coloring modes with certain video modes\
+\pard\pardeftab720\sa80\ql\qnatural
+\cf0 \
+3.3\
+Release Date: 3/13/2008\
+\
+Changes since 3.2.2:\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\sa80\ql\qnatural
+\ls5\ilvl0\cf0 {\listtext \'95 }Added user formula support using SFFE/GSL library.\
+{\listtext \'95 }Fixed bug where colors display incorrectly on Intel Macs after switching from full screen back to windowed driver.\
+{\listtext \'95 }Upgraded libpng to 1.2.25.\
+{\listtext \'95 }Included libgsl 1.10.\
+{\listtext \'95 }Updated build instructions with easier third party library build process.\
+{\listtext \'95 }Added performance mode, which inhibits text display (useful for VJing).\
+{\listtext \'95 }Fixed bug where color cycling would stop when moving from forward cycling to reverse.\
+\pard\pardeftab720\sa80\ql\qnatural
+\cf0 \
+3.2.2 \
+Release Date: 9/26/2006\
+\
+Changes since Beta 4:\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\sa80\ql\qnatural
+\ls6\ilvl0\cf0 {\listtext \'95 }Fixed bug which was preventing XaoS from rendering images over 2500x2500\
+{\listtext \'95 }Added fullscreen driver\
+{\listtext \'95 }Upgraded libpng to 1.2.12\
+\pard\pardeftab720\sa80\ql\qnatural
+\cf0 \
+3.2.1 Beta 4\
+\pard\pardeftab720\ql\qnatural
+\cf0 Release Date: 7/8/2006\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\ql\qnatural
+\ls7\ilvl0\cf0 \
+\pard\pardeftab720\ql\qnatural
+\cf0 Changes since Beta 3:\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\ql\qnatural
+\ls8\ilvl0\cf0 {\listtext \'95 }Fixed bug with colors on Intel Macs (default colors previously showed yellow instead of blue)\
+{\listtext \'95 }Fixed bug that prevented render animation option from working correctly\
+{\listtext \'95 }Added -windowsize and -autoscreensize command line arguments\
+\pard\tx940\tx1440\pardeftab720\li1440\fi-1440\ql\qnatural
+\ls8\ilvl1\cf0 -windowsize allows you to specify the window size on the command line\
+ -autoscreensize causes XaoS to attempt to automatically detect the pysical screen size\
+\pard\pardeftab720\sa80\ql\qnatural
+\cf0 \
+3.2.1 Beta 3\
+\pard\pardeftab720\ql\qnatural
+\cf0 Release Date: 6/27/2006\
+\
+Changes since Beta 2:\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\ql\qnatural
+\ls9\ilvl0\cf0 {\listtext \'95 }Support saving to png. libpng is included as a private framework.\
+{\listtext \'95 }Changed icon to match XaoS default image\
+{\listtext \'95 }Provide standard Mac OS keyboard shortcuts for applicable functions -- redo, undo, save, load\
+{\listtext \'95 }Repackaged as a disk image with Readme fil\
+\
+\pard\pardeftab720\sa80\ql\qnatural
+\cf0 3.2.1 Beta 2\
+\pard\pardeftab720\ql\qnatural
+\cf0 Release Date: 6/20/2006\
+\
+Changes since Beta 1:\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\ql\qnatural
+\ls10\ilvl0\cf0 {\listtext \'95 }Keyboard input has been implemented for all keys supported by XaoS.\
+{\listtext \'95 }Fixed bug where window events were not handled if driver was reinitialized.\
+{\listtext \'95 }Tutorials now play back.\
+{\listtext \'95 }Random examples now load.\
+{\listtext \'95 }Since Mac OS X doesn't allow single menu items directly in the menubar, I put "Stop Replay" for animation mode in the UI menu\
+{\listtext \'95 }Mac OS X applications have their own quit command in the Application menu.\'a0 So I removed the quit menu and preceeding separator from the file menu.\
+{\listtext \'95 }Swapped order of UI and Help menus in animation mode to comply with Human Interface Guidelines.\
+\pard\pardeftab720\ql\qnatural
+\cf0 \'a0\
+\pard\pardeftab720\sa80\ql\qnatural
+\cf0 3.2.1 Beta 1\
+\pard\pardeftab720\ql\qnatural
+\cf0 Release Date: 6/15/2006\
+\'a0\
+This was the original public release of XaoS for Mac OS X.\
+\
+\pard\pardeftab720\ql\qnatural
+
+\b \cf0 Included Software
+\b0 \
+\
+libpng 1.2.25\
+http://libpng.org/pub/png/libpng.html\
+\
+GNU Scientific Library 1.10 \
+http://www.gnu.org/software/gsl/\
+\
+
+\b About Free Software\
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720\ql\qnatural\pardirnatural
+
+\b0 \cf0 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; it is displayable from the program's online help feature. If not, you can find it on the Internet at http://www.gnu.org or you can write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.} \ No newline at end of file
diff --git a/src/ui/ui-drv/cocoa/Readme Cocoa b/src/ui/ui-drv/cocoa/Readme Cocoa
new file mode 100644
index 0000000..3e92f34
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/Readme Cocoa
@@ -0,0 +1,390 @@
+2006-10-23 - Andrew Stone (andrew@stone.com)
+ - to build for Videator: -DVIDEATOR_SUPPORT
+ - added this file
+ - added Credits.html
+ - modified InfoPlist.strings
+ - MainMenu.nib
+ - changed NewApplication to XaoS
+ - changed window title to indicate this version of XaoS talks to Videator
+
+ - AppController.m: added distributed notification with imageRep
+ - FractalView.m: added method to return current imageRep
+2006-10-25
+ - ui_cocoa.m now byte swaps color masks
+
+2006-10-26
+ - hot keys working
+ - tutorial and help working ala carbon
+
+2006-11-29 - J.B. Langston
+
+Committing additional changes submitted 10/30 by Andrew Stone:
+
+ - support for arrow keys
+ up/down change zoom speed
+ right/left: if cycling - change
+ if auto-rotation - change speed of rotation
+
+ - UI -> Performance Mode
+ This will turn off the echoing of messages to the screen
+
+ - going from cycle forward and backward no longer toggles cycling off
+
+ - BUG FIX: window now regains key status after after dialog
+
+2008-03-14 - J.B. Langston
+
+ - Fixed bug with smooth color modes on PowerPC Macs (filter.h)
+
+2008-03-17 - J.B. Langston
+
+ - Added user formula support using SFFE/libgsl
+
+ - Added support for libpng to Cocoa
+
+ - Added build instructions to Cocoa project
+
+2008-03-18 - J.B. Langston
+
+ - Moved Videator support into separate VideatorProxy class and updated with
+ Andrew's latest changes - UNTESTED
+
+ - Replaced funky bit-swapping code; now use #if __BIG_ENDIAN__ to set color
+ masks correctly
+
+ - Removed unnecessary xstdio_osx.c and made executable-relative paths work
+ with standard xstdio.c
+
+ - Added Enter key equivalent for OK button on custom dialogs
+
+ - Added call to resize image when maximizing window
+
+ - Added call to terminate app on window close
+
+ - Enabled long double support for deeper zooms
+
+ - Added event handling for middle and right mouse buttons
+
+ - Added event handling for scroll wheel panning
+
+ - Added copyright headers to all files
+
+ - Changed [view setNeedsDisplay:YES] to [view display] to draw immediately
+ in order to eliminate jerky zooming motion
+
+ - Added support to print status text
+
+ - Made save and open panels use last selected directory instead of always
+ going back to home directory
+
+ - Made window regains key status after open/save dialog
+
+ - Removed "-Videator Enabled" from titlebar
+
+ - Fixes to custom dialogs to correctly display long doubles and allow
+ horizontal scrolling instead of wrapping values
+
+2008-03-20
+
+ REFACTORING/CLEANUP
+
+ - Added autorelease pools to all driver functions, wrapping all controller calls
+
+ - removed autorelease pools from inside controller methods
+
+ - Removed Preferences nib, controller, menu item, and associated icons
+ (Videator support will be toggled via menu item in UI menu)
+
+ - changed driver and function name to cocoa_* instead of osx_*
+
+ - Added MACOSX define that can trigger shared functionality for Cocoa/Carbon drivers
+
+ - Removed separate fullscreen driver
+
+ - Removed wrapper functions from controller; now call view functions directly
+
+ - Added functions for driver init and uninit to controller
+
+ - Added pragma marks to categorize functions in controller and view
+
+ - Moved videator hook to view's drawRect:
+
+ - Added wait date to event handling to prevent busy waiting
+
+ HELP SUPPORT
+
+ - Created Apple Help conversion script
+
+ - Added help settings to Info.plist
+
+ - Updated showHelpWithContext:name: method to show main help page
+
+ - Added help conversion script to pre-compile script build phase
+
+2008-03-31
+
+ DIALOGS
+
+ - Add copy/paste functionality for custom dialogs
+
+ HELP
+
+ - Update help conversion script to automatically generate index
+
+ - Update help to use stylesheets
+
+2008-04-04
+
+ I18N
+
+ - Add reference to gettext library, and script command to copy it
+
+ - Add code to detect default locale and set LANG variable accordingly
+
+
+2008-04-05
+
+ MENUS
+
+ - Added Window menu and associated menu items
+
+ I18N
+
+ - Fixed bug where key equivalents were not found when foreign languages
+ were selected
+
+ - I18nized cut/copy/paste/etc. menu items, and OK/Cancel dialog buttons
+
+2008-04-06
+
+ I18N
+
+ - Add code to convert user's native text encoding (usually UTF-8) to
+ Latin1/2 to prevent garbled text through built-in text handling system
+
+ - Automate po/mo file build and packaging
+
+ - Add code to set locale directory correctly relative to executable path
+
+ MENUS
+
+ - Implement popup menus
+
+ - I18nize menu items in application menu
+
+ HELP
+
+ - fix bug in help conversion that results in missing headers for some files
+
+ - Add help applescript to automatically launch tutorials
+
+2008-04-07
+
+ MENUS
+
+ - Implement menu delegate to check/uncheck menu items when displayed
+
+ DIALOGS
+
+ - Hook up choose file button on custom dialogs
+
+2008-04-09
+
+ FULL SCREEN
+
+ - Implement fullscreen code
+
+ - Add menu item to UI menu to toggle fullscreen mode
+
+ - Change render basename type from to DIALOG_STRING to DIALOG_OFILE
+
+ DRIVER
+
+ - Add driver initialization code
+
+ - Add driver uninitialization code
+
+ MISC
+
+ - Conditionalize custom script build phases so they do not do unnecessary work
+
+2008-04-10
+
+ I18N
+
+ - Added italian translation
+
+ MISC
+
+ - Rebuilt Xcode project to fix issues with debugger and interface builder
+
+ - Incremented Cocoa version number from 3.3 to 3.4
+
+ HELP
+
+ - Got rid of space in help file name
+
+2008-04-14
+
+ I18N
+
+ - Make OK/Cancel buttons on custom dialogs autosize to fit i18n labels
+
+ MISC
+
+ - Change Performance Mode to VJ mode (changed shortcut from P to v)
+ (performance mode might be confused with performance enhancement)
+
+ - Added document icon
+
+ - Added Close menu item to file menu
+
+ - Fixed regression where window did not retain key status after dialog
+
+ - Add cursor changing code in cocoa driver
+
+ - Add hook to change cursor during performance mode
+
+2008-04-16
+
+ HELP
+
+ - Add css element to make dt elements bold
+
+ - Add anchors for usrform and usrformInit to help file
+
+ I18N
+
+ - Updated italian po and catalog
+
+ - Added Italian to configure.in ALL_LINGUAS
+
+ MISC
+
+ - Refine about dialog box
+
+ - Add comments and cleanup
+
+ - Changed version to 3.4pre1 in configure.in
+
+2008-04-17
+
+ BUGS
+
+ - Fix crash after animation rendering
+
+ Analysis: changes introduced for sffe made the uih variable from ui.c
+ global in ui.h so that the sffe parser can be accessed from custom
+ formula code in formulas.c. Uih was previously declared static in render.c
+ because the animation renderer maintains its own context. SFFE changed
+ this from static to extern so the uih in render.c was pointing to the same
+ uih in ui.c, instead of to a different structure. When animations were
+ rendered, the uih in ui.h got clobbered, and the next function that tried
+ to use it caused a segfault.
+
+ Fix:
+ 1. Change name of global uih pointer defined in ui.h from uih to globaluih.
+ 2. Change sffe code to access globaluih pointer instead of uih
+ 3. Add code to main function to set both uih and globaluih to point at the same structure
+ 4. Change code in cocoa driver to use globaluih as well
+
+ - Fix bug that causes XaoS to crash when using non-native (ugly) dialog
+ code for Render Animation dialog with open file dialog for basename
+
+ Analysis: There was a loop in ui_buildfile in dialog.c, that tried to
+ find a "*" in the default filename, and if it didn't find one, it would
+ run right off the end of the buffer and continue until a seg fault occurred.
+
+ Fix: the loop now checks for both "*" or a nul terminator as the exit
+ condition. If it doesn't find an asterisk, it still stops at the end
+ of the string.
+
+ - Make custom dialog boxes slide out of view before executing menu function
+
+ This prevents the dialog from hanging around after clicking OK during long
+ running operations such as rendering animations
+
+ - Add code to prevent rendering animation if absolute path is not specified
+ for Basename. This prevents files from being accidentally written to the
+ hard drive's root directory
+
+2008-04-23
+
+ I18N
+
+ - Changes to -initLocale: do not overwrite LANG if it is already set
+
+ - Added AppController.m and CustomDialog.m in i18n/Makefile.in.in
+
+ - Regenerated po and pot files with new strings from cocoa driver
+
+ MISC
+
+ - Conditionalize window menu with #ifdef MACOSX
+
+2008-04-24
+
+ - Add enable/disable menu item for Videator
+
+ - Move Close menu item to proper place in File menu
+
+ - Reindent code
+
+ - Cleanups to eliminate warnings
+
+ - Conditionalize videator code
+
+2008-04-26
+
+ - Update video encoding section to recommend ffmpeg, mencoder
+
+ - Move Berkeley MPEG encoder information to historical section
+
+ - Create help section to explain how to get support
+
+ - Add library copyright information to credits help section
+
+ - Update Development help section with recent contribution instructions
+
+ - Add Mac OS X help section
+
+ - Add links to Videator in Mac OS X help section
+
+2008-05-15
+
+ - Fix diacritical mark rendering on Mac OS X Tiger
+
+ - Update Italian translation
+
+ - Fix problem with localized application menu
+
+ - Add link to XaoS Website in About dialog
+
+2008-05-20
+
+ - Fix black screen with edge detection filters
+
+ - Fix black screen with pseudo-3d filter
+
+ - Fix black screen with hsv coloring modes
+
+ - Automatically save window position and size
+
+ - Update help file to remove workarounds for fixed issues
+
+2008-05-22
+
+ - Increment version numbers
+
+
+TODO:
+
+* bugs
+
+ - Fix catseye rendering (shows empty circle without increasing bailout)
+ - Cursor changing code only works until the user clicks a button
+
+* acs features
+ - Implement fast palette save/recall
+ - Implement autokeys on startup
+
diff --git a/src/ui/ui-drv/cocoa/VideatorProxy.h b/src/ui/ui-drv/cocoa/VideatorProxy.h
new file mode 100644
index 0000000..f4187ee
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/VideatorProxy.h
@@ -0,0 +1,42 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * Cocoa Driver by J.B. Langston III (jb-langston@austin.rr.com)
+ * Videator Support by Andrew Stone (Stone Design)
+ * For information about Videator, visit http://www.stone.com/Videator
+ *
+ * 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.
+ */
+#ifdef VIDEATOR_SUPPORT
+#import <Cocoa/Cocoa.h>
+
+@ interface VideatorProxy:NSObject {
+ BOOL _wantsThrottle;
+ NSDate *_lastFrameCreatedDate;
+ id _videatorProxy;
+ NSCalendarDate *_killDate;
+ BOOL _videatorEnabled;
+}
+
+-(void) sendImageRep:(NSBitmapImageRep *) imageRep;
+-(void) toggleVideator:(id) sender;
+-(BOOL) videatorEnabled;
+
+@end
+#endif
diff --git a/src/ui/ui-drv/cocoa/VideatorProxy.m b/src/ui/ui-drv/cocoa/VideatorProxy.m
new file mode 100644
index 0000000..506ac48
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/VideatorProxy.m
@@ -0,0 +1,157 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * Cocoa Driver by J.B. Langston III (jb-langston@austin.rr.com)
+ * Videator Support by Andrew Stone (Stone Design)
+ * For information about Videator, visit http://www.stone.com/Videator
+ *
+ * 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.
+ */
+#include <aconfig.h>
+#ifdef VIDEATOR_SUPPORT
+#import "VideatorProxy.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <libc.h>
+
+NSString *cheapHostName() {
+ NSString *host = @"localhost";
+ char s[_POSIX_HOST_NAME_MAX+1];
+ s[0] = '\0';
+ if (gethostname(s, _POSIX_HOST_NAME_MAX) == 0) {
+ if (strlen(s) > 0)
+ host = [[[NSString alloc] initWithUTF8String:s]autorelease];
+ }
+ return host;
+}
+
+#define VideatorServer ([NSString stringWithFormat:@"VideatorServer-%@",cheapHostName()])
+#define FRAME_REFRESH_THRESHOLD 0.04
+
+@protocol VideatorVendedProtocol
+// to notify in main thread
+- (void)runUpdateAlert:(NSString *)latestVersionNumber;
+// XaoS
+- (BOOL)wantsXaoSImage;
+- (void)setXaosImageData:(NSData *)bmData;
+// automator mode to check its not hung
+- (BOOL)heartBeat;
+@end
+
+
+@implementation VideatorProxy
+
++ (void)setupDefaults
+{
+ NSString *userDefaultsValuesPath;
+ NSDictionary *userDefaultsValuesDict;
+ NSDictionary *initialValuesDict;
+ NSArray *resettableUserDefaultsKeys;
+
+ userDefaultsValuesPath=[[NSBundle mainBundle] pathForResource:@"UserDefaults"
+ ofType:@"plist"];
+ userDefaultsValuesDict=[NSDictionary dictionaryWithContentsOfFile:userDefaultsValuesPath];
+
+ [[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];
+
+ resettableUserDefaultsKeys=[NSArray arrayWithObjects:@"EnableVideator",nil];
+ initialValuesDict=[userDefaultsValuesDict dictionaryWithValuesForKeys:resettableUserDefaultsKeys];
+
+ [[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:initialValuesDict];
+}
+
++ (void)initialize {
+ [self setupDefaults];
+}
+
+- (id)init {
+ self = [super init];
+ if (self) {
+ _videatorEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"EnableVideator"];
+ }
+ return self;
+}
+
+- (void)toggleVideator:(id)sender {
+ _videatorEnabled ^= 1;
+ [[NSUserDefaults standardUserDefaults] setBool:_videatorEnabled forKey:@"EnableVideator"];
+}
+
+- (BOOL)videatorEnabled {
+ return _videatorEnabled;
+}
+
+- (void)connectionDidDie:(NSNotification *)n {
+ _videatorProxy = nil;
+ _killDate = [[NSCalendarDate date] retain];
+ NSLog(@"Videator is dead... ...Long Live Videator!");
+}
+
+- (void)getProxy {
+
+ // do not try and reconnect to an application that is terminating:
+ if (_killDate && [_killDate timeIntervalSinceNow] > -10.0) return;
+ else _killDate = nil;
+
+ _videatorProxy = [[NSConnection rootProxyForConnectionWithRegisteredName:VideatorServer host:nil] retain];
+ // if we can't find it, no big deal:
+ if (_videatorProxy != nil) {
+ [_videatorProxy setProtocolForProxy:@protocol(VideatorVendedProtocol)];
+ [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(connectionDidDie:) name:@"VideatorWillTerminate" object:nil];
+ }
+}
+
+- (void)sendImageRep:(NSBitmapImageRep *)imageRep {
+ // simply return if user does not want this
+ if (!_videatorEnabled) return;
+
+ // Andrew's Videator hook - costs almost nothing since the view maintains the bitmapImageRep in hand -
+ // We call it here because other mechanisms might cause a redraw in the view but we don't want that overhead
+ // unless we've been notified that there really was a change:
+ // HOWEVER we can only shove so much stuff down the pipe - let's try 30 frames per second threshold
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSDate *now = [NSDate date];
+
+
+ if (_wantsThrottle) {
+ static float _FRAME_REFRESH_THRESHOLD = 0.0;
+ if (_FRAME_REFRESH_THRESHOLD == 0.0) {
+ _FRAME_REFRESH_THRESHOLD = [[NSUserDefaults standardUserDefaults] floatForKey:@"RefreshThreshold"];
+ if (_FRAME_REFRESH_THRESHOLD == 0.0) _FRAME_REFRESH_THRESHOLD = FRAME_REFRESH_THRESHOLD;
+ }
+ if (_lastFrameCreatedDate && [now timeIntervalSinceDate:_lastFrameCreatedDate] < _FRAME_REFRESH_THRESHOLD) return;
+ [_lastFrameCreatedDate release];
+ _lastFrameCreatedDate = [now retain];
+ }
+
+ if (!_videatorProxy) [self getProxy];
+ NS_DURING
+ if (_videatorProxy!=nil /* DO NOT WAIT FOR THE ROUNDTRIP && [_videatorProxy wantsXaoSImage] */)
+ [_videatorProxy setXaosImageData:[imageRep TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:0]];
+ NS_HANDLER
+
+ NS_ENDHANDLER
+
+ [pool release];
+}
+
+@end
+#endif \ No newline at end of file
diff --git a/src/ui/ui-drv/cocoa/XaoS.icns b/src/ui/ui-drv/cocoa/XaoS.icns
new file mode 100644
index 0000000..e03d0cb
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/XaoS.icns
Binary files differ
diff --git a/src/ui/ui-drv/cocoa/XaoS.xcodeproj/project.pbxproj b/src/ui/ui-drv/cocoa/XaoS.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..fd7e096
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/XaoS.xcodeproj/project.pbxproj
@@ -0,0 +1,831 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 44;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
+ 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
+ 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
+ D90A09560DB42FD900B7AAFD /* performanceCursor.tiff in Resources */ = {isa = PBXBuildFile; fileRef = D90A09550DB42FD900B7AAFD /* performanceCursor.tiff */; };
+ D90A096A0DB4465100B7AAFD /* XaoSDocument.icns in Resources */ = {isa = PBXBuildFile; fileRef = D90A09690DB4465100B7AAFD /* XaoSDocument.icns */; };
+ D962B0AD101CA598003C66CE /* grlib_cocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = D962B0AC101CA598003C66CE /* grlib_cocoa.m */; };
+ D962B20C101E9149003C66CE /* grlib.c in Sources */ = {isa = PBXBuildFile; fileRef = D962B20B101E9149003C66CE /* grlib.c */; };
+ D99B5B740DAEE9D100489809 /* ui_cocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = D99B5B730DAEE9D100489809 /* ui_cocoa.m */; };
+ D99B5B7E0DAEE9E700489809 /* AppController.m in Sources */ = {isa = PBXBuildFile; fileRef = D99B5B770DAEE9E700489809 /* AppController.m */; };
+ D99B5B7F0DAEE9E700489809 /* FractalView.m in Sources */ = {isa = PBXBuildFile; fileRef = D99B5B790DAEE9E700489809 /* FractalView.m */; };
+ D99B5B800DAEE9E700489809 /* CustomDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = D99B5B7B0DAEE9E700489809 /* CustomDialog.m */; };
+ D99B5B810DAEE9E700489809 /* VideatorProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = D99B5B7D0DAEE9E700489809 /* VideatorProxy.m */; };
+ D99B5C040DAEEA2700489809 /* cmplx.asm in Sources */ = {isa = PBXBuildFile; fileRef = D99B5B890DAEEA2700489809 /* cmplx.asm */; };
+ D99B5C050DAEEA2700489809 /* sffe.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5B8A0DAEEA2700489809 /* sffe.c */; };
+ D99B5C060DAEEA2700489809 /* sffe_cmplx_asm.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5B8B0DAEEA2700489809 /* sffe_cmplx_asm.c */; };
+ D99B5C070DAEEA2700489809 /* sffe_cmplx_gsl.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5B8C0DAEEA2700489809 /* sffe_cmplx_gsl.c */; };
+ D99B5C160DAEEA2700489809 /* subwindow.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BC70DAEEA2700489809 /* subwindow.c */; };
+ D99B5C170DAEEA2700489809 /* palettef.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BC80DAEEA2700489809 /* palettef.c */; };
+ D99B5C180DAEEA2700489809 /* interlace.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BC90DAEEA2700489809 /* interlace.c */; };
+ D99B5C190DAEEA2700489809 /* edge2.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BCA0DAEEA2700489809 /* edge2.c */; };
+ D99B5C1A0DAEEA2700489809 /* fractal.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BCB0DAEEA2700489809 /* fractal.c */; };
+ D99B5C1B0DAEEA2700489809 /* rotate.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BCC0DAEEA2700489809 /* rotate.c */; };
+ D99B5C1C0DAEEA2700489809 /* itersmall.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BCD0DAEEA2700489809 /* itersmall.c */; };
+ D99B5C1D0DAEEA2700489809 /* blur.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BCE0DAEEA2700489809 /* blur.c */; };
+ D99B5C1E0DAEEA2700489809 /* anti.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BCF0DAEEA2700489809 /* anti.c */; };
+ D99B5C1F0DAEEA2700489809 /* stereogram.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BD00DAEEA2700489809 /* stereogram.c */; };
+ D99B5C200DAEEA2700489809 /* edge.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BD10DAEEA2700489809 /* edge.c */; };
+ D99B5C210DAEEA2700489809 /* zoom.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BD20DAEEA2700489809 /* zoom.c */; };
+ D99B5C220DAEEA2700489809 /* star.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BD30DAEEA2700489809 /* star.c */; };
+ D99B5C230DAEEA2700489809 /* formulas.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BD40DAEEA2700489809 /* formulas.c */; };
+ D99B5C240DAEEA2700489809 /* emboss.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BD50DAEEA2700489809 /* emboss.c */; };
+ D99B5C250DAEEA2700489809 /* julia.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BD60DAEEA2700489809 /* julia.c */; };
+ D99B5C260DAEEA2700489809 /* btrace.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BD70DAEEA2700489809 /* btrace.c */; };
+ D99B5C270DAEEA2700489809 /* i386.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BD80DAEEA2700489809 /* i386.c */; };
+ D99B5C280DAEEA2700489809 /* dither.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BD90DAEEA2700489809 /* dither.c */; };
+ D99B5C290DAEEA2700489809 /* 3d.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BDA0DAEEA2700489809 /* 3d.c */; };
+ D99B5C2A0DAEEA2700489809 /* plane.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BDB0DAEEA2700489809 /* plane.c */; };
+ D99B5C2B0DAEEA2700489809 /* filter.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BDD0DAEEA2700489809 /* filter.c */; };
+ D99B5C2C0DAEEA2700489809 /* palette.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BDE0DAEEA2700489809 /* palette.c */; };
+ D99B5C2D0DAEEA2700489809 /* random.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BDF0DAEEA2700489809 /* random.c */; };
+ D99B5C2F0DAEEA2700489809 /* font.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BE10DAEEA2700489809 /* font.c */; };
+ D99B5C300DAEEA2700489809 /* image.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BE20DAEEA2700489809 /* image.c */; };
+ D99B5C310DAEEA2700489809 /* drivers.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BE40DAEEA2700489809 /* drivers.c */; };
+ D99B5C320DAEEA2700489809 /* dialog.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BE50DAEEA2700489809 /* dialog.c */; };
+ D99B5C330DAEEA2700489809 /* uihelp.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BE60DAEEA2700489809 /* uihelp.c */; };
+ D99B5C340DAEEA2700489809 /* uimenu.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BE70DAEEA2700489809 /* uimenu.c */; };
+ D99B5C350DAEEA2700489809 /* fparams.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BE80DAEEA2700489809 /* fparams.c */; };
+ D99B5C360DAEEA2700489809 /* ui.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BE90DAEEA2700489809 /* ui.c */; };
+ D99B5C370DAEEA2700489809 /* param.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BEA0DAEEA2700489809 /* param.c */; };
+ D99B5C380DAEEA2700489809 /* filesel.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BEB0DAEEA2700489809 /* filesel.c */; };
+ D99B5C390DAEEA2700489809 /* pipecmd.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BEC0DAEEA2700489809 /* pipecmd.c */; };
+ D99B5C3A0DAEEA2700489809 /* save.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BEE0DAEEA2700489809 /* save.c */; };
+ D99B5C3B0DAEEA2700489809 /* menu.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BEF0DAEEA2700489809 /* menu.c */; };
+ D99B5C3C0DAEEA2700489809 /* wstack.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BF00DAEEA2700489809 /* wstack.c */; };
+ D99B5C3D0DAEEA2700489809 /* playtext.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BF10DAEEA2700489809 /* playtext.c */; };
+ D99B5C3E0DAEEA2700489809 /* render.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BF20DAEEA2700489809 /* render.c */; };
+ D99B5C3F0DAEEA2700489809 /* play.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BF30DAEEA2700489809 /* play.c */; };
+ D99B5C400DAEEA2700489809 /* messg.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BF40DAEEA2700489809 /* messg.c */; };
+ D99B5C410DAEEA2700489809 /* ui_helper.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BF50DAEEA2700489809 /* ui_helper.c */; };
+ D99B5C420DAEEA2700489809 /* autopilot.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BF60DAEEA2700489809 /* autopilot.c */; };
+ D99B5C430DAEEA2700489809 /* xmenu.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BF80DAEEA2700489809 /* xmenu.c */; };
+ D99B5C440DAEEA2700489809 /* png.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BF90DAEEA2700489809 /* png.c */; };
+ D99B5C450DAEEA2700489809 /* xstring.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BFA0DAEEA2700489809 /* xstring.c */; };
+ D99B5C460DAEEA2700489809 /* xshl.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BFB0DAEEA2700489809 /* xshl.c */; };
+ D99B5C470DAEEA2700489809 /* xldio.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BFC0DAEEA2700489809 /* xldio.c */; };
+ D99B5C480DAEEA2700489809 /* help.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BFD0DAEEA2700489809 /* help.c */; };
+ D99B5C490DAEEA2700489809 /* xerror.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BFE0DAEEA2700489809 /* xerror.c */; };
+ D99B5C4A0DAEEA2700489809 /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5BFF0DAEEA2700489809 /* thread.c */; };
+ D99B5C4B0DAEEA2700489809 /* timers.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5C000DAEEA2700489809 /* timers.c */; };
+ D99B5C4D0DAEEA2700489809 /* xstdio.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5C020DAEEA2700489809 /* xstdio.c */; };
+ D99B5C4E0DAEEA2700489809 /* catalog.c in Sources */ = {isa = PBXBuildFile; fileRef = D99B5C030DAEEA2700489809 /* catalog.c */; };
+ D99B5C500DAEEA6900489809 /* XaoS.icns in Resources */ = {isa = PBXBuildFile; fileRef = D99B5C4F0DAEEA6900489809 /* XaoS.icns */; };
+ D99B5E070DAEEB1200489809 /* XaoSHelp in Resources */ = {isa = PBXBuildFile; fileRef = D99B5D700DAEEB1200489809 /* XaoSHelp */; };
+ D99B5E0C0DAEEB4C00489809 /* libintl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D99B5E090DAEEB4C00489809 /* libintl.dylib */; };
+ D99B5E0D0DAEEB4C00489809 /* libgsl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D99B5E0A0DAEEB4C00489809 /* libgsl.dylib */; };
+ D99B5E0E0DAEEB4C00489809 /* libpng.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D99B5E0B0DAEEB4C00489809 /* libpng.dylib */; };
+ D99B5E1D0DAEEBD400489809 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D99B5E1C0DAEEBD400489809 /* Carbon.framework */; };
+ D99B5E200DAEEC0E00489809 /* libintl.dylib in Copy Embedded Frameworks and Libraries */ = {isa = PBXBuildFile; fileRef = D99B5E090DAEEB4C00489809 /* libintl.dylib */; };
+ D99B5E210DAEEC0E00489809 /* libgsl.dylib in Copy Embedded Frameworks and Libraries */ = {isa = PBXBuildFile; fileRef = D99B5E0A0DAEEB4C00489809 /* libgsl.dylib */; };
+ D99B5E220DAEEC0E00489809 /* libpng.dylib in Copy Embedded Frameworks and Libraries */ = {isa = PBXBuildFile; fileRef = D99B5E0B0DAEEB4C00489809 /* libpng.dylib */; };
+ D99B5E690DAEF3A400489809 /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = D99B5E670DAEF3A400489809 /* Credits.html */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ D99B5E1F0DAEEC0D00489809 /* Copy Embedded Frameworks and Libraries */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 10;
+ files = (
+ D99B5E200DAEEC0E00489809 /* libintl.dylib in Copy Embedded Frameworks and Libraries */,
+ D99B5E210DAEEC0E00489809 /* libgsl.dylib in Copy Embedded Frameworks and Libraries */,
+ D99B5E220DAEEC0E00489809 /* libpng.dylib in Copy Embedded Frameworks and Libraries */,
+ );
+ name = "Copy Embedded Frameworks and Libraries";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
+ 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
+ 29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = "<group>"; };
+ 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
+ 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
+ 32CA4F630368D1EE00C91783 /* XaoS_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XaoS_Prefix.pch; sourceTree = "<group>"; };
+ 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 8D1107320486CEB800E47090 /* XaoS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XaoS.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ D90A09550DB42FD900B7AAFD /* performanceCursor.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = performanceCursor.tiff; sourceTree = "<group>"; };
+ D90A09690DB4465100B7AAFD /* XaoSDocument.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = XaoSDocument.icns; sourceTree = "<group>"; };
+ D95DA721101FE23800826B31 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
+ D962B0AC101CA598003C66CE /* grlib_cocoa.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = grlib_cocoa.m; sourceTree = "<group>"; };
+ D962B20B101E9149003C66CE /* grlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = grlib.c; path = ../../../filter/grlib.c; sourceTree = SOURCE_ROOT; };
+ D99B5B710DAEE9D100489809 /* aconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aconfig.h; sourceTree = "<group>"; };
+ D99B5B720DAEE9D100489809 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
+ D99B5B730DAEE9D100489809 /* ui_cocoa.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ui_cocoa.m; sourceTree = "<group>"; };
+ D99B5B760DAEE9E700489809 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
+ D99B5B770DAEE9E700489809 /* AppController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppController.m; sourceTree = "<group>"; };
+ D99B5B780DAEE9E700489809 /* FractalView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FractalView.h; sourceTree = "<group>"; };
+ D99B5B790DAEE9E700489809 /* FractalView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FractalView.m; sourceTree = "<group>"; };
+ D99B5B7A0DAEE9E700489809 /* CustomDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomDialog.h; sourceTree = "<group>"; };
+ D99B5B7B0DAEE9E700489809 /* CustomDialog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomDialog.m; sourceTree = "<group>"; };
+ D99B5B7C0DAEE9E700489809 /* VideatorProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideatorProxy.h; sourceTree = "<group>"; };
+ D99B5B7D0DAEE9E700489809 /* VideatorProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideatorProxy.m; sourceTree = "<group>"; };
+ D99B5B820DAEEA0800489809 /* Readme Cocoa */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Readme Cocoa"; sourceTree = "<group>"; };
+ D99B5B830DAEEA0800489809 /* HowToBuild.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HowToBuild.txt; sourceTree = "<group>"; };
+ D99B5B890DAEEA2700489809 /* cmplx.asm */ = {isa = PBXFileReference; explicitFileType = sourcecode.nasm; fileEncoding = 4; path = cmplx.asm; sourceTree = "<group>"; };
+ D99B5B8A0DAEEA2700489809 /* sffe.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sffe.c; sourceTree = "<group>"; };
+ D99B5B8B0DAEEA2700489809 /* sffe_cmplx_asm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sffe_cmplx_asm.c; sourceTree = "<group>"; };
+ D99B5B8C0DAEEA2700489809 /* sffe_cmplx_gsl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sffe_cmplx_gsl.c; sourceTree = "<group>"; };
+ D99B5B8F0DAEEA2700489809 /* archaccel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = archaccel.h; sourceTree = "<group>"; };
+ D99B5B900DAEEA2700489809 /* btrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btrace.h; sourceTree = "<group>"; };
+ D99B5B910DAEEA2700489809 /* c256.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = c256.h; sourceTree = "<group>"; };
+ D99B5B920DAEEA2700489809 /* catalog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catalog.h; sourceTree = "<group>"; };
+ D99B5B930DAEEA2700489809 /* complex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = complex.h; sourceTree = "<group>"; };
+ D99B5BA10DAEEA2700489809 /* cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cursor.h; sourceTree = "<group>"; };
+ D99B5BA20DAEEA2700489809 /* fconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fconfig.h; sourceTree = "<group>"; };
+ D99B5BA30DAEEA2700489809 /* filter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filter.h; sourceTree = "<group>"; };
+ D99B5BA40DAEEA2700489809 /* formulas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = formulas.h; sourceTree = "<group>"; };
+ D99B5BA50DAEEA2700489809 /* fractal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fractal.h; sourceTree = "<group>"; };
+ D99B5BA60DAEEA2700489809 /* gccaccel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gccaccel.h; sourceTree = "<group>"; };
+ D99B5BA70DAEEA2700489809 /* gccbuild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gccbuild.h; sourceTree = "<group>"; };
+ D99B5BA80DAEEA2700489809 /* generic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = generic.h; sourceTree = "<group>"; };
+ D99B5BA90DAEEA2700489809 /* grlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = grlib.h; sourceTree = "<group>"; };
+ D99B5BAA0DAEEA2700489809 /* hicolor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hicolor.h; sourceTree = "<group>"; };
+ D99B5BAC0DAEEA2700489809 /* __math.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = __math.h; sourceTree = "<group>"; };
+ D99B5BAD0DAEEA2700489809 /* ctrl87.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ctrl87.h; sourceTree = "<group>"; };
+ D99B5BAE0DAEEA2700489809 /* sstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sstring.h; sourceTree = "<group>"; };
+ D99B5BB30DAEEA2700489809 /* misc-f.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "misc-f.h"; sourceTree = "<group>"; };
+ D99B5BB40DAEEA2700489809 /* param.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = param.h; sourceTree = "<group>"; };
+ D99B5BB50DAEEA2700489809 /* pixel_t.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pixel_t.h; sourceTree = "<group>"; };
+ D99B5BB60DAEEA2700489809 /* plane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = plane.h; sourceTree = "<group>"; };
+ D99B5BB80DAEEA2700489809 /* timers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = timers.h; sourceTree = "<group>"; };
+ D99B5BB90DAEEA2700489809 /* true24.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = true24.h; sourceTree = "<group>"; };
+ D99B5BBA0DAEEA2700489809 /* truecolor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = truecolor.h; sourceTree = "<group>"; };
+ D99B5BBB0DAEEA2700489809 /* ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ui.h; sourceTree = "<group>"; };
+ D99B5BBC0DAEEA2700489809 /* ui_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ui_helper.h; sourceTree = "<group>"; };
+ D99B5BBE0DAEEA2700489809 /* version.h.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = version.h.in; sourceTree = "<group>"; };
+ D99B5BBF0DAEEA2700489809 /* xerror.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xerror.h; sourceTree = "<group>"; };
+ D99B5BC00DAEEA2700489809 /* xio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xio.h; sourceTree = "<group>"; };
+ D99B5BC10DAEEA2700489809 /* xldio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xldio.h; sourceTree = "<group>"; };
+ D99B5BC20DAEEA2700489809 /* xmenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xmenu.h; sourceTree = "<group>"; };
+ D99B5BC30DAEEA2700489809 /* xshl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xshl.h; sourceTree = "<group>"; };
+ D99B5BC40DAEEA2700489809 /* xthread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xthread.h; sourceTree = "<group>"; };
+ D99B5BC50DAEEA2700489809 /* zoom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zoom.h; sourceTree = "<group>"; };
+ D99B5BC70DAEEA2700489809 /* subwindow.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = subwindow.c; path = ../../../engine/subwindow.c; sourceTree = SOURCE_ROOT; };
+ D99B5BC80DAEEA2700489809 /* palettef.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = palettef.c; path = ../../../engine/palettef.c; sourceTree = SOURCE_ROOT; };
+ D99B5BC90DAEEA2700489809 /* interlace.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = interlace.c; path = ../../../engine/interlace.c; sourceTree = SOURCE_ROOT; };
+ D99B5BCA0DAEEA2700489809 /* edge2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = edge2.c; path = ../../../engine/edge2.c; sourceTree = SOURCE_ROOT; };
+ D99B5BCB0DAEEA2700489809 /* fractal.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = fractal.c; path = ../../../engine/fractal.c; sourceTree = SOURCE_ROOT; };
+ D99B5BCC0DAEEA2700489809 /* rotate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rotate.c; path = ../../../engine/rotate.c; sourceTree = SOURCE_ROOT; };
+ D99B5BCD0DAEEA2700489809 /* itersmall.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = itersmall.c; path = ../../../engine/itersmall.c; sourceTree = SOURCE_ROOT; };
+ D99B5BCE0DAEEA2700489809 /* blur.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = blur.c; path = ../../../engine/blur.c; sourceTree = SOURCE_ROOT; };
+ D99B5BCF0DAEEA2700489809 /* anti.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = anti.c; path = ../../../engine/anti.c; sourceTree = SOURCE_ROOT; };
+ D99B5BD00DAEEA2700489809 /* stereogram.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = stereogram.c; path = ../../../engine/stereogram.c; sourceTree = SOURCE_ROOT; };
+ D99B5BD10DAEEA2700489809 /* edge.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = edge.c; path = ../../../engine/edge.c; sourceTree = SOURCE_ROOT; };
+ D99B5BD20DAEEA2700489809 /* zoom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = zoom.c; path = ../../../engine/zoom.c; sourceTree = SOURCE_ROOT; };
+ D99B5BD30DAEEA2700489809 /* star.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = star.c; path = ../../../engine/star.c; sourceTree = SOURCE_ROOT; };
+ D99B5BD40DAEEA2700489809 /* formulas.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = formulas.c; path = ../../../engine/formulas.c; sourceTree = SOURCE_ROOT; };
+ D99B5BD50DAEEA2700489809 /* emboss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = emboss.c; path = ../../../engine/emboss.c; sourceTree = SOURCE_ROOT; };
+ D99B5BD60DAEEA2700489809 /* julia.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = julia.c; path = ../../../engine/julia.c; sourceTree = SOURCE_ROOT; };
+ D99B5BD70DAEEA2700489809 /* btrace.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = btrace.c; path = ../../../engine/btrace.c; sourceTree = SOURCE_ROOT; };
+ D99B5BD80DAEEA2700489809 /* i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = i386.c; path = ../../../engine/i386.c; sourceTree = SOURCE_ROOT; };
+ D99B5BD90DAEEA2700489809 /* dither.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = dither.c; path = ../../../engine/dither.c; sourceTree = SOURCE_ROOT; };
+ D99B5BDA0DAEEA2700489809 /* 3d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = 3d.c; path = ../../../engine/3d.c; sourceTree = SOURCE_ROOT; };
+ D99B5BDB0DAEEA2700489809 /* plane.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = plane.c; path = ../../../engine/plane.c; sourceTree = SOURCE_ROOT; };
+ D99B5BDD0DAEEA2700489809 /* filter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = filter.c; path = ../../../filter/filter.c; sourceTree = SOURCE_ROOT; };
+ D99B5BDE0DAEEA2700489809 /* palette.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = palette.c; path = ../../../filter/palette.c; sourceTree = SOURCE_ROOT; };
+ D99B5BDF0DAEEA2700489809 /* random.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = random.c; path = ../../../filter/random.c; sourceTree = SOURCE_ROOT; };
+ D99B5BE10DAEEA2700489809 /* font.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = font.c; path = ../../../filter/font.c; sourceTree = SOURCE_ROOT; };
+ D99B5BE20DAEEA2700489809 /* image.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = image.c; path = ../../../filter/image.c; sourceTree = SOURCE_ROOT; };
+ D99B5BE40DAEEA2700489809 /* drivers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = drivers.c; path = ../../drivers.c; sourceTree = SOURCE_ROOT; };
+ D99B5BE50DAEEA2700489809 /* dialog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = dialog.c; path = ../../dialog.c; sourceTree = SOURCE_ROOT; };
+ D99B5BE60DAEEA2700489809 /* uihelp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = uihelp.c; path = ../../uihelp.c; sourceTree = SOURCE_ROOT; };
+ D99B5BE70DAEEA2700489809 /* uimenu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = uimenu.c; path = ../../uimenu.c; sourceTree = SOURCE_ROOT; };
+ D99B5BE80DAEEA2700489809 /* fparams.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = fparams.c; path = ../../fparams.c; sourceTree = SOURCE_ROOT; };
+ D99B5BE90DAEEA2700489809 /* ui.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ui.c; path = ../../ui.c; sourceTree = SOURCE_ROOT; };
+ D99B5BEA0DAEEA2700489809 /* param.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = param.c; path = ../../param.c; sourceTree = SOURCE_ROOT; };
+ D99B5BEB0DAEEA2700489809 /* filesel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = filesel.c; path = ../../filesel.c; sourceTree = SOURCE_ROOT; };
+ D99B5BEC0DAEEA2700489809 /* pipecmd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pipecmd.c; path = ../../pipecmd.c; sourceTree = SOURCE_ROOT; };
+ D99B5BEE0DAEEA2700489809 /* save.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = save.c; path = "../../../ui-hlp/save.c"; sourceTree = SOURCE_ROOT; };
+ D99B5BEF0DAEEA2700489809 /* menu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = menu.c; path = "../../../ui-hlp/menu.c"; sourceTree = SOURCE_ROOT; };
+ D99B5BF00DAEEA2700489809 /* wstack.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wstack.c; path = "../../../ui-hlp/wstack.c"; sourceTree = SOURCE_ROOT; };
+ D99B5BF10DAEEA2700489809 /* playtext.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = playtext.c; path = "../../../ui-hlp/playtext.c"; sourceTree = SOURCE_ROOT; };
+ D99B5BF20DAEEA2700489809 /* render.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = render.c; path = "../../../ui-hlp/render.c"; sourceTree = SOURCE_ROOT; };
+ D99B5BF30DAEEA2700489809 /* play.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = play.c; path = "../../../ui-hlp/play.c"; sourceTree = SOURCE_ROOT; };
+ D99B5BF40DAEEA2700489809 /* messg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = messg.c; path = "../../../ui-hlp/messg.c"; sourceTree = SOURCE_ROOT; };
+ D99B5BF50DAEEA2700489809 /* ui_helper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ui_helper.c; path = "../../../ui-hlp/ui_helper.c"; sourceTree = SOURCE_ROOT; };
+ D99B5BF60DAEEA2700489809 /* autopilot.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = autopilot.c; path = "../../../ui-hlp/autopilot.c"; sourceTree = SOURCE_ROOT; };
+ D99B5BF80DAEEA2700489809 /* xmenu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xmenu.c; path = ../../../util/xmenu.c; sourceTree = SOURCE_ROOT; };
+ D99B5BF90DAEEA2700489809 /* png.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = png.c; path = ../../../util/png.c; sourceTree = SOURCE_ROOT; };
+ D99B5BFA0DAEEA2700489809 /* xstring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xstring.c; path = ../../../util/xstring.c; sourceTree = SOURCE_ROOT; };
+ D99B5BFB0DAEEA2700489809 /* xshl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xshl.c; path = ../../../util/xshl.c; sourceTree = SOURCE_ROOT; };
+ D99B5BFC0DAEEA2700489809 /* xldio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xldio.c; path = ../../../util/xldio.c; sourceTree = SOURCE_ROOT; };
+ D99B5BFD0DAEEA2700489809 /* help.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = help.c; path = ../../../util/help.c; sourceTree = SOURCE_ROOT; };
+ D99B5BFE0DAEEA2700489809 /* xerror.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xerror.c; path = ../../../util/xerror.c; sourceTree = SOURCE_ROOT; };
+ D99B5BFF0DAEEA2700489809 /* thread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = thread.c; path = ../../../util/thread.c; sourceTree = SOURCE_ROOT; };
+ D99B5C000DAEEA2700489809 /* timers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = timers.c; path = ../../../util/timers.c; sourceTree = SOURCE_ROOT; };
+ D99B5C020DAEEA2700489809 /* xstdio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xstdio.c; path = ../../../util/xstdio.c; sourceTree = SOURCE_ROOT; };
+ D99B5C030DAEEA2700489809 /* catalog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = catalog.c; path = ../../../util/catalog.c; sourceTree = SOURCE_ROOT; };
+ D99B5C4F0DAEEA6900489809 /* XaoS.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = XaoS.icns; sourceTree = "<group>"; };
+ D99B5D700DAEEB1200489809 /* XaoSHelp */ = {isa = PBXFileReference; lastKnownFileType = folder; name = XaoSHelp; path = ../../../../help/XaoSHelp; sourceTree = SOURCE_ROOT; };
+ D99B5E090DAEEB4C00489809 /* libintl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libintl.dylib; sourceTree = "<group>"; };
+ D99B5E0A0DAEEB4C00489809 /* libgsl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libgsl.dylib; sourceTree = "<group>"; };
+ D99B5E0B0DAEEB4C00489809 /* libpng.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libpng.dylib; sourceTree = "<group>"; };
+ D99B5E1C0DAEEBD400489809 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
+ D99B5E680DAEF3A400489809 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = English; path = English.lproj/Credits.html; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 8D11072E0486CEB800E47090 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
+ D99B5E1D0DAEEBD400489809 /* Carbon.framework in Frameworks */,
+ D99B5E0C0DAEEB4C00489809 /* libintl.dylib in Frameworks */,
+ D99B5E0D0DAEEB4C00489809 /* libgsl.dylib in Frameworks */,
+ D99B5E0E0DAEEB4C00489809 /* libpng.dylib in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 080E96DDFE201D6D7F000001 /* Classes */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5B760DAEE9E700489809 /* AppController.h */,
+ D99B5B770DAEE9E700489809 /* AppController.m */,
+ D99B5B780DAEE9E700489809 /* FractalView.h */,
+ D99B5B790DAEE9E700489809 /* FractalView.m */,
+ D99B5B7A0DAEE9E700489809 /* CustomDialog.h */,
+ D99B5B7B0DAEE9E700489809 /* CustomDialog.m */,
+ D99B5B7C0DAEE9E700489809 /* VideatorProxy.h */,
+ D99B5B7D0DAEE9E700489809 /* VideatorProxy.m */,
+ );
+ name = Classes;
+ sourceTree = "<group>";
+ };
+ 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5E1C0DAEEBD400489809 /* Carbon.framework */,
+ 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
+ );
+ name = "Linked Frameworks";
+ sourceTree = "<group>";
+ };
+ 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 29B97324FDCFA39411CA2CEA /* AppKit.framework */,
+ 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */,
+ 29B97325FDCFA39411CA2CEA /* Foundation.framework */,
+ );
+ name = "Other Frameworks";
+ sourceTree = "<group>";
+ };
+ 19C28FACFE9D520D11CA2CBB /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 8D1107320486CEB800E47090 /* XaoS.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 29B97314FDCFA39411CA2CEA /* XaoS */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5B820DAEEA0800489809 /* Readme Cocoa */,
+ D99B5B830DAEEA0800489809 /* HowToBuild.txt */,
+ 080E96DDFE201D6D7F000001 /* Classes */,
+ 29B97315FDCFA39411CA2CEA /* Other Sources */,
+ D99B5B860DAEEA2700489809 /* Shared Sources */,
+ 29B97317FDCFA39411CA2CEA /* Resources */,
+ D99B5E080DAEEB2B00489809 /* Embedded Frameworks and Libraries */,
+ 29B97323FDCFA39411CA2CEA /* Frameworks */,
+ 19C28FACFE9D520D11CA2CBB /* Products */,
+ );
+ name = XaoS;
+ sourceTree = "<group>";
+ };
+ 29B97315FDCFA39411CA2CEA /* Other Sources */ = {
+ isa = PBXGroup;
+ children = (
+ 32CA4F630368D1EE00C91783 /* XaoS_Prefix.pch */,
+ D99B5B710DAEE9D100489809 /* aconfig.h */,
+ D99B5B720DAEE9D100489809 /* version.h */,
+ D99B5B730DAEE9D100489809 /* ui_cocoa.m */,
+ D962B0AC101CA598003C66CE /* grlib_cocoa.m */,
+ );
+ name = "Other Sources";
+ sourceTree = "<group>";
+ };
+ 29B97317FDCFA39411CA2CEA /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5E670DAEF3A400489809 /* Credits.html */,
+ 8D1107310486CEB800E47090 /* Info.plist */,
+ 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
+ 29B97318FDCFA39411CA2CEA /* MainMenu.nib */,
+ D99B5C4F0DAEEA6900489809 /* XaoS.icns */,
+ D90A09690DB4465100B7AAFD /* XaoSDocument.icns */,
+ D90A09550DB42FD900B7AAFD /* performanceCursor.tiff */,
+ D99B5D700DAEEB1200489809 /* XaoSHelp */,
+ );
+ name = Resources;
+ sourceTree = "<group>";
+ };
+ 29B97323FDCFA39411CA2CEA /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
+ 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ D99B5B860DAEEA2700489809 /* Shared Sources */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5BF70DAEEA2700489809 /* util */,
+ D99B5BED0DAEEA2700489809 /* ui-hlp */,
+ D99B5BE30DAEEA2700489809 /* ui */,
+ D99B5BDC0DAEEA2700489809 /* filter */,
+ D99B5BC60DAEEA2700489809 /* engine */,
+ D99B5B870DAEEA2700489809 /* sffe */,
+ D99B5B8D0DAEEA2700489809 /* include */,
+ );
+ name = "Shared Sources";
+ sourceTree = "<group>";
+ };
+ D99B5B870DAEEA2700489809 /* sffe */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5B880DAEEA2700489809 /* asm */,
+ D99B5B8A0DAEEA2700489809 /* sffe.c */,
+ D99B5B8B0DAEEA2700489809 /* sffe_cmplx_asm.c */,
+ D99B5B8C0DAEEA2700489809 /* sffe_cmplx_gsl.c */,
+ );
+ name = sffe;
+ path = ../../../sffe;
+ sourceTree = SOURCE_ROOT;
+ };
+ D99B5B880DAEEA2700489809 /* asm */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5B890DAEEA2700489809 /* cmplx.asm */,
+ );
+ path = asm;
+ sourceTree = "<group>";
+ };
+ D99B5B8D0DAEEA2700489809 /* include */ = {
+ isa = PBXGroup;
+ children = (
+ D95DA721101FE23800826B31 /* config.h */,
+ D99B5B8F0DAEEA2700489809 /* archaccel.h */,
+ D99B5B900DAEEA2700489809 /* btrace.h */,
+ D99B5B910DAEEA2700489809 /* c256.h */,
+ D99B5B920DAEEA2700489809 /* catalog.h */,
+ D99B5B930DAEEA2700489809 /* complex.h */,
+ D99B5BA10DAEEA2700489809 /* cursor.h */,
+ D99B5BA20DAEEA2700489809 /* fconfig.h */,
+ D99B5BA30DAEEA2700489809 /* filter.h */,
+ D99B5BA40DAEEA2700489809 /* formulas.h */,
+ D99B5BA50DAEEA2700489809 /* fractal.h */,
+ D99B5BA60DAEEA2700489809 /* gccaccel.h */,
+ D99B5BA70DAEEA2700489809 /* gccbuild.h */,
+ D99B5BA80DAEEA2700489809 /* generic.h */,
+ D99B5BA90DAEEA2700489809 /* grlib.h */,
+ D99B5BAA0DAEEA2700489809 /* hicolor.h */,
+ D99B5BAB0DAEEA2700489809 /* i386 */,
+ D99B5BB30DAEEA2700489809 /* misc-f.h */,
+ D99B5BB40DAEEA2700489809 /* param.h */,
+ D99B5BB50DAEEA2700489809 /* pixel_t.h */,
+ D99B5BB60DAEEA2700489809 /* plane.h */,
+ D99B5BB80DAEEA2700489809 /* timers.h */,
+ D99B5BB90DAEEA2700489809 /* true24.h */,
+ D99B5BBA0DAEEA2700489809 /* truecolor.h */,
+ D99B5BBB0DAEEA2700489809 /* ui.h */,
+ D99B5BBC0DAEEA2700489809 /* ui_helper.h */,
+ D99B5BBE0DAEEA2700489809 /* version.h.in */,
+ D99B5BBF0DAEEA2700489809 /* xerror.h */,
+ D99B5BC00DAEEA2700489809 /* xio.h */,
+ D99B5BC10DAEEA2700489809 /* xldio.h */,
+ D99B5BC20DAEEA2700489809 /* xmenu.h */,
+ D99B5BC30DAEEA2700489809 /* xshl.h */,
+ D99B5BC40DAEEA2700489809 /* xthread.h */,
+ D99B5BC50DAEEA2700489809 /* zoom.h */,
+ );
+ name = include;
+ path = ../../../include;
+ sourceTree = SOURCE_ROOT;
+ };
+ D99B5BAB0DAEEA2700489809 /* i386 */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5BAC0DAEEA2700489809 /* __math.h */,
+ D99B5BAD0DAEEA2700489809 /* ctrl87.h */,
+ D99B5BAE0DAEEA2700489809 /* sstring.h */,
+ );
+ path = i386;
+ sourceTree = "<group>";
+ };
+ D99B5BC60DAEEA2700489809 /* engine */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5BC70DAEEA2700489809 /* subwindow.c */,
+ D99B5BC80DAEEA2700489809 /* palettef.c */,
+ D99B5BC90DAEEA2700489809 /* interlace.c */,
+ D99B5BCA0DAEEA2700489809 /* edge2.c */,
+ D99B5BCB0DAEEA2700489809 /* fractal.c */,
+ D99B5BCC0DAEEA2700489809 /* rotate.c */,
+ D99B5BCD0DAEEA2700489809 /* itersmall.c */,
+ D99B5BCE0DAEEA2700489809 /* blur.c */,
+ D99B5BCF0DAEEA2700489809 /* anti.c */,
+ D99B5BD00DAEEA2700489809 /* stereogram.c */,
+ D99B5BD10DAEEA2700489809 /* edge.c */,
+ D99B5BD20DAEEA2700489809 /* zoom.c */,
+ D99B5BD30DAEEA2700489809 /* star.c */,
+ D99B5BD40DAEEA2700489809 /* formulas.c */,
+ D99B5BD50DAEEA2700489809 /* emboss.c */,
+ D99B5BD60DAEEA2700489809 /* julia.c */,
+ D99B5BD70DAEEA2700489809 /* btrace.c */,
+ D99B5BD80DAEEA2700489809 /* i386.c */,
+ D99B5BD90DAEEA2700489809 /* dither.c */,
+ D99B5BDA0DAEEA2700489809 /* 3d.c */,
+ D99B5BDB0DAEEA2700489809 /* plane.c */,
+ );
+ name = engine;
+ sourceTree = "<group>";
+ };
+ D99B5BDC0DAEEA2700489809 /* filter */ = {
+ isa = PBXGroup;
+ children = (
+ D962B20B101E9149003C66CE /* grlib.c */,
+ D99B5BDD0DAEEA2700489809 /* filter.c */,
+ D99B5BDE0DAEEA2700489809 /* palette.c */,
+ D99B5BDF0DAEEA2700489809 /* random.c */,
+ D99B5BE10DAEEA2700489809 /* font.c */,
+ D99B5BE20DAEEA2700489809 /* image.c */,
+ );
+ name = filter;
+ sourceTree = "<group>";
+ };
+ D99B5BE30DAEEA2700489809 /* ui */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5BE40DAEEA2700489809 /* drivers.c */,
+ D99B5BE50DAEEA2700489809 /* dialog.c */,
+ D99B5BE60DAEEA2700489809 /* uihelp.c */,
+ D99B5BE70DAEEA2700489809 /* uimenu.c */,
+ D99B5BE80DAEEA2700489809 /* fparams.c */,
+ D99B5BE90DAEEA2700489809 /* ui.c */,
+ D99B5BEA0DAEEA2700489809 /* param.c */,
+ D99B5BEB0DAEEA2700489809 /* filesel.c */,
+ D99B5BEC0DAEEA2700489809 /* pipecmd.c */,
+ );
+ name = ui;
+ sourceTree = "<group>";
+ };
+ D99B5BED0DAEEA2700489809 /* ui-hlp */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5BEE0DAEEA2700489809 /* save.c */,
+ D99B5BEF0DAEEA2700489809 /* menu.c */,
+ D99B5BF00DAEEA2700489809 /* wstack.c */,
+ D99B5BF10DAEEA2700489809 /* playtext.c */,
+ D99B5BF20DAEEA2700489809 /* render.c */,
+ D99B5BF30DAEEA2700489809 /* play.c */,
+ D99B5BF40DAEEA2700489809 /* messg.c */,
+ D99B5BF50DAEEA2700489809 /* ui_helper.c */,
+ D99B5BF60DAEEA2700489809 /* autopilot.c */,
+ );
+ name = "ui-hlp";
+ sourceTree = "<group>";
+ };
+ D99B5BF70DAEEA2700489809 /* util */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5BF80DAEEA2700489809 /* xmenu.c */,
+ D99B5BF90DAEEA2700489809 /* png.c */,
+ D99B5BFA0DAEEA2700489809 /* xstring.c */,
+ D99B5BFB0DAEEA2700489809 /* xshl.c */,
+ D99B5BFC0DAEEA2700489809 /* xldio.c */,
+ D99B5BFD0DAEEA2700489809 /* help.c */,
+ D99B5BFE0DAEEA2700489809 /* xerror.c */,
+ D99B5BFF0DAEEA2700489809 /* thread.c */,
+ D99B5C000DAEEA2700489809 /* timers.c */,
+ D99B5C020DAEEA2700489809 /* xstdio.c */,
+ D99B5C030DAEEA2700489809 /* catalog.c */,
+ );
+ name = util;
+ sourceTree = "<group>";
+ };
+ D99B5E080DAEEB2B00489809 /* Embedded Frameworks and Libraries */ = {
+ isa = PBXGroup;
+ children = (
+ D99B5E090DAEEB4C00489809 /* libintl.dylib */,
+ D99B5E0A0DAEEB4C00489809 /* libgsl.dylib */,
+ D99B5E0B0DAEEB4C00489809 /* libpng.dylib */,
+ );
+ name = "Embedded Frameworks and Libraries";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 8D1107260486CEB800E47090 /* XaoS */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "XaoS" */;
+ buildPhases = (
+ D99B5E110DAEEB6800489809 /* Pre-Compile Script */,
+ 8D1107290486CEB800E47090 /* Resources */,
+ 8D11072C0486CEB800E47090 /* Sources */,
+ 8D11072E0486CEB800E47090 /* Frameworks */,
+ D99B5E1F0DAEEC0D00489809 /* Copy Embedded Frameworks and Libraries */,
+ D99B5E240DAEEC2200489809 /* Post-Compile Script */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = XaoS;
+ productInstallPath = "$(HOME)/Applications";
+ productName = XaoS;
+ productReference = 8D1107320486CEB800E47090 /* XaoS.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 29B97313FDCFA39411CA2CEA /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "XaoS" */;
+ compatibilityVersion = "Xcode 3.0";
+ hasScannedForEncodings = 1;
+ mainGroup = 29B97314FDCFA39411CA2CEA /* XaoS */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 8D1107260486CEB800E47090 /* XaoS */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 8D1107290486CEB800E47090 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */,
+ 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
+ D99B5C500DAEEA6900489809 /* XaoS.icns in Resources */,
+ D99B5E070DAEEB1200489809 /* XaoSHelp in Resources */,
+ D99B5E690DAEF3A400489809 /* Credits.html in Resources */,
+ D90A09560DB42FD900B7AAFD /* performanceCursor.tiff in Resources */,
+ D90A096A0DB4465100B7AAFD /* XaoSDocument.icns in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ D99B5E110DAEEB6800489809 /* Pre-Compile Script */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Pre-Compile Script";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "# create config.h from config.autoconf (normally done by makefile)\nif [ $PROJECT_DIR/../../../include/config/config.autoconf -nt $PROJECT_DIR/../../../include/config.h ]; then\n\tln -sf $PROJECT_DIR/../../../include/config/config.autoconf $PROJECT_DIR/../../../include/config.h\nfi\n\n# change libraries to use executable-relative paths\nif [ $PROJECT_DIR/thirdparty/lib/libpng.dylib -nt $PROJECT_DIR/libpng.dylib ]; then\n\tcp $PROJECT_DIR/thirdparty/lib/libpng.dylib $PROJECT_DIR/libpng.dylib\n\tinstall_name_tool -id @executable_path/../Frameworks/libpng.dylib $PROJECT_DIR/libpng.dylib\nfi\n\nif [ $PROJECT_DIR/thirdparty/lib/libgsl.dylib -nt $PROJECT_DIR/libgsl.dylib ]; then\n\tcp $PROJECT_DIR/thirdparty/lib/libgsl.dylib $PROJECT_DIR/libgsl.dylib\n\tinstall_name_tool -id @executable_path/../Frameworks/libgsl.dylib $PROJECT_DIR/libgsl.dylib\nfi\n\nif [ $PROJECT_DIR/thirdparty/lib/libintl.dylib -nt $PROJECT_DIR/libintl.dylib ]; then\n\tcp $PROJECT_DIR/thirdparty/lib/libintl.dylib $PROJECT_DIR/libintl.dylib\n\tinstall_name_tool -id @executable_path/../Frameworks/libintl.dylib $PROJECT_DIR/libintl.dylib\nfi\n\n# build apple help\nif [ $PROJECT_DIR/../../../../help/xaos.hlp -nt $PROJECT_DIR/../../../../help/XaoSHelp ]; then\n\tcd $PROJECT_DIR/../../../../help\n\t./applehelpconv\n\tcd $PROJECT_DIR\nfi\n\n";
+ };
+ D99B5E240DAEEC2200489809 /* Post-Compile Script */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Post-Compile Script";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "# Make resource subdirectories\nmkdir $BUILT_PRODUCTS_DIR/XaoS.app/Contents/Resources/tutorial\nmkdir $BUILT_PRODUCTS_DIR/XaoS.app/Contents/Resources/examples\nmkdir $BUILT_PRODUCTS_DIR/XaoS.app/Contents/Resources/catalogs\nmkdir $BUILT_PRODUCTS_DIR/XaoS.app/Contents/Resources/help\nmkdir $BUILT_PRODUCTS_DIR/XaoS.app/Contents/Resources/locale\n\n# Copy resources from project source directories\ncp $PROJECT_DIR/../../../../tutorial/*.x[ah]f $BUILT_PRODUCTS_DIR/XaoS.app/Contents/Resources/tutorial\ncp $PROJECT_DIR/../../../../examples/*/*.x[ap]f $BUILT_PRODUCTS_DIR/XaoS.app/Contents/Resources/examples\ncp $PROJECT_DIR/../../../../catalogs/*.cat $BUILT_PRODUCTS_DIR/XaoS.app/Contents/Resources/catalogs\ncp $PROJECT_DIR/../../../../help/xaos.hlp $BUILT_PRODUCTS_DIR/XaoS.app/Contents/Resources/help\n\n# Build message catalogs and copy to app bundle\ncd $PROJECT_DIR/../../../i18n\nlocaledir=$BUILT_PRODUCTS_DIR/XaoS.app/Contents/Resources/locale\npofiles=`ls *.po`\nmsgfmt=$PROJECT_DIR/thirdparty/bin/msgfmt\nfor pofile in $pofiles; do\n\tlang=`basename $pofile .po`\n\tmofile=${lang}.mo\n\tif [ $pofile -nt $mofile ]; then\n\t\t$msgfmt -o $mofile -c -v --statistics $pofile\n\tfi\n\tmkdir -p $localedir/$lang/LC_MESSAGES\n\tcp $mofile $localedir/$lang/LC_MESSAGES/xaos.mo\ndone\ncd $PROJECT_DIR";
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 8D11072C0486CEB800E47090 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D99B5B740DAEE9D100489809 /* ui_cocoa.m in Sources */,
+ D99B5B7E0DAEE9E700489809 /* AppController.m in Sources */,
+ D99B5B7F0DAEE9E700489809 /* FractalView.m in Sources */,
+ D99B5B800DAEE9E700489809 /* CustomDialog.m in Sources */,
+ D99B5B810DAEE9E700489809 /* VideatorProxy.m in Sources */,
+ D99B5C040DAEEA2700489809 /* cmplx.asm in Sources */,
+ D99B5C050DAEEA2700489809 /* sffe.c in Sources */,
+ D99B5C060DAEEA2700489809 /* sffe_cmplx_asm.c in Sources */,
+ D99B5C070DAEEA2700489809 /* sffe_cmplx_gsl.c in Sources */,
+ D99B5C160DAEEA2700489809 /* subwindow.c in Sources */,
+ D99B5C170DAEEA2700489809 /* palettef.c in Sources */,
+ D99B5C180DAEEA2700489809 /* interlace.c in Sources */,
+ D99B5C190DAEEA2700489809 /* edge2.c in Sources */,
+ D99B5C1A0DAEEA2700489809 /* fractal.c in Sources */,
+ D99B5C1B0DAEEA2700489809 /* rotate.c in Sources */,
+ D99B5C1C0DAEEA2700489809 /* itersmall.c in Sources */,
+ D99B5C1D0DAEEA2700489809 /* blur.c in Sources */,
+ D99B5C1E0DAEEA2700489809 /* anti.c in Sources */,
+ D99B5C1F0DAEEA2700489809 /* stereogram.c in Sources */,
+ D99B5C200DAEEA2700489809 /* edge.c in Sources */,
+ D99B5C210DAEEA2700489809 /* zoom.c in Sources */,
+ D99B5C220DAEEA2700489809 /* star.c in Sources */,
+ D99B5C230DAEEA2700489809 /* formulas.c in Sources */,
+ D99B5C240DAEEA2700489809 /* emboss.c in Sources */,
+ D99B5C250DAEEA2700489809 /* julia.c in Sources */,
+ D99B5C260DAEEA2700489809 /* btrace.c in Sources */,
+ D99B5C270DAEEA2700489809 /* i386.c in Sources */,
+ D99B5C280DAEEA2700489809 /* dither.c in Sources */,
+ D99B5C290DAEEA2700489809 /* 3d.c in Sources */,
+ D99B5C2A0DAEEA2700489809 /* plane.c in Sources */,
+ D99B5C2B0DAEEA2700489809 /* filter.c in Sources */,
+ D99B5C2C0DAEEA2700489809 /* palette.c in Sources */,
+ D99B5C2D0DAEEA2700489809 /* random.c in Sources */,
+ D99B5C2F0DAEEA2700489809 /* font.c in Sources */,
+ D99B5C300DAEEA2700489809 /* image.c in Sources */,
+ D99B5C310DAEEA2700489809 /* drivers.c in Sources */,
+ D99B5C320DAEEA2700489809 /* dialog.c in Sources */,
+ D99B5C330DAEEA2700489809 /* uihelp.c in Sources */,
+ D99B5C340DAEEA2700489809 /* uimenu.c in Sources */,
+ D99B5C350DAEEA2700489809 /* fparams.c in Sources */,
+ D99B5C360DAEEA2700489809 /* ui.c in Sources */,
+ D99B5C370DAEEA2700489809 /* param.c in Sources */,
+ D99B5C380DAEEA2700489809 /* filesel.c in Sources */,
+ D99B5C390DAEEA2700489809 /* pipecmd.c in Sources */,
+ D99B5C3A0DAEEA2700489809 /* save.c in Sources */,
+ D99B5C3B0DAEEA2700489809 /* menu.c in Sources */,
+ D99B5C3C0DAEEA2700489809 /* wstack.c in Sources */,
+ D99B5C3D0DAEEA2700489809 /* playtext.c in Sources */,
+ D99B5C3E0DAEEA2700489809 /* render.c in Sources */,
+ D99B5C3F0DAEEA2700489809 /* play.c in Sources */,
+ D99B5C400DAEEA2700489809 /* messg.c in Sources */,
+ D99B5C410DAEEA2700489809 /* ui_helper.c in Sources */,
+ D99B5C420DAEEA2700489809 /* autopilot.c in Sources */,
+ D99B5C430DAEEA2700489809 /* xmenu.c in Sources */,
+ D99B5C440DAEEA2700489809 /* png.c in Sources */,
+ D99B5C450DAEEA2700489809 /* xstring.c in Sources */,
+ D99B5C460DAEEA2700489809 /* xshl.c in Sources */,
+ D99B5C470DAEEA2700489809 /* xldio.c in Sources */,
+ D99B5C480DAEEA2700489809 /* help.c in Sources */,
+ D99B5C490DAEEA2700489809 /* xerror.c in Sources */,
+ D99B5C4A0DAEEA2700489809 /* thread.c in Sources */,
+ D99B5C4B0DAEEA2700489809 /* timers.c in Sources */,
+ D99B5C4D0DAEEA2700489809 /* xstdio.c in Sources */,
+ D99B5C4E0DAEEA2700489809 /* catalog.c in Sources */,
+ D962B0AD101CA598003C66CE /* grlib_cocoa.m in Sources */,
+ D962B20C101E9149003C66CE /* grlib.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 089C165DFE840E0CC02AAC07 /* English */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ 29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 29B97319FDCFA39411CA2CEA /* English */,
+ );
+ name = MainMenu.nib;
+ sourceTree = "<group>";
+ };
+ D99B5E670DAEF3A400489809 /* Credits.html */ = {
+ isa = PBXVariantGroup;
+ children = (
+ D99B5E680DAEF3A400489809 /* English */,
+ );
+ name = Credits.html;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ C01FCF4B08A954540054247B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = XaoS_Prefix.pch;
+ INFOPLIST_FILE = Info.plist;
+ INSTALL_PATH = "$(HOME)/Applications";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ "\"$(SRCROOT)/thirdparty/lib\"",
+ );
+ PRODUCT_NAME = XaoS;
+ WRAPPER_EXTENSION = app;
+ ZERO_LINK = YES;
+ };
+ name = Debug;
+ };
+ C01FCF4C08A954540054247B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = XaoS_Prefix.pch;
+ INFOPLIST_FILE = Info.plist;
+ INSTALL_PATH = "$(HOME)/Applications";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ "\"$(SRCROOT)/thirdparty/lib\"",
+ );
+ PRODUCT_NAME = XaoS;
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+ C01FCF4F08A954540054247B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = ./thirdparty/include;
+ OTHER_LDFLAGS = "-liconv";
+ PREBINDING = NO;
+ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk";
+ USER_HEADER_SEARCH_PATHS = ../../../include;
+ };
+ name = Debug;
+ };
+ C01FCF5008A954540054247B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = (
+ ppc,
+ i386,
+ );
+ GCC_FAST_MATH = YES;
+ GCC_OPTIMIZATION_LEVEL = 3;
+ GCC_UNROLL_LOOPS = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = ./thirdparty/include;
+ OTHER_CFLAGS = "";
+ OTHER_LDFLAGS = "-liconv";
+ PREBINDING = NO;
+ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk";
+ USER_HEADER_SEARCH_PATHS = ../../../include;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "XaoS" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ C01FCF4B08A954540054247B /* Debug */,
+ C01FCF4C08A954540054247B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ C01FCF4E08A954540054247B /* Build configuration list for PBXProject "XaoS" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ C01FCF4F08A954540054247B /* Debug */,
+ C01FCF5008A954540054247B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
+}
diff --git a/src/ui/ui-drv/cocoa/XaoSDocument.icns b/src/ui/ui-drv/cocoa/XaoSDocument.icns
new file mode 100644
index 0000000..a827ad7
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/XaoSDocument.icns
Binary files differ
diff --git a/src/ui/ui-drv/cocoa/XaoS_Prefix.pch b/src/ui/ui-drv/cocoa/XaoS_Prefix.pch
new file mode 100644
index 0000000..b52a674
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/XaoS_Prefix.pch
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'XaoS' target in the 'XaoS' project
+//
+
+#ifdef __OBJC__
+ #import <Cocoa/Cocoa.h>
+#endif
diff --git a/src/ui/ui-drv/cocoa/aconfig.h b/src/ui/ui-drv/cocoa/aconfig.h
new file mode 100644
index 0000000..d6127b6
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/aconfig.h
@@ -0,0 +1,123 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * Cocoa Driver by J.B. Langston III (jb-langston@austin.rr.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.
+ */
+#ifndef ACONFIG_H
+#define ACONFIG_H
+/* #undef HAVE_PTHREAD_SIGHANDLER */
+
+
+//#define DEBUG
+#define VIDEATOR_SUPPORT
+
+/* Triggers Mac OS X-specific behavior in common sources */
+#define MACOSX
+
+/* Cocoa driver needs to do some pre-initialization in its own main function */
+#define MAIN_FUNCTION XaoS_main
+
+/* XaoS xio library uses \01 to indicate paths relative to the executable */
+#define DATAPATH "\01/../Resources"
+#define USE_LOCALEPATH 1
+
+/* Using alloca causes stack overflows on large images */
+/* #undef C_ALLOCA */
+/* #define HAVE_ALLOCA 1 */
+/* #define HAVE_ALLOCA_H 1 */
+
+/* #undef const */
+#define USE_PTHREAD 1
+
+#define HAVE_FABSL 1
+/* #undef HAVE__FABSL */
+/* #undef HAVE___FABSL */
+#define HAVE_FTIME 1
+#define USE_PNG 1
+#define HAVE_FINITE 1
+#define HAVE_SELECT 1
+
+/* Long double is too slow on PowerPC; only enable for i386 build */
+#ifdef __i386__
+#define HAVE_LONG_DOUBLE 1
+#endif
+
+/* #undef HAVE_REDRAWWIN */
+/* #undef HAVE_WREDRAWLN */
+#define USE_NCURSES 1
+/* #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 */
+#define HAVE_SETITIMER 1
+/* 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
+/* #define MITSHM 1 */
+/* #undef CURSES_DRIVER */
+/* #undef BEOS_DRIVER */
+/* #undef AA_DRIVER */
+/* #undef GGI_DRIVER */
+/* #undef X11_DRIVER */
+/* #undef DGA_DRIVER */
+/* #undef SVGA_DRIVER */
+/* #undef WIN32_DRIVER */
+/* #undef DDRAW_DRIVER */
+/* #undef OSX_DRIVER */
+#define COCOA_DRIVER 1
+#define SIZEOF_SHORT 2
+#define SIZEOF_INT 4
+#define SIZEOF_LONG 4
+#define HAVE_GETTEXT 1
+#define NO_MALLOC_H 1
+
+/* Enable SFFE; use ASM for i386 and GSL for PowerPC */
+#define SFFE_USING 1
+#ifdef __i386__
+#define SFFE_CMPLX_ASM 1
+#else
+#define SFFE_CMPLX_GSL 1
+#endif
+
+/* Define colors based on hardware endianness */
+#if __BIG_ENDIAN__
+#define RMASK 0xff000000
+#define GMASK 0x00ff0000
+#define BMASK 0x0000ff00
+#else
+#define RMASK 0x000000ff
+#define GMASK 0x0000ff00
+#define BMASK 0x00ff0000
+#endif
+
+/* Use platform-provided text rendering instead of built-in */
+#define PLATFORM_TEXT_RENDERING 1
+
+
+#endif
diff --git a/src/ui/ui-drv/cocoa/grlib_cocoa.m b/src/ui/ui-drv/cocoa/grlib_cocoa.m
new file mode 100644
index 0000000..3fedb0c
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/grlib_cocoa.m
@@ -0,0 +1,142 @@
+#include <config.h>
+#ifdef PLATFORM_TEXT_RENDERING
+
+#import <Cocoa/Cocoa.h>
+
+#include <fconfig.h>
+#include <filter.h>
+#include <fractal.h>
+#include <ui_helper.h>
+#include <grlib.h>
+
+NSMutableDictionary *textAttributes(int fgcolor, int bgcolor) {
+
+ float red, green, blue;
+
+ NSMutableDictionary *attrsDictionary = [NSMutableDictionary
+ dictionaryWithCapacity:5];
+
+ [attrsDictionary setValue:[NSColor whiteColor]
+ forKey:NSForegroundColorAttributeName];
+
+ [attrsDictionary setValue:[NSFont
+ boldSystemFontOfSize:[NSFont systemFontSize]]
+ forKey:NSFontAttributeName];
+
+ //NSLog(@"%x", fgcolor);
+ red = (fgcolor & RMASK) / 255.0;
+ green = (fgcolor & GMASK) / 255.0;
+ blue = (fgcolor & BMASK) / 255.0;
+ [attrsDictionary setValue:[NSColor colorWithDeviceRed:red
+ green:green
+ blue:blue
+ alpha:1.0]
+ forKey:NSForegroundColorAttributeName];
+
+ red = (bgcolor & RMASK) / 255.0;
+ green = (bgcolor & GMASK) / 255.0;
+ blue = (bgcolor & BMASK) / 255.0;
+ NSShadow *textShadow = [[NSShadow alloc] init];
+ [textShadow setShadowColor:[NSColor colorWithDeviceRed:red
+ green:green
+ blue:blue
+ alpha:1.0]];
+ [textShadow setShadowOffset:NSMakeSize(2, -2)];
+ [textShadow setShadowBlurRadius:1];
+
+ [attrsDictionary setValue:textShadow forKey:NSShadowAttributeName];
+ [textShadow autorelease];
+
+ return attrsDictionary;
+}
+
+
+int
+xprint(struct image *image, CONST struct xfont *current, int x, int y,
+ CONST char *text, int fgcolor, int bgcolor, int mode)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc]
+ initWithBitmapDataPlanes:image->currlines
+ pixelsWide:image->width
+ pixelsHigh:image->height
+ bitsPerSample:8
+ samplesPerPixel:3
+ hasAlpha:NO
+ isPlanar:NO
+ colorSpaceName:NSDeviceRGBColorSpace
+ bytesPerRow:0
+ bitsPerPixel:32];
+
+ [NSGraphicsContext saveGraphicsState];
+ NSGraphicsContext *context = [NSGraphicsContext
+ graphicsContextWithBitmapImageRep:imageRep];
+ [NSGraphicsContext setCurrentContext:context];
+
+ NSString *messageText = [[[NSString stringWithUTF8String:text]
+ componentsSeparatedByString:@"\n"]
+ objectAtIndex:0];
+ //NSLog(messageText);
+
+ NSMutableDictionary *attrsDictionary = textAttributes(fgcolor, bgcolor);
+
+ NSSize textSize = [messageText sizeWithAttributes:attrsDictionary];
+ [messageText drawAtPoint:NSMakePoint(x, image->height - y - textSize.height)
+ withAttributes:attrsDictionary];
+
+ [NSGraphicsContext restoreGraphicsState];
+
+ /*
+ * The calling functions expect the return value to be the number of
+ * bytes in the string, not the number of characters (this is not always
+ * equal for UTF-8 strings). Therefore, we don't use [messageText length].
+ */
+ int bytesUsed = [messageText
+ lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
+
+ [imageRep release];
+ [pool release];
+
+ return bytesUsed;
+}
+
+int xtextwidth(CONST struct xfont *font, CONST char *text)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSString *messageText = [[[NSString stringWithUTF8String:text]
+ componentsSeparatedByString:@"\n"]
+ objectAtIndex:0];
+
+ NSMutableDictionary *attrsDictionary = textAttributes(0, 0);
+
+ NSSize textSize = [messageText sizeWithAttributes:attrsDictionary];
+
+ [pool release];
+ return ceil(textSize.width) + 2;
+}
+
+int xtextheight(CONST struct xfont *font) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSString *messageText = @"Test String";
+
+ NSMutableDictionary *attrsDictionary = textAttributes(0, 0);
+ NSSize textSize = [messageText sizeWithAttributes:attrsDictionary];
+ [pool release];
+ return ceil(textSize.height) + 2;
+}
+
+int xtextcharw(CONST struct xfont *font, CONST char c)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSString *messageText = [NSString stringWithFormat:@"%c", c];
+
+ NSMutableDictionary *attrsDictionary = textAttributes(0, 0);
+ NSSize textSize = [messageText sizeWithAttributes:attrsDictionary];
+ [pool release];
+ return ceil(textSize.width) + 2;
+}
+#endif \ No newline at end of file
diff --git a/src/ui/ui-drv/cocoa/performanceCursor.tiff b/src/ui/ui-drv/cocoa/performanceCursor.tiff
new file mode 100644
index 0000000..fe7faf4
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/performanceCursor.tiff
Binary files differ
diff --git a/src/ui/ui-drv/cocoa/ui_cocoa.m b/src/ui/ui-drv/cocoa/ui_cocoa.m
new file mode 100644
index 0000000..0e107dc
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/ui_cocoa.m
@@ -0,0 +1,267 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 by
+ *
+ * Jan Hubicka (hubicka@paru.cas.cz)
+ * Thomas Marsh (tmarsh@austin.ibm.com)
+ *
+ * Cocoa Driver by J.B. Langston III (jb-langston@austin.rr.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.
+ */
+#import "AppController.h"
+
+#include "ui.h"
+
+struct ui_driver cocoa_driver, cocoa_fullscreen_driver;
+
+#ifdef USE_LOCALEPATH
+char *localepath;
+#endif
+
+static void
+cocoa_printText(int x, int y, CONST char *text)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [[controller view] printText:text atX:x y:y];
+ [pool release];
+}
+
+static void
+cocoa_refreshDisplay()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [[controller view] display];
+ [pool release];
+}
+
+static void
+cocoa_flipBuffers ()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [[controller view] flipBuffers];
+ [pool release];
+}
+
+static void
+cocoa_freeBuffers (char *b1, char *b2)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [[controller view] freeBuffers];
+ [pool release];
+}
+
+static int
+cocoa_allocBuffers (char **b1, char **b2)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ int rowLength = [[controller view] allocBuffer1:b1 buffer2:b2];
+ [pool release];
+ return rowLength;
+}
+
+static void
+cocoa_getImageSize (int *w, int *h)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [[controller view] getWidth:w height:h];
+ [pool release];
+}
+
+static void
+cocoa_processEvents (int wait, int *mx, int *my, int *mb, int *k)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ //NSDate *eventDate = wait ? [NSDate distantFuture] : [NSDate distantPast];
+ NSEvent *event = [NSApp nextEventMatchingMask: NSAnyEventMask
+ untilDate: nil //eventDate
+ inMode: NSDefaultRunLoopMode
+ dequeue: YES];
+ if (event != nil) {
+ [NSApp sendEvent: event];
+ }
+ [[controller view] getMouseX:mx mouseY:my mouseButton:mb keys:k];
+ [pool release];
+}
+
+
+static int
+cocoa_initDriver ()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ int status = [controller initDriver:&cocoa_driver fullscreen:NO];
+ [pool release];
+ return status;
+}
+
+static int
+cocoa_initFullScreenDriver ()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ int status = [controller initDriver:&cocoa_fullscreen_driver fullscreen:YES];
+ [pool release];
+ return status;
+}
+
+static void
+cocoa_uninitDriver ()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [controller uninitDriver];
+ [pool release];
+}
+
+static void
+cocoa_getMouse (int *x, int *y, int *b)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [[controller view] getMouseX:x mouseY:y mouseButton:b];
+ [pool release];
+}
+
+
+static void
+cocoa_setCursorType (int type)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [[controller view] setCursorType:type];
+ [pool release];
+}
+
+static void
+cocoa_buildMenu (struct uih_context *uih, CONST char *name)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [controller buildMenuWithContext:uih name:name];
+ [pool release];
+}
+
+static void
+cocoa_showPopUpMenu (struct uih_context *c, CONST char *name)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [controller showPopUpMenuWithContext:c name:name];
+ [pool release];
+}
+
+
+static void
+cocoa_showDialog (struct uih_context *c, CONST char *name)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [controller showDialogWithContext:c name:name];
+ [pool release];
+}
+
+static void
+cocoa_showHelp (struct uih_context *c, CONST char *name)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [controller showHelpWithContext:c name:name];
+ [pool release];
+}
+
+int
+main(int argc, char* argv[])
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ [NSApplication sharedApplication];
+ [NSBundle loadNibNamed:@"MainMenu" owner:NSApp];
+ controller = [[AppController alloc] init];
+ [pool release];
+ return MAIN_FUNCTION(argc, argv);
+}
+
+struct gui_driver cocoa_gui_driver = {
+/* setrootmenu */ cocoa_buildMenu,
+/* enabledisable */ NULL,
+/* menu */ cocoa_showPopUpMenu,
+/* dialog */ cocoa_showDialog,
+/* help */ cocoa_showHelp
+};
+
+
+static struct params cocoa_params[] = {
+{NULL, 0, NULL, NULL}
+};
+
+struct ui_driver cocoa_driver = {
+/* name */ "Mac OS X Windowed Driver",
+/* init */ cocoa_initDriver,
+/* getsize */ cocoa_getImageSize,
+/* processevents */ cocoa_processEvents,
+/* getmouse */ cocoa_getMouse,
+/* uninit */ cocoa_uninitDriver,
+/* set_color */ NULL,
+/* set_range */ NULL,
+/* print */ cocoa_printText,
+/* display */ cocoa_refreshDisplay,
+/* alloc_buffers */ cocoa_allocBuffers,
+/* free_buffers */ cocoa_freeBuffers,
+/* filp_buffers */ cocoa_flipBuffers,
+/* mousetype */ cocoa_setCursorType,
+/* flush */ NULL,
+/* textwidth */ 12,
+/* textheight */ 12,
+/* params */ cocoa_params,
+/* flags */ PIXELSIZE,
+/* width */ 0.0,
+/* height */ 0.0,
+/* maxwidth */ 0,
+/* maxheight */ 0,
+/* imagetype */ UI_TRUECOLOR,
+/* palettestart */ 0,
+/* paletteend */ 256,
+/* maxentries */ 255,
+/* rmask */ RMASK,
+/* gmask */ GMASK,
+/* bmask */ BMASK,
+/* gui_driver */ &cocoa_gui_driver
+};
+
+struct ui_driver cocoa_fullscreen_driver = {
+/* name */ "Mac OS X Full Screen Driver",
+/* init */ cocoa_initFullScreenDriver,
+/* getsize */ cocoa_getImageSize,
+/* processevents */ cocoa_processEvents,
+/* getmouse */ cocoa_getMouse,
+/* uninit */ cocoa_uninitDriver,
+/* set_color */ NULL,
+/* set_range */ NULL,
+/* print */ cocoa_printText,
+/* display */ cocoa_refreshDisplay,
+/* alloc_buffers */ cocoa_allocBuffers,
+/* free_buffers */ cocoa_freeBuffers,
+/* filp_buffers */ cocoa_flipBuffers,
+/* mousetype */ cocoa_setCursorType,
+/* flush */ NULL,
+/* textwidth */ 12,
+/* textheight */ 12,
+/* params */ cocoa_params,
+/* flags */ PIXELSIZE | FULLSCREEN,
+/* width */ 0.0,
+/* height */ 0.0,
+/* maxwidth */ 0,
+/* maxheight */ 0,
+/* imagetype */ UI_TRUECOLOR,
+/* palettestart */ 0,
+/* paletteend */ 256,
+/* maxentries */ 255,
+/* rmask */ RMASK,
+/* gmask */ GMASK,
+/* bmask */ BMASK,
+/* gui_driver */ &cocoa_gui_driver
+};
+/* DONT FORGET TO ADD DOCUMENTATION ABOUT YOUR DRIVER INTO xaos.hlp FILE!*/
diff --git a/src/ui/ui-drv/cocoa/version.h b/src/ui/ui-drv/cocoa/version.h
new file mode 100644
index 0000000..719d117
--- /dev/null
+++ b/src/ui/ui-drv/cocoa/version.h
@@ -0,0 +1,22 @@
+/*
+ * 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 "3.5"
diff --git a/src/ui/ui-drv/gtk/Makefile.in b/src/ui/ui-drv/gtk/Makefile.in
new file mode 100644
index 0000000..e5ca90f
--- /dev/null
+++ b/src/ui/ui-drv/gtk/Makefile.in
@@ -0,0 +1,39 @@
+CC = @CC@
+CFLAGS = @CFLAGS@
+LIBS = @LIBS@ -lm
+LFLAGS = @LDFLAGS@
+#AR = @AR@
+RANLIB = @RANLIB@
+
+SRCS = ui_gtk.c
+
+OBJS = $(SRCS:.c=.o)
+
+TLIB = @LIBPATH@/libuigtk.a
+
+
+all: $(TLIB)
+
+$(TLIB):$(OBJS)
+ rm -f $@
+ $(AR) rc $@ $^
+ $(RANLIB) $@
+
+clean:
+ rm -f $(TLIB)
+ rm -f *.[oas]
+ rm -f *~
+ rm -f core
+
+distclean:clean
+ rm Makefile
+
+#dep:
+# rm -f .depend
+# make .depend
+#
+#.depend:
+# echo '# Program dependencies' >.depend
+# gcc -I svgalib $(DEFINES) -MM $(patsubst %.o,%.c,$(OBJS)) >>.depend
+#
+#include .depend
diff --git a/src/ui/ui-drv/gtk/ui_gtk.c b/src/ui/ui-drv/gtk/ui_gtk.c
new file mode 100644
index 0000000..294b9e0
--- /dev/null
+++ b/src/ui/ui-drv/gtk/ui_gtk.c
@@ -0,0 +1,764 @@
+#include "aconfig.h"
+#ifdef GTK_DRIVER
+/*includes */
+#include <cairo.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include <filter.h>
+#include <grlib.h>
+#include <ui.h>
+
+int width = 640;
+int height = 480;
+
+int mouse_x = 0;
+int mouse_y = 0;
+int mouse_buttons = 0;
+int keys = 0;
+
+GtkWidget *drawing_area;
+GtkWidget *menu_bar;
+GtkWidget *window;
+GHashTable *menuitem_table = NULL;
+
+int current_surface;
+cairo_surface_t *surface[2];
+
+static void window_destroyed(GtkWidget * widget, gpointer data) {
+ ui_quit();
+}
+
+static gboolean mouse_moved(GtkWidget * widget, GdkEventMotion * event,
+ gpointer data) {
+ mouse_x = event->x;
+ mouse_y = event->y;
+ return TRUE;
+}
+
+static gboolean key_pressed(GtkWidget * widget, GdkEventKey * event,
+ gpointer data) {
+ guint32 key;
+
+ switch (event->keyval) {
+ case GDK_Left:
+ keys |= 1;
+ ui_key(UIKEY_LEFT);
+ break;
+ case GDK_Right:
+ keys |= 2;
+ ui_key(UIKEY_RIGHT);
+ break;
+ case GDK_Up:
+ keys |= 4;
+ ui_key(UIKEY_UP);
+ break;
+ case GDK_Down:
+ keys |= 8;
+ ui_key(UIKEY_DOWN);
+ break;
+ case GDK_Page_Up:
+ keys |= 4;
+ ui_key(UIKEY_PGUP);
+ break;
+ case GDK_Page_Down:
+ keys |= 8;
+ ui_key(UIKEY_PGDOWN);
+ break;
+ case GDK_BackSpace:
+ ui_key(UIKEY_BACKSPACE);
+ break;
+ case GDK_Escape:
+ ui_key(UIKEY_ESC);
+ break;
+ case GDK_Home:
+ ui_key(UIKEY_HOME);
+ break;
+ case GDK_End:
+ ui_key(UIKEY_END);
+ break;
+ case GDK_Tab:
+ ui_key(UIKEY_TAB);
+ break;
+ default:
+ key = gdk_keyval_to_unicode(event->keyval);
+ ui_key(key);
+ }
+ return TRUE;
+}
+
+static gboolean key_released(GtkWidget * widget, GdkEventKey * event,
+ gpointer data) {
+ switch (event->keyval) {
+ case GDK_Left:
+ keys &= ~1;
+ break;
+ case GDK_Right:
+ keys &= ~2;
+ break;
+ case GDK_Up:
+ keys &= ~4;
+ break;
+ case GDK_Down:
+ keys &= ~8;
+ break;
+ case GDK_Page_Up:
+ keys &= ~4;
+ break;
+ case GDK_Page_Down:
+ keys &= ~8;
+ break;
+ }
+ return TRUE;
+}
+
+static gboolean button_pressed(GtkWidget * widget, GdkEventButton * event,
+ gpointer data) {
+ switch (event->button) {
+ case 1:
+ mouse_buttons |= BUTTON1;
+ break;
+ case 2:
+ mouse_buttons |= BUTTON2;
+ break;
+ case 3:
+ mouse_buttons |= BUTTON3;
+ break;
+ }
+ return TRUE;
+}
+
+static gboolean button_released(GtkWidget * widget, GdkEventButton * event,
+ gpointer data) {
+ switch (event->button) {
+ case 1:
+ mouse_buttons &= ~BUTTON1;
+ break;
+ case 2:
+ mouse_buttons &= ~BUTTON2;
+ break;
+ case 3:
+ mouse_buttons &= ~BUTTON3;
+ break;
+ }
+ return TRUE;
+}
+
+static gboolean drawing_area_resized(GtkWidget * widget,
+ GdkEventConfigure * event) {
+ if (surface[0] && surface[1]) {
+ width = event->width;
+ height = event->height;
+ ui_resize();
+ }
+
+ return FALSE;
+}
+
+static gboolean drawing_area_exposed(GtkWidget * widget,
+ GdkEventExpose * event, gpointer data) {
+ cairo_t *cr;
+
+ cr = gdk_cairo_create(widget->window);
+
+ cairo_set_source_surface(cr, surface[current_surface], 0, 0);
+ cairo_paint(cr);
+
+ cairo_destroy(cr);
+
+ return FALSE;
+}
+
+void menuitem_activated(GtkMenuItem * item, gpointer data) {
+ /*
+ * gtk emits activate signal when radio buttons are deactivated as well.
+ * we want to ignore these signals.
+ */
+
+ if (!GTK_IS_RADIO_MENU_ITEM(item) || gtk_check_menu_item_get_active(
+ GTK_CHECK_MENU_ITEM(item)))
+ ui_menuactivate((CONST menuitem *) data, NULL);
+}
+
+static void build_menu(struct uih_context *uih, CONST char *name,
+ GtkWidget * parent) {
+ CONST menuitem *item;
+ gchar *menulabel;
+ GtkWidget *menuitem;
+ GtkWidget *submenu;
+ GSList *group = NULL;
+
+ int i;
+
+ for (i = 0; (item = menu_item(name, i)) != NULL; i++) {
+ if (item->type == MENU_SEPARATOR)
+ menuitem = gtk_separator_menu_item_new();
+ else {
+ if (item->type == MENU_CUSTOMDIALOG || item->type == MENU_DIALOG)
+ menulabel = g_strconcat(item->name, "...", NULL);
+ else
+ menulabel = g_strdup(item->name);
+
+ if (item->flags & MENUFLAG_CHECKBOX)
+ menuitem = gtk_check_menu_item_new_with_label(menulabel);
+ else if (item->flags & MENUFLAG_RADIO) {
+ menuitem = gtk_radio_menu_item_new_with_label(group, menulabel);
+ group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM
+ (menuitem));
+ } else
+ menuitem = gtk_menu_item_new_with_label(menulabel);
+
+ if (menu_enabled(item, uih))
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
+ (menuitem), TRUE);
+
+ g_free(menulabel);
+
+ g_hash_table_insert(menuitem_table, (gpointer) item->shortname,
+ menuitem);
+ }
+
+ gtk_menu_shell_append(GTK_MENU_SHELL(parent), menuitem);
+ gtk_widget_show(menuitem);
+
+ if (item->type == MENU_SUBMENU) {
+ submenu = gtk_menu_new();
+ build_menu(uih, item->shortname, submenu);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
+ } else {
+ g_signal_connect(G_OBJECT(menuitem), "activate",
+ G_CALLBACK(menuitem_activated),
+ (gpointer) item);
+ }
+ }
+}
+
+static void dorootmenu(struct uih_context *uih, CONST char *name) {
+ if (menuitem_table)
+ g_hash_table_destroy(menuitem_table);
+
+ gtk_container_foreach(GTK_CONTAINER(menu_bar),
+ (GtkCallback) gtk_widget_destroy, NULL);
+
+ menuitem_table = g_hash_table_new(g_str_hash, g_str_equal);
+ build_menu(uih, name, menu_bar);
+}
+
+static void dialog(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)) {
+
+ GtkFileChooserAction action;
+ gchar *title;
+ switch (dialog[0].type) {
+ case DIALOG_IFILE:
+ action = GTK_FILE_CHOOSER_ACTION_OPEN;
+ title = "Open File";
+ break;
+ case DIALOG_OFILE:
+ action = GTK_FILE_CHOOSER_ACTION_SAVE;
+ title = "Save as...";
+ break;
+ }
+
+ GtkWidget *chooser = gtk_file_chooser_dialog_new(title, GTK_WINDOW
+ (window), action, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ GtkFileFilter *filter = gtk_file_filter_new();
+ // TODO: Set default extension for save dialog
+ gtk_file_filter_add_pattern(filter, g_strrstr(dialog[0].defstr, "*"));
+ gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(chooser), filter);
+
+ gint result = gtk_dialog_run(GTK_DIALOG(chooser));
+
+ if (result == GTK_RESPONSE_OK) {
+ gchar *filename = gtk_file_chooser_get_filename(
+ GTK_FILE_CHOOSER(chooser));
+ dialogparam *param = malloc(sizeof(dialogparam));
+ param->dstring = strdup(filename);
+ ui_menuactivate(item, param);
+ }
+ gtk_widget_destroy(chooser);
+
+ } else {
+ GtkWidget *window, *table;
+ GHashTable *widget_hash = g_hash_table_new(g_str_hash, g_str_equal);
+
+ window = gtk_dialog_new_with_buttons("XaoS", NULL, GTK_DIALOG_MODAL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL, GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL);
+
+ gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_OK);
+
+ table = gtk_table_new(nitems, 5, FALSE);
+ gtk_container_set_border_width(GTK_CONTAINER(table), 5);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 5);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 5);
+
+ int i;
+ for (i = 0; i < nitems; i++) {
+ GtkWidget *label = gtk_label_new(dialog[i].question);
+ GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0);
+ gtk_container_add(GTK_CONTAINER(align), GTK_WIDGET(label));
+ gtk_table_attach_defaults(GTK_TABLE(table), align, 0, 1, i, i + 1);
+
+ switch (dialog[i].type) {
+ case DIALOG_COORD: {
+ GtkWidget *widget;
+ gchar *value;
+ widget = gtk_entry_new();
+ value = g_strdup_printf("%f", dialog[i].deffloat);
+ gtk_entry_set_text(GTK_ENTRY(widget), value);
+ g_free(value);
+ gtk_table_attach_defaults(GTK_TABLE(table), widget, 1, 2, i, i
+ + 1);
+
+ g_hash_table_insert(widget_hash, dialog[i].question, widget);
+
+ widget = gtk_label_new("+");
+ gtk_table_attach_defaults(GTK_TABLE(table), widget, 2, 3, i, i
+ + 1);
+
+ widget = gtk_entry_new();
+ value = g_strdup_printf("%f", dialog[i].deffloat2);
+ gtk_entry_set_text(GTK_ENTRY(widget), value);
+ gtk_table_attach_defaults(GTK_TABLE(table), widget, 3, 4, i, i
+ + 1);
+ g_free(value);
+
+ gchar *key = g_strconcat(dialog[i].question, "2", NULL);
+ g_hash_table_insert(widget_hash, key, widget);
+ //g_free(key);
+
+ widget = gtk_label_new("i");
+ gtk_table_attach_defaults(GTK_TABLE(table), widget, 4, 5, i, i
+ + 1);
+
+ break;
+ }
+ case DIALOG_IFILE:
+ case DIALOG_OFILE: {
+ GtkFileChooserAction action;
+ gchar *title;
+ switch (dialog[i].type) {
+ case DIALOG_IFILE:
+ action = GTK_FILE_CHOOSER_ACTION_OPEN;
+ title = "Open File";
+ break;
+ case DIALOG_OFILE:
+ action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
+ title = "Save as...";
+ break;
+ }
+
+ // TODO: Set default chooser value
+ GtkWidget *chooser = gtk_file_chooser_button_new(title, action);
+ gtk_table_attach_defaults(GTK_TABLE(table), chooser, 1, 4, i, i
+ + 1);
+
+ g_hash_table_insert(widget_hash, dialog[i].question, chooser);
+ break;
+ }
+ case DIALOG_CHOICE: {
+ GtkWidget *combo = gtk_combo_box_new_text();
+ CONST
+ char **str = (CONST char **) dialog[i].defstr;
+ int y;
+ for (y = 0; str[y] != NULL; y++)
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), str[y]);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combo), dialog[i].defint);
+ gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 4, i, i
+ + 1);
+
+ g_hash_table_insert(widget_hash, dialog[i].question, combo);
+ break;
+
+ }
+ default: {
+ GtkWidget *entry = gtk_entry_new();
+ gchar *value;
+ switch (dialog[i].type) {
+ case DIALOG_INT:
+ value = g_strdup_printf("%d", dialog[i].defint);
+ break;
+ case DIALOG_FLOAT:
+ value = g_strdup_printf("%f", dialog[i].deffloat);
+ break;
+ case DIALOG_STRING:
+ case DIALOG_KEYSTRING:
+ value = g_strdup(dialog[i].defstr);
+ break;
+ }
+ gtk_entry_set_text(GTK_ENTRY(entry), value);
+ g_free(value);
+ gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 4, i, i
+ + 1);
+
+ g_hash_table_insert(widget_hash, dialog[i].question, entry);
+ break;
+ }
+ }
+
+ }
+
+ gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(window)->vbox), table);
+ gtk_widget_show_all(window);
+
+ gint result = gtk_dialog_run(GTK_DIALOG(window));
+
+ if (result == GTK_RESPONSE_OK) {
+ dialogparam *params = malloc(sizeof(dialogparam) * nitems);
+
+ for (i = 0; i < nitems; i++) {
+ GtkWidget *widget = g_hash_table_lookup(widget_hash,
+ dialog[i]. question);
+ switch (dialog[i].type) {
+ case DIALOG_IFILE:
+ case DIALOG_OFILE: {
+ gchar *filename = gtk_file_chooser_get_filename(
+ GTK_FILE_CHOOSER(widget));
+ if (filename == NULL)
+ filename = "";
+ params[i].dstring = strdup(filename);
+ break;
+ }
+ case DIALOG_STRING:
+ case DIALOG_KEYSTRING:
+ params[i].dstring = strdup(gtk_entry_get_text(
+ GTK_ENTRY(widget)));
+ break;
+ case DIALOG_INT:
+ params[i].dint
+ = atoi(gtk_entry_get_text(GTK_ENTRY(widget)));
+ break;
+ case DIALOG_FLOAT:
+ // TODO: Should use long double conversion instead of atof
+ params[i].number = atof(gtk_entry_get_text(
+ GTK_ENTRY(widget)));
+ break;
+ case DIALOG_COORD:
+ params[i].dcoord[0] = atof(gtk_entry_get_text(
+ GTK_ENTRY(widget)));
+ gchar *key = g_strconcat(dialog[i].question, "2", NULL);
+ widget = g_hash_table_lookup(widget_hash, key);
+ g_free(key);
+ params[i].dcoord[1] = atof(gtk_entry_get_text(
+ GTK_ENTRY(widget)));
+ break;
+ case DIALOG_CHOICE:
+ params[i].dint = gtk_combo_box_get_active(
+ GTK_COMBO_BOX(widget));
+ break;
+ }
+ }
+
+ g_hash_table_destroy(widget_hash);
+ gtk_widget_destroy(window);
+ ui_menuactivate(item, params);
+
+ } else {
+ g_hash_table_destroy(widget_hash);
+ gtk_widget_destroy(window);
+ }
+ }
+
+}
+
+static void enabledisable(struct uih_context *uih, CONST char *name) {
+ if (menuitem_table) {
+ CONST struct menuitem *item = menu_findcommand(name);
+ GtkCheckMenuItem *menuitem = g_hash_table_lookup(menuitem_table, name);
+ g_signal_handlers_block_matched(menuitem, G_SIGNAL_MATCH_FUNC, 0, 0, 0,
+ menuitem_activated, 0);
+ gtk_check_menu_item_set_active(menuitem, menu_enabled(item, uih));
+ g_signal_handlers_unblock_matched(menuitem, G_SIGNAL_MATCH_FUNC, 0, 0,
+ 0, menuitem_activated, 0);
+ }
+}
+
+static void print(int x, int y, CONST char *text) {
+}
+
+static void display() {
+ gtk_widget_queue_draw(drawing_area);
+}
+
+static void flip_buffers() {
+ current_surface ^= 1;
+}
+
+void free_buffers(char *b1, char *b2) {
+ cairo_surface_destroy(surface[0]);
+ cairo_surface_destroy(surface[1]);
+ surface[0] = NULL;
+ surface[1] = NULL;
+}
+
+int alloc_buffers(char **b1, char **b2) {
+ surface[0] = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
+ surface[1] = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
+
+ *b1 = (char *) cairo_image_surface_get_data(surface[0]);
+ *b2 = (char *) cairo_image_surface_get_data(surface[1]);
+
+ current_surface = 0;
+
+ return cairo_image_surface_get_stride(surface[0]);
+}
+
+static void getsize(int *w, int *h) {
+ *w = width;
+ *h = height;
+}
+
+static void processevents(int wait, int *mx, int *my, int *mb, int *k) {
+ while (gtk_events_pending())
+ gtk_main_iteration_do(wait ? TRUE : FALSE);
+
+ *mx = mouse_x;
+ *my = mouse_y;
+ *mb = mouse_buttons;
+ *k = keys;
+}
+
+static int init() {
+ GtkWidget *vbox;
+
+ int argc = 0;
+ char **argv = NULL;
+
+ gtk_init(&argc, &argv);
+
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
+ gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
+ gtk_window_set_title(GTK_WINDOW(window), "XaoS");
+
+ g_signal_connect(G_OBJECT(window), "destroy",
+ G_CALLBACK(window_destroyed), NULL);
+
+ vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(window), vbox);
+ gtk_widget_show(vbox);
+
+ menu_bar = gtk_menu_bar_new();
+ gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 0);
+ gtk_widget_show(menu_bar);
+
+ drawing_area = gtk_drawing_area_new();
+ gtk_box_pack_end(GTK_BOX(vbox), drawing_area, TRUE, TRUE, 0);
+ gtk_widget_show(drawing_area);
+
+ GTK_WIDGET_SET_FLAGS(drawing_area, GTK_CAN_FOCUS);
+ gtk_widget_grab_focus(drawing_area);
+
+ gtk_widget_add_events(drawing_area, GDK_POINTER_MOTION_MASK
+ | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
+
+ g_signal_connect(G_OBJECT(drawing_area), "motion-notify-event",
+ G_CALLBACK(mouse_moved), NULL);
+
+ g_signal_connect(G_OBJECT(drawing_area), "button-press-event",
+ G_CALLBACK(button_pressed), NULL);
+
+ g_signal_connect(G_OBJECT(drawing_area), "button-release-event",
+ G_CALLBACK(button_released), NULL);
+
+ g_signal_connect(G_OBJECT(drawing_area), "key-press-event",
+ G_CALLBACK(key_pressed), NULL);
+
+ g_signal_connect(G_OBJECT(drawing_area), "key-release-event",
+ G_CALLBACK(key_released), NULL);
+
+ g_signal_connect(G_OBJECT(drawing_area), "expose-event",
+ G_CALLBACK(drawing_area_exposed), NULL);
+
+ g_signal_connect(G_OBJECT(drawing_area), "configure-event",
+ G_CALLBACK(drawing_area_resized), NULL);
+
+ gtk_widget_show_all(window);
+
+ return ( /*1 for sucess 0 for fail */1);
+}
+
+static void uninit() {
+ /*
+ * Disconnect window destroy event to prevent XaoS from
+ * quitting when switching drivers
+ */
+ g_signal_handlers_disconnect_matched(window, G_SIGNAL_MATCH_FUNC, 0, 0, 0,
+ window_destroyed, 0);
+
+ gtk_widget_destroy(window);
+}
+
+static void getmouse(int *x, int *y, int *b) {
+ *x = mouse_x;
+ *y = mouse_y;
+ *b = mouse_buttons;
+}
+
+static void mousetype(int type) {
+}
+
+static int skip(CONST char *text)
+{
+ int i = 0;
+ while (*text && *text != '\n')
+ i++, text++;
+ return (i);
+}
+
+#ifdef PLATFORM_TEXT_RENDERING
+
+int
+xprint(struct image *image, CONST struct xfont *current, int x, int y,
+ CONST char *text, int fgcolor, int bgcolor, int mode)
+{
+ cairo_t *cr = cairo_create(surface[image->currimage]);
+
+ cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_BOLD);
+ cairo_set_font_size (cr, 18.0);
+
+ char line[BUFSIZ];
+ int pos = strcspn(text, "\n");
+ strncpy(line, text, pos);
+ line[pos] = '\0';
+
+ cairo_text_extents_t extents;
+ cairo_text_extents (cr, line, &extents);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_move_to (cr, x + 1, y + extents.height + 1);
+ cairo_show_text (cr, line);
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_move_to (cr, x, y + extents.height);
+ cairo_show_text (cr, line);
+
+ cairo_destroy(cr);
+
+ return strlen(line);
+}
+
+int xtextwidth(CONST struct xfont *font, CONST char *text)
+{
+ cairo_t *cr = cairo_create(surface[current_surface]);
+
+ cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_BOLD);
+ cairo_set_font_size (cr, 18.0);
+
+ char line[BUFSIZ];
+ int pos = strcspn(text, "\n");
+ strncpy(line, text, pos);
+ line[pos] = '\0';
+
+ cairo_text_extents_t extents;
+ cairo_text_extents (cr, line, &extents);
+
+ cairo_destroy(cr);
+
+ return ceil(extents.width) + 1;
+}
+
+int xtextheight(CONST struct xfont *font) {
+ cairo_t *cr = cairo_create(surface[current_surface]);
+
+ cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_BOLD);
+ cairo_set_font_size (cr, 18.0);
+
+ cairo_text_extents_t extents;
+ cairo_text_extents (cr, "Wg'", &extents);
+
+ cairo_destroy(cr);
+
+ return ceil(extents.height) + 5;
+}
+
+int xtextcharw(CONST struct xfont *font, CONST char c)
+{
+ cairo_t *cr = cairo_create(surface[current_surface]);
+
+ cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_BOLD);
+ cairo_set_font_size (cr, 18.0);
+
+ char text[2];
+ sprintf(text, "%c", c);
+
+ cairo_text_extents_t extents;
+ cairo_text_extents (cr, text, &extents);
+
+ cairo_destroy(cr);
+
+ return ceil(extents.width) + 1;
+}
+
+#endif
+
+static struct params params[] = { { "", P_HELP, NULL, "GTK+ driver options:" },
+ { NULL, 0, NULL, NULL } };
+
+struct gui_driver gtk_gui_driver = {
+/* dorootmenu */dorootmenu,
+/* enabledisable */enabledisable,
+/* popup */NULL,
+/* dialog */dialog,
+/* help */NULL };
+
+struct ui_driver gtk_driver = {
+/* name */"GTK+ Driver",
+/* init */init,
+/* getsize */getsize,
+/* processevents */processevents,
+/* getmouse */getmouse,
+/* uninit */uninit,
+/* set_color */NULL,
+/* set_range */NULL,
+/* print */print,
+/* display */display,
+/* alloc_buffers */alloc_buffers,
+/* free_buffers */free_buffers,
+/* filp_buffers */flip_buffers,
+/* mousetype */mousetype,
+/* flush */NULL,
+/* textwidth */12,
+/* textheight */12,
+/* params */params,
+
+/* flags */RESOLUTION | PIXELSIZE | NOFLUSHDISPLAY | FULLSCREEN
+ | PALETTE_ROTATION | ROTATE_INSIDE_CALCULATION,
+
+/* width */0.01,
+/* height */0.01,
+/* maxwidth */0,
+/* maxheight */0,
+/* imagetype */UI_TRUECOLOR,
+/* palettestart */0,
+/* paletteend */0,
+/* maxentries */0,
+/* rmask */0x00ff0000,
+/* gmask */0x0000ff00,
+/* bmask */0x000000ff,
+/* gui_driver */&gtk_gui_driver };
+
+#endif
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"
diff --git a/src/ui/ui-drv/template/Makefile.in b/src/ui/ui-drv/template/Makefile.in
new file mode 100644
index 0000000..185abd4
--- /dev/null
+++ b/src/ui/ui-drv/template/Makefile.in
@@ -0,0 +1,39 @@
+CC = @CC@
+CFLAGS = @CFLAGS@
+LIBS = @LIBS@ -lm
+LFLAGS = @LDFLAGS@
+#AR = @AR@
+RANLIB = @RANLIB@
+
+SRCS = ui_template.c
+
+OBJS = $(SRCS:.c=.o)
+
+TLIB = @LIBPATH@/libuitemplate.a
+
+
+all: $(TLIB)
+
+$(TLIB):$(OBJS)
+ rm -f $@
+ $(AR) rc $@ $^
+ $(RANLIB) $@
+
+clean:
+ rm -f $(TLIB)
+ rm -f *.[oas]
+ rm -f *~
+ rm -f core
+
+distclean:clean
+ rm Makefile
+
+#dep:
+# rm -f .depend
+# make .depend
+#
+#.depend:
+# echo '# Program dependencies' >.depend
+# gcc -I svgalib $(DEFINES) -MM $(patsubst %.o,%.c,$(OBJS)) >>.depend
+#
+#include .depend
diff --git a/src/ui/ui-drv/template/ui_template.c b/src/ui/ui-drv/template/ui_template.c
new file mode 100644
index 0000000..1ac3b0a
--- /dev/null
+++ b/src/ui/ui-drv/template/ui_template.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/win32/Makefile.in b/src/ui/ui-drv/win32/Makefile.in
new file mode 100644
index 0000000..f2cd8a0
--- /dev/null
+++ b/src/ui/ui-drv/win32/Makefile.in
@@ -0,0 +1,43 @@
+CC = @CC@
+CFLAGS = @CFLAGS@
+LIBS = @LIBS@ -lm
+LFLAGS = @LDFLAGS@
+AR = @AR@
+RANLIB = @RANLIB@
+
+SRCS = ui_win32.c dxguid.c winmenu.c windialo.c about.c
+
+OBJS = $(SRCS:.c=.o) #xaos.res
+
+TLIB = @LIBPATH@/libuiwin32.a
+
+
+all: ui_win32.o xaos.res $(TLIB)
+
+$(TLIB):$(OBJS)
+ rm -f $@
+ $(AR) rc $@ $(OBJS)
+ $(RANLIB) $@
+
+clean:
+ rm -f $(TLIB)
+ rm -f *.[oas]
+ rm -f *~
+ rm -f core
+ rm -f xaos.res
+
+xaos.res: xaos.rc resource.h xaos.dlg
+ windres xaos.rc -O coff -o $@
+
+distclean:clean
+ rm Makefile
+
+#dep:
+# rm -f .depend
+# make .depend
+#
+#.depend:
+# echo '# Program dependencies' >.depend
+# gcc -I svgalib $(DEFINES) -MM $(patsubst %.o,%.c,$(OBJS)) >>.depend
+#
+#include .depend
diff --git a/src/ui/ui-drv/win32/about.c b/src/ui/ui-drv/win32/about.c
new file mode 100644
index 0000000..22b040d
--- /dev/null
+++ b/src/ui/ui-drv/win32/about.c
@@ -0,0 +1,239 @@
+#include <windows.h>
+#include "fconfig.h"
+#include "xerror.h"
+#include "ui_win32.h"
+#include "about.h"
+void CenterWindow(HWND hwndChild, HWND hwndParent)
+{
+ RECT rChild, rParent, rWorkArea;
+ int wChild, hChild, wParent, hParent;
+ int xNew, yNew;
+ BOOL bResult;
+
+ GetWindowRect(hwndChild, &rChild);
+ wChild = rChild.right - rChild.left;
+ hChild = rChild.bottom - rChild.top;
+
+ GetWindowRect(hwndParent, &rParent);
+ wParent = rParent.right - rParent.left;
+ hParent = rParent.bottom - rParent.top;
+
+ bResult = SystemParametersInfo(SPI_GETWORKAREA, // system parameter to query or set
+ sizeof(RECT), &rWorkArea, 0);
+ if (!bResult) {
+ rWorkArea.left = rWorkArea.top = 0;
+ rWorkArea.right = GetSystemMetrics(SM_CXSCREEN);
+ rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN);
+ }
+
+ xNew = rParent.left + ((wParent - wChild) / 2);
+ if (xNew < rWorkArea.left) {
+ xNew = rWorkArea.left;
+ } else if ((xNew + wChild) > rWorkArea.right) {
+ xNew = rWorkArea.right - wChild;
+ }
+
+ yNew = rParent.top + ((hParent - hChild) / 2);
+ if (yNew < rWorkArea.top) {
+ yNew = rWorkArea.top;
+ } else if ((yNew + hChild) > rWorkArea.bottom) {
+ yNew = rWorkArea.bottom - hChild;
+ }
+
+ SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0,
+ SWP_NOSIZE | SWP_NOZORDER);
+ return;
+}
+
+
+static LPTSTR GetStringRes(int id)
+{
+ static TCHAR buffer[MAX_PATH];
+
+ buffer[0] = 0;
+ LoadString(GetModuleHandle(NULL), id, buffer, MAX_PATH);
+ return buffer;
+}
+
+static LRESULT CALLBACK
+About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ static HFONT hfontDlg; // Font for dialog text
+ static HFONT hFinePrint; // Font for 'fine print' in dialog
+ DWORD dwVerInfoSize; // Size of version information block
+ LPSTR lpVersion; // String pointer to 'version' text
+ DWORD dwVerHnd = 0; // An 'ignored' parameter, always '0'
+ UINT uVersionLen;
+ WORD wRootLen;
+ BOOL bRetCode;
+ int i;
+ char szFullPath[256];
+ char szResult[256];
+ char szGetName[256];
+ DWORD dwVersion;
+ char szVersion[40];
+ DWORD dwResult;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ ShowWindow(hDlg, SW_HIDE);
+
+ if (PRIMARYLANGID(GetUserDefaultLangID()) == LANG_JAPANESE) {
+ hfontDlg =
+ CreateFont(14, 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, 0, 0,
+ 0, VARIABLE_PITCH | FF_DONTCARE, "");
+ hFinePrint =
+ CreateFont(11, 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, 0, 0,
+ 0, VARIABLE_PITCH | FF_DONTCARE, "");
+ } else {
+ hfontDlg = CreateFont(14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ VARIABLE_PITCH | FF_SWISS, "");
+ hFinePrint = CreateFont(11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ VARIABLE_PITCH | FF_SWISS, "");
+ }
+
+ CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER));
+ GetModuleFileName(hInstance, szFullPath, sizeof(szFullPath));
+#if 0
+ // Now lets dive in and pull out the version information:
+ dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
+ if (dwVerInfoSize) {
+ LPSTR lpstrVffInfo;
+ HANDLE hMem;
+ hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
+ lpstrVffInfo = GlobalLock(hMem);
+ GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize,
+ lpstrVffInfo);
+ // The below 'hex' value looks a little confusing, but
+ // essentially what it is, is the hexidecimal representation
+ // of a couple different values that represent the language
+ // and character set that we are wanting string values for.
+ // 040904E4 is a very common one, because it means:
+ // US English, Windows MultiLingual characterset
+ // Or to pull it all apart:
+ // 04------ = SUBLANG_ENGLISH_USA
+ // --09---- = LANG_ENGLISH
+ // --11---- = LANG_JAPANESE
+ // ----04E4 = 1252 = Codepage for Windows:Multilingual
+
+ lstrcpy(szGetName, GetStringRes(IDS_VER_INFO_LANG));
+
+ wRootLen = (WORD) lstrlen(szGetName); // Save this position
+
+ // Set the title of the dialog:
+ lstrcat(szGetName, "ProductName");
+ bRetCode = VerQueryValue((LPVOID) lpstrVffInfo,
+ (LPSTR) szGetName,
+ (LPVOID) & lpVersion,
+ (UINT *) & uVersionLen);
+
+ // Notice order of version and string...
+ if (PRIMARYLANGID(GetUserDefaultLangID()) == LANG_JAPANESE) {
+ lstrcpy(szResult, lpVersion);
+ lstrcat(szResult, " ‚̃o[ƒWƒ‡ƒ“î•ñ");
+ } else {
+ lstrcpy(szResult, "About ");
+ lstrcat(szResult, lpVersion);
+ }
+
+ // -----------------------------------------------------
+
+ SetWindowText(hDlg, szResult);
+
+ // Walk through the dialog items that we want to replace:
+ for (i = DLG_VERFIRST; i <= DLG_VERLAST; i++) {
+ GetDlgItemText(hDlg, i, szResult, sizeof(szResult));
+ szGetName[wRootLen] = (char) 0;
+ lstrcat(szGetName, szResult);
+ uVersionLen = 0;
+ lpVersion = NULL;
+ x_message("lpstrVffInfo %s", lpstrVffInfo);
+ bRetCode = VerQueryValue((LPVOID) lpstrVffInfo,
+ (LPSTR) szGetName,
+ (LPVOID) & lpVersion,
+ (UINT *) & uVersionLen);
+
+ if (bRetCode && uVersionLen && lpVersion) {
+ // Replace dialog item text with version info
+ lstrcpy(szResult, lpVersion);
+ SetDlgItemText(hDlg, i, szResult);
+ } else {
+ dwResult = GetLastError();
+
+ wsprintf(szResult, GetStringRes(IDS_VERSION_ERROR),
+ dwResult);
+ SetDlgItemText(hDlg, i, szResult);
+ }
+ SendMessage(GetDlgItem(hDlg, i), WM_SETFONT,
+ /* (ULONG_PTR) */
+ (unsigned long *) ((i == DLG_VERLAST) ?
+ hFinePrint : hfontDlg),
+ TRUE);
+ } // for (i = DLG_VERFIRST; i <= DLG_VERLAST; i++)
+
+
+ GlobalUnlock(hMem);
+ GlobalFree(hMem);
+ } else {
+ // No version information available.
+ } // if (dwVerInfoSize)
+#endif
+ for (i = DLG_VERFIRST; i <= IDC_LICENSE; i++) {
+ SendMessage(GetDlgItem(hDlg, i), WM_SETFONT,
+ /* (ULONG_PTR) */
+ (unsigned long *) ((i == DLG_VERLAST) ? hFinePrint
+ : hfontDlg), TRUE);
+ } // for (i = DLG_VERFIRST; i <= DLG_VERLAST; i++)
+
+ SendMessage(GetDlgItem(hDlg, IDC_LABEL), WM_SETFONT,
+ (WPARAM) hfontDlg, (LPARAM) TRUE);
+
+ // We are using GetVersion rather then GetVersionEx
+ // because earlier versions of Windows NT and Win32s
+ // didn't include GetVersionEx:
+ dwVersion = GetVersion();
+
+ if (dwVersion < 0x80000000) {
+ // Windows NT
+ wsprintf(szVersion, "Microsoft Windows NT %u.%u (Build: %u)",
+ (DWORD) (LOBYTE(LOWORD(dwVersion))),
+ (DWORD) (HIBYTE(LOWORD(dwVersion))),
+ (DWORD) (HIWORD(dwVersion)));
+ } else if (LOBYTE(LOWORD(dwVersion)) < 4) {
+ // Win32s
+ wsprintf(szVersion, "Microsoft Win32s %u.%u (Build: %u)",
+ (DWORD) (LOBYTE(LOWORD(dwVersion))),
+ (DWORD) (HIBYTE(LOWORD(dwVersion))),
+ (DWORD) (HIWORD(dwVersion) & ~0x8000));
+ } else {
+ // Windows 95
+ wsprintf(szVersion, "Microsoft Windows 95 %u.%u",
+ (DWORD) (LOBYTE(LOWORD(dwVersion))),
+ (DWORD) (HIBYTE(LOWORD(dwVersion))));
+ }
+
+ SetWindowText(GetDlgItem(hDlg, IDC_OSVERSION), szVersion);
+ ShowWindow(hDlg, SW_SHOW);
+ return (TRUE);
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
+ EndDialog(hDlg, TRUE);
+ DeleteObject(hfontDlg);
+ DeleteObject(hFinePrint);
+ return (TRUE);
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+void AboutBox(void)
+{
+#ifdef DDRAW_DRIVER
+ if (directX == 1)
+ return;
+#endif
+ DialogBox(hInstance, "AboutBox", hWnd, (DLGPROC) About);
+}
diff --git a/src/ui/ui-drv/win32/about.h b/src/ui/ui-drv/win32/about.h
new file mode 100644
index 0000000..f42c873
--- /dev/null
+++ b/src/ui/ui-drv/win32/about.h
@@ -0,0 +1,20 @@
+#define IDC_STATIC -1
+
+#define DLG_VERFIRST 400
+#define IDC_COMPANY DLG_VERFIRST
+#define IDC_FILEDESC DLG_VERFIRST+1
+#define IDC_PRODVER DLG_VERFIRST+2
+#define IDC_COPYRIGHT DLG_VERFIRST+3
+#define IDC_OSVERSION DLG_VERFIRST+4
+#define IDC_TRADEMARK DLG_VERFIRST+5
+#define DLG_VERLAST DLG_VERFIRST+5
+#define IDC_LICENSE DLG_VERFIRST+6
+
+#define IDC_LABEL IDC_LICENSE+1
+
+
+#define IDS_APP_TITLE 500
+#define IDS_DISPLAYCHANGED 501
+#define IDS_VER_INFO_LANG 502
+#define IDS_VERSION_ERROR 503
+#define IDS_NO_HELP 504
diff --git a/src/ui/ui-drv/win32/about.rc b/src/ui/ui-drv/win32/about.rc
new file mode 100644
index 0000000..cb5d3a4
--- /dev/null
+++ b/src/ui/ui-drv/win32/about.rc
@@ -0,0 +1,19 @@
+ABOUTBOX DIALOG DISCARDABLE 22, 17, 197, 74+4*18
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "About"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,162,2,32,14,WS_GROUP
+ ICON "BIG",IDC_STATIC,3,2,18,20
+ LTEXT "Free Sofware Foundation",IDC_COMPANY,30,2,130,8
+ LTEXT "XaoS - a realtime fractal zoomer",IDC_FILEDESC,30,10,121,8
+ RTEXT "3.5",IDC_PRODVER,136,10,17,8
+ LTEXT "Copyright 1996-2008 Jan Hubicka, Thomas Marsh and others",IDC_COPYRIGHT,30,18,167,8
+ LTEXT "OSVERSION",IDC_OSVERSION,46,34,138,8
+ LTEXT "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. \n\nThis 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. \n\nYou 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.",IDC_LICENSE,3,49,192,5*18
+ LTEXT "Crashing on:",IDC_LABEL,4,34,40,8
+ CONTROL "",IDC_STATIC,"Static",SS_BLACKRECT,2,31,194,1
+ CONTROL "",IDC_STATIC,"Static",SS_BLACKRECT,2,44,194,1
+END
+
+
diff --git a/src/ui/ui-drv/win32/dxguid.c b/src/ui/ui-drv/win32/dxguid.c
new file mode 100644
index 0000000..5c6a2ae
--- /dev/null
+++ b/src/ui/ui-drv/win32/dxguid.c
@@ -0,0 +1,1102 @@
+#include <aconfig.h>
+#ifdef DDRAW_DRIVER
+#include <ddraw.h>
+#include <dinput.h>
+
+/* This is a replacement for microsofts dxguid.lib and parts of dinput.lib. */
+
+#undef DEFINE_GUID
+#define DEFINE_GUID(n,a,b,c,d,e,f,g,h,i,j,k) const GUID n = {a,b,c,{d,e,f,g,h,i,j,k}}
+
+/* DirectDraw */
+DEFINE_GUID(CLSID_DirectDraw, 0xD7B70EE0, 0x4340, 0x11CF, 0xB0, 0x63, 0x00,
+ 0x20, 0xAF, 0xC2, 0xCD, 0x35);
+DEFINE_GUID(CLSID_DirectDrawClipper, 0x593817A0, 0x7DB3, 0x11CF, 0xA2,
+ 0xDE, 0x00, 0xAA, 0x00, 0xb9, 0x33, 0x56);
+DEFINE_GUID(IID_IDirectDraw, 0x6C14DB80, 0xA733, 0x11CE, 0xA5, 0x21, 0x00,
+ 0x20, 0xAF, 0x0B, 0xE5, 0x60);
+DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0, 0x2B43, 0x11CF, 0xA2, 0xDE, 0x00,
+ 0xAA, 0x00, 0xB9, 0x33, 0x56);
+DEFINE_GUID(IID_IDirectDrawSurface, 0x6C14DB81, 0xA733, 0x11CE, 0xA5, 0x21,
+ 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
+DEFINE_GUID(IID_IDirectDrawSurface2, 0x57805885, 0x6eec, 0x11cf, 0x94,
+ 0x41, 0xa8, 0x23, 0x03, 0xc1, 0x0e, 0x27);
+DEFINE_GUID(IID_IDirectDrawSurface3, 0xDA044E00, 0x69B2, 0x11D0, 0xA1,
+ 0xD5, 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xBB);
+
+DEFINE_GUID(IID_IDirectDrawPalette, 0x6C14DB84, 0xA733, 0x11CE, 0xA5, 0x21,
+ 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
+DEFINE_GUID(IID_IDirectDrawClipper, 0x6C14DB85, 0xA733, 0x11CE, 0xA5, 0x21,
+ 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
+DEFINE_GUID(IID_IDirectDrawColorControl, 0x4B9F0EE0, 0x0D7E, 0x11D0, 0x9B,
+ 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8);
+
+DEFINE_GUID(IID_IDirectInputA, 0x89521360, 0xAA8A, 0x11CF, 0xBF, 0xC7,
+ 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(IID_IDirectInputW, 0x89521361, 0xAA8A, 0x11CF, 0xBF, 0xC7,
+ 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(IID_IDirectInput2A, 0x5944E662, 0xAA8A, 0x11CF, 0xBF, 0xC7,
+ 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(IID_IDirectInput2W, 0x5944E663, 0xAA8A, 0x11CF, 0xBF, 0xC7,
+ 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
+
+DEFINE_GUID(IID_IDirectInputDeviceA, 0x5944E680, 0xC92E, 0x11CF, 0xBF,
+ 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(IID_IDirectInputDeviceW, 0x5944E681, 0xC92E, 0x11CF, 0xBF,
+ 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(IID_IDirectInputDevice2A, 0x5944E682, 0xC92E, 0x11CF, 0xBF,
+ 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(IID_IDirectInputDevice2W, 0x5944E683, 0xC92E, 0x11CF, 0xBF,
+ 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(IID_IDirectInputEffect, 0xE7E1F7C0, 0x88D2, 0x11D0, 0x9A, 0xD0,
+ 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_XAxis, 0xA36D02E0, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44, 0x45,
+ 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_YAxis, 0xA36D02E1, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44, 0x45,
+ 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_ZAxis, 0xA36D02E2, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44, 0x45,
+ 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_RxAxis, 0xA36D02F4, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44,
+ 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_RyAxis, 0xA36D02F5, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44,
+ 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_RzAxis, 0xA36D02E3, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44,
+ 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_Slider, 0xA36D02E4, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44,
+ 0x45, 0x53, 0x54, 0x00, 0x00);
+
+DEFINE_GUID(GUID_Button, 0xA36D02F0, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44,
+ 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_Key, 0x55728220, 0xD33C, 0x11CF, 0xBF, 0xC7, 0x44, 0x45,
+ 0x53, 0x54, 0x00, 0x00);
+
+DEFINE_GUID(GUID_POV, 0xA36D02F2, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44, 0x45,
+ 0x53, 0x54, 0x00, 0x00);
+
+DEFINE_GUID(GUID_Unknown, 0xA36D02F3, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44,
+ 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_SysMouse, 0x6F1D2B60, 0xD5A0, 0x11CF, 0xBF, 0xC7, 0x44,
+ 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_SysKeyboard, 0x6F1D2B61, 0xD5A0, 0x11CF, 0xBF, 0xC7, 0x44,
+ 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_Joystick, 0x6F1D2B70, 0xD5A0, 0x11CF, 0xBF, 0xC7, 0x44,
+ 0x45, 0x53, 0x54, 0x00, 0x00);
+DEFINE_GUID(GUID_ConstantForce, 0x13541C20, 0x8E33, 0x11D0, 0x9A, 0xD0,
+ 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_RampForce, 0x13541C21, 0x8E33, 0x11D0, 0x9A, 0xD0, 0x00,
+ 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_Square, 0x13541C22, 0x8E33, 0x11D0, 0x9A, 0xD0, 0x00,
+ 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_Sine, 0x13541C23, 0x8E33, 0x11D0, 0x9A, 0xD0, 0x00, 0xA0,
+ 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_Triangle, 0x13541C24, 0x8E33, 0x11D0, 0x9A, 0xD0, 0x00,
+ 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_SawtoothUp, 0x13541C25, 0x8E33, 0x11D0, 0x9A, 0xD0, 0x00,
+ 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_SawtoothDown, 0x13541C26, 0x8E33, 0x11D0, 0x9A, 0xD0,
+ 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_Spring, 0x13541C27, 0x8E33, 0x11D0, 0x9A, 0xD0, 0x00,
+ 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_Damper, 0x13541C28, 0x8E33, 0x11D0, 0x9A, 0xD0, 0x00,
+ 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_Inertia, 0x13541C29, 0x8E33, 0x11D0, 0x9A, 0xD0, 0x00,
+ 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_Friction, 0x13541C2A, 0x8E33, 0x11D0, 0x9A, 0xD0, 0x00,
+ 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+DEFINE_GUID(GUID_CustomForce, 0x13541C2B, 0x8E33, 0x11D0, 0x9A, 0xD0, 0x00,
+ 0xA0, 0xC9, 0xA0, 0x6E, 0x35);
+
+
+DIOBJECTDATAFORMAT rgodf_c_dfDIKeyboard[] = {
+ {&GUID_Key, 0, -2147483636, 0}
+ ,
+ {&GUID_Key, 1, -2147483380, 0}
+ ,
+ {&GUID_Key, 2, -2147483124, 0}
+ ,
+ {&GUID_Key, 3, -2147482868, 0}
+ ,
+ {&GUID_Key, 4, -2147482612, 0}
+ ,
+ {&GUID_Key, 5, -2147482356, 0}
+ ,
+ {&GUID_Key, 6, -2147482100, 0}
+ ,
+ {&GUID_Key, 7, -2147481844, 0}
+ ,
+ {&GUID_Key, 8, -2147481588, 0}
+ ,
+ {&GUID_Key, 9, -2147481332, 0}
+ ,
+ {&GUID_Key, 10, -2147481076, 0}
+ ,
+ {&GUID_Key, 11, -2147480820, 0}
+ ,
+ {&GUID_Key, 12, -2147480564, 0}
+ ,
+ {&GUID_Key, 13, -2147480308, 0}
+ ,
+ {&GUID_Key, 14, -2147480052, 0}
+ ,
+ {&GUID_Key, 15, -2147479796, 0}
+ ,
+ {&GUID_Key, 16, -2147479540, 0}
+ ,
+ {&GUID_Key, 17, -2147479284, 0}
+ ,
+ {&GUID_Key, 18, -2147479028, 0}
+ ,
+ {&GUID_Key, 19, -2147478772, 0}
+ ,
+ {&GUID_Key, 20, -2147478516, 0}
+ ,
+ {&GUID_Key, 21, -2147478260, 0}
+ ,
+ {&GUID_Key, 22, -2147478004, 0}
+ ,
+ {&GUID_Key, 23, -2147477748, 0}
+ ,
+ {&GUID_Key, 24, -2147477492, 0}
+ ,
+ {&GUID_Key, 25, -2147477236, 0}
+ ,
+ {&GUID_Key, 26, -2147476980, 0}
+ ,
+ {&GUID_Key, 27, -2147476724, 0}
+ ,
+ {&GUID_Key, 28, -2147476468, 0}
+ ,
+ {&GUID_Key, 29, -2147476212, 0}
+ ,
+ {&GUID_Key, 30, -2147475956, 0}
+ ,
+ {&GUID_Key, 31, -2147475700, 0}
+ ,
+ {&GUID_Key, 32, -2147475444, 0}
+ ,
+ {&GUID_Key, 33, -2147475188, 0}
+ ,
+ {&GUID_Key, 34, -2147474932, 0}
+ ,
+ {&GUID_Key, 35, -2147474676, 0}
+ ,
+ {&GUID_Key, 36, -2147474420, 0}
+ ,
+ {&GUID_Key, 37, -2147474164, 0}
+ ,
+ {&GUID_Key, 38, -2147473908, 0}
+ ,
+ {&GUID_Key, 39, -2147473652, 0}
+ ,
+ {&GUID_Key, 40, -2147473396, 0}
+ ,
+ {&GUID_Key, 41, -2147473140, 0}
+ ,
+ {&GUID_Key, 42, -2147472884, 0}
+ ,
+ {&GUID_Key, 43, -2147472628, 0}
+ ,
+ {&GUID_Key, 44, -2147472372, 0}
+ ,
+ {&GUID_Key, 45, -2147472116, 0}
+ ,
+ {&GUID_Key, 46, -2147471860, 0}
+ ,
+ {&GUID_Key, 47, -2147471604, 0}
+ ,
+ {&GUID_Key, 48, -2147471348, 0}
+ ,
+ {&GUID_Key, 49, -2147471092, 0}
+ ,
+ {&GUID_Key, 50, -2147470836, 0}
+ ,
+ {&GUID_Key, 51, -2147470580, 0}
+ ,
+ {&GUID_Key, 52, -2147470324, 0}
+ ,
+ {&GUID_Key, 53, -2147470068, 0}
+ ,
+ {&GUID_Key, 54, -2147469812, 0}
+ ,
+ {&GUID_Key, 55, -2147469556, 0}
+ ,
+ {&GUID_Key, 56, -2147469300, 0}
+ ,
+ {&GUID_Key, 57, -2147469044, 0}
+ ,
+ {&GUID_Key, 58, -2147468788, 0}
+ ,
+ {&GUID_Key, 59, -2147468532, 0}
+ ,
+ {&GUID_Key, 60, -2147468276, 0}
+ ,
+ {&GUID_Key, 61, -2147468020, 0}
+ ,
+ {&GUID_Key, 62, -2147467764, 0}
+ ,
+ {&GUID_Key, 63, -2147467508, 0}
+ ,
+ {&GUID_Key, 64, -2147467252, 0}
+ ,
+ {&GUID_Key, 65, -2147466996, 0}
+ ,
+ {&GUID_Key, 66, -2147466740, 0}
+ ,
+ {&GUID_Key, 67, -2147466484, 0}
+ ,
+ {&GUID_Key, 68, -2147466228, 0}
+ ,
+ {&GUID_Key, 69, -2147465972, 0}
+ ,
+ {&GUID_Key, 70, -2147465716, 0}
+ ,
+ {&GUID_Key, 71, -2147465460, 0}
+ ,
+ {&GUID_Key, 72, -2147465204, 0}
+ ,
+ {&GUID_Key, 73, -2147464948, 0}
+ ,
+ {&GUID_Key, 74, -2147464692, 0}
+ ,
+ {&GUID_Key, 75, -2147464436, 0}
+ ,
+ {&GUID_Key, 76, -2147464180, 0}
+ ,
+ {&GUID_Key, 77, -2147463924, 0}
+ ,
+ {&GUID_Key, 78, -2147463668, 0}
+ ,
+ {&GUID_Key, 79, -2147463412, 0}
+ ,
+ {&GUID_Key, 80, -2147463156, 0}
+ ,
+ {&GUID_Key, 81, -2147462900, 0}
+ ,
+ {&GUID_Key, 82, -2147462644, 0}
+ ,
+ {&GUID_Key, 83, -2147462388, 0}
+ ,
+ {&GUID_Key, 84, -2147462132, 0}
+ ,
+ {&GUID_Key, 85, -2147461876, 0}
+ ,
+ {&GUID_Key, 86, -2147461620, 0}
+ ,
+ {&GUID_Key, 87, -2147461364, 0}
+ ,
+ {&GUID_Key, 88, -2147461108, 0}
+ ,
+ {&GUID_Key, 89, -2147460852, 0}
+ ,
+ {&GUID_Key, 90, -2147460596, 0}
+ ,
+ {&GUID_Key, 91, -2147460340, 0}
+ ,
+ {&GUID_Key, 92, -2147460084, 0}
+ ,
+ {&GUID_Key, 93, -2147459828, 0}
+ ,
+ {&GUID_Key, 94, -2147459572, 0}
+ ,
+ {&GUID_Key, 95, -2147459316, 0}
+ ,
+ {&GUID_Key, 96, -2147459060, 0}
+ ,
+ {&GUID_Key, 97, -2147458804, 0}
+ ,
+ {&GUID_Key, 98, -2147458548, 0}
+ ,
+ {&GUID_Key, 99, -2147458292, 0}
+ ,
+ {&GUID_Key, 100, -2147458036, 0}
+ ,
+ {&GUID_Key, 101, -2147457780, 0}
+ ,
+ {&GUID_Key, 102, -2147457524, 0}
+ ,
+ {&GUID_Key, 103, -2147457268, 0}
+ ,
+ {&GUID_Key, 104, -2147457012, 0}
+ ,
+ {&GUID_Key, 105, -2147456756, 0}
+ ,
+ {&GUID_Key, 106, -2147456500, 0}
+ ,
+ {&GUID_Key, 107, -2147456244, 0}
+ ,
+ {&GUID_Key, 108, -2147455988, 0}
+ ,
+ {&GUID_Key, 109, -2147455732, 0}
+ ,
+ {&GUID_Key, 110, -2147455476, 0}
+ ,
+ {&GUID_Key, 111, -2147455220, 0}
+ ,
+ {&GUID_Key, 112, -2147454964, 0}
+ ,
+ {&GUID_Key, 113, -2147454708, 0}
+ ,
+ {&GUID_Key, 114, -2147454452, 0}
+ ,
+ {&GUID_Key, 115, -2147454196, 0}
+ ,
+ {&GUID_Key, 116, -2147453940, 0}
+ ,
+ {&GUID_Key, 117, -2147453684, 0}
+ ,
+ {&GUID_Key, 118, -2147453428, 0}
+ ,
+ {&GUID_Key, 119, -2147453172, 0}
+ ,
+ {&GUID_Key, 120, -2147452916, 0}
+ ,
+ {&GUID_Key, 121, -2147452660, 0}
+ ,
+ {&GUID_Key, 122, -2147452404, 0}
+ ,
+ {&GUID_Key, 123, -2147452148, 0}
+ ,
+ {&GUID_Key, 124, -2147451892, 0}
+ ,
+ {&GUID_Key, 125, -2147451636, 0}
+ ,
+ {&GUID_Key, 126, -2147451380, 0}
+ ,
+ {&GUID_Key, 127, -2147451124, 0}
+ ,
+ {&GUID_Key, 128, -2147450868, 0}
+ ,
+ {&GUID_Key, 129, -2147450612, 0}
+ ,
+ {&GUID_Key, 130, -2147450356, 0}
+ ,
+ {&GUID_Key, 131, -2147450100, 0}
+ ,
+ {&GUID_Key, 132, -2147449844, 0}
+ ,
+ {&GUID_Key, 133, -2147449588, 0}
+ ,
+ {&GUID_Key, 134, -2147449332, 0}
+ ,
+ {&GUID_Key, 135, -2147449076, 0}
+ ,
+ {&GUID_Key, 136, -2147448820, 0}
+ ,
+ {&GUID_Key, 137, -2147448564, 0}
+ ,
+ {&GUID_Key, 138, -2147448308, 0}
+ ,
+ {&GUID_Key, 139, -2147448052, 0}
+ ,
+ {&GUID_Key, 140, -2147447796, 0}
+ ,
+ {&GUID_Key, 141, -2147447540, 0}
+ ,
+ {&GUID_Key, 142, -2147447284, 0}
+ ,
+ {&GUID_Key, 143, -2147447028, 0}
+ ,
+ {&GUID_Key, 144, -2147446772, 0}
+ ,
+ {&GUID_Key, 145, -2147446516, 0}
+ ,
+ {&GUID_Key, 146, -2147446260, 0}
+ ,
+ {&GUID_Key, 147, -2147446004, 0}
+ ,
+ {&GUID_Key, 148, -2147445748, 0}
+ ,
+ {&GUID_Key, 149, -2147445492, 0}
+ ,
+ {&GUID_Key, 150, -2147445236, 0}
+ ,
+ {&GUID_Key, 151, -2147444980, 0}
+ ,
+ {&GUID_Key, 152, -2147444724, 0}
+ ,
+ {&GUID_Key, 153, -2147444468, 0}
+ ,
+ {&GUID_Key, 154, -2147444212, 0}
+ ,
+ {&GUID_Key, 155, -2147443956, 0}
+ ,
+ {&GUID_Key, 156, -2147443700, 0}
+ ,
+ {&GUID_Key, 157, -2147443444, 0}
+ ,
+ {&GUID_Key, 158, -2147443188, 0}
+ ,
+ {&GUID_Key, 159, -2147442932, 0}
+ ,
+ {&GUID_Key, 160, -2147442676, 0}
+ ,
+ {&GUID_Key, 161, -2147442420, 0}
+ ,
+ {&GUID_Key, 162, -2147442164, 0}
+ ,
+ {&GUID_Key, 163, -2147441908, 0}
+ ,
+ {&GUID_Key, 164, -2147441652, 0}
+ ,
+ {&GUID_Key, 165, -2147441396, 0}
+ ,
+ {&GUID_Key, 166, -2147441140, 0}
+ ,
+ {&GUID_Key, 167, -2147440884, 0}
+ ,
+ {&GUID_Key, 168, -2147440628, 0}
+ ,
+ {&GUID_Key, 169, -2147440372, 0}
+ ,
+ {&GUID_Key, 170, -2147440116, 0}
+ ,
+ {&GUID_Key, 171, -2147439860, 0}
+ ,
+ {&GUID_Key, 172, -2147439604, 0}
+ ,
+ {&GUID_Key, 173, -2147439348, 0}
+ ,
+ {&GUID_Key, 174, -2147439092, 0}
+ ,
+ {&GUID_Key, 175, -2147438836, 0}
+ ,
+ {&GUID_Key, 176, -2147438580, 0}
+ ,
+ {&GUID_Key, 177, -2147438324, 0}
+ ,
+ {&GUID_Key, 178, -2147438068, 0}
+ ,
+ {&GUID_Key, 179, -2147437812, 0}
+ ,
+ {&GUID_Key, 180, -2147437556, 0}
+ ,
+ {&GUID_Key, 181, -2147437300, 0}
+ ,
+ {&GUID_Key, 182, -2147437044, 0}
+ ,
+ {&GUID_Key, 183, -2147436788, 0}
+ ,
+ {&GUID_Key, 184, -2147436532, 0}
+ ,
+ {&GUID_Key, 185, -2147436276, 0}
+ ,
+ {&GUID_Key, 186, -2147436020, 0}
+ ,
+ {&GUID_Key, 187, -2147435764, 0}
+ ,
+ {&GUID_Key, 188, -2147435508, 0}
+ ,
+ {&GUID_Key, 189, -2147435252, 0}
+ ,
+ {&GUID_Key, 190, -2147434996, 0}
+ ,
+ {&GUID_Key, 191, -2147434740, 0}
+ ,
+ {&GUID_Key, 192, -2147434484, 0}
+ ,
+ {&GUID_Key, 193, -2147434228, 0}
+ ,
+ {&GUID_Key, 194, -2147433972, 0}
+ ,
+ {&GUID_Key, 195, -2147433716, 0}
+ ,
+ {&GUID_Key, 196, -2147433460, 0}
+ ,
+ {&GUID_Key, 197, -2147433204, 0}
+ ,
+ {&GUID_Key, 198, -2147432948, 0}
+ ,
+ {&GUID_Key, 199, -2147432692, 0}
+ ,
+ {&GUID_Key, 200, -2147432436, 0}
+ ,
+ {&GUID_Key, 201, -2147432180, 0}
+ ,
+ {&GUID_Key, 202, -2147431924, 0}
+ ,
+ {&GUID_Key, 203, -2147431668, 0}
+ ,
+ {&GUID_Key, 204, -2147431412, 0}
+ ,
+ {&GUID_Key, 205, -2147431156, 0}
+ ,
+ {&GUID_Key, 206, -2147430900, 0}
+ ,
+ {&GUID_Key, 207, -2147430644, 0}
+ ,
+ {&GUID_Key, 208, -2147430388, 0}
+ ,
+ {&GUID_Key, 209, -2147430132, 0}
+ ,
+ {&GUID_Key, 210, -2147429876, 0}
+ ,
+ {&GUID_Key, 211, -2147429620, 0}
+ ,
+ {&GUID_Key, 212, -2147429364, 0}
+ ,
+ {&GUID_Key, 213, -2147429108, 0}
+ ,
+ {&GUID_Key, 214, -2147428852, 0}
+ ,
+ {&GUID_Key, 215, -2147428596, 0}
+ ,
+ {&GUID_Key, 216, -2147428340, 0}
+ ,
+ {&GUID_Key, 217, -2147428084, 0}
+ ,
+ {&GUID_Key, 218, -2147427828, 0}
+ ,
+ {&GUID_Key, 219, -2147427572, 0}
+ ,
+ {&GUID_Key, 220, -2147427316, 0}
+ ,
+ {&GUID_Key, 221, -2147427060, 0}
+ ,
+ {&GUID_Key, 222, -2147426804, 0}
+ ,
+ {&GUID_Key, 223, -2147426548, 0}
+ ,
+ {&GUID_Key, 224, -2147426292, 0}
+ ,
+ {&GUID_Key, 225, -2147426036, 0}
+ ,
+ {&GUID_Key, 226, -2147425780, 0}
+ ,
+ {&GUID_Key, 227, -2147425524, 0}
+ ,
+ {&GUID_Key, 228, -2147425268, 0}
+ ,
+ {&GUID_Key, 229, -2147425012, 0}
+ ,
+ {&GUID_Key, 230, -2147424756, 0}
+ ,
+ {&GUID_Key, 231, -2147424500, 0}
+ ,
+ {&GUID_Key, 232, -2147424244, 0}
+ ,
+ {&GUID_Key, 233, -2147423988, 0}
+ ,
+ {&GUID_Key, 234, -2147423732, 0}
+ ,
+ {&GUID_Key, 235, -2147423476, 0}
+ ,
+ {&GUID_Key, 236, -2147423220, 0}
+ ,
+ {&GUID_Key, 237, -2147422964, 0}
+ ,
+ {&GUID_Key, 238, -2147422708, 0}
+ ,
+ {&GUID_Key, 239, -2147422452, 0}
+ ,
+ {&GUID_Key, 240, -2147422196, 0}
+ ,
+ {&GUID_Key, 241, -2147421940, 0}
+ ,
+ {&GUID_Key, 242, -2147421684, 0}
+ ,
+ {&GUID_Key, 243, -2147421428, 0}
+ ,
+ {&GUID_Key, 244, -2147421172, 0}
+ ,
+ {&GUID_Key, 245, -2147420916, 0}
+ ,
+ {&GUID_Key, 246, -2147420660, 0}
+ ,
+ {&GUID_Key, 247, -2147420404, 0}
+ ,
+ {&GUID_Key, 248, -2147420148, 0}
+ ,
+ {&GUID_Key, 249, -2147419892, 0}
+ ,
+ {&GUID_Key, 250, -2147419636, 0}
+ ,
+ {&GUID_Key, 251, -2147419380, 0}
+ ,
+ {&GUID_Key, 252, -2147419124, 0}
+ ,
+ {&GUID_Key, 253, -2147418868, 0}
+ ,
+ {&GUID_Key, 254, -2147418612, 0}
+ ,
+ {&GUID_Key, 255, -2147418356, 0}
+};
+
+const DIDATAFORMAT c_dfDIKeyboard = { 24,
+ 16,
+ 2,
+ 256,
+ 256,
+ rgodf_c_dfDIKeyboard
+};
+
+DIOBJECTDATAFORMAT rgodf_c_dfDIMouse[] = {
+ {&GUID_XAxis, 0, 16776963, 0}
+ ,
+ {&GUID_YAxis, 4, 16776963, 0}
+ ,
+ {&GUID_ZAxis, 8, -2130706685, 0}
+ ,
+ {0, 12, 16776972, 0}
+ ,
+ {0, 13, 16776972, 0}
+ ,
+ {0, 14, -2130706676, 0}
+ ,
+ {0, 15, -2130706676, 0}
+};
+
+const DIDATAFORMAT c_dfDIMouse = { 24,
+ 16,
+ 2,
+ 16,
+ 7,
+ rgodf_c_dfDIMouse
+};
+
+DIOBJECTDATAFORMAT rgodf_c_dfDIJoystick[] = {
+ {&GUID_XAxis, 0, -2130706685, 256}
+ ,
+ {&GUID_YAxis, 4, -2130706685, 256}
+ ,
+ {&GUID_ZAxis, 8, -2130706685, 256}
+ ,
+ {&GUID_RxAxis, 12, -2130706685, 256}
+ ,
+ {&GUID_RyAxis, 16, -2130706685, 256}
+ ,
+ {&GUID_RzAxis, 20, -2130706685, 256}
+ ,
+ {&GUID_Slider, 24, -2130706685, 256}
+ ,
+ {&GUID_Slider, 28, -2130706685, 256}
+ ,
+ {&GUID_POV, 32, -2130706672, 0}
+ ,
+ {&GUID_POV, 36, -2130706672, 0}
+ ,
+ {&GUID_POV, 40, -2130706672, 0}
+ ,
+ {&GUID_POV, 44, -2130706672, 0}
+ ,
+ {0, 48, -2130706676, 0}
+ ,
+ {0, 49, -2130706676, 0}
+ ,
+ {0, 50, -2130706676, 0}
+ ,
+ {0, 51, -2130706676, 0}
+ ,
+ {0, 52, -2130706676, 0}
+ ,
+ {0, 53, -2130706676, 0}
+ ,
+ {0, 54, -2130706676, 0}
+ ,
+ {0, 55, -2130706676, 0}
+ ,
+ {0, 56, -2130706676, 0}
+ ,
+ {0, 57, -2130706676, 0}
+ ,
+ {0, 58, -2130706676, 0}
+ ,
+ {0, 59, -2130706676, 0}
+ ,
+ {0, 60, -2130706676, 0}
+ ,
+ {0, 61, -2130706676, 0}
+ ,
+ {0, 62, -2130706676, 0}
+ ,
+ {0, 63, -2130706676, 0}
+ ,
+ {0, 64, -2130706676, 0}
+ ,
+ {0, 65, -2130706676, 0}
+ ,
+ {0, 66, -2130706676, 0}
+ ,
+ {0, 67, -2130706676, 0}
+ ,
+ {0, 68, -2130706676, 0}
+ ,
+ {0, 69, -2130706676, 0}
+ ,
+ {0, 70, -2130706676, 0}
+ ,
+ {0, 71, -2130706676, 0}
+ ,
+ {0, 72, -2130706676, 0}
+ ,
+ {0, 73, -2130706676, 0}
+ ,
+ {0, 74, -2130706676, 0}
+ ,
+ {0, 75, -2130706676, 0}
+ ,
+ {0, 76, -2130706676, 0}
+ ,
+ {0, 77, -2130706676, 0}
+ ,
+ {0, 78, -2130706676, 0}
+ ,
+ {0, 79, -2130706676, 0}
+};
+
+const DIDATAFORMAT c_dfDIJoystick = { 24,
+ 16,
+ 1,
+ 80,
+ 44,
+ rgodf_c_dfDIJoystick
+};
+
+DIOBJECTDATAFORMAT rgodf_c_dfDIJoystick2[] = {
+ {&GUID_XAxis, 0, -2130706685, 256}
+ ,
+ {&GUID_YAxis, 4, -2130706685, 256}
+ ,
+ {&GUID_ZAxis, 8, -2130706685, 256}
+ ,
+ {&GUID_RxAxis, 12, -2130706685, 256}
+ ,
+ {&GUID_RyAxis, 16, -2130706685, 256}
+ ,
+ {&GUID_RzAxis, 20, -2130706685, 256}
+ ,
+ {&GUID_Slider, 24, -2130706685, 256}
+ ,
+ {&GUID_Slider, 28, -2130706685, 256}
+ ,
+ {&GUID_POV, 32, -2130706672, 0}
+ ,
+ {&GUID_POV, 36, -2130706672, 0}
+ ,
+ {&GUID_POV, 40, -2130706672, 0}
+ ,
+ {&GUID_POV, 44, -2130706672, 0}
+ ,
+ {0, 48, -2130706676, 0}
+ ,
+ {0, 49, -2130706676, 0}
+ ,
+ {0, 50, -2130706676, 0}
+ ,
+ {0, 51, -2130706676, 0}
+ ,
+ {0, 52, -2130706676, 0}
+ ,
+ {0, 53, -2130706676, 0}
+ ,
+ {0, 54, -2130706676, 0}
+ ,
+ {0, 55, -2130706676, 0}
+ ,
+ {0, 56, -2130706676, 0}
+ ,
+ {0, 57, -2130706676, 0}
+ ,
+ {0, 58, -2130706676, 0}
+ ,
+ {0, 59, -2130706676, 0}
+ ,
+ {0, 60, -2130706676, 0}
+ ,
+ {0, 61, -2130706676, 0}
+ ,
+ {0, 62, -2130706676, 0}
+ ,
+ {0, 63, -2130706676, 0}
+ ,
+ {0, 64, -2130706676, 0}
+ ,
+ {0, 65, -2130706676, 0}
+ ,
+ {0, 66, -2130706676, 0}
+ ,
+ {0, 67, -2130706676, 0}
+ ,
+ {0, 68, -2130706676, 0}
+ ,
+ {0, 69, -2130706676, 0}
+ ,
+ {0, 70, -2130706676, 0}
+ ,
+ {0, 71, -2130706676, 0}
+ ,
+ {0, 72, -2130706676, 0}
+ ,
+ {0, 73, -2130706676, 0}
+ ,
+ {0, 74, -2130706676, 0}
+ ,
+ {0, 75, -2130706676, 0}
+ ,
+ {0, 76, -2130706676, 0}
+ ,
+ {0, 77, -2130706676, 0}
+ ,
+ {0, 78, -2130706676, 0}
+ ,
+ {0, 79, -2130706676, 0}
+ ,
+ {0, 80, -2130706676, 0}
+ ,
+ {0, 81, -2130706676, 0}
+ ,
+ {0, 82, -2130706676, 0}
+ ,
+ {0, 83, -2130706676, 0}
+ ,
+ {0, 84, -2130706676, 0}
+ ,
+ {0, 85, -2130706676, 0}
+ ,
+ {0, 86, -2130706676, 0}
+ ,
+ {0, 87, -2130706676, 0}
+ ,
+ {0, 88, -2130706676, 0}
+ ,
+ {0, 89, -2130706676, 0}
+ ,
+ {0, 90, -2130706676, 0}
+ ,
+ {0, 91, -2130706676, 0}
+ ,
+ {0, 92, -2130706676, 0}
+ ,
+ {0, 93, -2130706676, 0}
+ ,
+ {0, 94, -2130706676, 0}
+ ,
+ {0, 95, -2130706676, 0}
+ ,
+ {0, 96, -2130706676, 0}
+ ,
+ {0, 97, -2130706676, 0}
+ ,
+ {0, 98, -2130706676, 0}
+ ,
+ {0, 99, -2130706676, 0}
+ ,
+ {0, 100, -2130706676, 0}
+ ,
+ {0, 101, -2130706676, 0}
+ ,
+ {0, 102, -2130706676, 0}
+ ,
+ {0, 103, -2130706676, 0}
+ ,
+ {0, 104, -2130706676, 0}
+ ,
+ {0, 105, -2130706676, 0}
+ ,
+ {0, 106, -2130706676, 0}
+ ,
+ {0, 107, -2130706676, 0}
+ ,
+ {0, 108, -2130706676, 0}
+ ,
+ {0, 109, -2130706676, 0}
+ ,
+ {0, 110, -2130706676, 0}
+ ,
+ {0, 111, -2130706676, 0}
+ ,
+ {0, 112, -2130706676, 0}
+ ,
+ {0, 113, -2130706676, 0}
+ ,
+ {0, 114, -2130706676, 0}
+ ,
+ {0, 115, -2130706676, 0}
+ ,
+ {0, 116, -2130706676, 0}
+ ,
+ {0, 117, -2130706676, 0}
+ ,
+ {0, 118, -2130706676, 0}
+ ,
+ {0, 119, -2130706676, 0}
+ ,
+ {0, 120, -2130706676, 0}
+ ,
+ {0, 121, -2130706676, 0}
+ ,
+ {0, 122, -2130706676, 0}
+ ,
+ {0, 123, -2130706676, 0}
+ ,
+ {0, 124, -2130706676, 0}
+ ,
+ {0, 125, -2130706676, 0}
+ ,
+ {0, 126, -2130706676, 0}
+ ,
+ {0, 127, -2130706676, 0}
+ ,
+ {0, 128, -2130706676, 0}
+ ,
+ {0, 129, -2130706676, 0}
+ ,
+ {0, 130, -2130706676, 0}
+ ,
+ {0, 131, -2130706676, 0}
+ ,
+ {0, 132, -2130706676, 0}
+ ,
+ {0, 133, -2130706676, 0}
+ ,
+ {0, 134, -2130706676, 0}
+ ,
+ {0, 135, -2130706676, 0}
+ ,
+ {0, 136, -2130706676, 0}
+ ,
+ {0, 137, -2130706676, 0}
+ ,
+ {0, 138, -2130706676, 0}
+ ,
+ {0, 139, -2130706676, 0}
+ ,
+ {0, 140, -2130706676, 0}
+ ,
+ {0, 141, -2130706676, 0}
+ ,
+ {0, 142, -2130706676, 0}
+ ,
+ {0, 143, -2130706676, 0}
+ ,
+ {0, 144, -2130706676, 0}
+ ,
+ {0, 145, -2130706676, 0}
+ ,
+ {0, 146, -2130706676, 0}
+ ,
+ {0, 147, -2130706676, 0}
+ ,
+ {0, 148, -2130706676, 0}
+ ,
+ {0, 149, -2130706676, 0}
+ ,
+ {0, 150, -2130706676, 0}
+ ,
+ {0, 151, -2130706676, 0}
+ ,
+ {0, 152, -2130706676, 0}
+ ,
+ {0, 153, -2130706676, 0}
+ ,
+ {0, 154, -2130706676, 0}
+ ,
+ {0, 155, -2130706676, 0}
+ ,
+ {0, 156, -2130706676, 0}
+ ,
+ {0, 157, -2130706676, 0}
+ ,
+ {0, 158, -2130706676, 0}
+ ,
+ {0, 159, -2130706676, 0}
+ ,
+ {0, 160, -2130706676, 0}
+ ,
+ {0, 161, -2130706676, 0}
+ ,
+ {0, 162, -2130706676, 0}
+ ,
+ {0, 163, -2130706676, 0}
+ ,
+ {0, 164, -2130706676, 0}
+ ,
+ {0, 165, -2130706676, 0}
+ ,
+ {0, 166, -2130706676, 0}
+ ,
+ {0, 167, -2130706676, 0}
+ ,
+ {0, 168, -2130706676, 0}
+ ,
+ {0, 169, -2130706676, 0}
+ ,
+ {0, 170, -2130706676, 0}
+ ,
+ {0, 171, -2130706676, 0}
+ ,
+ {0, 172, -2130706676, 0}
+ ,
+ {0, 173, -2130706676, 0}
+ ,
+ {0, 174, -2130706676, 0}
+ ,
+ {0, 175, -2130706676, 0}
+ ,
+ {&GUID_XAxis, 176, -2130706685, 512}
+ ,
+ {&GUID_YAxis, 180, -2130706685, 512}
+ ,
+ {&GUID_ZAxis, 184, -2130706685, 512}
+ ,
+ {&GUID_RxAxis, 188, -2130706685, 512}
+ ,
+ {&GUID_RyAxis, 192, -2130706685, 512}
+ ,
+ {&GUID_RzAxis, 196, -2130706685, 512}
+ ,
+ {&GUID_Slider, 24, -2130706685, 512}
+ ,
+ {&GUID_Slider, 28, -2130706685, 512}
+ ,
+ {&GUID_XAxis, 208, -2130706685, 768}
+ ,
+ {&GUID_YAxis, 212, -2130706685, 768}
+ ,
+ {&GUID_ZAxis, 216, -2130706685, 768}
+ ,
+ {&GUID_RxAxis, 220, -2130706685, 768}
+ ,
+ {&GUID_RyAxis, 224, -2130706685, 768}
+ ,
+ {&GUID_RzAxis, 228, -2130706685, 768}
+ ,
+ {&GUID_Slider, 24, -2130706685, 768}
+ ,
+ {&GUID_Slider, 28, -2130706685, 768}
+ ,
+ {&GUID_XAxis, 240, -2130706685, 1024}
+ ,
+ {&GUID_YAxis, 244, -2130706685, 1024}
+ ,
+ {&GUID_ZAxis, 248, -2130706685, 1024}
+ ,
+ {&GUID_RxAxis, 252, -2130706685, 1024}
+ ,
+ {&GUID_RyAxis, 256, -2130706685, 1024}
+ ,
+ {&GUID_RzAxis, 260, -2130706685, 1024}
+ ,
+ {&GUID_Slider, 24, -2130706685, 1024}
+ ,
+ {&GUID_Slider, 28, -2130706685, 1024}
+};
+
+const DIDATAFORMAT c_dfDIJoystick2 = { 24,
+ 16,
+ 1,
+ 272,
+ 164,
+ rgodf_c_dfDIJoystick2
+};
+
+
+/* DirectSound */
+
+// Direct Sound Component GUID {47D4D946-62E8-11cf-93BC-444553540000}
+DEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc,
+ 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
+
+// DirectSound Capture Component GUID {B0210780-89CD-11d0-AF08-00A0C925CD16}
+DEFINE_GUID(CLSID_DirectSoundCapture, 0xb0210780, 0x89cd, 0x11d0, 0xaf,
+ 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16);
+#endif
diff --git a/src/ui/ui-drv/win32/installer/XaoS Installer.nsi b/src/ui/ui-drv/win32/installer/XaoS Installer.nsi
new file mode 100644
index 0000000..cfd49ba
--- /dev/null
+++ b/src/ui/ui-drv/win32/installer/XaoS Installer.nsi
@@ -0,0 +1,138 @@
+;--------------------------------
+;Include Modern UI
+
+ !include "MUI2.nsh"
+
+;--------------------------------
+;General
+
+ ;Name and file
+ Name "XaoS"
+ OutFile "XaoS Installer.exe"
+
+ ;Default installation folder
+ InstallDir "$PROGRAMFILES\XaoS"
+
+ ;Get installation folder from registry if available
+ InstallDirRegKey HKLM "Software\XaoS" ""
+
+ ;Request application privileges for Windows Vista
+ RequestExecutionLevel admin
+
+;--------------------------------
+;Variables
+
+ Var StartMenuFolder
+
+;--------------------------------
+;Interface Settings
+
+ !define MUI_HEADERIMAGE
+ !define MUI_HEADERIMAGE_BITMAP "XaoS.bmp"
+ !define MUI_ABORTWARNING
+
+;--------------------------------
+;Language Selection Dialog Settings
+
+ ;Remember the installer language
+ !define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
+ !define MUI_LANGDLL_REGISTRY_KEY "Software\XaoS"
+ !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
+
+;--------------------------------
+;Pages
+
+ !insertmacro MUI_PAGE_WELCOME
+ !insertmacro MUI_PAGE_LICENSE "..\..\..\..\..\copying"
+ !insertmacro MUI_PAGE_DIRECTORY
+
+ ;Start Menu Folder Page Configuration
+ !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
+ !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\XaoS"
+ !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
+
+ !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
+
+ !insertmacro MUI_PAGE_INSTFILES
+ !insertmacro MUI_PAGE_FINISH
+
+ !insertmacro MUI_UNPAGE_WELCOME
+ !insertmacro MUI_UNPAGE_CONFIRM
+ !insertmacro MUI_UNPAGE_INSTFILES
+ !insertmacro MUI_UNPAGE_FINISH
+
+;--------------------------------
+;Languages
+
+ !insertmacro MUI_LANGUAGE "English"
+ !insertmacro MUI_LANGUAGE "French"
+ !insertmacro MUI_LANGUAGE "German"
+ !insertmacro MUI_LANGUAGE "Spanish"
+ !insertmacro MUI_LANGUAGE "Italian"
+ !insertmacro MUI_LANGUAGE "Czech"
+ !insertmacro MUI_LANGUAGE "Hungarian"
+ !insertmacro MUI_LANGUAGE "Romanian"
+
+;--------------------------------
+;Reserve Files
+
+ ;If you are using solid compression, files that are required before
+ ;the actual installation should be stored first in the data block,
+ ;because this will make your installer start faster.
+
+ !insertmacro MUI_RESERVEFILE_LANGDLL
+
+;--------------------------------
+;Installer Sections
+
+Section "XaoS" XaoS
+
+ SetOutPath "$INSTDIR"
+
+ File /r "XaoS\*"
+
+ ;Store installation folder
+ WriteRegStr HKLM "Software\XaoS" "" $INSTDIR
+
+ ;Create uninstaller
+ WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+ !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
+
+ ;Create shortcuts
+ CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
+ CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
+
+ SetOutPath "$INSTDIR\bin"
+
+ CreateShortCut "$SMPROGRAMS\$StartMenuFolder\XaoS.lnk" "$INSTDIR\bin\xaos.exe"
+
+ !insertmacro MUI_STARTMENU_WRITE_END
+
+SectionEnd
+
+;--------------------------------
+;Uninstaller Section
+
+Section "Uninstall"
+
+ RMDir /r /REBOOTOK "$INSTDIR"
+
+ !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
+
+ Delete "$SMPROGRAMS\$StartMenuFolder\XaoS.lnk"
+ Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
+ RMDir "$SMPROGRAMS\$StartMenuFolder"
+
+ DeleteRegKey /ifempty HKLM "Software\XaoS"
+
+SectionEnd
+
+;--------------------------------
+;Uninstaller Functions
+
+Function un.onInit
+
+ !insertmacro MUI_UNGETLANGUAGE
+
+FunctionEnd \ No newline at end of file
diff --git a/src/ui/ui-drv/win32/installer/XaoS.bmp b/src/ui/ui-drv/win32/installer/XaoS.bmp
new file mode 100644
index 0000000..47b4b82
--- /dev/null
+++ b/src/ui/ui-drv/win32/installer/XaoS.bmp
Binary files differ
diff --git a/src/ui/ui-drv/win32/resource.h b/src/ui/ui-drv/win32/resource.h
new file mode 100644
index 0000000..596a030
--- /dev/null
+++ b/src/ui/ui-drv/win32/resource.h
@@ -0,0 +1,3 @@
+/*#define IDI_XAOS_ICON 128
+ #define IDI_SMALL_ICON 129 */
+/*#define IDOK 0 */
diff --git a/src/ui/ui-drv/win32/small.ico b/src/ui/ui-drv/win32/small.ico
new file mode 100644
index 0000000..8481328
--- /dev/null
+++ b/src/ui/ui-drv/win32/small.ico
Binary files differ
diff --git a/src/ui/ui-drv/win32/ui_win32.c b/src/ui/ui-drv/win32/ui_win32.c
new file mode 100644
index 0000000..fff810c
--- /dev/null
+++ b/src/ui/ui-drv/win32/ui_win32.c
@@ -0,0 +1,1886 @@
+/* This file actually implements three drivers (win32 and DirectX
+ windowed/fullscreen) drivers, because they have a lot of common stuff. */
+#include <config.h>
+#ifdef WIN32_DRIVER
+#define _WIN32_WINNT 0x0501 /* Enable access to Windows XP APIs */
+#include <windows.h>
+#ifdef HTML_HELP
+#include <htmlhelp.h>
+#endif
+#ifdef DDRAW_DRIVER
+#include <ddraw.h>
+#endif
+#include <malloc.h>
+#include <string.h>
+#include <stdio.h>
+#include <xmenu.h>
+#include <xerror.h>
+#include "ui.h"
+#include "ui_win32.h"
+#include "resource.h"
+#include "xio.h"
+#include <cursor.h>
+
+#define MAXRESOLUTIONS 256
+#define DXWIDTH 320
+#define DXHEIGHT 200
+#define DXBPP 8
+#define WWIDTH (480+4*48)
+#define WHEIGHT (360+4*36)
+
+#define DXFULLSCREEN 1
+#define DXWINDOWED 2
+
+#define MOUSEWIDTH 16
+#define MOUSEHEIGHT 16
+
+#ifdef HAVE_GETTEXT
+
+#include <libintl.h>
+
+#include <locale.h>
+
+#else
+
+#define gettext(STRING) STRING
+
+#endif
+
+
+
+HINSTANCE hInstance;
+HWND hWnd;
+CONST char *helptopic = "main";
+
+struct ui_driver win32_driver;
+struct ui_driver dxw_driver, dxf_driver;
+
+static int initialized = 0, needredraw = 0;
+
+static char *helpname = NULL;
+
+/* This variables are used by drivers in initializetion */
+static int windowpos;
+static CONST char *size = "520x430";
+static CONST char *dxsize = "320x200x8";
+
+
+/* Display information */
+static int displayX, displayY, bitDepth;
+static int lineSize;
+static int fontWidth, fontHeight;
+static HPALETTE hPalette = NULL;
+static char *buffer1;
+static char *buffer2;
+static int currentbuff = 0;
+static BITMAPINFO *bmp = NULL;
+
+/* Mouse */
+static int mouseX, mouseY, mouseButtons = 0;
+static int captured = 0, tmpcaptured = 0;
+
+/* Keyboard state */
+static int altPressed;
+static int arrowsPressed;
+
+/* WindowProc comunication variables */
+static BOOL closeFlag;
+static int resized = 0;
+static int active = 1;
+
+/* Curent class information */
+static HICON hIcon;
+static HICON hIconSm;
+static HFONT hFont = NULL;
+
+/* DirectX stuff */
+#ifdef DDRAW_DRIVER
+int directX = 0;
+static LPDIRECTDRAWPALETTE dxPalette = NULL;
+static LPDIRECTDRAW lpDD = NULL;
+static LPDIRECTDRAW2 lpDD2 = NULL;
+static LPDIRECTDRAWSURFACE lpSurfaces[2], BackSurface[2];
+static DDSURFACEDESC surface[2];
+static CONST char *mousepointer = mouse_pointer_data;
+static char *storeddata = NULL;
+static HMODULE hModule = NULL;
+static int oldmouseX, oldmouseY;
+#else
+#define directX 0
+#endif
+static PUCHAR backpalette[256][4];
+static HMODULE hModule2;
+static RECT rcWindow;
+static RECT rcViewport;
+static RECT rcScreen;
+static int MyHelpMsg;
+/*clipboard*/
+static WORD clipboard_format;
+
+/* forward declarations */
+#ifdef DDRAW_DRIVER
+static void DeInitDD(void);
+static void PaintDD(void);
+static void UpdateMouseDD(void);
+#endif
+static void Paint(HDC hDC);
+static void CalculateBITMAPINFO(void);
+static void win32_display(void);
+static void DeInitWindow(void);
+
+#ifdef DDRAW_DRIVER
+ /* FIXME: In windowed mode we don't support 8bpp yet! */
+#define DXSUPPORTEDDEPTH(fullscreen,depth) \
+ (!(depth < 8 || (!fullscreen && depth != 16 && depth !=24 && depth != 32)))
+
+static char *store(char *data, int depth, int lpitch, int width,
+ int height, int xpos, int ypos)
+{
+ int d = depth / 8;
+ char *store = malloc(d * MOUSEWIDTH * MOUSEHEIGHT);
+ int y;
+ if (xpos + MOUSEWIDTH > width)
+ xpos = width - MOUSEWIDTH;
+ if (ypos + MOUSEHEIGHT > height)
+ ypos = height - MOUSEHEIGHT;
+ if (xpos < 0)
+ xpos = 0;
+ if (ypos < 0)
+ ypos = 0;
+ for (y = 0; y < MOUSEHEIGHT; y++)
+ memcpy(store + d * MOUSEWIDTH * y,
+ data + xpos * d + (ypos + y) * lpitch, MOUSEWIDTH * d);
+ return store;
+}
+
+static void
+restore(char *data, CONST char *store, int depth, int lpitch, int width,
+ int height, int xpos, int ypos)
+{
+ int y;
+ int d = depth / 8;
+ if (xpos + MOUSEWIDTH > width)
+ xpos = width - MOUSEWIDTH;
+ if (ypos + MOUSEHEIGHT > height)
+ ypos = height - MOUSEHEIGHT;
+ if (xpos < 0)
+ xpos = 0;
+ if (ypos < 0)
+ ypos = 0;
+ for (y = 0; y < MOUSEHEIGHT; y++)
+ memcpy(data + xpos * d + (ypos + y) * lpitch,
+ store + d * MOUSEWIDTH * y, MOUSEWIDTH * d);
+}
+
+static void
+drawmouse(char *data, CONST char *mouse, int depth, int lpitch, int width,
+ int height, int xpos, int ypos)
+{
+ int x, y, z, c;
+ int d = depth / 8;
+ for (y = 0; y < MOUSEWIDTH; y++)
+ for (x = 0; x < MOUSEWIDTH; x++)
+ if (mouse[x + MOUSEWIDTH * y] && x + xpos > 0
+ && (x + xpos) < width && y + ypos > 0
+ && y + ypos < height) {
+ c = mouse[x + MOUSEWIDTH * y] == 2 ? (d ==
+ 1 ? 1 : 255) : 0;
+ for (z = 0; z < d; z++)
+ data[z + d * (x + xpos) + (y + ypos) * lpitch] = c;
+ }
+}
+#endif
+static void getdimens(float *width, float *height)
+{
+ HDC hDC = GetDC(hWnd);
+ *width = GetDeviceCaps(hDC, HORZSIZE) / 10.0;
+ *height = GetDeviceCaps(hDC, VERTSIZE) / 10.0;
+ if (*width > 100 || *width < 1)
+ *width = 29.0;
+ if (*height > 100 || *height < 1)
+ *height = 21.0;
+ ReleaseDC(hWnd, hDC);
+}
+
+static void getres(float *width, float *height)
+{
+ HDC hDC = GetDC(hWnd);
+ *width = 2.54 / GetDeviceCaps(hDC, LOGPIXELSX);
+ *height = 2.54 / GetDeviceCaps(hDC, LOGPIXELSY);
+ ReleaseDC(hWnd, hDC);
+}
+
+/******************************************************************************
+ Win32 driver helper routines
+ */
+
+static LRESULT CALLBACK WindowProc(HWND hWnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ )
+{
+ PAINTSTRUCT paintStruct;
+ HDC hDC;
+ if (uMsg == (unsigned int) MyHelpMsg) {
+ win32_help(NULL, helptopic);
+ return 0;
+ }
+ switch (uMsg) {
+ case WM_COMMAND:
+ win32_pressed(wParam);
+ break;
+ case WM_SIZE:
+ // resize window
+ if (directX == DXFULLSCREEN)
+ return 0;
+ if (LOWORD(lParam) == 0 && HIWORD(lParam) == 0) {
+ active = 0;
+ break;
+ } /*Minimized window */
+ active = 1;
+ if (displayX != LOWORD(lParam) || displayY != HIWORD(lParam))
+ resized = 1;
+ displayX = LOWORD(lParam);
+ displayY = HIWORD(lParam);
+ break;
+ case WM_DISPLAYCHANGE:
+ if (directX == DXFULLSCREEN)
+ return 0;
+ mouseButtons = 0;
+ resized = 1;
+ hDC = GetDC(hWnd);
+ bitDepth = GetDeviceCaps(hDC, BITSPIXEL);
+ ReleaseDC(hWnd, hDC);
+ break;
+ case WM_CLOSE:
+ // close window
+ closeFlag = TRUE;
+ return 0;
+ case WM_MOUSEMOVE:
+ case WM_LBUTTONUP:
+ case WM_LBUTTONDOWN:
+ case WM_RBUTTONUP:
+ case WM_RBUTTONDOWN:
+ case WM_MBUTTONUP:
+ case WM_MBUTTONDOWN:
+ // handle mouse move and mouse buttons
+ mouseButtons = wParam;
+ if (!captured) {
+ if (mouseButtons && !tmpcaptured)
+ SetCapture(hWnd), tmpcaptured = 1;
+ if (!mouseButtons && tmpcaptured)
+ ReleaseCapture(), tmpcaptured = 0;
+ }
+ mouseX = (short) LOWORD(lParam);
+ mouseY = (short) HIWORD(lParam);
+#ifdef DDRAW_DRIVER
+ if (directX == DXFULLSCREEN) {
+ POINT p;
+ GetCursorPos(&p);
+ mouseX = p.x;
+ mouseY = p.y;
+ UpdateMouseDD();
+ }
+#endif
+ break;
+ case WM_PAINT:
+ // redraw screen
+ if (directX == DXFULLSCREEN)
+ return 0;
+ needredraw = 1;
+ if (GetUpdateRect(hWnd, NULL, FALSE)) {
+ HDC hDC = BeginPaint(hWnd, &paintStruct);
+ if (hDC) {
+#ifdef DDRAW_DRIVER
+ if (directX)
+ PaintDD();
+ else
+#endif
+ Paint(hDC);
+ EndPaint(hWnd, &paintStruct);
+ }
+ }
+ return 0;
+ case WM_QUERYNEWPALETTE:
+ // windows calls this when window is reactivated.
+ if (directX == DXFULLSCREEN)
+ return 0;
+ hDC = GetDC(hWnd);
+#ifdef DDRAW_DRIVER
+ if (directX == DXWINDOWED) {
+ if (dxPalette) {
+ IDirectDrawSurface_SetPalette(lpSurfaces[0], dxPalette);
+ IDirectDrawPalette_SetEntries(dxPalette, 0, 0, 255,
+ (PALETTEENTRY *)
+ backpalette);
+ }
+ } else
+#endif
+ {
+ SelectPalette(hDC, hPalette, FALSE);
+ RealizePalette(hDC);
+ }
+ ReleaseDC(hWnd, hDC);
+ return TRUE;
+ case WM_MOVE:
+ if (directX != DXFULLSCREEN) {
+ GetWindowRect(hWnd, &rcWindow);
+ GetClientRect(hWnd, &rcViewport);
+ GetClientRect(hWnd, &rcScreen);
+ ClientToScreen(hWnd, (POINT *) & rcScreen.left);
+ ClientToScreen(hWnd, (POINT *) & rcScreen.right);
+ }
+ break;
+ case WM_SETCURSOR:
+ if (directX == DXFULLSCREEN) {
+ SetCursor(NULL);
+ return TRUE;
+ }
+ break;
+#ifdef DDRAW_DRIVER
+ case WM_ACTIVATEAPP:
+ {
+ int oldactive = active;
+ mouseButtons = 0;
+ if (directX == DXFULLSCREEN) {
+ needredraw = 1;
+ active = (wParam == WA_ACTIVE)
+ || (wParam == WA_CLICKACTIVE) /*(BOOL) wParam */ ;
+ PaintDD();
+ if (!oldactive && active && captured)
+ SetCursor(NULL), SetCapture(hWnd);
+ if (oldactive && !active && captured)
+ ReleaseCapture();
+ return 0L;
+ }
+ }
+#endif
+ break;
+ }
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+}
+
+/*Create Xaos Window. It is either used for normal window mode or
+ as basis for DirectX */
+static int InitWindow(void)
+{
+ int width = CW_USEDEFAULT, height = CW_USEDEFAULT;
+ int xpos = CW_USEDEFAULT, ypos = CW_USEDEFAULT;
+ LOGPALETTE *logPalette;
+ WNDCLASS wndClass;
+ LOGFONT logFont;
+ ATOM a;
+ HDC hDC;
+ TEXTMETRIC textMetric;
+ HGLOBAL oldFont;
+ RECT r;
+ closeFlag = FALSE;
+
+ altPressed = arrowsPressed = 0;
+ if (hIcon == NULL)
+ hIcon = LoadIcon(hInstance, "BIG");
+ mouseButtons = 0;
+ mouseX = 0;
+ mouseY = 0;
+ {
+ static FARPROC proc;
+ if (hModule2 == NULL) {
+ hModule2 = LoadLibrary("user32");
+ proc = GetProcAddress(hModule2, "RegisterClassExA");
+ }
+ if (proc != NULL) {
+ WNDCLASSEX ExWndClass;
+ memset(&ExWndClass, 0, sizeof(WNDCLASSEX));
+ if (hIconSm == NULL)
+ hIconSm = LoadIcon(hInstance, "SMALL");
+ ExWndClass.hIconSm = hIconSm;
+ memset(&ExWndClass, 0, sizeof(WNDCLASSEX));
+ ExWndClass.style = CS_OWNDC;
+ ExWndClass.cbSize = sizeof(WNDCLASSEX);
+ ExWndClass.lpfnWndProc = WindowProc;
+ ExWndClass.hInstance = hInstance;
+ ExWndClass.hIcon = hIcon;
+ ExWndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ ExWndClass.lpszClassName = "XaosWindow";
+ ExWndClass.hbrBackground =
+ (HBRUSH) GetStockObject(BLACK_BRUSH);
+ a = (ATOM) proc(&ExWndClass);
+ } else {
+ memset(&wndClass, 0, sizeof(WNDCLASS));
+ wndClass.style = CS_OWNDC;
+ wndClass.lpfnWndProc = WindowProc;
+ wndClass.hInstance = hInstance;
+ wndClass.hIcon = hIcon;
+ wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wndClass.lpszClassName = "XaosWindow";
+ wndClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
+ a = RegisterClass(&wndClass);
+ }
+ }
+ if (!a) {
+ x_error("Unable to create windows class");
+ return 0;
+ }
+
+ /* First time use defaut size, otherwise use saved sizes */
+ if (sscanf(size, "%ix%ix", &width, &height) != 2) {
+ width = WWIDTH;
+ height = WHEIGHT;
+ }
+ if (windowpos) {
+ xpos = rcWindow.left;
+ ypos = rcWindow.top;
+ width = rcWindow.right - rcWindow.left;
+ height = rcWindow.bottom - rcWindow.top;
+ }
+
+ /* create main window */
+ if (directX == DXFULLSCREEN)
+ hWnd =
+ CreateWindowEx(WS_EX_TOPMOST, "XaoSWindow", "XaoS", WS_POPUP,
+ 0, 0, GetSystemMetrics(SM_CXSCREEN),
+ GetSystemMetrics(SM_CYSCREEN), NULL, NULL,
+ hInstance, NULL);
+ else
+
+ hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, "XaoSWindow", "XaoS",
+ WS_OVERLAPPEDWINDOW | WS_EX_LEFTSCROLLBAR,
+ xpos, ypos, width, height, NULL, NULL,
+ hInstance, NULL);
+
+ if (!hWnd) {
+ x_error("Unable to create app window");
+ return 0;
+ }
+
+ clipboard_format = RegisterClipboardFormat("image/x-xaos.position");
+
+
+ /* create font */
+ memset(&logFont, 0, sizeof(LOGFONT));
+ hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
+ logFont.lfHeight = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72);
+ logFont.lfWeight = FW_NORMAL;
+ logFont.lfPitchAndFamily = FIXED_PITCH;
+ strcpy(logFont.lfFaceName, "Courier");
+
+ hFont = CreateFontIndirect(&logFont);
+ oldFont = SelectObject(hDC, hFont);
+ GetTextMetrics(hDC, &textMetric);
+ SelectObject(hDC, oldFont);
+ DeleteDC(hDC);
+
+ fontHeight = textMetric.tmHeight;
+ fontWidth = textMetric.tmAveCharWidth;
+
+ ShowWindow(hWnd, SW_NORMAL);
+
+ GetClientRect(hWnd, &r);
+ displayX = r.right;
+ displayY = r.bottom;
+
+ /* create palette */
+ CalculateBITMAPINFO(); /* calculate BITMAPINFO structure */
+ logPalette = malloc(sizeof(LOGPALETTE) + 4 * 256);
+ logPalette->palVersion = 0x300;
+ logPalette->palNumEntries = 256;
+ memcpy(logPalette->palPalEntry, bmp->bmiColors, 4 * 256);
+ hPalette = CreatePalette(logPalette);
+ free(logPalette);
+
+ /* select and realize palette */
+ hDC = GetDC(hWnd);
+ SelectPalette(hDC, hPalette, FALSE);
+ RealizePalette(hDC);
+ ReleaseDC(hWnd, hDC);
+
+ // increase priority of XaoS
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
+
+ MyHelpMsg = RegisterWindowMessage(HELPMSGSTRING);
+
+ return 1;
+}
+
+static void DeInitWindow()
+{
+ if (tmpcaptured)
+ ReleaseCapture();
+ if (directX != DXFULLSCREEN)
+ windowpos = 1, GetWindowRect(hWnd, &rcWindow);
+ /* normalize priority */
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
+ if (helpname)
+ WinHelp(hWnd, helpname, HELP_QUIT, 0), free(helpname), helpname =
+ NULL;
+
+ /* destroy windows and other objects */
+ DeleteObject(hFont);
+ DestroyWindow(hWnd);
+ UnregisterClass("XaosWindow", hInstance);
+ if (bmp) {
+ free(bmp);
+ bmp = NULL;
+ }
+ if (hModule2 != NULL)
+ FreeLibrary(hModule2);
+ hModule2 = NULL;
+ win32_uninitializewindows();
+}
+
+/* Display buffer to screen */
+static void Paint(HDC hDC)
+{
+ if (!initialized || !buffer1)
+ return;
+ StretchDIBits(hDC, 0, 0, displayX, displayY,
+ 0, 0, displayX, displayY,
+ (currentbuff == 0) ? buffer1 : buffer2,
+ bmp, DIB_RGB_COLORS, SRCCOPY);
+ needredraw = 0;
+}
+
+
+
+static int Init(void)
+{
+ HDC hDC;
+ buffer1 = buffer2 = NULL;
+
+ // get bit depth
+ hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
+ bitDepth = GetDeviceCaps(hDC, BITSPIXEL);
+ if (bitDepth < 8)
+ bitDepth = 16;
+ if (bitDepth < 10)
+ bitDepth = 8;
+ if (bitDepth >= 10 && bitDepth < 20)
+ bitDepth = 16;
+ if (bitDepth >= 20 && bitDepth < 28)
+ bitDepth = 24;
+ if (bitDepth >= 32 && bitDepth < 32)
+ bitDepth = 32;
+ DeleteDC(hDC);
+
+ // create windows and other objects
+ if (!InitWindow())
+ return 0;
+
+ CalculateBITMAPINFO(); /* calculate BITMAPINFO structure */
+
+
+ return 1;
+}
+
+static void getmouse(int *mx, int *my, int *mb)
+{
+ *mb = 0;
+ if (mouseButtons & MK_LBUTTON)
+ *mb |= 256;
+ if (mouseButtons & MK_MBUTTON)
+ *mb |= 512;
+ if (mouseButtons & MK_RBUTTON)
+ *mb |= 1024;
+ *mx = mouseX;
+ *my = mouseY;
+}
+
+static void
+Processevents(int wait, int *mx, int *my, int *mb, int *k, int *c)
+{
+ MSG msg;
+ int r;
+ if (wait) {
+ // wait for message if in wait mode
+ r = GetMessage(&msg, hWnd, 0, 0);
+ wait = 0;
+ } else {
+ // don't wait for message
+ r = PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE);
+ }
+#if 0
+ if (needredraw) {
+ if (directX)
+ PaintDD();
+ else
+ win32_display();
+ }
+#endif
+ if (r > 0) {
+ if (msg.message == WM_CHAR) {
+ // ascii char
+ *c = msg.wParam;
+ }
+ if (msg.message == WM_KEYUP)
+ switch (msg.wParam) {
+ case VK_MENU:
+ altPressed = 0;
+ break;
+ case VK_UP:
+ arrowsPressed &= ~4;
+ break;
+ case VK_DOWN:
+ arrowsPressed &= ~8;
+ break;
+ case VK_LEFT:
+ arrowsPressed &= ~1;
+ break;
+ case VK_RIGHT:
+ arrowsPressed &= ~2;
+ break;
+ }
+ if (msg.message == WM_KEYDOWN) {
+ // any key
+ switch (msg.wParam) {
+ case VK_MENU:
+ /*x_message("Alt"); */
+ altPressed = 1;
+ break;
+ case VK_UP:
+ *c = UIKEY_UP;
+ arrowsPressed |= 4;
+ break;
+ case VK_DOWN:
+ *c = UIKEY_DOWN;
+ arrowsPressed |= 8;
+ break;
+ case VK_LEFT:
+ *c = UIKEY_LEFT;
+ arrowsPressed |= 1;
+ break;
+ case VK_RIGHT:
+ *c = UIKEY_RIGHT;
+ arrowsPressed |= 2;
+ break;
+ case VK_ESCAPE:
+ *c = UIKEY_ESC;
+ break;
+ case VK_BACK:
+ *c = UIKEY_BACKSPACE;
+ break;
+ case VK_TAB:
+ *c = UIKEY_TAB;
+ break;
+ case VK_HOME:
+ *c = UIKEY_HOME;
+ break;
+ case VK_END:
+ *c = UIKEY_END;
+ break;
+ case VK_PRIOR:
+ *c = UIKEY_PGUP;
+ break;
+ case VK_NEXT:
+ *c = UIKEY_PGDOWN;
+ break;
+#ifdef DDRAW_DRIVER
+ case VK_RETURN:
+ /*x_message("Enter %i",altPressed); */
+ if (altPressed) {
+ HDC hDC;
+ CONST char *cmd;
+ CONST menuitem *item;
+ if (directX == DXFULLSCREEN) {
+ int depth;
+ cmd = "dX-windowed";
+ hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
+ depth = GetDeviceCaps(hDC, BITSPIXEL);
+ DeleteDC(hDC);
+ if (!DXSUPPORTEDDEPTH(0, depth))
+ cmd = "win32";
+ } else {
+ cmd = "dX-fullscreen";
+ }
+ item = menu_findcommand(cmd);
+ ui_menuactivate(item, NULL);
+ }
+ break;
+#endif
+ }
+ }
+ // forward messages to window
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ getmouse(mx, my, mb); // get mouse position
+
+ *k = arrowsPressed;
+
+ if (closeFlag)
+ *c = -2; // force quit if so requested
+
+}
+
+// calculate BITMAPINFO structure. It is used to copy bitmaps
+static void CalculateBITMAPINFO()
+{
+ int i;
+ if (!bmp)
+ bmp = (BITMAPINFO *) malloc(sizeof(BITMAPINFOHEADER) + 4 * 256);
+
+ memset(bmp, 0, sizeof(BITMAPINFOHEADER));
+ bmp->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmp->bmiHeader.biWidth = displayX;
+ bmp->bmiHeader.biHeight = -displayY;
+ bmp->bmiHeader.biPlanes = 1;
+ bmp->bmiHeader.biBitCount = bitDepth;
+
+ // create default palette
+ for (i = 0; i < 256; i++) {
+ bmp->bmiColors[i].rgbRed = i;
+ bmp->bmiColors[i].rgbGreen = i;
+ bmp->bmiColors[i].rgbBlue = i;
+ }
+}
+
+#ifdef DDRAW_DRIVER
+
+/**************************************************************************************
+ DirectDraw driver helper routines
+ */
+static char *resstr[MAXRESOLUTIONS];
+static struct resolutions {
+ int width, height;
+} ressize[MAXRESOLUTIONS];
+static int nresolutions;
+/* callback for DirectX resolutions */
+static HRESULT WINAPI
+EnumModesCallback(LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext)
+{
+ if (nresolutions < MAXRESOLUTIONS)
+ if (lpDDSurfaceDesc->ddpfPixelFormat.u1.dwRGBBitCount == 8 ||
+ lpDDSurfaceDesc->ddpfPixelFormat.u1.dwRGBBitCount == 16 ||
+ lpDDSurfaceDesc->ddpfPixelFormat.u1.dwRGBBitCount == 24 ||
+ lpDDSurfaceDesc->ddpfPixelFormat.u1.dwRGBBitCount == 32) {
+ int i;
+ char s[20];
+ for (i = 0; i < nresolutions; i++)
+ if ((int) ressize[i].width ==
+ (int) lpDDSurfaceDesc->dwWidth
+ && (int) ressize[i].height ==
+ (int) lpDDSurfaceDesc->dwHeight)
+ return DDENUMRET_OK;
+ ressize[nresolutions].width = lpDDSurfaceDesc->dwWidth;
+ ressize[nresolutions].height = lpDDSurfaceDesc->dwHeight;
+ sprintf(s, "%ix%i", lpDDSurfaceDesc->dwWidth,
+ lpDDSurfaceDesc->dwHeight);
+ resstr[nresolutions] = strdup(s);
+ nresolutions++;
+ }
+ return DDENUMRET_OK;
+}
+
+typedef HRESULT WINAPI(*ddrawcreateptr) (GUID FAR * lpGUID,
+ LPDIRECTDRAW FAR * lplpDD,
+ IUnknown FAR * pUnkOuter);
+static ddrawcreateptr DirectDrawCreatePtr;
+
+static int ResizeDD(int fullscreen)
+{
+ HRESULT ddrval;
+ DDSURFACEDESC ddsd;
+ /*DDCAPS2 ddscaps; */
+ LPDIRECTDRAWCLIPPER pClipper;
+ int dxwidth;
+ int dxheight;
+ int dxbpp;
+
+ // free DirectX objects
+ if (lpSurfaces[0])
+ IDirectDrawSurface_Release(lpSurfaces[0]);
+ lpSurfaces[0] = NULL;
+ if (dxPalette)
+ IDirectDrawPalette_Release(dxPalette);
+ dxPalette = NULL;
+ /* Set cooperative level */
+ ddrval = IDirectDraw2_SetCooperativeLevel(lpDD2, hWnd,
+ fullscreen
+ ? (DDSCL_FULLSCREEN |
+ DDSCL_EXCLUSIVE |
+ DDSCL_ALLOWREBOOT)
+ : DDSCL_NORMAL);
+ if (ddrval != DD_OK) {
+ DeInitDD();
+ x_error("Failed to set cooperative level");
+ return 0;
+ }
+
+ if (fullscreen) {
+ if (sscanf(dxsize, "%ix%ix%i", &dxwidth, &dxheight, &dxbpp) != 3) {
+ dxwidth = DXWIDTH;
+ dxheight = DXHEIGHT;
+ dxbpp = DXBPP;
+ }
+ displayX = dxwidth;
+ displayY = dxheight;
+ bitDepth = dxbpp;
+ if (bitDepth < 10)
+ bitDepth = 8;
+ if (bitDepth >= 10 && bitDepth < 20)
+ bitDepth = 16;
+ if (bitDepth >= 20 && bitDepth < 28)
+ bitDepth = 24;
+ if (bitDepth >= 32 && bitDepth < 32)
+ bitDepth = 32;
+
+ /* set resolution and bit depth */
+ ddrval =
+ IDirectDraw2_SetDisplayMode(lpDD2, displayX, displayY,
+ bitDepth, 0, 0);
+ if (ddrval != DD_OK) {
+ /* The display mode cannot be changed.
+ The mode is either not supported or
+ another application has exclusive mode.
+
+ Try 320x200x256 and 640x480x256 modes before giving up */
+ displayX = 320;
+ displayY = 200;
+ bitDepth = 8;
+ ddrval =
+ IDirectDraw2_SetDisplayMode(lpDD2, displayX, displayY,
+ bitDepth, 0, 0);
+ if (ddrval != DD_OK) {
+ displayY = 240;
+ if (ddrval != DD_OK) {
+ displayX = 640;
+ displayY = 480;
+ ddrval =
+ IDirectDraw2_SetDisplayMode(lpDD2, displayX,
+ displayY, bitDepth, 0,
+ 0);
+ if (ddrval != DD_OK) {
+ /* Bad luck... give up. */
+ DeInitDD();
+ return 0;
+ }
+ }
+ }
+ }
+ SetRect(&rcViewport, 0, 0, displayX, displayY);
+ rcScreen = rcViewport;
+ } else {
+ /* Get the dimensions of the viewport and screen bounds */
+ GetClientRect(hWnd, &rcViewport);
+ GetClientRect(hWnd, &rcScreen);
+ ClientToScreen(hWnd, (POINT *) & rcScreen.left);
+ ClientToScreen(hWnd, (POINT *) & rcScreen.right);
+ /*bitDepth = GetDeviceCaps (hDC, BITSPIXEL); */
+
+ /* Create clipper object for window */
+ ddrval = IDirectDraw_CreateClipper(lpDD, 0, &pClipper, NULL);
+ if (ddrval != DD_OK) {
+ DeInitDD();
+ x_error("Failed to create clipper object");
+ return 0;
+ }
+ /* Asociate it */
+ IDirectDrawClipper_SetHWnd(pClipper, 0, hWnd);
+ }
+ /* Create the primary surface with one back buffer */
+ CalculateBITMAPINFO(); // calculate BITMAPINFO structure
+
+ memset(&ddsd, 0, sizeof(ddsd));
+ ddsd.dwSize = sizeof(ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ ddrval = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpSurfaces[0], NULL);
+ if (ddrval != DD_OK) {
+ DeInitDD();
+ x_error("Failed to create flipping surface");
+ return 0;
+ }
+
+ if (!fullscreen) {
+ IDirectDrawSurface_SetClipper(lpSurfaces[0], pClipper);
+ IDirectDrawClipper_Release(pClipper);
+ if (IDirectDrawSurface_GetSurfaceDesc(lpSurfaces[0], &ddsd) !=
+ DD_OK) {
+ DeInitDD();
+ x_error("Failed to get pixel format");
+ return 0;
+ }
+ bitDepth = ddsd.ddpfPixelFormat.u1.dwRGBBitCount;
+ }
+
+ if (bitDepth == 8) {
+ /* create palette */
+ ddrval =
+ IDirectDraw_CreatePalette(lpDD, DDPCAPS_8BIT,
+ (LPPALETTEENTRY) bmp->bmiColors,
+ &dxPalette, NULL);
+ if (ddrval != DD_OK) {
+ DeInitDD();
+ x_error("Failed to create palette");
+ return 0;
+ }
+
+ /* set palette */
+ IDirectDrawSurface_SetPalette(lpSurfaces[0], dxPalette);
+ }
+ if (fullscreen)
+ SetCursor(NULL);
+ needredraw = 1;
+ return 1;
+
+}
+
+/* init DirectX */
+static int InitDD(int fullscreen)
+{
+ HRESULT ddrval;
+ HDC hDC;
+ directX = fullscreen ? DXFULLSCREEN : DXWINDOWED;
+
+ if (!hModule)
+ hModule = LoadLibrary("ddraw");
+ if (!hModule) {
+ /*x_error ("Unable to load DirectX (ddraw.dll)"); */
+ return 0;
+ }
+ /* DirectDraw don't support 16 color modes. Don't even try to initialize
+ it then. Also avoid unsupported bit depths in the windowed driver */
+ hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
+ bitDepth = GetDeviceCaps(hDC, BITSPIXEL);
+ DeleteDC(hDC);
+
+ if (!DXSUPPORTEDDEPTH(fullscreen, bitDepth))
+ return 0;
+
+
+ DirectDrawCreatePtr =
+ (ddrawcreateptr) GetProcAddress(hModule, "DirectDrawCreate");
+ if (!DirectDrawCreatePtr) {
+ x_error
+ ("Unable to get hook DirectDrawCreate in ddraw.dll. Check your DirectX installation");
+ return 0;
+ }
+
+ lpDD = NULL;
+ lpDD2 = NULL;
+ lpSurfaces[0] = NULL;
+ lpSurfaces[1] = NULL;
+ buffer1 = buffer2 = NULL;
+
+ bitDepth = 8;
+
+ InitWindow();
+ UpdateWindow(hWnd);
+ SetFocus(hWnd);
+
+
+ /* contact DirectX */
+ ddrval = DirectDrawCreatePtr(NULL, &lpDD, NULL);
+ if (ddrval != DD_OK) {
+ DeInitDD();
+ x_error("Failed to create DirectDraw object");
+ return 0;
+ }
+
+ /* get IDirectDraw2 interface */
+ ddrval =
+ IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2,
+ (LPVOID *) & lpDD2);
+ if (ddrval != DD_OK) {
+ DeInitDD();
+ x_error("Failed to get DirectDraw2 object");
+ return 0;
+ }
+ /* enumerate modes */
+#ifdef DDRAW_DRIVER
+ if (!nresolutions && directX == DXFULLSCREEN)
+ IDirectDraw2_EnumDisplayModes(lpDD2, 0, NULL, NULL,
+ EnumModesCallback);
+#endif
+
+
+ if (!ResizeDD(fullscreen))
+ return 0;
+ if (fullscreen) {
+ SetCapture(hWnd); // make sure no other windows get mouse messages
+
+ captured = 1;
+ }
+
+ return 1;
+}
+
+/* uninitialize DirectX */
+static void DeInitDD(void)
+{
+ if (captured)
+ ReleaseCapture(), captured = 0; // free mouse
+
+ // free DirectX objects
+ if (lpSurfaces[0])
+ IDirectDrawSurface_Release(lpSurfaces[0]);
+ lpSurfaces[0] = NULL;
+ if (BackSurface[0])
+ IDirectDrawSurface_Release(BackSurface[0]);
+ BackSurface[0] = NULL;
+ if (BackSurface[1])
+ IDirectDrawSurface_Release(BackSurface[1]);
+ BackSurface[1] = NULL;
+ if (dxPalette)
+ IDirectDrawPalette_Release(dxPalette);
+ dxPalette = NULL;
+ if (lpDD2)
+ IDirectDraw2_Release(lpDD2);
+ lpDD2 = NULL;
+ if (lpDD)
+ IDirectDraw_Release(lpDD);
+ lpDD = NULL;
+ DeInitWindow();
+ if (hModule != NULL)
+ FreeLibrary(hModule), hModule = NULL;
+ hWnd = NULL;
+ directX = 0;
+}
+
+static LRESULT CALLBACK WindowProc(HWND hwnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ );
+static void UpdateMouseDD()
+{
+ DDSURFACEDESC m_surface;
+ PUCHAR dst;
+ DWORD ddrval;
+ memset(&m_surface, 0, sizeof(DDSURFACEDESC));
+ m_surface.dwSize = sizeof(DDSURFACEDESC);
+ ddrval = IDirectDrawSurface_Lock(lpSurfaces[0], NULL, &m_surface,
+ DDLOCK_WAIT, NULL);
+ if (ddrval != DD_OK) {
+ return;
+ }
+
+ dst = (PUCHAR) m_surface.lpSurface;
+ if (storeddata) {
+ restore(dst, storeddata, bitDepth, m_surface.u1.lPitch, displayX,
+ displayY, oldmouseX, oldmouseY);
+ free(storeddata);
+ }
+ storeddata =
+ store(dst, bitDepth, m_surface.u1.lPitch, displayX, displayY,
+ mouseX, mouseY);
+ drawmouse(dst, mousepointer, bitDepth, m_surface.u1.lPitch, displayX,
+ displayY, mouseX, mouseY);
+ oldmouseX = mouseX;
+ oldmouseY = mouseY;
+ IDirectDrawSurface_Unlock(lpSurfaces[0], m_surface.lpSurface);
+}
+
+/* Display buffer */
+static void PaintDD()
+{
+ DWORD ddrval;
+ if (!IsWindowVisible(hWnd) || !active || !initialized
+ || !BackSurface[0])
+ return;
+ IDirectDrawSurface_Unlock(BackSurface[0], surface[0].lpSurface);
+ IDirectDrawSurface_Unlock(BackSurface[1], surface[1].lpSurface);
+ if (directX == DXFULLSCREEN) {
+ if (storeddata)
+ free(storeddata), storeddata = NULL;
+ storeddata =
+ store(currentbuff ? buffer2 : buffer1, bitDepth, lineSize,
+ displayX, displayY, mouseX, mouseY);
+ drawmouse(currentbuff ? buffer2 : buffer1, mousepointer, bitDepth,
+ lineSize, displayX, displayY, mouseX, mouseY);
+ ddrval =
+ IDirectDrawSurface_BltFast(lpSurfaces[0], 0, 0,
+ BackSurface[currentbuff], &rcScreen,
+ FALSE);
+ restore(currentbuff ? buffer2 : buffer1, storeddata, bitDepth,
+ lineSize, displayX, displayY, mouseX, mouseY);
+ oldmouseX = mouseX;
+ oldmouseY = mouseY;
+ } else {
+ ddrval = IDirectDrawSurface_Blt(lpSurfaces[0], &rcScreen,
+ BackSurface[currentbuff],
+ &rcViewport, DDBLT_WAIT, NULL);
+ }
+ if (ddrval != DD_OK) {
+ if ((int) ddrval == (int) DDERR_SURFACELOST) {
+ IDirectDrawSurface_Restore(lpSurfaces[0]);
+ IDirectDrawSurface_Restore(BackSurface[0]);
+ IDirectDrawSurface_Restore(BackSurface[1]);
+ ddrval = IDirectDrawSurface_Blt(lpSurfaces[0], &rcScreen,
+ BackSurface[currentbuff],
+ &rcViewport, DDBLT_WAIT, NULL);
+ //if (ddrval == DDERR_SURFACELOST) resized=1; /*We've lost our fractal*/
+ }
+ }
+ ddrval = IDirectDrawSurface_Lock(BackSurface[0], NULL, &surface[0],
+ DDLOCK_WAIT, NULL);
+ ddrval = IDirectDrawSurface_Lock(BackSurface[1], NULL, &surface[1],
+ DDLOCK_WAIT, NULL);
+ if (buffer1 != (char *) surface[0].lpSurface ||
+ buffer2 != (char *) surface[1].lpSurface) {
+ DeInitDD();
+ x_fatalerror
+ ("Unexpected event - buffers moved! Please contact authors!");
+ }
+ needredraw = 0;
+
+}
+#endif
+
+/**************************************************************************************
+ Drivers implementation
+ */
+
+
+
+static void flip_buffers(void)
+{
+ currentbuff ^= 1;
+}
+
+
+static void processevents(int wait, int *mx, int *my, int *mb, int *k)
+{
+ int c = -1;
+ *mb = 0;
+ *k = 0;
+ Processevents(wait, mx, my, mb, k, &c);
+ if (c > -1) {
+ ui_key(c);
+ }
+
+ if (c == -2)
+ ui_quit(); // -2 signals program exit
+
+ if (resized) {
+ ui_resize(); // tell Xaos to resize
+
+ }
+}
+
+static void print(int x, int y, CONST char *text)
+{
+ HDC hDC;
+ static char current[256];
+ char s[256];
+#ifdef DDRAW_DRIVER
+ if (directX == DXFULLSCREEN) {
+ HGLOBAL oldFont;
+ if (IDirectDrawSurface_GetDC(lpSurfaces[0], &hDC) != DD_OK)
+ return;
+ SetTextColor(hDC, 0xffffff);
+ SetBkColor(hDC, 0x000000);
+ oldFont = SelectObject(hDC, hFont);
+ ExtTextOut(hDC, x, y, 0, NULL, text, strlen(text), NULL);
+ SelectObject(hDC, oldFont);
+ IDirectDrawSurface_ReleaseDC(lpSurfaces[0], hDC);
+ return;
+ }
+#endif
+ if (!text[0])
+ strcpy(s, "XaoS");
+ else
+ sprintf(s, "XaoS - %s", text);
+ if (strcmp(current, s))
+ strcpy(current, s), SetWindowText(hWnd, s);
+}
+
+static void mousetype(int type)
+{
+ char *cursor;
+ switch (type) {
+ default:
+ case 0:
+ cursor = IDC_ARROW;
+ break;
+ case 1:
+ cursor = IDC_WAIT;
+ break;
+ case 2:
+ cursor = IDC_NO;
+ break;
+ }
+ SetCursor(LoadCursor(NULL, cursor));
+}
+
+static void set_palette(ui_palette pal1, int start, int end)
+{
+ PUCHAR pal = (PUCHAR) pal1;
+ HDC hDC;
+ int i;
+ // store new palette entries locally
+ memcpy(backpalette + 4 * start, pal, (end - start) * 4);
+ for (i = start; i <= end; i++) {
+ bmp->bmiColors[i].rgbRed = *(pal + 4 * (i - start) + 0);
+ bmp->bmiColors[i].rgbGreen = *(pal + 4 * (i - start) + 1);
+ bmp->bmiColors[i].rgbBlue = *(pal + 4 * (i - start) + 2);
+ bmp->bmiColors[i].rgbReserved = 0;
+ }
+ // update window/screen
+#ifdef DDRAW_DRIVER
+ if (directX) {
+ IDirectDrawPalette_SetEntries(dxPalette, 0, start, end - start + 1,
+ (PALETTEENTRY *) pal);
+ } else
+#endif
+ {
+ SetPaletteEntries(hPalette, start, end - start + 1,
+ (PALETTEENTRY *) pal);
+ hDC = GetDC(hWnd);
+ UnrealizeObject(hPalette);
+ RealizePalette(hDC);
+ ReleaseDC(hWnd, hDC);
+ win32_display();
+ }
+}
+
+static void win32_copy(struct uih_context *uih)
+{
+ char *c = ui_getpos();
+ HANDLE hData = GlobalAlloc(GMEM_DDESHARE, strlen(c) + 1);
+ char *data;
+ if (!hData) {
+ x_error("Out of memory");
+ free(c);
+ return;
+ }
+ if (!(data = GlobalLock(hData))) {
+ x_error("Out of memory");
+ free(c);
+ return;
+ }
+ memcpy(hData, c, strlen(c) + 1);
+ GlobalUnlock(hData);
+ if (OpenClipboard(hWnd)) {
+ EmptyClipboard();
+ SetClipboardData(clipboard_format, hData);
+ }
+ free(c);
+}
+
+static void win32_paste(void)
+{
+ if (OpenClipboard(hWnd)) {
+ HANDLE hClipData;
+ char *text;
+ if (!(hClipData = GetClipboardData(clipboard_format))) {
+ CloseClipboard();
+ return;
+ }
+ if (!(text = GlobalLock(hClipData))) {
+ x_error("Out of memory");
+ CloseClipboard();
+ }
+ ui_loadstr(strdup(text));
+ GlobalUnlock(hClipData);
+ CloseClipboard();
+ }
+}
+
+#define MAX_MENUITEMS_I18N 7
+static menuitem menuitems_i18n[MAX_MENUITEMS_I18N];
+
+int uiw_no_menuitems_i18n, uiw_no_cutpasteitems_i18n;
+
+static menuitem *cutpasteitems;
+static void add_cutpasteitems()
+{
+ // General method (not needed currently):
+ int no_menuitems_i18n = uiw_no_menuitems_i18n; /* This variable must be local. */
+ MENUSEPARATOR_I("edit");
+ MENUNOP_I("edit", NULL, gettext("Copy"), "copy", 0, win32_copy);
+ MENUNOP_I("edit", NULL, gettext("Paste"), "paste", 0, win32_paste);
+ MENUNOP_I("misc", NULL, "Generate .dlg files", "genresources", 0,
+ win32_genresources);
+ MENUSEPARATOR_I("helpmenu");
+ MENUNOP_I("helpmenu", NULL, gettext("About"), "about", 0, AboutBox);
+ no_menuitems_i18n -= uiw_no_menuitems_i18n;
+ cutpasteitems = &(menuitems_i18n[uiw_no_menuitems_i18n]);
+ uiw_no_cutpasteitems_i18n = no_menuitems_i18n;
+ menu_add(cutpasteitems, uiw_no_cutpasteitems_i18n);
+ uiw_no_menuitems_i18n += no_menuitems_i18n;
+
+}
+
+
+static int win32_init(void)
+{
+ int r;
+
+#ifdef DDRAW_DRIVER
+ directX = 0;
+#endif
+ r = Init();
+ if (!r)
+ return r;
+ win32_driver.textwidth = fontWidth;
+ win32_driver.textheight = fontHeight;
+ getres(&win32_driver.width, &win32_driver.height);
+ win32_createrootmenu();
+ uiw_no_menuitems_i18n = 0;
+ add_cutpasteitems();
+ return r;
+}
+
+static void win32_uninitialize(void)
+{
+ DeInitWindow();
+ menu_delete(cutpasteitems, uiw_no_cutpasteitems_i18n);
+}
+
+static void win32_getsize(int *width, int *height)
+{
+ resized = 0;
+ *width = displayX;
+ *height = displayY;
+ switch (bitDepth) {
+ case 8:
+ win32_driver.imagetype = UI_C256;
+ break;
+ case 16:
+ /* Windows seems to always use 15bpp mode */
+ win32_driver.imagetype = UI_TRUECOLOR16;
+ win32_driver.rmask = 31 * 32 * 32;
+ win32_driver.gmask = 31 * 32;
+ win32_driver.bmask = 31;
+ break;
+ case 24:
+ win32_driver.imagetype = UI_TRUECOLOR24;
+ win32_driver.rmask = 0xff0000;
+ win32_driver.gmask = 0x00ff00;
+ win32_driver.bmask = 0x0000ff;
+ break;
+ case 32:
+ win32_driver.imagetype = UI_TRUECOLOR;
+ win32_driver.rmask = 0xff0000;
+ win32_driver.gmask = 0x00ff00;
+ win32_driver.bmask = 0x0000ff;
+ break;
+ }
+ CalculateBITMAPINFO();
+}
+
+
+
+static void win32_display()
+{
+ HDC hDC = GetDC(hWnd);
+ if (IsWindowVisible(hWnd))
+ Paint(hDC);
+ ReleaseDC(hWnd, hDC);
+}
+
+static int win32_alloc_buffers(char **b1, char **b2)
+{
+ currentbuff = 0;
+ // calculate DWORD aligned line length
+ lineSize = displayX * ((bitDepth + 7) / 8);
+ lineSize += 3 - ((lineSize - 1) & 3);
+
+ buffer1 = (char *) malloc(displayY * lineSize);
+ buffer2 = (char *) malloc(displayY * lineSize);
+ *b1 = buffer1;
+ *b2 = buffer2;
+ initialized = 1;
+ return lineSize;
+}
+
+static void win32_free_buffers(char *b1, char *b2)
+{
+ initialized = 0;
+ free(buffer1);
+ free(buffer2);
+ buffer1 = buffer2 = NULL;
+}
+
+static CONST char *CONST dx_depth[] = { "8bpp (256 colors)",
+ "16bpp (65536 colors)",
+ "24bpp (16777216 colors)",
+ "32bpp (16777216 colors)",
+ NULL
+};
+
+#ifdef DDRAW_DRIVER
+static menudialog dx_resdialog[] = {
+ DIALOGCHOICE("Resolution", resstr, 0),
+ DIALOGCHOICE("Depth", dx_depth, 0),
+ {NULL}
+};
+
+static menudialog *dx_resizedialog(struct uih_context *c)
+{
+ int i;
+ switch (bitDepth) {
+ case 8:
+ dx_resdialog[1].defint = 0;
+ break;
+ case 16:
+ dx_resdialog[1].defint = 1;
+ break;
+ case 24:
+ dx_resdialog[1].defint = 2;
+ break;
+ case 32:
+ dx_resdialog[1].defint = 3;
+ }
+ for (i = 0; i < MAXRESOLUTIONS; i++)
+ if (displayX == ressize[i].width && displayY == ressize[i].height) {
+ dx_resdialog[0].defint = i;
+ break;
+ }
+ return dx_resdialog;
+}
+
+static void dx_resize(struct uih_context *c, dialogparam * p)
+{
+ static char s[10];
+ CONST static char *CONST st[] = { "8", "16", "24", "32" };
+ sprintf(s, "%sx%s", resstr[p[0].dint], st[p[1].dint]);
+ dxsize = s;
+ resized = 1;
+ ui_call_resize();
+}
+
+int uiw_no_resizeitems_i18n;
+
+static menuitem *resizeitems;
+
+static void add_resizeitems()
+{
+ // General method, it's needed:
+ int no_menuitems_i18n = uiw_no_menuitems_i18n; /* This variable must be local. */
+ MENUCDIALOG_I("ui", "=", gettext("Resize"), "resize", 0, dx_resize,
+ dx_resizedialog);
+ no_menuitems_i18n -= uiw_no_menuitems_i18n;
+ resizeitems = &(menuitems_i18n[uiw_no_menuitems_i18n]);
+ uiw_no_resizeitems_i18n = no_menuitems_i18n;
+ menu_add(resizeitems, uiw_no_resizeitems_i18n);
+ uiw_no_menuitems_i18n += no_menuitems_i18n;
+
+}
+
+
+static int dx_alloc_buffers(char **b1, char **b2)
+{
+ DWORD ddrval;
+ DDSURFACEDESC ddsd;
+ int i;
+ currentbuff = 0;
+ memset(surface, 0, sizeof(DDSURFACEDESC) * 2);
+ memset(&ddsd, 0, sizeof(DDSURFACEDESC));
+ ddsd.dwSize = sizeof(ddsd);
+ if (IDirectDrawSurface_GetSurfaceDesc(lpSurfaces[0], &ddsd) != DD_OK) {
+ DeInitDD();
+ x_error("Failed to get pixel format");
+ return 0;
+ }
+ for (i = 0; i < 2; i++) {
+ ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
+ ddsd.dwWidth = displayX;
+ ddsd.dwHeight = displayY;
+ ddsd.ddsCaps.dwCaps =
+ DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+
+ ddrval =
+ IDirectDraw_CreateSurface(lpDD, &ddsd, &BackSurface[i], NULL);
+ if (ddrval != DD_OK) {
+ DeInitDD();
+ x_error("Failed to create back surface");
+ return 0;
+ }
+ }
+ for (i = 0; i < 2; i++) {
+ surface[i].dwSize = sizeof(DDSURFACEDESC);
+ ddrval = IDirectDrawSurface_Lock(BackSurface[i], NULL, surface + i,
+ DDLOCK_WAIT, NULL);
+ if (ddrval != DD_OK) {
+ DeInitDD();
+ x_fatalerror("Failed to lock offscreen surfaces");
+ }
+ }
+ buffer1 = *b1 = (char *) surface[0].lpSurface;
+ buffer2 = *b2 = (char *) surface[1].lpSurface;
+ lineSize = surface[0].u1.lPitch;
+ initialized = 1;
+ return lineSize;
+}
+
+static void dx_free_buffers(char *b1, char *b2)
+{
+ IDirectDrawSurface_Unlock(BackSurface[0], surface[0].lpSurface);
+ IDirectDrawSurface_Unlock(BackSurface[1], surface[1].lpSurface);
+ if (BackSurface[0])
+ IDirectDrawSurface_Release(BackSurface[0]);
+ if (BackSurface[1])
+ IDirectDrawSurface_Release(BackSurface[1]);
+ BackSurface[0] = NULL;
+ BackSurface[1] = NULL;
+ initialized = 0;
+ buffer1 = buffer2 = NULL;
+}
+
+static int dx_imgparams(void)
+{
+ DDSURFACEDESC s;
+ memset(&s, 0, sizeof(s));
+ s.dwSize = sizeof(s);
+ if (IDirectDrawSurface_GetSurfaceDesc(lpSurfaces[0], &s) != DD_OK) {
+ DeInitDD();
+ x_error("Failed to get pixel format");
+ return 0;
+ }
+ switch (s.ddpfPixelFormat.u1.dwRGBBitCount) {
+ case 8:
+ dxw_driver.imagetype = UI_C256;
+ dxf_driver.imagetype = UI_C256;
+ break;
+ case 16:
+ case 15:
+ dxw_driver.imagetype = UI_TRUECOLOR16;
+ dxf_driver.imagetype = UI_TRUECOLOR16;
+ break;
+ case 24:
+ dxw_driver.imagetype = UI_TRUECOLOR24;
+ dxf_driver.imagetype = UI_TRUECOLOR24;
+ break;
+ case 32:
+ dxw_driver.imagetype = UI_TRUECOLOR;
+ dxf_driver.imagetype = UI_TRUECOLOR;
+ break;
+ default:
+ x_fatalerror
+ ("Unsupported bit depth! Only 8bpp, 16bpp, 24bpp and 32bpp modes supported\n");
+ return 0;
+ }
+ dxw_driver.rmask = s.ddpfPixelFormat.u2.dwRBitMask;
+ dxw_driver.gmask = s.ddpfPixelFormat.u3.dwGBitMask;
+ dxw_driver.bmask = s.ddpfPixelFormat.u4.dwBBitMask;
+ dxf_driver.rmask = s.ddpfPixelFormat.u2.dwRBitMask;
+ dxf_driver.gmask = s.ddpfPixelFormat.u3.dwGBitMask;
+ dxf_driver.bmask = s.ddpfPixelFormat.u4.dwBBitMask;
+ dxf_driver.textwidth = fontWidth;
+ dxf_driver.textheight = fontHeight;
+ dxw_driver.textwidth = fontWidth;
+ dxw_driver.textheight = fontHeight;
+ return 1;
+}
+
+static int dxw_init(void)
+{
+ int r;
+
+ r = InitDD(0);
+ if (!r)
+ return r;
+
+ if (!dx_imgparams())
+ return 0;
+ win32_createrootmenu();
+ getres(&dxw_driver.width, &dxw_driver.height);
+ uiw_no_menuitems_i18n = 0;
+ add_cutpasteitems();
+ return r;
+}
+
+static int dxf_init(void)
+{
+ int r;
+
+ getdimens(&dxf_driver.width, &dxf_driver.height);
+ r = InitDD(1);
+ if (!r)
+ return r;
+
+ if (!dx_imgparams())
+ return 0;
+ uiw_no_menuitems_i18n = 0;
+ add_resizeitems();
+ add_cutpasteitems();
+ return r;
+}
+
+
+
+static void dx_uninitialize(void)
+{
+ if (directX == DXFULLSCREEN)
+ menu_delete(resizeitems, uiw_no_resizeitems_i18n);
+ menu_delete(cutpasteitems, uiw_no_cutpasteitems_i18n);
+ DeInitDD();
+}
+
+
+
+
+static void dx_getsize(int *width, int *height)
+{
+ if (resized) {
+ resized = 0;
+ if (!ResizeDD(directX == DXFULLSCREEN)) {
+ DeInitDD();
+ x_fatalerror("Failed to resize");
+ }
+ if (!dx_imgparams()) {
+ DeInitDD();
+ x_fatalerror("Internal program error #34234");
+ }
+ }
+ *width = displayX;
+ *height = displayY;
+ CalculateBITMAPINFO();
+}
+
+static void dx_mousetype(int type)
+{
+ switch (type) {
+ default:
+ case 0:
+ mousepointer = mouse_pointer_data;
+ break;
+ case 1:
+ mousepointer = wait_pointer_data;
+ break;
+ case 2:
+ mousepointer = replay_pointer_data;
+ break;
+ }
+ UpdateMouseDD();
+}
+#endif
+
+void win32_help(struct uih_context *c, CONST char *name)
+{
+#ifdef HTML_HELP
+ FILE *f;
+ char *n;
+ if (helpname == NULL) {
+ if (directX == DXFULLSCREEN)
+ ShowWindow(hWnd, SW_MINIMIZE);
+ n = xio_fixpath("\01\\help\\xaoshelp.chm");
+ if ((f = fopen(n, "r"))) {
+ fclose(f);
+ } else {
+ free(n);
+ n = xio_fixpath("\01\\..\\help\\xaoshelp.chm");
+ if ((f = fopen(n, "r"))) {
+ fclose(f);
+ } else
+ n = strdup("..\\help\\xaoshelp.chm");
+ }
+ helpname = n;
+ }
+ HH_AKLINK link;
+ link.cbStruct = sizeof(HH_AKLINK) ;
+ link.fReserved = FALSE ;
+ link.pszKeywords = name ;
+ link.pszUrl = NULL ;
+ link.pszMsgText = NULL ;
+ link.pszMsgTitle = NULL ;
+ link.pszWindow = NULL ;
+ link.fIndexOnFail = TRUE ;
+
+ if (!HtmlHelp(hWnd, helpname, HH_ALINK_LOOKUP, (DWORD) &link)) {
+ x_error("Could not display help for topic %s from file %s", name, helpname);
+ }
+#else
+ x_error("Help support not included in this executable.");
+#endif
+}
+
+
+static struct params params[] = {
+ {"", P_HELP, NULL, "Win32 driver options:"},
+ {"-size", P_STRING, &size,
+ "Window size in format WIDTHxHEIGHT (320x200)"},
+ {NULL, 0, NULL, NULL}
+};
+
+static struct params dxfparams[] = {
+ {"", P_HELP, NULL, "DirectX fullscreen driver options:"},
+ {"-mode", P_STRING, &dxsize,
+ "Select preffered graphics mode in format WIDTHxHEIGHTxDEPTH (320x200x8)"},
+ {NULL, 0, NULL, NULL}
+};
+
+static struct params dxwparams[] = {
+ {"", P_HELP, NULL, "DirectX windowed driver options:"},
+ {"-size", P_STRING, &size,
+ "Window size in format WIDTHxHEIGHT (320x200)"},
+ {NULL, 0, NULL, NULL}
+};
+
+extern int XaoS_main(int argc, char **argv);
+int STDCALL
+WinMain(HINSTANCE hInstance1,
+ HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+ static char name0[256];
+ static char *argv[256];
+ int argc = 1;
+ int i;
+
+ GetModuleFileName(hInstance1, name0, 256);
+ /* Allocate everything virtually - be on the safe side */
+ argv[0] = strdup(name0);
+ lpCmdLine = strdup(lpCmdLine);
+
+ for (i = 0; lpCmdLine[i]; i++) {
+ if (lpCmdLine[i] == ' ' || lpCmdLine[i] == '\t')
+ lpCmdLine[i] = 0;
+ else if (!i || !lpCmdLine[i - 1])
+ argv[argc] = lpCmdLine + i, argc++;
+ }
+
+ /* Attach to parent console if available so output will be visible */
+ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
+ /* make sure stdout is not already redirected before redefining */
+ if (_fileno(stdout) == -1 || _get_osfhandle(fileno(stdout)) == -1)
+ freopen("CON", "w", stdout);
+ }
+
+ hInstance = hInstance1;
+ return XaoS_main(argc, argv);
+}
+
+static CONST struct gui_driver win32_gui_driver = {
+ win32_dorootmenu,
+ win32_enabledisable,
+ win32_menu,
+ win32_dialog,
+ win32_help
+};
+
+static CONST struct gui_driver win32_fullscreen_gui_driver = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ win32_help
+};
+
+struct ui_driver win32_driver = {
+ "win32",
+ win32_init,
+ win32_getsize,
+ processevents,
+ getmouse,
+ win32_uninitialize,
+ NULL, // win32_set_color,
+ set_palette,
+ print,
+ win32_display,
+ win32_alloc_buffers,
+ win32_free_buffers,
+ flip_buffers,
+ mousetype,
+ NULL,
+ 16 + 16,
+ 12,
+ params,
+ PIXELSIZE | UPDATE_AFTER_PALETTE,
+ 0.0, 0.0,
+ 0, 0,
+ UI_C256,
+ 0, 256, 255,
+ 0, 0, 0,
+ &win32_gui_driver
+};
+
+#ifdef DDRAW_DRIVER
+struct ui_driver dxw_driver = {
+ "dX-window",
+ dxw_init,
+ dx_getsize,
+ processevents,
+ getmouse,
+ dx_uninitialize,
+ NULL, // dx_set_color,
+ set_palette,
+ print,
+ PaintDD,
+ dx_alloc_buffers,
+ dx_free_buffers,
+ flip_buffers,
+ mousetype,
+ NULL,
+ 16 + 16,
+ 12,
+ dxwparams,
+ PIXELSIZE,
+ 0.0, 0.0,
+ 0, 0,
+ UI_C256,
+ 0, 256, 255,
+ 0, 0, 0,
+ &win32_gui_driver
+};
+
+struct ui_driver dxf_driver = {
+ "dX-fullscreen",
+ dxf_init,
+ dx_getsize,
+ processevents,
+ getmouse,
+ dx_uninitialize,
+ NULL, // dx_set_color,
+ set_palette,
+ print,
+ PaintDD,
+ dx_alloc_buffers,
+ dx_free_buffers,
+ flip_buffers,
+ dx_mousetype,
+ NULL,
+ 16 + 16,
+ 12,
+ dxfparams,
+ FULLSCREEN | SCREENSIZE,
+ 0.0, 0.0,
+ 0, 0,
+ UI_C256,
+ 0, 256, 255,
+ 0, 0, 0,
+ &win32_fullscreen_gui_driver
+};
+#endif
+
+void x_message(const char *text, ...)
+{
+ va_list ap;
+ char buf[4096];
+ va_start(ap, text);
+ vsprintf(buf, text, ap);
+ if (directX == DXFULLSCREEN)
+ ShowWindow(hWnd, SW_MINIMIZE);
+ MessageBox(NULL, buf, "XaoS", MB_OK | MB_ICONINFORMATION);
+ va_end(ap);
+}
+
+void x_error(const char *text, ...)
+{
+ va_list ap;
+ char buf[4096];
+ va_start(ap, text);
+ vsprintf(buf, text, ap);
+ if (directX == DXFULLSCREEN)
+ ShowWindow(hWnd, SW_MINIMIZE);
+ MessageBox(NULL, buf, "XaoS have problem", MB_OK | MB_ICONEXCLAMATION);
+ va_end(ap);
+}
+
+void x_fatalerror(const char *text, ...)
+{
+ va_list ap;
+ char buf[4096];
+ va_start(ap, text);
+ vsprintf(buf, text, ap);
+ if (directX == DXFULLSCREEN)
+ ShowWindow(hWnd, SW_MINIMIZE);
+ MessageBox(NULL, buf, "Unrecovable XaoS error", MB_OK | MB_ICONSTOP);
+ va_end(ap);
+ exit(1);
+}
+
+
+#endif /* WIN32_DRIVER */
diff --git a/src/ui/ui-drv/win32/ui_win32.h b/src/ui/ui-drv/win32/ui_win32.h
new file mode 100644
index 0000000..cd64526
--- /dev/null
+++ b/src/ui/ui-drv/win32/ui_win32.h
@@ -0,0 +1,20 @@
+
+#ifndef UI_WIN32_H
+#include <windows.h>
+#include <ui.h>
+extern int directX;
+extern CONST char *helptopic;
+extern HWND hWnd;
+extern HINSTANCE hInstance;
+HMENU win32_createrootmenu(void);
+void win32_pressed(int id);
+void win32_dorootmenu(struct uih_context *uih, CONST char *name);
+void win32_enabledisable(struct uih_context *uih, CONST char *name);
+void win32_menu(struct uih_context *c, CONST char *name);
+void win32_uninitializewindows(void);
+void win32_dialog(struct uih_context *uih, CONST char *name);
+void win32_genresources(struct uih_context *uih);
+void win32_help(struct uih_context *uih, CONST char *name);
+void CenterWindow(HWND hwndChild, HWND hwndParent);
+void AboutBox(void);
+#endif
diff --git a/src/ui/ui-drv/win32/version.rc b/src/ui/ui-drv/win32/version.rc
new file mode 100644
index 0000000..2606338
--- /dev/null
+++ b/src/ui/ui-drv/win32/version.rc
@@ -0,0 +1,39 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+1 VERSIONINFO
+ FILEVERSION 3,5,0,0
+ PRODUCTVERSION 3,5,0,0
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "Brought to you by Jan Hubicka, Thomas Marsh and many others\0"
+ VALUE "CompanyName", "Free Software Foundation\0"
+ VALUE "FileDescription", "XaoS - a realtime fractal zoomer\0"
+ VALUE "FileVersion", "0.0\0"
+ VALUE "InternalName", "XaoS\0"
+ VALUE "LegalCopyright", "Copyright 1996-2008 Jan Hubicka, Thomas Marsh and many others. Many parts are copyrighted by their authors. See the source distribution\0"
+ VALUE "LegalTrademarks", "\0"
+ VALUE "OriginalFilename", "\0"
+ VALUE "ProductName", "XaoS\0"
+ VALUE "ProductVersion", "3.5\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 0x04E4, 0x411, 0x04E4
+ END
+END
diff --git a/src/ui/ui-drv/win32/windialo.c b/src/ui/ui-drv/win32/windialo.c
new file mode 100644
index 0000000..dd0a9e6
--- /dev/null
+++ b/src/ui/ui-drv/win32/windialo.c
@@ -0,0 +1,471 @@
+#include <windows.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdio.h>
+#include <config.h>
+/*#include <filter.h>
+ #include <ui_helper.h> */
+#include <xerror.h>
+#include <xldio.h>
+#include <ui.h>
+#include <xmenu.h>
+#include "ui_win32.h"
+
+#ifdef HAVE_GETTEXT
+#include <libintl.h>
+#else
+#define gettext(STRING) STRING
+#endif
+
+TCHAR text[100];
+
+#define QUESTIONSTART 100
+#define ITEMSTART 10
+#define PERITEM 5
+
+#define OK 1
+#define CANCEL 2
+#define HELP 3
+
+static struct dialogrecord {
+ CONST menuitem *item;
+ CONST menudialog *dialog;
+ int nitems;
+ HWND windialog;
+ struct uih_context *c;
+ struct dialogrecord *next, *prev;
+} *firstdialog = NULL;
+static CONST char *win32_getextension(CONST char *ch)
+{
+ int i = 0;
+ while (ch[i]) {
+ if (ch[i] == '*')
+ return (ch + i + 1);
+ i++;
+ }
+ return ch + i;
+}
+
+static char *win32_dofiledialog(struct uih_context *uih,
+ CONST menuitem * item,
+ CONST menudialog * dialog)
+{
+ OPENFILENAME ofn;
+ char szDirName[256];
+ char szFile[256], szFileTitle[256];
+ UINT i, p;
+ char szFilter[256];
+
+ helptopic = item->shortname;
+ szDirName[0] = 0;
+ /*GetSystemDirectory(szDirName, sizeof(szDirName)); */
+ szFile[0] = 0;
+ if (dialog[0].type == DIALOG_OFILE) {
+ strcpy(szFile, dialog[0].defstr);
+ for (i = 0; dialog[0].defstr[i] && dialog[0].defstr[i] != '*';
+ i++);
+ szFile[i] = 0;
+ strcpy(szFile,
+ ui_getfile(szFile, win32_getextension(dialog[0].defstr)));
+ }
+
+ for (i = 0; dialog[0].defstr[i] && dialog[0].defstr[i] != '*'; i++)
+ if (!dialog[0].defstr[i])
+ i = 0;
+ strcpy(szFilter, dialog[0].defstr + i);
+ p = strlen(szFilter);
+ strcpy(szFilter + p + 1, dialog[0].defstr + i);
+ p += strlen(szFilter + p + 1) + 1;
+ strcpy(szFilter + p + 1, "All files");
+ p += strlen(szFilter + p + 1) + 1;
+ strcpy(szFilter + p + 1, "*.*");
+ p += strlen(szFilter + p + 1) + 1;
+ szFilter[p + 1] = 0;
+
+ memset(&ofn, 0, sizeof(OPENFILENAME));
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hWnd;
+ ofn.lpstrFilter = szFilter;
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = szFile;
+ ofn.nMaxFile = sizeof(szFile);
+ ofn.lpstrFileTitle = szFileTitle;
+ ofn.nMaxFileTitle = sizeof(szFileTitle);
+ ofn.lpstrInitialDir = szDirName;
+ ofn.Flags =
+ OFN_SHOWHELP | OFN_PATHMUSTEXIST | (dialog[0].type ==
+ DIALOG_IFILE ?
+ OFN_FILEMUSTEXIST :
+ OFN_OVERWRITEPROMPT);
+ if (dialog[0].type == DIALOG_IFILE)
+ i = GetOpenFileName(&ofn);
+ else
+ i = GetSaveFileName(&ofn);
+ helptopic = "main";
+ if (i) {
+ return (strdup(ofn.lpstrFile));
+ }
+ return NULL;
+}
+
+
+static void
+win32_filedialog(struct uih_context *uih, CONST menuitem * item,
+ CONST menudialog * dialog)
+{
+ char *name = win32_dofiledialog(uih, item, dialog);
+ if (name) {
+ dialogparam *param = malloc(sizeof(dialogparam));
+ param->dstring = name;
+ ui_menuactivate(item, param);
+ }
+}
+
+static void win32_freedialog(struct dialogrecord *r)
+{
+ if (r->next)
+ r->next->prev = r->prev;
+ if (r->prev)
+ r->prev->next = r->next;
+ else
+ firstdialog = r->next;
+ free(r);
+}
+
+static int win32_dodialog(struct dialogrecord *r, HWND hDLG)
+{
+ dialogparam *p = calloc(sizeof(*p), r->nitems);
+ int i;
+ char s[256];
+ for (i = 0; i < r->nitems; i++) {
+ switch (r->dialog[i].type) {
+ case DIALOG_IFILE:
+ case DIALOG_OFILE:
+ case DIALOG_STRING:
+ case DIALOG_KEYSTRING:
+ GetDlgItemText(hDLG, i * PERITEM + ITEMSTART, s, sizeof(s));
+ p[i].dstring = strdup(s);
+ break;
+ case DIALOG_INT:
+ GetDlgItemText(hDLG, i * PERITEM + ITEMSTART, s, sizeof(s));
+ p[i].dint = r->dialog[i].defint;
+ sscanf(s, "%i", &p[i].dint);
+ break;
+ case DIALOG_FLOAT:
+ GetDlgItemText(hDLG, i * PERITEM + ITEMSTART, s, sizeof(s));
+ p[i].number = r->dialog[i].deffloat;
+ p[i].number = x_strtold(s, NULL);
+ break;
+ case DIALOG_COORD:
+ GetDlgItemText(hDLG, i * PERITEM + ITEMSTART, s, sizeof(s));
+ p[i].dcoord[0] = r->dialog[i].deffloat;
+ p[i].dcoord[0] = x_strtold(s, NULL);
+ GetDlgItemText(hDLG, i * PERITEM + ITEMSTART + 1, s,
+ sizeof(s));
+ p[i].dcoord[1] = r->dialog[i].deffloat2;
+ p[i].dcoord[1] = x_strtold(s, NULL);
+ break;
+ case DIALOG_CHOICE:
+ /*x_message("Choice is not implemented yet"); */
+ {
+ int y;
+ y = LOWORD(SendDlgItemMessage
+ (hDLG, i * PERITEM + ITEMSTART, CB_GETCURSEL, 0,
+ 0L));
+ p[i].dint =
+ LOWORD(SendDlgItemMessage
+ (hDLG, i * PERITEM + ITEMSTART, CB_GETITEMDATA,
+ (WPARAM) y, 0L));
+ }
+ }
+ }
+ ui_menuactivate(r->item, p);
+ return 1;
+}
+
+static BOOL APIENTRY
+DialogHandler(HWND hDLG, UINT message, UINT wParam, LONG lParam)
+{
+ struct dialogrecord *rec = firstdialog;
+ int i;
+/* while(rec->windialog!=hDLG) rec=rec->next; */
+ if (!rec->windialog)
+ rec->windialog = hDLG;
+ switch (message) {
+ case WM_INITDIALOG:
+ /*x_message("Creating dialog"); */
+ ShowWindow(hDLG, SW_HIDE);
+ /*CenterWindow (hDLG, GetWindow (hDLG, GW_OWNER)); */
+ if (GetWindowText(hDLG, text, GetWindowTextLength(hDLG) + 1) > 0);
+ SetWindowText(hDLG, gettext(text));
+ SetDlgItemText(hDLG, OK, gettext("OK"));
+ SetDlgItemText(hDLG, CANCEL, gettext("Cancel"));
+ SetDlgItemText(hDLG, HELP, gettext("Help"));
+ for (i = 0; rec->dialog[i].question; i++) {
+ if (GetDlgItemText
+ (hDLG, i * PERITEM + QUESTIONSTART, text, 100) > 0)
+ SetDlgItemText(hDLG, i * PERITEM + QUESTIONSTART,
+ gettext(text));
+ switch (rec->dialog[i].type) {
+ char s[256];
+ case DIALOG_STRING:
+ case DIALOG_IFILE:
+ case DIALOG_OFILE:
+ SetDlgItemText(hDLG, i * PERITEM + ITEMSTART,
+ rec->dialog[i].defstr);
+ break;
+ case DIALOG_INT:
+ sprintf(s, "%i", rec->dialog[i].defint);
+ SetDlgItemText(hDLG, i * PERITEM + ITEMSTART, s);
+ break;
+ case DIALOG_COORD:
+ sprintf(s, "%g", (double) rec->dialog[i].deffloat2);
+ SetDlgItemText(hDLG, i * PERITEM + ITEMSTART + 1, s);
+ /*Fall trought */
+ case DIALOG_FLOAT:
+ sprintf(s, "%g", (double) rec->dialog[i].deffloat);
+ SetDlgItemText(hDLG, i * PERITEM + ITEMSTART, s);
+ break;
+ case DIALOG_CHOICE:
+ {
+ CONST char **strings =
+ (CONST char **) rec->dialog[i].defstr;
+ int y;
+ int pos;
+ for (y = 0; strings[y]; y++) {
+ pos =
+ LOWORD(SendDlgItemMessage
+ (hDLG, i * PERITEM + ITEMSTART,
+ CB_ADDSTRING, (WPARAM) 0,
+ (LPARAM) (LPSTR) strings[y]));
+ /*x_message("%s %i",strings[y],pos); */
+ SendMessage(GetDlgItem
+ (hDLG, i * PERITEM + ITEMSTART),
+ CB_SETITEMDATA, (WPARAM) pos, y);
+ if (y == rec->dialog[i].defint) {
+ pos =
+ SendMessage(GetDlgItem
+ (hDLG,
+ i * PERITEM + ITEMSTART),
+ CB_SETCURSEL, (WPARAM) pos,
+ 0L);
+ /*x_message("Default %i",pos); */
+ }
+ }
+ pos =
+ LOWORD(SendDlgItemMessage
+ (hDLG, i * PERITEM + ITEMSTART, CB_GETCOUNT,
+ (WPARAM) 0, 0));
+ /*x_message("Count %i",pos); */
+ }
+ break;
+ }
+ }
+ CenterWindow(hDLG, GetWindow(hDLG, GW_OWNER));
+ ShowWindow(hDLG, SW_SHOW);
+ return (TRUE);
+ case WM_SYSCOMMAND:
+ if (wParam == SC_CLOSE) {
+ EndDialog(hDLG, 0);
+ return (TRUE);
+ }
+ break;
+ case WM_COMMAND:
+ if (wParam == OK) {
+ if (win32_dodialog(rec, hDLG)) {
+ EndDialog(hDLG, 0);
+ return (TRUE);
+ }
+ }
+ if (wParam == CANCEL) {
+ EndDialog(hDLG, 0);
+ return (TRUE);
+ }
+ if (wParam == HELP) {
+ win32_help(rec->c, rec->item->shortname);
+ return (TRUE);
+ }
+ {
+ int i = (wParam - ITEMSTART) / PERITEM;
+ int pos = (wParam - ITEMSTART) % PERITEM;
+ if (i >= 0 && i < rec->nitems) {
+ if (pos == 1
+ && (rec->dialog[i].type == DIALOG_IFILE
+ || rec->dialog[i].type == DIALOG_OFILE)) {
+ /*x_message("File dialog\n"); */
+ char *file =
+ win32_dofiledialog(rec->c, rec->item,
+ rec->dialog + i);
+ if (file) {
+ SetDlgItemText(hDLG, wParam - 1, file);
+ free(file);
+ }
+ }
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+#define INPUTSIZE 20
+#define XBORDER 0
+#define YBORDER 5
+#define XSEP 4
+
+#define CHARWIDTH 4
+#define MINWIDTH ((7*3)*CHARWIDTH)
+#define LINEHEIGHT 14
+#define TEXTHEIGHT 11
+
+static FILE *file;
+static void
+win32_outputdialog(struct uih_context *uih, CONST struct menuitem *item)
+{
+ CONST menudialog *dialog;
+ int leftsize = 0;
+ int rightsize = 0;
+ int width, height;
+ int i;
+ rightsize = INPUTSIZE;
+ if (item->type != MENU_DIALOG && item->type != MENU_CUSTOMDIALOG)
+ return;
+ if (item->flags & MENUFLAG_NOMENU)
+ return;
+ dialog = menu_getdialog(uih, item);
+ for (i = 0; dialog[i].question; i++) {
+ if (leftsize < (int) strlen(dialog[i].question))
+ leftsize = strlen(dialog[i].question);
+ }
+ if (i == 1
+ && (dialog[0].type == DIALOG_IFILE
+ || dialog[0].type == DIALOG_OFILE))
+ return;
+ leftsize = XBORDER + leftsize * CHARWIDTH + XSEP;
+ rightsize = XBORDER + rightsize * CHARWIDTH;
+ width = leftsize + rightsize;
+ if (width < MINWIDTH)
+ width = MINWIDTH;
+ height = 2 * YBORDER + (i + 1) * LINEHEIGHT;
+ fprintf(file, "%sBox DIALOG %i, %i, %i, %i\n", item->shortname, 52,
+ 57, width, height);
+ fprintf(file, "STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU\n");
+ fprintf(file, "CAPTION \"%s\"\n", item->name);
+ fprintf(file, "FONT 8, \"MS Shell Dlg\"\n");
+ fprintf(file, "BEGIN\n");
+ for (i = 0; dialog[i].question; i++) {
+ fprintf(file, " RTEXT \"%s\", %i, %i, %i, %i, %i, WS_GROUP\n",
+ dialog[i].question,
+ i * PERITEM + QUESTIONSTART,
+ 0, YBORDER + i * LINEHEIGHT, leftsize - XSEP, TEXTHEIGHT);
+ switch (dialog[i].type) {
+ case DIALOG_INT:
+ case DIALOG_FLOAT:
+ case DIALOG_STRING:
+ case DIALOG_KEYSTRING:
+ fprintf(file,
+ " EDITTEXT %i, %i, %i, %i, %i, ES_AUTOHSCROLL | WS_TABSTOP\n",
+ i * PERITEM + ITEMSTART, leftsize,
+ i * LINEHEIGHT + YBORDER, rightsize - XSEP,
+ TEXTHEIGHT);
+ break;
+ case DIALOG_COORD:
+ fprintf(file,
+ " EDITTEXT %i, %i, %i, %i, %i, ES_AUTOHSCROLL | WS_TABSTOP\n",
+ i * PERITEM + ITEMSTART, leftsize,
+ i * LINEHEIGHT + YBORDER,
+ (rightsize - XSEP - 4 * CHARWIDTH) / 2, TEXTHEIGHT);
+ fprintf(file,
+ " EDITTEXT %i, %i, %i, %i, %i, ES_AUTOHSCROLL | WS_TABSTOP\n",
+ i * PERITEM + ITEMSTART + 1,
+ leftsize + (rightsize - XSEP + CHARWIDTH) / 2,
+ i * LINEHEIGHT + YBORDER,
+ (rightsize - XSEP - 4 * CHARWIDTH) / 2, TEXTHEIGHT);
+ fprintf(file, " RTEXT \"+\", -1, %i, %i, %i, %i\n",
+ leftsize + (rightsize - XSEP - 2 * CHARWIDTH) / 2,
+ YBORDER + i * LINEHEIGHT, CHARWIDTH, TEXTHEIGHT);
+ fprintf(file, " RTEXT \"i\", -1, %i, %i, %i, %i\n",
+ leftsize + rightsize - XSEP - CHARWIDTH,
+ YBORDER + i * LINEHEIGHT, CHARWIDTH, TEXTHEIGHT);
+ break;
+ case DIALOG_CHOICE:
+ fprintf(file,
+ " COMBOBOX %i, %i, %i, %i, %i, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP\n",
+ i * PERITEM + ITEMSTART, leftsize,
+ i * LINEHEIGHT + YBORDER, rightsize - XSEP,
+ TEXTHEIGHT * 10);
+ break;
+ case DIALOG_IFILE:
+ case DIALOG_OFILE:
+#define BROWSEWIDTH ((strlen("Browse")+1)*CHARWIDTH)
+ fprintf(file,
+ " EDITTEXT %i, %i, %i, %i, %i, ES_AUTOHSCROLL | WS_TABSTOP\n",
+ i * PERITEM + ITEMSTART, leftsize,
+ i * LINEHEIGHT + YBORDER,
+ rightsize - 2 * XSEP - BROWSEWIDTH, TEXTHEIGHT);
+ fprintf(file,
+ " PUSHBUTTON \"Browse\", %i, %i, %i, %i, %i, WS_GROUP\n",
+ i * PERITEM + ITEMSTART + 1,
+ leftsize + rightsize - XSEP - BROWSEWIDTH,
+ i * LINEHEIGHT + YBORDER, BROWSEWIDTH, TEXTHEIGHT);
+ break;
+ }
+ }
+ fprintf(file,
+ " DEFPUSHBUTTON \"&OK\", %i, %i, %i, %i, %i, WS_GROUP\n", OK,
+ XSEP / 2, i * LINEHEIGHT + YBORDER, width / 3 - XSEP, 14);
+ fprintf(file, " PUSHBUTTON \"&Cancel\", %i, %i, %i, %i, %i\n", CANCEL,
+ width / 3 + XSEP / 2, i * LINEHEIGHT + YBORDER,
+ width / 3 - XSEP, 14);
+ fprintf(file, " PUSHBUTTON \"&Help\", %i, %i, %i, %i, %i\n", HELP,
+ 2 * width / 3 + XSEP / 2, i * LINEHEIGHT + YBORDER,
+ width / 3 - XSEP, 14);
+ fprintf(file, "END\n");
+}
+
+void win32_genresources(struct uih_context *uih)
+{
+ file = fopen("xaos.dlg", "w");
+ menu_forall(uih, win32_outputdialog);
+ fclose(file);
+
+}
+
+void win32_dialog(struct uih_context *uih, CONST char *name)
+{
+ CONST menuitem *item = menu_findcommand(name);
+ CONST menudialog *dialog;
+ int nitems;
+ char s[256];
+
+ if (!item)
+ return;
+ dialog = menu_getdialog(uih, item);
+ if (!dialog)
+ return;
+ for (nitems = 0; dialog[nitems].question; nitems++);
+ if (nitems == 1
+ && (dialog[0].type == DIALOG_IFILE
+ || dialog[0].type == DIALOG_OFILE))
+ win32_filedialog(uih, item, dialog);
+ else {
+ struct dialogrecord *r = calloc(sizeof(*r), 1);
+ r->next = firstdialog;
+ firstdialog = r;
+ r->prev = NULL;
+ r->item = item;
+ r->nitems = nitems;
+ r->dialog = dialog;
+ r->c = uih;
+ sprintf(s, "%sBox", item->shortname);
+ if (DialogBox(hInstance, s, hWnd, DialogHandler) == -1) {
+ /*r->windialog=CreateDialog (hInstance, s, hWnd, DialogHandler);
+ if(r->windialog==NULL) { */
+ x_message("Failed to create dialog %s", item->shortname);
+ win32_freedialog(r);
+ }
+ win32_freedialog(r);
+ /*x_message("Dialog (%s %i %s) not implemented", name, nitems, dialog[0].question); */
+ }
+}
diff --git a/src/ui/ui-drv/win32/winmenu.c b/src/ui/ui-drv/win32/winmenu.c
new file mode 100644
index 0000000..d04f941
--- /dev/null
+++ b/src/ui/ui-drv/win32/winmenu.c
@@ -0,0 +1,243 @@
+#include <windows.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <config.h>
+/*#include <filter.h>
+ #include <ui_helper.h> */
+#include <xerror.h>
+#include <ui.h>
+#include <xmenu.h>
+#include "ui_win32.h"
+#define IDMUL 64
+#define MAIN 0
+#define POPUP 1
+#define WSUBMENU 2
+struct menurecord {
+ int type;
+ int id;
+ struct uih_context *c;
+ CONST menuitem *item;
+ struct menurecord *nextrecord;
+ struct menurecord *prevrecord;
+ HMENU menu;
+ struct menurecord *submenu;
+ struct menurecord *nextsubmenu;
+} *firstrecord;
+struct menurecord rootmenu;
+
+static void win32_appendmenu(struct uih_context *c,
+ struct menurecord *menu);
+HMENU win32_createrootmenu()
+{
+ /*printf("Createrootmenu\n"); */
+ rootmenu.id = 0;
+ rootmenu.menu = CreateMenu();
+ rootmenu.nextrecord = firstrecord;
+ rootmenu.prevrecord = NULL;
+ firstrecord = &rootmenu;
+ rootmenu.nextsubmenu = NULL;
+ rootmenu.submenu = NULL;
+ /*printf("Createrootmenu OK\n"); */
+ return rootmenu.menu;
+};
+
+static struct menurecord *win32_createmenu(struct uih_context *c,
+ CONST char *name, int type)
+{
+ struct menurecord *m = calloc(sizeof(*m), 1);
+ static int id = 1;
+ /*printf("Createmenu %s\n",name); */
+ m->id = id++;
+ m->type = type;
+ if (type != POPUP)
+ m->menu = CreateMenu();
+ else
+ m->menu = CreatePopupMenu();
+ m->c = c;
+ m->item = menu_findcommand(name);
+ m->nextrecord = firstrecord;
+ m->prevrecord = NULL;
+ firstrecord = m;
+ m->nextsubmenu = NULL;
+ m->submenu = NULL;
+ win32_appendmenu(c, m);
+ /*printf("Createmenu OK\n"); */
+ return m;
+};
+
+static void
+win32_appendmenu(struct uih_context *c, struct menurecord *menu)
+{
+ int i, y, hotkeyed;
+ CONST menuitem *item;
+ char out[256];
+ char used[256];
+ memset(used, 0, 256);
+ /*printf("Appendmenu %s\n",menu->item->shortname); */
+ for (i = 0; (item = menu_item(menu->item->shortname, i)) != NULL; i++) {
+ struct menurecord *submenu = NULL;
+ int flags = MF_ENABLED | MF_STRING;
+ if (item->type == MENU_SEPARATOR)
+ flags |= MF_SEPARATOR;
+ if (item->type == MENU_SUBMENU) {
+ submenu = win32_createmenu(c, item->shortname, WSUBMENU);
+ flags |= MF_POPUP;
+ submenu->nextsubmenu = menu->submenu;
+ menu->submenu = submenu;
+ }
+ if (item->flags & (MENUFLAG_RADIO | MENUFLAG_CHECKBOX) &&
+ menu_enabled(item, c))
+ flags |= MF_CHECKED;
+ /*printf(" %s\n",item->name); */
+
+ hotkeyed = 0;
+ for (y = 0; item->name[y]; y++) {
+ if (!hotkeyed) {
+ unsigned char c = tolower(item->name[y]);
+ if (((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'))
+ && !used[c])
+ used[c] = 1, hotkeyed = 1, out[y] = '&';
+ }
+ out[y + hotkeyed] = item->name[y];
+ }
+ out[y + hotkeyed] = 0;
+ if (item->type == MENU_CUSTOMDIALOG || item->type == MENU_DIALOG)
+ strcat(out, "...");
+ if (menu->type != MAIN && item->key) {
+ strcat(out, "\t");
+ strcat(out, item->key);
+ }
+ AppendMenu(menu->menu, flags,
+ (submenu !=
+ NULL ? (UINT) submenu->menu : (UINT) (menu->id *
+ IDMUL + i)),
+ out);
+
+ }
+ /*printf("Appendmenu OK\n"); */
+}
+
+static void win32_freestructures(struct menurecord *menu)
+{
+ struct menurecord *sub, *nextsub;
+ /*printf("Freestructures\n"); */
+ sub = menu->submenu;
+ while (sub != NULL) {
+ nextsub = sub->nextsubmenu;
+ win32_freestructures(sub);
+ sub = nextsub;
+ }
+ if (menu->nextrecord)
+ menu->nextrecord->prevrecord = menu->prevrecord;
+ if (menu->prevrecord)
+ menu->prevrecord->nextrecord = menu->nextrecord;
+ else
+ firstrecord = menu->nextrecord;
+ free(menu);
+}
+
+void win32_pressed(int id)
+{
+ struct menurecord *menu = firstrecord;
+ /*printf("Pressed\n"); */
+ while (menu) {
+ if (id / IDMUL == menu->id) {
+ ui_menuactivate(menu_item(menu->item->shortname, id % IDMUL),
+ NULL);
+ return;
+ }
+ menu = menu->nextrecord;
+ }
+ x_error("Unknown menu");
+}
+
+/* first destroy the old contents */
+void win32_dorootmenu(struct uih_context *uih, CONST char *name)
+{
+ struct menurecord *sub, *nextsub;
+ /*printf("dorootmenu %s\n",name); */
+ /* Delete the old entries */
+ while (DeleteMenu(rootmenu.menu, 0, MF_BYPOSITION));
+ sub = rootmenu.submenu;
+ rootmenu.c = uih;
+ while (sub != NULL) {
+ nextsub = sub->nextsubmenu;
+ win32_freestructures(sub);
+ sub = nextsub;
+ }
+ rootmenu.item = menu_findcommand(name);
+ rootmenu.submenu = NULL;
+ win32_appendmenu(uih, &rootmenu);
+ SetMenu(hWnd, rootmenu.menu);
+ /*printf("OK\n"); */
+}
+
+/* Check all created menus to see if there is the changed item and do changes
+ as neccesary.
+
+ This implementation is rather ugly and slow. Try if it is fast enought
+ and change it otherwise */
+void win32_enabledisable(struct uih_context *uih, CONST char *name)
+{
+ CONST struct menuitem *chgitem = menu_findcommand(name);
+ CONST struct menuitem *item;
+ struct menurecord *menu = firstrecord;
+ int i;
+ int checked = menu_enabled(chgitem, uih);
+ while (menu) {
+ if (menu->item != NULL)
+ for (i = 0;
+ (item = menu_item(menu->item->shortname, i)) != NULL;
+ i++) {
+ if (item == chgitem) {
+ if (chgitem->flags & MENUFLAG_RADIO && checked) {
+ int y;
+ for (y = 0;
+ (item =
+ menu_item(menu->item->shortname, y)) != NULL;
+ y++)
+ if (item->flags & MENUFLAG_RADIO)
+ CheckMenuItem(menu->menu,
+ menu->id * IDMUL + y,
+ MF_BYCOMMAND | MF_UNCHECKED);
+ }
+ CheckMenuItem(menu->menu, menu->id * IDMUL + i,
+ MF_BYCOMMAND | (checked ? MF_CHECKED :
+ MF_UNCHECKED));
+ }
+ }
+ menu = menu->nextrecord;
+ }
+}
+
+void win32_menu(struct uih_context *c, CONST char *name)
+{
+
+ POINT p;
+ struct menurecord *m = firstrecord;
+
+ /*Delete records about all popups, since they are closed now */
+ while (m) {
+ if (m->type == POPUP) {
+ DestroyMenu(m->menu), win32_freestructures(m);
+ break;
+ }
+ m = m->nextrecord;
+ }
+ m = win32_createmenu(c, name, POPUP);
+ GetCursorPos(&p);
+ /*printf("menu %s %i %i\n",name,p.x,p.y); */
+ TrackPopupMenu(m->menu, 0, p.x, p.y, 0, hWnd, 0);
+}
+
+void win32_uninitializewindows()
+{
+ while (firstrecord) {
+ struct menurecord *r = firstrecord;
+ while (r->type == WSUBMENU)
+ r = r->nextrecord;
+ DestroyMenu(r->menu);
+ win32_freestructures(r);
+ }
+}
diff --git a/src/ui/ui-drv/win32/xaos.dlg b/src/ui/ui-drv/win32/xaos.dlg
new file mode 100644
index 0000000..132a122
--- /dev/null
+++ b/src/ui/ui-drv/win32/xaos.dlg
@@ -0,0 +1,228 @@
+lettersBox DIALOG 52, 57, 160, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Letters per second"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Letters per second:", 100, 0, 5, 76, 11, WS_GROUP
+ EDITTEXT 10, 80, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 49, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 55, 19, 49, 14
+ PUSHBUTTON "&Help", 3, 108, 19, 49, 14
+END
+commandBox DIALOG 52, 57, 136, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Command"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Your command:", 100, 0, 5, 52, 11, WS_GROUP
+ EDITTEXT 10, 56, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 41, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 47, 19, 41, 14
+ PUSHBUTTON "&Help", 3, 92, 19, 41, 14
+END
+renderanimBox DIALOG 52, 57, 204, 192
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Render animation"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "File to render:", 100, 0, 5, 120, 11, WS_GROUP
+ EDITTEXT 10, 124, 5, 44, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ PUSHBUTTON "Browse", 11, 172, 5, 28, 11, WS_GROUP
+ RTEXT "Basename:", 105, 0, 19, 120, 11, WS_GROUP
+ EDITTEXT 15, 124, 19, 44, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ PUSHBUTTON "Browse", 16, 172, 19, 28, 11, WS_GROUP
+ RTEXT "Width:", 110, 0, 33, 120, 11, WS_GROUP
+ EDITTEXT 20, 124, 33, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "Height:", 115, 0, 47, 120, 11, WS_GROUP
+ EDITTEXT 25, 124, 47, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "Real width (cm):", 120, 0, 61, 120, 11, WS_GROUP
+ EDITTEXT 30, 124, 61, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "Real height (cm):", 125, 0, 75, 120, 11, WS_GROUP
+ EDITTEXT 35, 124, 75, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "Framerate:", 130, 0, 89, 120, 11, WS_GROUP
+ EDITTEXT 40, 124, 89, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "Image type:", 135, 0, 103, 120, 11, WS_GROUP
+ COMBOBOX 45, 124, 103, 76, 110, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
+ RTEXT "Antialiasing:", 140, 0, 117, 120, 11, WS_GROUP
+ COMBOBOX 50, 124, 117, 76, 110, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
+ RTEXT "Always recalculate:", 145, 0, 131, 120, 11, WS_GROUP
+ COMBOBOX 55, 124, 131, 76, 110, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
+ RTEXT "Calculate MPEG motion vectors:", 150, 0, 145, 120, 11, WS_GROUP
+ COMBOBOX 60, 124, 145, 76, 110, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
+ RTEXT "Recommended I frame distance:", 155, 0, 159, 120, 11, WS_GROUP
+ EDITTEXT 65, 124, 159, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 173, 64, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 70, 173, 64, 14
+ PUSHBUTTON "&Help", 3, 138, 173, 64, 14
+END
+textBox DIALOG 52, 57, 104, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Display text"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Text:", 100, 0, 5, 20, 11, WS_GROUP
+ EDITTEXT 10, 24, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 30, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 36, 19, 30, 14
+ PUSHBUTTON "&Help", 3, 71, 19, 30, 14
+END
+colorBox DIALOG 52, 57, 108, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Color"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Color:", 100, 0, 5, 24, 11, WS_GROUP
+ COMBOBOX 10, 28, 5, 76, 110, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 32, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 38, 19, 32, 14
+ PUSHBUTTON "&Help", 3, 74, 19, 32, 14
+END
+usrformBox DIALOG 52, 57, 116, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "User formula"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Formula:", 100, 0, 5, 32, 11, WS_GROUP
+ EDITTEXT 10, 36, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 34, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 40, 19, 34, 14
+ PUSHBUTTON "&Help", 3, 79, 19, 34, 14
+END
+usrformInitBox DIALOG 52, 57, 144, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "User initialization"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Initialization:", 100, 0, 5, 60, 11, WS_GROUP
+ EDITTEXT 10, 64, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 44, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 50, 19, 44, 14
+ PUSHBUTTON "&Help", 3, 98, 19, 44, 14
+END
+uimandelbrotBox DIALOG 52, 57, 128, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Mandelbrot mode"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Julia-seed:", 100, 0, 5, 44, 11, WS_GROUP
+ EDITTEXT 10, 48, 5, 30, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ EDITTEXT 11, 88, 5, 30, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "+", -1, 82, 5, 4, 11
+ RTEXT "i", -1, 120, 5, 4, 11
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 38, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 44, 19, 38, 14
+ PUSHBUTTON "&Help", 3, 87, 19, 38, 14
+END
+uiperturbationBox DIALOG 52, 57, 136, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Perturbation"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Perturbation:", 100, 0, 5, 52, 11, WS_GROUP
+ EDITTEXT 10, 56, 5, 30, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ EDITTEXT 11, 96, 5, 30, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "+", -1, 90, 5, 4, 11
+ RTEXT "i", -1, 128, 5, 4, 11
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 41, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 47, 19, 41, 14
+ PUSHBUTTON "&Help", 3, 92, 19, 41, 14
+END
+uiviewBox DIALOG 52, 57, 112, 66
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "View"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Center:", 100, 0, 5, 28, 11, WS_GROUP
+ EDITTEXT 10, 32, 5, 30, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ EDITTEXT 11, 72, 5, 30, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "+", -1, 66, 5, 4, 11
+ RTEXT "i", -1, 104, 5, 4, 11
+ RTEXT "Radius:", 105, 0, 19, 28, 11, WS_GROUP
+ EDITTEXT 15, 32, 19, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "Angle:", 110, 0, 33, 28, 11, WS_GROUP
+ EDITTEXT 20, 32, 33, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 47, 33, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 39, 47, 33, 14
+ PUSHBUTTON "&Help", 3, 76, 47, 33, 14
+END
+paletteBox DIALOG 52, 57, 152, 66
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Custom palette"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Algorithm number:", 100, 0, 5, 68, 11, WS_GROUP
+ EDITTEXT 10, 72, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "Seed:", 105, 0, 19, 68, 11, WS_GROUP
+ EDITTEXT 15, 72, 19, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ RTEXT "Shift:", 110, 0, 33, 68, 11, WS_GROUP
+ EDITTEXT 20, 72, 33, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 47, 46, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 52, 47, 46, 14
+ PUSHBUTTON "&Help", 3, 103, 47, 46, 14
+END
+cyclingspeedBox DIALOG 52, 57, 156, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Color cycling speed"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Frames per second:", 100, 0, 5, 72, 11, WS_GROUP
+ EDITTEXT 10, 76, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 48, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 54, 19, 48, 14
+ PUSHBUTTON "&Help", 3, 106, 19, 48, 14
+END
+shiftpaletteBox DIALOG 52, 57, 112, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Shift palette"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Amount:", 100, 0, 5, 28, 11, WS_GROUP
+ EDITTEXT 10, 32, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 33, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 39, 19, 33, 14
+ PUSHBUTTON "&Help", 3, 76, 19, 33, 14
+END
+maxiterBox DIALOG 52, 57, 128, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Iterations"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Iterations:", 100, 0, 5, 44, 11, WS_GROUP
+ EDITTEXT 10, 48, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 38, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 44, 19, 38, 14
+ PUSHBUTTON "&Help", 3, 87, 19, 38, 14
+END
+bailoutBox DIALOG 52, 57, 116, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Bailout"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Bailout:", 100, 0, 5, 32, 11, WS_GROUP
+ EDITTEXT 10, 36, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 34, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 40, 19, 34, 14
+ PUSHBUTTON "&Help", 3, 79, 19, 34, 14
+END
+rotationspeedBox DIALOG 52, 57, 168, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Rotation speed"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Rotations per second:", 100, 0, 5, 84, 11, WS_GROUP
+ EDITTEXT 10, 88, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 52, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 58, 19, 52, 14
+ PUSHBUTTON "&Help", 3, 114, 19, 52, 14
+END
+speedBox DIALOG 52, 57, 140, 38
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Zooming speed"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ RTEXT "Zooming speed:", 100, 0, 5, 56, 11, WS_GROUP
+ EDITTEXT 10, 60, 5, 76, 11, ES_AUTOHSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK", 1, 2, 19, 42, 14, WS_GROUP
+ PUSHBUTTON "&Cancel", 2, 48, 19, 42, 14
+ PUSHBUTTON "&Help", 3, 95, 19, 42, 14
+END
diff --git a/src/ui/ui-drv/win32/xaos.exe.manifest b/src/ui/ui-drv/win32/xaos.exe.manifest
new file mode 100644
index 0000000..9a3a947
--- /dev/null
+++ b/src/ui/ui-drv/win32/xaos.exe.manifest
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<assemblyIdentity version="3.5.0.0" processorArchitecture="X86" name="net.sourceforge.XaoS" type="win32" />
+<description>Your application description here.</description>
+<dependency>
+<dependentAssembly>
+<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" />
+</dependentAssembly>
+</dependency>
+</assembly>
diff --git a/src/ui/ui-drv/win32/xaos.ico b/src/ui/ui-drv/win32/xaos.ico
new file mode 100644
index 0000000..54a99cf
--- /dev/null
+++ b/src/ui/ui-drv/win32/xaos.ico
Binary files differ
diff --git a/src/ui/ui-drv/win32/xaos.rc b/src/ui/ui-drv/win32/xaos.rc
new file mode 100644
index 0000000..5564505
--- /dev/null
+++ b/src/ui/ui-drv/win32/xaos.rc
@@ -0,0 +1,16 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+#include <windows.h>
+#include "resource.h"
+#include "about.h"
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "xaos.exe.manifest"
+BIG ICON DISCARDABLE "xaos.ico"
+SMALL ICON DISCARDABLE "small.ico"
+
+#include "xaos.dlg"
+#include "version.rc"
+#include "about.rc"
diff --git a/src/ui/ui-drv/x11/Makefile.in b/src/ui/ui-drv/x11/Makefile.in
new file mode 100644
index 0000000..c4ac33c
--- /dev/null
+++ b/src/ui/ui-drv/x11/Makefile.in
@@ -0,0 +1,40 @@
+CC = @CC@
+CFLAGS = @CFLAGS@
+LIBS = @LIBS@ -lm
+LFLAGS = @LDFLAGS@
+AR = @AR@
+RANLIB = @RANLIB@
+
+SRCS = xlib.c \
+ ui_x11.c
+
+OBJS = $(SRCS:.c=.o)
+
+TLIB = @LIBPATH@/libuix11.a
+
+
+all: $(TLIB)
+
+$(TLIB):$(OBJS)
+ rm -f $@
+ $(AR) rc $@ $(OBJS)
+ $(RANLIB) $@
+
+clean:
+ rm -f $(TLIB)
+ rm -f *.[oas]
+ rm -f *~
+ rm -f core
+
+distclean:clean
+ rm Makefile
+
+#dep:
+# rm -f .depend
+# make .depend
+#
+#.depend:
+# echo '# Program dependencies' >.depend
+# gcc -I svgalib $(DEFINES) -MM $(patsubst %.o,%.c,$(OBJS)) >>.depend
+#
+#include .depend
diff --git a/src/ui/ui-drv/x11/ui_x11.c b/src/ui/ui-drv/x11/ui_x11.c
new file mode 100644
index 0000000..9b5daa3
--- /dev/null
+++ b/src/ui/ui-drv/x11/ui_x11.c
@@ -0,0 +1,597 @@
+/*
+ * 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.
+ */
+#include "aconfig.h"
+#ifdef X11_DRIVER
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/cursorfont.h>
+#include "xlib.h"
+#ifdef MITSHM
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+#endif
+#include <fconfig.h>
+#include <ui.h>
+xlibparam xparams = { 0, 0, 0, 0, NULL, -1 };
+
+static int allocated;
+Cursor normal, xwait, replay;
+
+struct ui_driver x11_driver;
+static xdisplay *d;
+static char *size;
+static int Xsync;
+static int busy;
+static int sharedcolormap;
+#if 0
+static char *selection;
+#endif
+#ifdef MITSHM
+static int Completion;
+#endif
+#ifdef AMIGA
+#define XFlush(x) while(0)
+#endif
+
+static void x11_setpaletterange(ui_palette p, int s, int e)
+{
+ xsetpaletterange(d, p, s, e);
+}
+
+static int x11_set_color(int r, int g, int b, int init)
+{
+ if (init)
+ xfree_colors(d);
+ return (xalloc_color(d, r * 256, g * 256, b * 256, init));
+}
+
+static void x11_print(int x, int y, CONST char *text)
+{
+ xmoveto(d, x, y + x11_driver.textheight - 2);
+ xouttext(d, text);
+
+}
+
+static void x11_flush(void)
+{
+ XFlush(d->display);
+}
+
+static int display;
+static int flipped = 0;
+static void x11_display(void)
+{
+ XFlush(d->display);
+#ifdef MITSHM
+ if (d->SharedMemFlag) {
+ if (busy) {
+ display = 1;
+ return;
+ }
+ busy++;
+ display = 0;
+ }
+#endif
+ if (Xsync)
+ XSync(d->display, 0);
+ if (flipped)
+ xflip_buffers(d), flipped = 0;
+ draw_screen(d);
+#ifdef MITSHM
+ if (d->SharedMemFlag) {
+ XSync(d->display, 0);
+ }
+#endif
+}
+
+static void x11_flip_buffers(void)
+{
+ flipped ^= 1;
+}
+
+static void x11_free_buffers(char *b1, char *b2)
+{
+ if (allocated) {
+ XSync(d->display, 0);
+ allocated = 0;
+ free_image(d);
+ }
+}
+
+static int x11_alloc_buffers(char **b1, char **b2)
+{
+ if (!allocated) {
+ XSync(d->display, 0);
+ allocated = 1;
+ if (!alloc_image(d)) {
+ return (0);
+ }
+ xflip_buffers(d);
+ }
+ *b1 = d->vbuff;
+ *b2 = d->back;
+ flipped = 0;
+#if 0
+ if (d->SharedMemFlag) {
+ x11_driver.flags |= UI_KEEP_BUFFER;
+ }
+#endif
+ return (d->linewidth);
+}
+
+static void x11_getsize(int *w, int *h)
+{
+ XSync(d->display, 0);
+ xupdate_size(d);
+ *w = d->width;
+ *h = d->height;
+}
+
+static void x11_processevents(int wait, int *mx, int *my, int *mb, int *k)
+{
+ static int mousex = 100, mousey = 0;
+ static int iflag = 0;
+ static unsigned int mousebuttons = 0;
+ static int resized;
+ XEvent ev;
+
+
+ if (XPending(d->display) || busy >= 2 || wait) {
+ do {
+ XNextEvent(d->display, &ev);
+ switch (ev.type) {
+ case ClientMessage:
+ if ((int) ev.xclient.format == 32
+ && ev.xclient.data.l[0] == wmDeleteWindow)
+ ui_quit();
+ break;
+ case ButtonRelease:
+ mousex = ev.xbutton.x;
+ mousey = ev.xbutton.y;
+ switch (ev.xbutton.button) {
+ case 1:
+ mousebuttons &= ~BUTTON1;
+ break;
+ case 2:
+ mousebuttons &= ~BUTTON2;
+ break;
+ case 3:
+ mousebuttons &= ~BUTTON3;
+ break;
+ }
+ break;
+ case ButtonPress:
+ mousex = ev.xbutton.x;
+ mousey = ev.xbutton.y;
+ if (!
+ (mousex < 0 || mousey < 0 || mousex > (int) d->width
+ || mousey > (int) d->height)) {
+ switch (ev.xbutton.button) {
+ case 1:
+ mousebuttons |= BUTTON1;
+ break;
+ case 2:
+ mousebuttons |= BUTTON2;
+ break;
+ case 3:
+ mousebuttons |= BUTTON3;
+ break;
+ }
+ }
+ break;
+ case MotionNotify:
+ mousex = ev.xmotion.x;
+ mousey = ev.xmotion.y;
+ mousebuttons =
+ ev.xmotion.state & (BUTTON1 | BUTTON2 | BUTTON3);
+ break;
+ case Expose:
+ if (resized)
+ break;
+ x11_display();
+ break;
+ case ResizeRequest:
+ XResizeWindow(d->display, d->window,
+ ev.xresizerequest.width,
+ ev.xresizerequest.height);
+ XResizeWindow(d->display, d->parent_window,
+ ev.xresizerequest.width,
+ ev.xresizerequest.height);
+ XSync(d->display, 0);
+ resized = 2;
+ ui_resize();
+ resized = 0;
+ break;
+
+ case ConfigureNotify:
+ {
+ int oldw = d->width, oldh = d->height;
+ XSync(d->display, 0);
+ xupdate_size(d);
+ if ((int) d->width != oldw || (int) d->height != oldh) {
+ resized = 2;
+ ui_resize();
+ resized = 0;
+ }
+ }
+ break;
+ case KeyRelease:
+ {
+ switch (XLookupKeysym(&ev.xkey, 0)) {
+ case XK_Left:
+ iflag &= ~1;
+ break;
+ case XK_Right:
+ iflag &= ~2;
+ break;
+ case XK_Up:
+ iflag &= ~4;
+ break;
+ case XK_Down:
+ iflag &= ~8;
+ break;
+ }
+ }
+ break;
+ case KeyPress:
+ {
+ KeySym ksym;
+ switch (ksym = XLookupKeysym(&ev.xkey, 0)) {
+ case XK_Left:
+ iflag |= 1;
+ ui_key(UIKEY_LEFT);
+ break;
+ case XK_Right:
+ iflag |= 2;
+ ui_key(UIKEY_RIGHT);
+ break;
+ case XK_Up:
+ iflag |= 4;
+ ui_key(UIKEY_UP);
+ break;
+ case XK_Down:
+ iflag |= 8;
+ ui_key(UIKEY_DOWN);
+ break;
+#ifdef XK_Page_Up
+ case XK_Page_Up:
+ iflag |= 4;
+ ui_key(UIKEY_PGUP);
+ break;
+ case XK_Page_Down:
+ iflag |= 8;
+ ui_key(UIKEY_PGDOWN);
+ break;
+#endif
+ case XK_Escape:
+ ui_key(UIKEY_ESC);
+ case XK_BackSpace:
+ ui_key(UIKEY_BACKSPACE);
+ break; /* This statement was missing.
+ I'm not sure if this is needed
+ because new X drivers handle
+ UIKEY_BACKSPACE better or
+ double backspaces were problems
+ in earlier versions of XaoS, too.
+ -- Zoltan, 2004-10-30 */
+ default:
+ {
+ CONST char *name;
+ char buff[256];
+ if (ksym == XK_F1)
+ name = "h";
+ else {
+ name = buff;
+ buff[XLookupString
+ (&ev.xkey, buff, 256, &ksym, NULL)] =
+ 0;
+ }
+ if (strlen(name) == 1) {
+ if (ui_key(*name) == 2) {
+ return;
+ }
+ }
+ }
+ }
+ }
+ break;
+ default:
+#ifdef MITSHM
+ if (ev.xany.type == Completion) {
+ busy--;
+ if (display)
+ x11_display();
+ }
+#endif
+ break;
+ }
+ }
+ while (busy >= 2 || /*XEventsQueued (d->display, QueuedAlready) */
+ XPending(d->display));
+ }
+ *mx = mousex;
+ *my = mousey;
+ *mb = mousebuttons;
+ *k = iflag;
+}
+
+/*static int defined; */
+static void x11_cursor(int mode)
+{
+ /*if(defined)
+ XUndefineCursor(d->display,d->window),defined=0; */
+ switch (mode) {
+ case NORMALMOUSE:
+ XDefineCursor(d->display, d->window, normal);
+ /*defined=1; */
+ break;
+ case WAITMOUSE:
+ XDefineCursor(d->display, d->window, xwait);
+ /*defined=1; */
+ break;
+ case REPLAYMOUSE:
+ XDefineCursor(d->display, d->window, replay);
+ /*defined=1; */
+ break;
+ }
+ XFlush(d->display);
+}
+
+#if 0
+static Atom atom;
+void x11_copy()
+{
+ if (slection)
+ free(selection), selection = NULL;
+ selection = ui_getpos();
+ atom = XInternAtom(d->display, "image/x-xaos.position", False);
+ printf("%i\n", atom);
+ XSetSelectionOwner(d->display, atom, d->window, CurrentTime);
+}
+#endif
+static int x11_init(void)
+{
+ if (xparams.windowid != -1)
+ xparams.rootwindow = xparams.fullscreen = 0;
+ if (xparams.fullscreen || xparams.rootwindow)
+ sharedcolormap = 1; /*private colormap is broken in fullscreen
+ mode (at least at my X) */
+ xparams.privatecolormap = !sharedcolormap;
+ if (xparams.display == NULL) { /*solaris stuff */
+ xparams.display = getenv("DISPLAY");
+ }
+ if (size != NULL) {
+ int x, y;
+ sscanf(size, "%ix%i", &x, &y);
+ if (x < 0)
+ x = XSIZE;
+ if (y < 0)
+ y = YSIZE;
+ d = xalloc_display("XaoS", x, y, &xparams);
+ } else
+ d = xalloc_display("XaoS", XSIZE, YSIZE, &xparams);
+ if (d == NULL)
+ return 0;
+ /*normal=XCreateFontCursor(d->display,XC_arrow); */
+ normal = XCreateFontCursor(d->display, XC_left_ptr);
+ xwait = XCreateFontCursor(d->display, XC_watch);
+ replay = XCreateFontCursor(d->display, XC_dot);
+ if (d->truecolor || d->privatecolormap)
+ x11_driver.flags &= ~RANDOM_PALETTE_SIZE;
+ if (!alloc_image(d)) {
+ xfree_display(d);
+ return (0);
+ }
+ allocated = 1;
+ switch (d->visual->class) {
+ case StaticGray:
+ if (d->depth == 1) {
+ if (BitmapBitOrder(d->display) == LSBFirst)
+ if (WhitePixel(d->display, d->screen))
+ x11_driver.imagetype = UI_LBITMAP;
+ else
+ x11_driver.imagetype = UI_LIBITMAP;
+ else if (WhitePixel(d->display, d->screen))
+ x11_driver.imagetype = UI_MBITMAP;
+ else
+ x11_driver.imagetype = UI_MIBITMAP;
+ } else {
+ /*Warning! this is untested. I believe it works */
+ /*x11_driver.set_color = x11_set_color; */
+ x11_driver.palettestart = 0;
+ x11_driver.paletteend = 256;
+ x11_driver.maxentries = 256;
+ x11_driver.imagetype = UI_GRAYSCALE;
+ }
+ break;
+ case StaticColor:
+ smallcolor:
+ {
+ int end = 256;
+ int start = 0;
+ int entries = d->visual->map_entries;
+ if (d->visual->class == TrueColor) {
+ entries = (int) (d->image[0]->red_mask |
+ d->image[0]->green_mask |
+ d->image[0]->blue_mask);
+ }
+ x11_driver.imagetype = UI_FIXEDCOLOR;
+ if (end > entries)
+ end = entries;
+ if (end < 64)
+ start = 0;
+ x11_driver.set_range = x11_setpaletterange;
+ x11_driver.palettestart = start;
+ x11_driver.paletteend = end;
+ x11_driver.maxentries = end - start;
+ }
+ break;
+ case PseudoColor:
+ case GrayScale:
+ if (d->privatecolormap) {
+ int end = 256;
+ int start = 16;
+ if (end > d->visual->map_entries)
+ end = d->visual->map_entries;
+ if (end < 64)
+ start = 0;
+ x11_driver.set_range = x11_setpaletterange;
+ x11_driver.palettestart = start;
+ x11_driver.paletteend = end;
+ x11_driver.maxentries = end - start;
+ } else {
+ int end = 256;
+ if (end > d->visual->map_entries)
+ end = d->visual->map_entries;
+ x11_driver.set_color = x11_set_color, x11_driver.flags |=
+ RANDOM_PALETTE_SIZE;
+ x11_driver.palettestart = 0;
+ x11_driver.paletteend = end;
+ x11_driver.maxentries = end;
+ }
+ break;
+ case TrueColor:
+ x11_driver.rmask = d->image[0]->red_mask;
+ x11_driver.gmask = d->image[0]->green_mask;
+ x11_driver.bmask = d->image[0]->blue_mask;
+ {
+ unsigned char c[4];
+ int order = MSBFirst;
+ *(unsigned short *) c = 0xff;
+ if (c[0] == (unsigned char) 0xff)
+ order = LSBFirst;
+ if (order != d->image[0]->byte_order) {
+ int shift = 32 - d->image[0]->bits_per_pixel;
+#define SWAPE(c) (((c&0xffU)<<24)|((c&0xff00U)<<8)|((c&0xff0000U)>>8)|((c&0xff000000U)>>24))
+ x11_driver.rmask = SWAPE(x11_driver.rmask) >> shift;
+ x11_driver.gmask = SWAPE(x11_driver.gmask) >> shift;
+ x11_driver.bmask = SWAPE(x11_driver.bmask) >> shift;
+ }
+ }
+ switch (d->image[0]->bits_per_pixel) {
+ case 8:
+ goto smallcolor;
+ case 16:
+ x11_driver.imagetype = UI_TRUECOLOR16;
+ break;
+ case 24:
+ x11_driver.imagetype = UI_TRUECOLOR24;
+ break;
+ case 32:
+ x11_driver.imagetype = UI_TRUECOLOR;
+ break;
+ default:
+ printf("Fatal error:unsupported bits per pixel!\n");
+ }
+ }
+ x11_driver.maxwidth = XDisplayWidth(d->display, d->screen);
+ x11_driver.maxheight = XDisplayHeight(d->display, d->screen);
+ x11_driver.width =
+ ((double) ((unsigned int) XDisplayWidthMM(d->display, d->screen)))
+ / x11_driver.maxwidth / 10.0;
+ x11_driver.height =
+ ((double) ((unsigned int) XDisplayHeightMM(d->display, d->screen)))
+ / x11_driver.maxheight / 10.0;
+ x11_driver.textheight = xsetfont(d, "fixed");
+ x11_driver.textwidth =
+ d->font_struct->max_bounds.rbearing -
+ d->font_struct->min_bounds.lbearing;
+#ifdef MITSHM
+ Completion = XShmGetEventBase(d->display) + ShmCompletion;
+#endif
+ if (d->privatecolormap) {
+ x11_driver.flags |= PALETTE_ROTATION | ROTATE_INSIDE_CALCULATION;
+ }
+ return (1);
+}
+
+static void x11_uninitialise(void)
+{
+#if 0
+ if (selection)
+ free(selection), selection = NULL;
+#endif
+ xfree_colors(d);
+ xfree_display(d);
+}
+
+static void x11_getmouse(int *x, int *y, int *b)
+{
+ int rootx, rooty;
+ Window rootreturn, childreturn;
+ XQueryPointer(d->display, d->window,
+ &rootreturn, &childreturn,
+ &rootx, &rooty, x, y, (unsigned int *) b);
+}
+
+static CONST struct params params[] = {
+ {"", P_HELP, NULL, "X11 driver options:"},
+ {"-display", P_STRING, &xparams.display, "Select display"},
+ {"-size", P_STRING, &size, "Select size of window (WIDTHxHEIGHT)."},
+ {"-sync", P_SWITCH, &Xsync,
+ "Generate sync signals before looking for events. This\n\t\t\thelps on old and buggy HP-UX X servers."},
+ {"-shared", P_SWITCH, &sharedcolormap,
+ "Use shared colormap on pseudocolor display."},
+ {"-usedefault", P_SWITCH, &xparams.usedefault,
+ "Use default visual if autodetection causes troubles."},
+ {"-nomitshm", P_SWITCH, &xparams.nomitshm,
+ "Disable MITSHM extension."},
+ {"-fullscreen", P_SWITCH, &xparams.fullscreen,
+ "Enable fullscreen mode."},
+ {"-windowid", P_NUMBER, &xparams.windowid, "Use selected window."},
+ {"-window-id", P_NUMBER, &xparams.windowid, "Use selected window."},
+ {"-root", P_SWITCH, &xparams.rootwindow, "Use root window."},
+ {NULL, 0, NULL, NULL}
+};
+
+struct ui_driver x11_driver = {
+ "X11",
+ x11_init,
+ x11_getsize,
+ x11_processevents,
+ x11_getmouse,
+ x11_uninitialise,
+ NULL,
+ NULL,
+ x11_print,
+ x11_display,
+ x11_alloc_buffers,
+ x11_free_buffers,
+ x11_flip_buffers,
+ x11_cursor,
+ x11_flush,
+ 8,
+ 8,
+ params,
+ RESOLUTION | PIXELSIZE | NOFLUSHDISPLAY /*| UPDATE_AFTER_RESIZE */ ,
+ 0.0, 0.0,
+ 0, 0,
+ UI_C256,
+ 16, 254, 254 - 16
+};
+
+#endif
diff --git a/src/ui/ui-drv/x11/xlib.c b/src/ui/ui-drv/x11/xlib.c
new file mode 100644
index 0000000..87308b8
--- /dev/null
+++ b/src/ui/ui-drv/x11/xlib.c
@@ -0,0 +1,663 @@
+/*
+ * 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.
+ */
+#include "aconfig.h"
+#ifdef X11_DRIVER
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <config.h>
+#ifndef NO_MALLOC_H
+#include <malloc.h>
+#endif
+#include "xlib.h"
+#ifdef AMIGA
+#define XFlush(x) while(0)
+#endif
+
+#define chkalloc(n) if (!n) fprintf(stderr, "out of memory\n"), exit(-1)
+
+extern int prog_argc;
+extern char **prog_argv;
+Atom wmDeleteWindow;
+
+int xupdate_size(xdisplay * d)
+{
+ int tmp;
+ Window wtmp;
+ unsigned int width = d->width, height = d->height;
+ XSync(d->display, False);
+ XGetGeometry(d->display, d->window, &wtmp, &tmp, &tmp, &d->width,
+ &d->height, (unsigned int *) &tmp, (unsigned int *) &tmp);
+ if (d->width != width || d->height != height)
+ return 1;
+ return 0;
+}
+
+void xflip_buffers(xdisplay * d)
+{
+ d->back = d->vbuffs[d->current];
+ d->current ^= 1;
+ d->vbuff = d->vbuffs[d->current];
+}
+
+
+void draw_screen(xdisplay * d)
+{
+#ifdef MITSHM
+ if (d->SharedMemFlag) {
+ XShmPutImage(d->display, d->window, d->gc, d->image[d->current], 0,
+ 0, 0, 0, d->bwidth, d->bheight, True);
+ } else
+#endif
+ XPutImage(d->display, d->window, d->gc, d->image[d->current], 0, 0,
+ 0, 0, d->bwidth, d->bheight);
+ /*XFlush(d->display); *//*gives small rest to X but degrades perofrmance
+ too much */
+ d->screen_changed = 0;
+}
+
+#ifdef MITSHM
+int alloc_shm_image(xdisplay * new)
+{
+ register char *ptr;
+ int temp, size = 0, i;
+ ptr = DisplayString(new->display);
+ if (!ptr || (*ptr == ':') || !strncmp(ptr, "localhost:", 10) ||
+ !strncmp(ptr, "unix:", 5) || !strncmp(ptr, "local:", 6)) {
+ new->SharedMemOption =
+ XQueryExtension(new->display, "MIT-SHM", &temp, &temp, &temp);
+ } else {
+ new->SharedMemOption = False;
+ return 0;
+ }
+ new->SharedMemFlag = False;
+
+ if (new->SharedMemFlag) {
+ XShmDetach(new->display, &new->xshminfo[0]);
+ XShmDetach(new->display, &new->xshminfo[1]);
+ new->image[0]->data = (char *) NULL;
+ new->image[1]->data = (char *) NULL;
+ shmdt(new->xshminfo[0].shmaddr);
+ shmdt(new->xshminfo[1].shmaddr);
+ }
+ for (i = 0; i < 2; i++) {
+ if (new->SharedMemOption) {
+ new->SharedMemFlag = False;
+ new->image[i] =
+ XShmCreateImage(new->display, new->visual, new->depth,
+ new->depth == 1 ? XYBitmap : ZPixmap, NULL,
+ &new->xshminfo[i], new->width,
+ new->height);
+ if (new->image[i]) {
+ temp =
+ new->image[i]->bytes_per_line *
+ (new->image[i]->height + 150);
+ new->linewidth = new->image[i]->bytes_per_line;
+ if (temp > size)
+ size = temp;
+ new->xshminfo[i].shmid =
+ shmget(IPC_PRIVATE, size, IPC_CREAT | 0777);
+ if (new->xshminfo[i].shmid != -1) {
+ errno = 0;
+ new->xshminfo[i].shmaddr =
+ (char *) shmat(new->xshminfo[i].shmid, 0, 0);
+ if (!errno) {
+ new->image[i]->data = new->xshminfo[i].shmaddr;
+ new->data[i] = new->vbuffs[i] =
+ (char *) new->image[i]->data;
+ new->xshminfo[i].readOnly = True;
+
+ new->SharedMemFlag =
+ XShmAttach(new->display, &new->xshminfo[i]);
+ XSync(new->display, False);
+ if (!new->SharedMemFlag) {
+ XDestroyImage(new->image[i]);
+ new->image[i] = (XImage *) NULL;
+ new->SharedMemFlag = 0;
+ return 0;
+ }
+ }
+ /* Always Destroy Shared Memory Ident */
+ shmctl(new->xshminfo[i].shmid, IPC_RMID, 0);
+ }
+ if (!new->SharedMemFlag) {
+ XDestroyImage(new->image[i]);
+ new->image[i] = (XImage *) NULL;
+ new->SharedMemFlag = 0;
+ return 0;
+ }
+ } else {
+ new->SharedMemFlag = 0;
+ return 0;
+ }
+ } else {
+ new->SharedMemFlag = 0;
+ return 0;
+ }
+ }
+ new->current = 0;
+ xflip_buffers(new);
+ return 1;
+}
+
+void free_shm_image(xdisplay * d)
+{
+ if (d->SharedMemFlag) {
+ XDestroyImage(d->image[0]);
+ XDestroyImage(d->image[1]);
+ XShmDetach(d->display, &d->xshminfo[0]);
+ XShmDetach(d->display, &d->xshminfo[1]);
+ shmdt(d->xshminfo[0].shmaddr);
+ shmdt(d->xshminfo[1].shmaddr);
+ }
+}
+
+#endif
+
+int alloc_image(xdisplay * d)
+{
+ int i;
+ d->bwidth = d->width;
+ d->bheight = d->height;
+#ifdef MITSHM
+ if (!d->params->nomitshm && d->depth != 1 && alloc_shm_image(d)) {
+ return 1;
+ }
+#endif
+ for (i = 0; i < 2; i++) {
+
+ d->image[i] =
+ XCreateImage(d->display, d->visual, d->depth,
+ d->depth == 1 ? XYBitmap : ZPixmap, 0, NULL,
+ d->width, d->height, 32, 0);
+ if (d->image[i] == NULL) {
+ printf("Out of memory for image..exiting\n");
+ exit(-1);
+ }
+ d->image[i]->data =
+ malloc(d->image[i]->bytes_per_line * d->height);
+ if (d->image[i]->data == NULL) {
+ printf("Out of memory for image buffers..exiting\n");
+ exit(-1);
+ }
+ {
+ unsigned char c[4];
+ int byteexact = 0;
+ *(unsigned short *) c = 0xff;
+ if ((!(d->image[i]->red_mask & ~0xffU)
+ || !(d->image[i]->red_mask & ~0xff00U)
+ || !(d->image[i]->red_mask & ~0xff0000U)
+ || !(d->image[i]->red_mask & ~0xff000000U))
+ && (!(d->image[i]->green_mask & ~0xffU)
+ || !(d->image[i]->green_mask & ~0xff00U)
+ || !(d->image[i]->green_mask & ~0xff0000U)
+ || !(d->image[i]->green_mask & ~0xff000000U))
+ && (!(d->image[i]->blue_mask & ~0xffU)
+ || !(d->image[i]->blue_mask & ~0xff00U)
+ || !(d->image[i]->blue_mask & ~0xff0000U)
+ || !(d->image[i]->blue_mask & ~0xff000000U)))
+ byteexact = 1;
+ if (!byteexact) {
+ /*Make endianity correct */
+ if (c[0] == (unsigned char) 0xff) {
+ if (d->image[i]->byte_order != LSBFirst) {
+ d->image[i]->byte_order = LSBFirst;
+ /*XInitImage(d->image[i]); */
+ }
+ } else {
+ if (d->image[i]->byte_order != MSBFirst) {
+ d->image[i]->byte_order = MSBFirst;
+ /*XInitImage(d->image[i]); */
+ }
+ }
+ }
+ }
+ d->data[i] = d->vbuffs[i] = (char *) d->image[i]->data;
+ d->linewidth = d->image[i]->bytes_per_line;
+ }
+ xflip_buffers(d);
+ return 1;
+}
+
+void free_image(xdisplay * d)
+{
+#ifdef MITSHM
+ if (d->SharedMemFlag) {
+ free_shm_image(d);
+ return;
+ }
+#endif
+ XDestroyImage(d->image[0]);
+ XDestroyImage(d->image[1]);
+}
+
+#define MAX(x,y) ((x)>(y)?(x):(y))
+
+
+xdisplay *xalloc_display(CONST char *s, int x, int y, xlibparam * params)
+{
+ xdisplay *new;
+ Visual *defaultvisual;
+ XVisualInfo vis;
+ int found;
+ int i;
+
+ XClassHint classHint;
+ XWMHints *hints;
+ char **faked_argv;
+
+ new = (xdisplay *) calloc(sizeof(xdisplay), 1);
+ chkalloc(new);
+ new->display = XOpenDisplay(params->display);
+ if (!new->display) {
+ free((void *) new);
+ return NULL;
+ }
+ new->screen = DefaultScreen(new->display);
+
+ new->attributes =
+ (XSetWindowAttributes *) malloc(sizeof(XSetWindowAttributes));
+ chkalloc(new->attributes);
+ new->attributes->background_pixel =
+ BlackPixel(new->display, new->screen);
+ new->attributes->border_pixel = BlackPixel(new->display, new->screen);
+ new->attributes->event_mask = ButtonPressMask | StructureNotifyMask |
+ ButtonReleaseMask | PointerMotionMask | KeyPressMask |
+ ExposureMask | KeyReleaseMask;
+
+
+ new->attr_mask = CWBackPixel | CWEventMask;
+ if (params->fullscreen || params->rootwindow) {
+ new->attributes->override_redirect = True;
+ new->attr_mask |= CWOverrideRedirect;
+ } else
+ new->attr_mask |= CWBorderPixel;
+ new->class = InputOutput;
+ new->xcolor.n = 0;
+ new->parent_window = RootWindow(new->display, new->screen);
+ defaultvisual = DefaultVisual(new->display, new->screen);
+ new->params = params;
+
+ found = 0;
+ for (i = 31; i > 13 && !found; i--)
+ if (XMatchVisualInfo
+ (new->display, new->screen, i, TrueColor, &vis)) {
+ found = 1;
+ }
+ if (defaultvisual->class != StaticGray
+ && defaultvisual->class != GrayScale) {
+ for (i = 8; i && !found; i--)
+ if (XMatchVisualInfo
+ (new->display, new->screen, i, PseudoColor, &vis)) {
+ found = 1;
+ }
+ for (i = 8; i && !found; i--)
+ if (XMatchVisualInfo
+ (new->display, new->screen, i, StaticColor, &vis)) {
+ found = 1;
+ }
+ for (i = 8; i && !found; i--)
+ if (XMatchVisualInfo
+ (new->display, new->screen, i, TrueColor, &vis)) {
+ found = 1;
+ }
+ }
+ if (!found
+ && XMatchVisualInfo(new->display, new->screen, 8, StaticGray,
+ &vis)) {
+ found = 1;
+ }
+ for (i = 8; i && !found; i--)
+ if (XMatchVisualInfo
+ (new->display, new->screen, i, GrayScale, &vis)) {
+ found = 1;
+ }
+ if (!found
+ && XMatchVisualInfo(new->display, new->screen, 1, StaticGray,
+ &vis)) {
+ found = 8;
+ }
+ if (!found || params->fullscreen || params->rootwindow) {
+ new->visual = defaultvisual;
+ new->depth = DefaultDepth(new->display, new->screen);
+ } else {
+ new->visual = vis.visual;
+ new->depth = vis.depth;
+ }
+
+ switch (new->visual->class) {
+ case StaticColor:
+ case StaticGray:
+ smallcolor:
+ new->truecolor = 0;
+ new->fixedcolormap = 1;
+ break;
+ case PseudoColor:
+ case GrayScale:
+ if (new->depth <= 8) {
+ new->truecolor = 0;
+ new->fixedcolormap = 0;
+ } else {
+ goto visuals;
+ }
+ break;
+ case TrueColor:
+ new->truecolor = 1;
+ new->fixedcolormap = 1;
+ if (new->depth <= 8)
+ goto smallcolor;
+ if (new->depth > 32) {
+ goto visuals;
+ }
+ break;
+ default:
+ visuals:
+ printf
+ ("Unusuported visual. Please contact authors. Maybe it will be supported in next release:)\n");
+ return (NULL);
+ }
+ new->privatecolormap = params->privatecolormap;
+ new->attributes->colormap = new->defaultcolormap =
+ DefaultColormap(new->display, new->screen);
+ if (new->visual->visualid != defaultvisual->visualid) {
+ new->privatecolormap = 1;
+ }
+ if ( /*!new->fixedcolormap && */ new->privatecolormap) {
+ unsigned long pixels[256];
+ int i;
+ new->attributes->colormap =
+ XCreateColormap(new->display,
+ RootWindow(new->display, new->screen),
+ new->visual, AllocNone);
+ if (new->visual->visualid == defaultvisual->visualid
+ && new->visual->class == PseudoColor) {
+ XAllocColorCells(new->display, new->attributes->colormap, 1, 0,
+ 0, pixels, MAX(new->visual->map_entries,
+ 256));
+ for (i = 0; i < 16; i++) {
+ new->xcolor.c[i].pixel = pixels[i];
+ }
+ XQueryColors(new->display, new->defaultcolormap, new->xcolor.c,
+ 16);
+ XStoreColors(new->display, new->attributes->colormap,
+ new->xcolor.c, 16);
+ }
+ }
+ new->colormap = new->attributes->colormap;
+ new->attr_mask |= CWColormap;
+
+ new->window_name = (char *) s;
+ new->height = y;
+ new->width = x;
+ new->border_width = 2;
+ new->lastx = 0;
+ new->lasty = 0;
+ new->font_struct = (XFontStruct *) NULL;
+
+ if (params->fullscreen || params->rootwindow) {
+ Window wtmp;
+ int tmp;
+ /* Get size of the root window */
+ XGetGeometry(new->display, RootWindow(new->display, new->screen), &wtmp, &tmp, &tmp, &new->width, &new->height, (unsigned int *) &tmp, /* border width */
+ (unsigned int *) &tmp); /* depth */
+ new->border_width = 0;
+ }
+
+ if (params->windowid != -1) {
+ Window wtmp;
+ int tmp;
+
+ new->parent_window = params->windowid;
+ XGetGeometry(new->display, new->parent_window, &wtmp, &tmp, &tmp, &new->width, &new->height, (unsigned int *) &tmp, /* border width */
+ (unsigned int *) &tmp); /* depth */
+ XSelectInput(new->display, new->parent_window, ResizeRedirectMask);
+ }
+ if (params->rootwindow)
+ new->window = RootWindow(new->display, new->screen);
+ else
+ new->window = XCreateWindow(new->display, new->parent_window, 0, 0,
+ new->width, new->height,
+ new->border_width, new->depth,
+ new->class, new->visual,
+ new->attr_mask, new->attributes);
+
+ classHint.res_name = (char *) "xaos";
+ classHint.res_class = (char *) "XaoS";
+ hints = XAllocWMHints();
+ hints->initial_state = NormalState;
+ hints->window_group = new->window;
+ hints->flags = (WindowGroupHint | StateHint);
+
+ {
+ int fake = 0;
+
+ if (prog_argc < 2)
+ fake = 1;
+
+ if (fake == 0)
+ if (strcmp(prog_argv[prog_argc - 2], "-driver") &&
+ strcmp(prog_argv[prog_argc - 1], "x11"))
+ fake = 1;
+
+ if (fake) {
+ int i;
+ faked_argv =
+ (char **) malloc((prog_argc + 2) * sizeof(char *));
+ for (i = 0; i < prog_argc; i++)
+ faked_argv[i] = prog_argv[i];
+ faked_argv[prog_argc] = (char *) "-driver";
+ faked_argv[prog_argc + 1] = (char *) "x11";
+
+ XSetWMProperties(new->display, new->window, NULL, NULL,
+ faked_argv, prog_argc + 2, NULL, hints,
+ &classHint);
+
+ free(faked_argv);
+ } else
+ XSetWMProperties(new->display, new->window, NULL, NULL,
+ prog_argv, prog_argc, NULL, hints,
+ &classHint);
+ }
+ XSetIconName(new->display, new->window, "xaos");
+
+ wmDeleteWindow = XInternAtom(new->display, "WM_DELETE_WINDOW", False);
+ XSetWMProtocols(new->display, new->window, &wmDeleteWindow, 1);
+
+ new->gc = XCreateGC(new->display, new->window, 0L, &(new->xgcvalues));
+ XSetBackground(new->display, new->gc,
+ BlackPixel(new->display, new->screen));
+ XSetForeground(new->display, new->gc,
+ WhitePixel(new->display, new->screen));
+ XStoreName(new->display, new->window, new->window_name);
+ XMapWindow(new->display, new->window);
+ if (params->fullscreen || params->rootwindow)
+ XSetInputFocus(new->display, new->window, RevertToNone,
+ CurrentTime);
+
+ return (new);
+}
+
+void xsetcolor(xdisplay * d, int col)
+{
+ switch (col) {
+ case 0:
+ XSetForeground(d->display, d->gc,
+ BlackPixel(d->display, d->screen));
+ break;
+ case 1:
+ XSetForeground(d->display, d->gc,
+ WhitePixel(d->display, d->screen));
+ break;
+ default:
+ if ((col - 2) > d->xcolor.n) {
+ fprintf(stderr, "color error\n");
+ exit(-1);
+ }
+ XSetForeground(d->display, d->gc, d->xcolor.c[col - 2].pixel);
+ break;
+ }
+}
+
+void xsetpaletterange(xdisplay * d, ui_palette c, int start, int end)
+{
+ int i;
+ if (d->visual->class == StaticColor || d->visual->class == TrueColor) {
+ for (i = start; i < end; i++)
+ d->xcolor.c[i].pixel = i;
+ XQueryColors(d->display, d->colormap, d->xcolor.c + start,
+ end - start);
+ for (i = start; i < end; i++) {
+ c[i - start][0] = d->xcolor.c[i].red / 256;
+ c[i - start][1] = d->xcolor.c[i].green / 256;
+ c[i - start][2] = d->xcolor.c[i].blue / 256;
+ }
+
+ } else {
+ for (i = start; i < end; i++) {
+ d->xcolor.c[i].pixel = i;
+ d->xcolor.c[i].flags = DoRed | DoGreen | DoBlue;
+ d->xcolor.c[i].red = c[i - start][0] * 256;
+ d->xcolor.c[i].green = c[i - start][1] * 256;
+ d->xcolor.c[i].blue = c[i - start][2] * 256;
+ }
+ XStoreColors(d->display, d->colormap, d->xcolor.c + start,
+ end - start);
+ }
+}
+
+int xalloc_color(xdisplay * d, int r, int g, int b, int readwrite)
+{
+ d->xcolor.n++;
+ d->xcolor.c[d->xcolor.n - 1].flags = DoRed | DoGreen | DoBlue;
+ d->xcolor.c[d->xcolor.n - 1].red = r;
+ d->xcolor.c[d->xcolor.n - 1].green = g;
+ d->xcolor.c[d->xcolor.n - 1].blue = b;
+ d->xcolor.c[d->xcolor.n - 1].pixel = d->xcolor.n - 1;
+ if ((readwrite && !d->fixedcolormap) || d->privatecolormap) {
+ unsigned long cell;
+ if (d->privatecolormap) {
+ cell = d->xcolor.c[d->xcolor.n - 1].pixel += 16;
+ if ((int) d->xcolor.c[d->xcolor.n - 1].pixel >=
+ d->visual->map_entries) {
+ d->xcolor.n--;
+ return (-1);
+ }
+ } else {
+ if (!XAllocColorCells
+ (d->display, d->colormap, 0, 0, 0, &cell, 1)) {
+ d->xcolor.n--;
+ if (d->xcolor.n <= 32)
+ printf
+ ("Colormap is too full! close some colorfull applications or use -private\n");
+ return (-1);
+ }
+ d->xcolor.c[d->xcolor.n - 1].pixel = cell;
+ }
+ XStoreColor(d->display, d->colormap,
+ &(d->xcolor.c[d->xcolor.n - 1]));
+ return ((int) cell);
+ }
+ if (!XAllocColor
+ (d->display, d->colormap, &(d->xcolor.c[d->xcolor.n - 1]))) {
+ d->xcolor.n--;
+ if (d->xcolor.n <= 32)
+ printf
+ ("Colormap is too full! close some colorfull aplications or use -private\n");
+ return (-1);
+ }
+ d->pixels[d->xcolor.n - 1] = d->xcolor.c[d->xcolor.n - 1].pixel;
+ return (d->depth !=
+ 8 ? d->xcolor.n - 1 : (int) d->xcolor.c[d->xcolor.n -
+ 1].pixel);
+}
+
+void xfree_colors(xdisplay * d)
+{
+ unsigned long pixels[256];
+ int i;
+ for (i = 0; i < d->xcolor.n; i++)
+ pixels[i] = d->xcolor.c[i].pixel;
+ if (!d->privatecolormap)
+ XFreeColors(d->display, d->colormap, pixels, d->xcolor.n, 0);
+ d->xcolor.n = 0;
+}
+
+void xfree_display(xdisplay * d)
+{
+ XSync(d->display, 0);
+ if (d->font_struct != (XFontStruct *) NULL) {
+ XFreeFont(d->display, d->font_struct);
+ }
+ XUnmapWindow(d->display, d->window);
+ XDestroyWindow(d->display, d->window);
+ XCloseDisplay(d->display);
+ free((void *) d->attributes);
+ free((void *) d);
+}
+
+void xclear_screen(xdisplay * d)
+{
+ XClearWindow(d->display, d->window);
+ d->screen_changed = 1;
+}
+
+void xmoveto(xdisplay * d, int x, int y)
+{
+ d->lastx = x, d->lasty = y;
+}
+
+int xsetfont(xdisplay * d, CONST char *font_name)
+{
+
+ if (d->font_struct != (XFontStruct *) NULL) {
+ XFreeFont(d->display, d->font_struct);
+ }
+ d->font_struct = XLoadQueryFont(d->display, font_name);
+ XSetFont(d->display, d->gc, d->font_struct->fid);
+ if (!d->font_struct) {
+ fprintf(stderr, "could not load font: %s\n", font_name);
+ exit(-1);
+ }
+ return (d->font_struct->max_bounds.ascent +
+ d->font_struct->max_bounds.descent);
+}
+
+void xouttext(xdisplay * d, CONST char *string)
+{
+ int sz;
+
+ sz = (int) strlen(string);
+ XDrawImageString(d->display, d->window, d->gc, d->lastx, d->lasty,
+ string, sz);
+}
+
+void xresize(xdisplay * d, XEvent * ev)
+{
+ XSync(d->display, False);
+ d->width = ev->xconfigure.width;
+ d->height = ev->xconfigure.height;
+}
+
+#endif
diff --git a/src/ui/ui-drv/x11/xlib.h b/src/ui/ui-drv/x11/xlib.h
new file mode 100644
index 0000000..485a032
--- /dev/null
+++ b/src/ui/ui-drv/x11/xlib.h
@@ -0,0 +1,139 @@
+/*
+ * 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.
+ */
+#ifndef XAOS_X11_H
+#define XAOS_X11_H
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+#include <X11/keysymdef.h>
+#include "config.h"
+#include "ui.h"
+#ifdef MITSHM
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+#endif /* MITSHM */
+
+typedef struct {
+ int n;
+ XColor c[256];
+} xcol_t;
+
+typedef struct {
+ int privatecolormap;
+ int usedefault;
+ int nomitshm;
+ int fullscreen;
+ char *display;
+ int windowid;
+ int rootwindow;
+} xlibparam;
+
+typedef struct {
+ Colormap colormap;
+ Colormap defaultcolormap;
+ int fixedcolormap;
+ int privatecolormap;
+ xlibparam *params;
+ Display *display;
+ Window parent_window;
+ Window window;
+ unsigned int width, height;
+ unsigned int bwidth, bheight;
+ unsigned int border_width;
+ unsigned long background;
+ int depth;
+ unsigned int class;
+ Visual *visual;
+ unsigned long valuemask;
+ XSetWindowAttributes *attributes;
+ unsigned long attr_mask;
+ XSizeHints sizehints;
+ int screen;
+ char *window_name;
+ int status;
+ GC gc;
+ XGCValues xgcvalues;
+ xcol_t xcolor;
+ Pixmap pixmap;
+ XFontStruct *font_struct;
+ int screen_changed;
+ int lastx, lasty;
+ int mouse_x, mouse_y;
+ unsigned int mouse_buttons;
+ int current;
+ XImage *image[2];
+#ifdef MITSHM
+ XShmSegmentInfo xshminfo[2];
+ int SharedMemOption;
+ int SharedMemFlag;
+#endif /* MITSHM */
+ unsigned long pixels[256];
+ char *vbuffs[2];
+ char *data[2];
+ char *vbuff;
+ char *back;
+ int truecolor;
+ int linewidth;
+} xdisplay;
+
+void xsetpaletterange(xdisplay * d, ui_palette c, int start, int end);
+extern int alloc_shm_image(xdisplay * d);
+extern void free_shm_image(xdisplay * d);
+extern int alloc_image(xdisplay * d);
+extern void free_image(xdisplay * d);
+extern int xupdate_size(xdisplay * d);
+extern void xflip_buffers(xdisplay * d);
+extern xdisplay *xalloc_display(CONST char *n, int x, int y,
+ xlibparam * p);
+extern void xfree_display(xdisplay * d);
+extern void xsetcolor(xdisplay * d, int col);
+extern int xsetfont(xdisplay * d, CONST char *font_name);
+extern int xalloc_color(xdisplay * d, int r, int g, int b, int readwrite);
+extern void xfree_colors(xdisplay * d);
+extern void xline(xdisplay * d, int x1, int y1, int x2, int y2);
+extern void xmoveto(xdisplay * d, int x, int y);
+extern void xlineto(xdisplay * d, int x, int y);
+extern void xrect(xdisplay * d, int x1, int y1, int x2, int y2);
+extern void xfillrect(xdisplay * d, int x1, int y1, int x2, int y2);
+extern void xarc(xdisplay * d, int x, int y, unsigned int w,
+ unsigned int h, int a1, int a2);
+extern void xfillarc(xdisplay * d, int x, int y, unsigned int w,
+ unsigned int h, int a1, int a2);
+extern void xpoint(xdisplay * d, int x, int y);
+extern void xflush(xdisplay * d);
+extern void xclear_screen(xdisplay * d);
+extern void xrotate_palette(xdisplay * d, int direction,
+ unsigned char c[3][256], int ncolors);
+extern void draw_screen(xdisplay * d);
+extern void xouttext(xdisplay * d, CONST char *string);
+extern void xresize(xdisplay * d, XEvent * ev);
+extern int xmouse_x(xdisplay * d);
+extern int xmouse_y(xdisplay * d);
+extern void xmouse_update(xdisplay * d);
+extern unsigned int xmouse_buttons(xdisplay * d);
+
+extern Atom wmDeleteWindow;
+
+#endif /* XAOS_X11_H */
diff --git a/src/ui/ui.c b/src/ui/ui.c
new file mode 100644
index 0000000..413d357
--- /dev/null
+++ b/src/ui/ui.c
@@ -0,0 +1,1761 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 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.
+ */
+#include <config.h>
+#undef _EFENCE_
+#ifdef _plan9_
+#include <u.h>
+#include <libc.h>
+#include <ctype.h>
+#else
+#include <limits.h>
+#include <aconfig.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <math.h>
+#ifdef __EMX__
+#include <float.h>
+#endif
+#ifdef __EMX__
+#include <sys/types.h>
+#endif
+#ifndef _MAC
+#include <sys/stat.h>
+#endif
+#include <time.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <signal.h>
+#endif
+#include <fconfig.h>
+#ifndef _plan9_
+#include <assert.h>
+#endif
+#include <filter.h>
+#include <ui_helper.h>
+#include <ui.h>
+#include <param.h>
+#include <version.h>
+#include <timers.h>
+#include <plane.h>
+#include <xthread.h>
+#include <xerror.h>
+#include <xmenu.h>
+#include <grlib.h>
+#include <archaccel.h>
+#include "uiint.h"
+#ifdef HAVE_GETTEXT
+#include <libintl.h>
+#include <locale.h>
+#else
+#define gettext(STRING) STRING
+#endif
+
+#ifdef SFFE_USING
+#include "sffe.h"
+#endif
+
+#ifdef DESTICKY
+int euid, egid;
+#endif
+#ifdef DEBUG
+#ifdef __linux__
+#include <malloc.h>
+#define MEMCHECK
+#endif
+#endif
+#define textheight1 (driver->textheight)
+#define textwidth1 (driver->textwidth)
+#define ui_flush() (driver->flush?driver->flush(),1:0)
+#ifdef MEMCHECK
+#define STATUSLINES 13
+#else
+#define STATUSLINES 11
+#endif
+static void ui_mouse(int mousex, int mousey, int mousebuttons,
+ int iterchange);
+#ifndef exit_xaos
+#define exit_xaos(i) exit(i)
+#endif
+
+xio_pathdata configfile;
+static void ui_unregistermenus(void);
+static void ui_mkimages(int, int);
+static void ui_mainloop(int loop);
+
+int prog_argc;
+int err;
+char **prog_argv;
+/*UI state */
+uih_context *uih;
+CONST struct ui_driver *driver;
+char statustext[256];
+int ui_nogui;
+static struct image *image;
+static int statusstart;
+static struct uih_window *statuswindow = NULL;
+static int ministatusstart;
+static struct uih_window *ministatuswindow = NULL;
+static int mouse;
+/* Used by ui_mouse */
+static int dirty = 0;
+static int lastiter;
+static int maxiter;
+static int lastbuttons, lastx, lasty;
+static int callresize = 0;
+static tl_timer *maintimer;
+static tl_timer *arrowtimer;
+static tl_timer *loopt;
+static int todriver = 0;
+
+/* Command line variables */
+static char *defpipe;
+static char *defdriver = NULL;
+static int deflist;
+static int printconfig;
+static int printspeed;
+static int delaytime = 0;
+static int defthreads = 0;
+static int maxframerate = 80;
+static float defscreenwidth = 0.0, defscreenheight = 0.0, defpixelwidth =
+ 0.0, defpixelheight = 0.0;
+
+#ifdef SFFE_USING
+char *sffeform = NULL;
+char *sffeinit = NULL;
+#endif
+
+CONST struct params global_params[] = {
+ {"-delay", P_NUMBER, &delaytime,
+ "Delay screen updates (milliseconds)"},
+ {"-driver", P_STRING, &defdriver, "Select driver"},
+ {"-list", P_SWITCH, &deflist, "List available drivers. Then exit"},
+ {"-config", P_SWITCH, &printconfig, "Print configuration. Then exit"},
+ {"-speedtest", P_SWITCH, &printspeed,
+ "Test speed of calculation loop. Then exit"},
+#ifndef nthreads
+ {"-threads", P_NUMBER, &defthreads,
+ "Set number of threads (CPUs) to use"},
+#else
+ {"-threads", P_NUMBER, &defthreads,
+ "Multiple CPUs unsupported - please recompile XaoS with threads enabled"},
+#endif
+#ifdef COMPILE_PIPE
+ {"-pipe", P_STRING, &defpipe,
+ "Accept commands from pipe (use \"-\" for stdin)"},
+#else
+ {"-pipe", P_STRING, &defpipe,
+ "Pipe input unavailable (recompile XaoS)"},
+#endif
+ {"-maxframerate", P_NUMBER, &maxframerate,
+ "Maximal framerate (0 for unlimited - default)"},
+ {"", P_HELP, NULL,
+ "Screen size options: \n\n Knowledge of exact screen size makes random dot stereogram look better. \n Also is used for choosing correct view area"},
+ {"-screenwidth", P_FLOAT, &defscreenwidth,
+ "exact size of screen in centimeters"},
+ {"-screenheight", P_FLOAT, &defscreenheight,
+ "exact size of screen in centimeters"},
+ {"", P_HELP, NULL,
+ " Use this option in case you use some kind of virtual screen\n or something similiar that confuses previous options"},
+ {"-pixelwidth", P_FLOAT, &defpixelwidth,
+ "exact size of one pixel in centimeters"},
+ {"-pixelheight", P_FLOAT, &defpixelheight,
+ "exact size of one pixel in centimeters"},
+#ifdef SFFE_USING
+ {"-formula", P_STRING, &sffeform,
+ "user formula"},
+ {"-forminit", P_STRING, &sffeinit,
+ "z0 for user formula"},
+#endif
+ {NULL, 0, NULL, NULL}
+};
+
+static int resizeregistered = 0;
+static void ui_updatemenus(uih_context * c, CONST char *name)
+{
+ CONST struct menuitem *item;
+ if (ui_nogui) {
+ if (name == NULL) {
+ printf("Root \"%s\"", uih->menuroot);
+ }
+ item = menu_findcommand(name);
+ if (item == NULL) {
+ /*x_fatalerror ("Internall error:unknown command %s", name); */
+ return;
+ }
+ if (item->flags & MENUFLAG_CHECKBOX) {
+ if (menu_enabled(item, c))
+ printf("checkbox \"%s\" on\n", name);
+ else
+ printf("checkbox \"%s\" off\n", name);
+ }
+ if (item->flags & MENUFLAG_RADIO) {
+ if (menu_enabled(item, c))
+ printf("radio \"%s\"\n", name);
+ }
+ }
+ if (driver != NULL && driver->gui_driver) {
+ if (name == NULL) {
+ if (driver->gui_driver->setrootmenu)
+ driver->gui_driver->setrootmenu(c, uih->menuroot);
+ return;
+ }
+ item = menu_findcommand(name);
+ if (item == NULL) {
+ /*fprintf (stderr, "Internall error:unknown command %s\n", name); */
+ return;
+ }
+ if (item->flags & (MENUFLAG_CHECKBOX | MENUFLAG_RADIO)) {
+ if (driver->gui_driver->enabledisable)
+ driver->gui_driver->enabledisable(uih, name);
+ }
+ }
+}
+
+static void mousetype(int m)
+{
+#ifdef _plan9_
+#define filevisible 0
+#endif
+ if (ui_nmenus || helpvisible || filevisible || dialogvisible
+ || yesnodialogvisible)
+ m = NORMALMOUSE;
+ if (mouse != m) {
+ mouse = m;
+ if (driver->mousetype != NULL)
+ driver->mousetype(m);
+ }
+}
+
+static void ui_display(void)
+{
+ if (nthreads == 1)
+ uih_drawwindows(uih);
+ driver->display();
+ uih_cycling_continue(uih);
+ if (!(driver->flags & NOFLUSHDISPLAY))
+ ui_flush();
+}
+
+float ui_get_windowwidth(int width)
+{
+ if (defscreenwidth > 0.0 && driver->flags & RESOLUTION)
+ return (defscreenwidth * width / driver->maxwidth);
+ if (defscreenwidth > 0.0)
+ return (defscreenwidth);
+ if (defpixelwidth > 0.0)
+ return (defpixelwidth * width);
+ return (0);
+}
+
+static float get_windowwidth(int width)
+{
+ float w = ui_get_windowwidth(width);
+ if (w)
+ return w;
+ if (driver->flags & PIXELSIZE)
+ return (driver->width * width);
+ if (driver->flags & SCREENSIZE)
+ return (driver->width);
+ if (driver->flags & RESOLUTION)
+ return (29.0 / driver->maxwidth * width);
+ return (29.0);
+}
+
+float ui_get_windowheight(int height)
+{
+ if (defscreenheight > 0.0 && driver->flags & RESOLUTION)
+ return (defscreenheight * height / driver->maxheight);
+ if (defscreenheight > 0.0)
+ return (defscreenheight);
+ if (defpixelheight > 0.0)
+ return (defpixelheight * height);
+ return 0;
+}
+
+static float get_windowheight(int height)
+{
+ float h = ui_get_windowheight(height);
+ if (h)
+ return h;
+ if (driver->flags & PIXELSIZE)
+ return (driver->height * height);
+ if (driver->flags & SCREENSIZE)
+ return (driver->height);
+ if (driver->flags & RESOLUTION)
+ return (21.0 / driver->maxheight * height);
+ return (21.5);
+}
+
+extern int dynsize;
+static void ui_outofmem(void)
+{
+ x_error(gettext("XaoS is out of memory."));
+}
+
+#define CHECKPROCESSEVENTS(b,k) assert(!((k)&~15)&&!((b)&~(BUTTON1|BUTTON2|BUTTON3)))
+static int
+ui_passfunc(struct uih_context *c, int display, CONST char *text,
+ float percent)
+{
+ char str[80];
+ int x = 0, y = 0, b = 0, k = 0;
+ driver->processevents(0, &x, &y, &b, &k);
+ ui_mouse(x, y, b, k);
+ CHECKPROCESSEVENTS(b, k);
+ if (!uih->play) {
+ if (uih->display)
+ ui_display(), display = 1;
+ if (!c->interruptiblemode && !uih->play) {
+ if (display) {
+ if (percent)
+ sprintf(str, "%s %3.2f%% ", text,
+ (double) percent);
+ else
+ sprintf(str, "%s ", text);
+ driver->print(0, uih->image->height - textheight1, str);
+ ui_flush();
+ }
+ } else {
+ if (!(driver->flags & NOFLUSHDISPLAY))
+ ui_flush();
+ }
+ }
+ return (0);
+}
+
+static void ui_updatestatus(void)
+{
+ double times =
+ (uih->fcontext->currentformula->v.rr) / (uih->fcontext->s.rr);
+ double timesnop = log(times) / log(10.0);
+ double speed;
+ uih_drawwindows(uih);
+ driver->display();
+ uih_cycling_continue(uih);
+ speed = uih_displayed(uih);
+ sprintf(statustext,
+ gettext
+ ("%s %.2f times (%.1fE) %2.2f frames/sec %c %i %i %i %i "),
+ times < 1 ? gettext("unzoomed") : gettext("zoomed"),
+ times < 1 ? 1.0 / times : times, timesnop, speed,
+ uih->autopilot ? 'A' : ' ', uih->fcontext->coloringmode + 1,
+ uih->fcontext->incoloringmode + 1, uih->fcontext->plane + 1,
+ uih->fcontext->maxiter);
+
+ if (!(driver->flags & NOFLUSHDISPLAY))
+ ui_flush();
+ STAT(printf(gettext("framerate:%f\n"), speed));
+ driver->print(0, 0, "");
+}
+
+void ui_updatestarts(void)
+{
+ int y = 0;
+ y += ui_menuwidth();
+ ministatusstart = y;
+ if (ministatuswindow != NULL)
+ y += xtextheight(uih->font);
+ statusstart = y;
+ if (statuswindow != NULL)
+ y += xtextheight(uih->font) * STATUSLINES;
+ uih->messg.messagestart = y;
+}
+
+void ui_menuactivate(CONST menuitem * item, dialogparam * d)
+{
+ if (item == NULL)
+ return;
+ ui_closemenus();
+ if (item->type == MENU_SUBMENU) {
+ ui_menu(item->shortname);
+ return;
+ } else {
+ if (menu_havedialog(item, uih) && d == NULL) {
+ ui_builddialog(item);
+ return;
+ }
+ if (uih->incalculation && !(item->flags & MENUFLAG_INCALC)) {
+ menu_addqueue(item, d);
+ if (item->flags & MENUFLAG_INTERRUPT)
+ uih_interrupt(uih);
+ return;
+ }
+ if (item->flags & MENUFLAG_CHECKBOX) {
+ char s[256];
+ ui_updatestatus();
+ if (!menu_enabled(item, uih))
+ sprintf(s, gettext("Enabling: %s. "), item->name);
+ else
+ sprintf(s, gettext("Disabling: %s. "), item->name);
+ uih_message(uih, s);
+ ui_flush();
+ } else
+ uih_message(uih, item->name);
+ uih_saveundo(uih);
+ menu_activate(item, uih, d);
+ if (d != NULL)
+ menu_destroydialog(item, d, uih);
+ }
+}
+
+xio_path ui_getfile(CONST char *basename, CONST char *extension)
+{
+ return (xio_getfilename(basename, extension));
+}
+
+static void
+ui_statuspos(uih_context * uih, int *x, int *y, int *w, int *h, void *data)
+{
+ *x = 0;
+ *y = statusstart;
+ *w = uih->image->width;
+ *h = xtextheight(uih->font) * STATUSLINES;
+}
+
+static void ui_drawstatus(uih_context * uih, void *data)
+{
+ char str[6000];
+ int h = xtextheight(uih->font);
+ sprintf(str, gettext("Fractal name:%s"),
+ uih->fcontext->currentformula->name[!uih->fcontext->
+ mandelbrot]);
+ xprint(uih->image, uih->font, 0, statusstart, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ sprintf(str, gettext("Fractal type:%s"),
+ uih->
+ fcontext->mandelbrot ? gettext("Mandelbrot") :
+ gettext("Julia"));
+#ifdef SFFE_USING
+ if (uih->fcontext->currentformula->flags & SFFE_FRACTAL) {
+ sprintf(str, gettext("Formula:%s"), uih->parser->expression);
+ };
+#endif
+ xprint(uih->image, uih->font, 0, statusstart + h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ sprintf(str, gettext("View:[%1.12f,%1.12f]"),
+ (double) uih->fcontext->s.cr, (double) uih->fcontext->s.ci);
+ xprint(uih->image, uih->font, 0, statusstart + 2 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ sprintf(str, gettext("size:[%1.12f,%1.12f]"),
+ (double) uih->fcontext->s.rr, (double) uih->fcontext->s.ri);
+ xprint(uih->image, uih->font, 0, statusstart + 3 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ sprintf(str, gettext("Rotation:%4.2f Screen size:%i:%i"),
+ (double) uih->fcontext->angle, uih->image->width,
+ uih->image->height);
+ xprint(uih->image, uih->font, 0, statusstart + 4 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ sprintf(str, gettext("Iterations:%-4i Palette size:%i"),
+ uih->fcontext->maxiter, uih->image->palette->size);
+ xprint(uih->image, uih->font, 0, statusstart + 5 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ sprintf(str, "Bailout:%4.2f", (double) uih->fcontext->bailout);
+ xprint(uih->image, uih->font, 0, statusstart + 6 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ sprintf(str, gettext("Autopilot:%-4s Plane:%s"),
+ uih->autopilot ? gettext("On") : gettext("Off"),
+ planename[uih->fcontext->plane]);
+ xprint(uih->image, uih->font, 0, statusstart + 7 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ sprintf(str, gettext("incoloring:%s outcoloring:%s"),
+ incolorname[uih->fcontext->incoloringmode],
+ outcolorname[uih->fcontext->coloringmode]);
+ xprint(uih->image, uih->font, 0, statusstart + 8 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ sprintf(str, gettext("zoomspeed:%f"), (float) uih->maxstep * 1000);
+ xprint(uih->image, uih->font, 0, statusstart + 9 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ if (uih->fcontext->mandelbrot)
+ strcpy(str, gettext("Parameter:none"));
+ else
+ sprintf(str, gettext("Parameter:[%f,%f]"),
+ (float) uih->fcontext->pre, (float) uih->fcontext->pim);
+ xprint(uih->image, uih->font, 0, statusstart + 10 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+#ifdef MEMCHECK
+ {
+ struct mallinfo i = mallinfo();
+ sprintf(str, "Allocated arena:%i Wasted:%i %i", i.arena, i.ordblks,
+ i.fordblks);
+ xprint(uih->image, uih->font, 0, statusstart + 11 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ sprintf(str, "Mmaped blocks%i Mmaped area:%i keep:%i", i.hblks,
+ i.hblkhd, i.keepcost);
+ xprint(uih->image, uih->font, 0, statusstart + 12 * h, str,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+ }
+#endif
+ ui_flush();
+}
+
+static void ui_status(uih_context * uih)
+{
+ if (statuswindow == NULL) {
+ statuswindow =
+ uih_registerw(uih, ui_statuspos, ui_drawstatus, NULL, 0);
+ } else {
+ uih_removew(uih, statuswindow);
+ statuswindow = NULL;
+ }
+ ui_updatemenus(uih, "status");
+ ui_updatemenus(uih, "animministatus");
+ ui_updatestarts();
+}
+
+static int ui_statusenabled(uih_context * uih)
+{
+ return (statuswindow != NULL);
+}
+
+static void
+ui_ministatuspos(uih_context * uih, int *x, int *y, int *w, int *h,
+ void *data)
+{
+ *x = 0;
+ *y = ministatusstart;
+ *w = uih->image->width;
+ *h = xtextheight(uih->font);
+}
+
+static void ui_drawministatus(uih_context * uih, void *data)
+{
+ xprint(uih->image, uih->font, 0, ministatusstart, statustext,
+ FGCOLOR(uih), BGCOLOR(uih), 0);
+}
+
+static void ui_noguisw(uih_context * uih)
+{
+ ui_nogui ^= 1;
+ ui_updatemenus(uih, "nogui");
+}
+
+static int ui_noguienabled(uih_context * uih)
+{
+ return (ui_nogui);
+}
+
+static void ui_ministatus(uih_context * uih)
+{
+ if (ministatuswindow == NULL) {
+ ministatuswindow =
+ uih_registerw(uih, ui_ministatuspos, ui_drawministatus, NULL,
+ 0);
+ } else {
+ uih_removew(uih, ministatuswindow);
+ ministatuswindow = NULL;
+ }
+ ui_updatestarts();
+ ui_updatemenus(uih, "ministatus");
+ ui_updatemenus(uih, "animministatus");
+}
+
+static int ui_ministatusenabled(uih_context * uih)
+{
+ return (ministatuswindow != NULL);
+}
+
+static void ui_message(struct uih_context *u)
+{
+ char s[80];
+ if (uih->play)
+ return;
+ mousetype(WAITMOUSE);
+ sprintf(s, gettext("Please wait while calculating %s"),
+ uih->fcontext->currentformula->name[!uih->fcontext->
+ mandelbrot]);
+ driver->print(0, 0, s);
+}
+
+#define ROTATESPEEDUP 30
+static int
+procescounter(int *counter, CONST char *text, int speed, int keys,
+ int lastkeys, int down, int up, int tenskip, int min,
+ int max)
+{
+ static int pid = -1;
+ int changed = 0;
+ char str[80];
+ if (tl_lookup_timer(arrowtimer) > 1000000)
+ tl_reset_timer(arrowtimer);
+ if ((keys & up) && !(lastkeys & up)) {
+ (*counter)++;
+ tenskip = 0;
+ changed = 1;
+ tl_reset_timer(arrowtimer);
+ }
+ if ((keys & down) && !(lastkeys & down)) {
+ (*counter)--;
+ tenskip = 0;
+ changed = 1;
+ tl_reset_timer(arrowtimer);
+ }
+ while (tl_lookup_timer(arrowtimer) > speed * FRAMETIME) {
+ tl_slowdown_timer(arrowtimer, speed * FRAMETIME);
+ if (keys & up) {
+ if (tenskip && !(*counter % 10))
+ (*counter) += 10;
+ else
+ (*counter)++;
+ changed = 1;
+ }
+ if (keys & down) {
+ if (tenskip && !(*counter % 10))
+ (*counter) -= 10;
+ else
+ (*counter)--;
+ changed = 1;
+ }
+ }
+ if (changed) {
+ if (*counter > max)
+ *counter = max;
+ if (*counter < min)
+ *counter = min;
+ sprintf(str, text, *counter);
+ uih_rmmessage(uih, pid);
+ pid = uih_message(uih, str);
+ ui_flush();
+ }
+ return changed;
+}
+
+static void
+ui_mouse(int mousex, int mousey, int mousebuttons, int iterchange)
+{
+ int flags;
+ char str[80];
+ static int spid;
+ flags = 0;
+ if (mousex != lastx || mousey != lasty)
+ flags |= MOUSE_MOVE;
+ if ((mousebuttons & BUTTON1) && !(lastbuttons & BUTTON1))
+ flags |= MOUSE_PRESS;
+ if (!(mousebuttons & BUTTON1) && (lastbuttons & BUTTON1))
+ flags |= MOUSE_RELEASE;
+ if (mousebuttons & BUTTON1)
+ flags |= MOUSE_DRAG;
+ lastx = mousex;
+ lasty = mousey;
+ lastbuttons = mousebuttons;
+ tl_update_time();
+ CHECKPROCESSEVENTS(mousebuttons, iterchange);
+ if (ui_helpmouse(mousex, mousey, mousebuttons, flags)) {
+ uih_update(uih, mousex, mousey, 0);
+ return;
+ }
+#ifndef _plan9_
+ if (ui_mousefilesel(mousex, mousey, mousebuttons, flags)) {
+ uih_update(uih, mousex, mousey, 0);
+ return;
+ }
+#endif
+ if (ui_dialogmouse(mousex, mousey, mousebuttons, flags)) {
+ uih_update(uih, mousex, mousey, 0);
+ return;
+ }
+ if (ui_menumouse(mousex, mousey, mousebuttons, flags)) {
+ uih_update(uih, mousex, mousey, 0);
+ return;
+ }
+ uih_update(uih, mousex, mousey, mousebuttons);
+ if (uih->play) {
+ procescounter(&uih->letterspersec,
+ gettext("Letters per second %i "), 2, iterchange,
+ lastiter, 1, 2, 0, 1, INT_MAX);
+ return;
+ }
+ if (!uih->cycling) {
+ if (uih->rotatemode == ROTATE_CONTINUOUS) {
+ static int rpid;
+ if (iterchange == 2) {
+ uih->rotationspeed +=
+ ROTATESPEEDUP * tl_lookup_timer(maintimer) / 1000000.0;
+ uih_rmmessage(uih, rpid);
+ sprintf(str,
+ gettext
+ ("Rotation speed:%2.2f degrees per second "),
+ (float) uih->rotationspeed);
+ rpid = uih_message(uih, str);
+ ui_flush();
+ }
+ if (iterchange == 1) {
+ uih->rotationspeed -=
+ ROTATESPEEDUP * tl_lookup_timer(maintimer) / 1000000.0;
+ uih_rmmessage(uih, rpid);
+ sprintf(str,
+ gettext
+ ("Rotation speed:%2.2f degrees per second "),
+ (float) uih->rotationspeed);
+ rpid = uih_message(uih, str);
+ ui_flush();
+ }
+ tl_reset_timer(maintimer);
+ } else {
+ if (!dirty)
+ maxiter = uih->fcontext->maxiter;
+ if (procescounter
+ (&maxiter, gettext("Iterations: %i "), 1, iterchange,
+ lastiter, 1, 2, 1, 1, INT_MAX) || (iterchange & 3)) {
+ dirty = 1;
+ lastiter = iterchange;
+ return;
+ }
+ }
+ }
+ if (dirty) {
+ if (uih->incalculation)
+ uih_interrupt(uih);
+ else
+ uih_setmaxiter(uih, maxiter), dirty = 0;
+ }
+ if (uih->cycling) {
+ if (procescounter
+ (&uih->cyclingspeed, gettext("Cycling speed: %i "), 1,
+ iterchange, lastiter, 1, 2, 0, -1000000, INT_MAX)) {
+ uih_setcycling(uih, uih->cyclingspeed);
+ }
+ }
+ if (iterchange & 4
+ && (tl_lookup_timer(maintimer) > FRAMETIME || mousebuttons)) {
+ double mul1 = tl_lookup_timer(maintimer) / FRAMETIME;
+ double su = 1 + (SPEEDUP - 1) * mul1;
+ if (su > 2 * SPEEDUP)
+ su = SPEEDUP;
+ tl_reset_timer(maintimer);
+ uih->speedup *= su, uih->maxstep *= su;
+ sprintf(str, gettext("speed:%2.2f "),
+ (double) uih->speedup * (1.0 / STEP));
+ uih_rmmessage(uih, spid);
+ spid = uih_message(uih, str);
+ ui_flush();
+ }
+ if (iterchange & 8
+ && (tl_lookup_timer(maintimer) > FRAMETIME || mousebuttons)) {
+ double mul1 = tl_lookup_timer(maintimer) / FRAMETIME;
+ double su = 1 + (SPEEDUP - 1) * mul1;
+ if (su > 2 * SPEEDUP)
+ su = SPEEDUP;
+ tl_reset_timer(maintimer);
+ uih->speedup /= su, uih->maxstep /= su;
+ sprintf(str, gettext("speed:%2.2f "),
+ (double) uih->speedup * (1 / STEP));
+ uih_rmmessage(uih, spid);
+ spid = uih_message(uih, str);
+ ui_flush();
+ }
+ lastiter = iterchange;
+ return;
+}
+
+void ui_call_resize(void)
+{
+ callresize = 1;
+ uih_interrupt(uih);
+}
+
+static int
+ui_alloccolor(struct palette *pal, int init, int r, int g, int b)
+{
+ int i;
+ i = driver->set_color(r, g, b, init);
+ if (i == -1)
+ return (-1);
+ if (init)
+ pal->size = 0;
+ pal->pixels[pal->size] = i;
+ pal->rgb[i][0] = r;
+ pal->rgb[i][1] = g;
+ pal->rgb[i][2] = b;
+ pal->size++;
+ if (driver->flags & UPDATE_AFTER_PALETTE) {
+ uih->display = 1;
+ }
+ return (i);
+}
+
+static void
+ui_setpalette(struct palette *pal, int start, int end, rgb_t * rgb1)
+{
+ driver->set_range((ui_palette) rgb1, start, end);
+}
+
+static void ui_flip(struct image *image)
+{
+ flipgeneric(image);
+ driver->flip_buffers();
+}
+
+static int ui_driverselected(uih_context * c, int d)
+{
+ return (driver == drivers[d]);
+}
+
+static void ui_setdriver(uih_context * c, int d)
+{
+ todriver = d + 1;
+}
+
+static void processbuffer(void)
+{
+ CONST menuitem *item;
+ dialogparam *d;
+ if (uih->incalculation)
+ return;
+ while ((item = menu_delqueue(&d)) != NULL) {
+ ui_menuactivate(item, d);
+ }
+}
+
+static void ui_doquit(int i) NORETURN;
+static void ui_doquit(int i)
+{
+ uih_cycling_off(uih);
+ uih_freecatalog(uih);
+ uih_freecontext(uih);
+ tl_free_timer(maintimer);
+ tl_free_timer(arrowtimer);
+ tl_free_timer(loopt);
+ driver->free_buffers(NULL, NULL);
+ driver->uninit();
+ destroypalette(image->palette);
+ destroy_image(image);
+ xth_uninit();
+ xio_uninit();
+ ui_unregistermenus();
+ uih_unregistermenus();
+ exit_xaos(i);
+}
+
+void ui_quit(void)
+{
+#ifndef _MAC
+ printf(gettext("Thank you for using XaoS\n"));
+#endif
+ ui_doquit(0);
+}
+
+static void ui_quitwr(uih_context * c, int quit)
+{
+ if (c == NULL) {
+ ui_unregistermenus();
+ uih_unregistermenus();
+ xio_uninit();
+ exit_xaos(0);
+ }
+ if (quit)
+ ui_quit();
+}
+
+int ui_key(int key)
+{
+ int sym;
+ char mkey[2];
+ CONST menuitem *item;
+#ifdef _plan9_
+#define ui_keyfilesel(k) 0
+#endif
+ if (!ui_helpkeys(key) && !ui_keyfilesel(key) && !ui_dialogkeys(key)
+ && !ui_menukey(key))
+ switch (sym = tolower(key)) {
+ case ' ':
+ ui_closemenus();
+ uih->display = 1;
+ if (uih->play) {
+ if (uih->incalculation)
+ ui_updatestatus();
+ else {
+ uih_skipframe(uih);
+ driver->print(0, 0,
+ gettext("Skipping, please wait..."));
+ }
+ }
+ break;
+ default:
+ {
+ int number;
+ if (sym >= '0' && sym <= '9') {
+ number = sym - '1';
+ if (number < 0)
+ number = 9;
+ if (number == -1)
+ break;
+ }
+ }
+ mkey[0] = key;
+ mkey[1] = 0;
+ item = menu_findkey(mkey, uih->menuroot);
+ if (item == NULL) {
+ mkey[0] = sym;
+ item = menu_findkey(mkey, uih->menuroot);
+ }
+ if (item != NULL) {
+ dialogparam *p = NULL;
+ if (menu_havedialog(item, uih)) {
+ CONST menudialog *d = menu_getdialog(uih, item);
+ int mousex, mousey, buttons;
+ driver->getmouse(&mousex, &mousey, &buttons);
+ if (d[0].question != NULL && d[1].question == NULL
+ && d[0].type == DIALOG_COORD) {
+ p = (dialogparam *) malloc(sizeof(dialogparam));
+ uih_screentofractalcoord(uih, mousex, mousey,
+ p->dcoord, p->dcoord + 1);
+ }
+ }
+ ui_menuactivate(item, p);
+ }
+ break;
+ }
+ processbuffer();
+ return 0;
+}
+
+#ifdef _EFENCE_
+int EF_ALIGNMENT = 1;
+int EF_PROTECT_BELOW = 0;
+int EF_PROTECT_FREE = 1;
+#endif
+static void ui_helpwr(struct uih_context *c)
+{
+ ui_help("main");
+}
+
+char *ui_getpos(void)
+{
+ return (uih_savepostostr(uih));
+}
+
+void ui_loadstr(CONST char *n)
+{
+ uih_loadstr(uih, n);
+}
+
+static menuitem *menuitems;
+/* This structure is now empty. All static definitions have been moved
+ to ui_registermenus_i18n() which fills up its own static array. */
+
+/* Registering internationalized menus. See also include/xmenu.h
+ for details. Note that MAX_MENUITEMS_I18N may be increased
+ if more items will be added in future. */
+
+/* Details of implementation:
+ *
+ * There are static menuitems_i18n[] arrays for several *.c files.
+ * In these files this array is common for all functions.
+ * Here, e.g. add_resizeitems() and ui_registermenus_i18n()
+ * use the same array and ui_no_menuitems_i18n is the counter
+ * that counts the number of items. The local variables
+ * count the local items.
+ */
+
+#define MAX_MENUITEMS_I18N 20
+/* These variables must be global: */
+static menuitem menuitems_i18n[MAX_MENUITEMS_I18N];
+int ui_no_menuitems_i18n = 0, ui_no_resizeitems;
+static menuitem *resizeitems;
+
+#define UI (MENUFLAG_NOPLAY|MENUFLAG_NOOPTION)
+static void add_resizeitems()
+{
+ // General version, it's needed now:
+ int no_menuitems_i18n = ui_no_menuitems_i18n; /* This variable must be local. */
+ MENUNOP_I("ui", "=", gettext("Resize"), "resize",
+ UI | MENUFLAG_INTERRUPT, ui_call_resize);
+ MENUNOP_I("uia", "=", gettext("Resize"), "animresize",
+ UI | MENUFLAG_INTERRUPT, ui_call_resize);
+ no_menuitems_i18n -= ui_no_menuitems_i18n;
+ resizeitems = &menuitems_i18n[ui_no_menuitems_i18n];
+ menu_add(resizeitems, no_menuitems_i18n);
+ ui_no_resizeitems = no_menuitems_i18n;
+ ui_no_menuitems_i18n += no_menuitems_i18n;
+}
+
+static void ui_registermenus_i18n(void)
+{
+ int no_menuitems_i18n = ui_no_menuitems_i18n; /* This variable must be local. */
+#ifndef MACOSX
+ SUBMENU_I("file", "q", gettext("Quit"), "quitmenu");
+ MENUINT_I("quitmenu", NULL, gettext("Exit now"), "quit",
+ MENUFLAG_INTERRUPT | MENUFLAG_ATSTARTUP, ui_quitwr, 1);
+ MENUINT_I("quitmenu", NULL, gettext("Not yet"), "noquit", UI,
+ ui_quitwr, 0);
+#endif
+ MENUNOP_I("helpmenu", "h", gettext("Help"), "help", MENUFLAG_INCALC,
+ ui_helpwr);
+ MENUNOPCB_I("ui", NULL, gettext("Disable XaoS's builtin GUI"), "nogui",
+ MENUFLAG_INCALC | MENUFLAG_ATSTARTUP | MENUFLAG_NOMENU,
+ ui_noguisw, ui_noguienabled);
+ MENUSEPARATOR_I("ui");
+ MENUNOPCB_I("ui", "/", gettext("Status"), "status", MENUFLAG_INCALC, ui_status, ui_statusenabled); /*FIXME: add also ? as key */
+
+ MENUNOPCB_I("ui", "l", gettext("Ministatus"), "ministatus",
+ MENUFLAG_INCALC, ui_ministatus, ui_ministatusenabled);
+ MENUSEPARATOR_I("ui");
+ MENUSEPARATOR_I("uia");
+ MENUNOPCB_I("uia", "/", gettext("Status"), "animstatus", UI | MENUFLAG_INCALC, ui_status, ui_statusenabled); /*FIXME: add also ? as key */
+
+ MENUNOPCB_I("uia", "l", gettext("Ministatus"), "animministatus",
+ UI | MENUFLAG_INCALC, ui_ministatus, ui_ministatusenabled);
+ MENUSEPARATOR_I("uia");
+ SUBMENU_I("ui", NULL, gettext("Driver"), "drivers");
+ SUBMENU_I("uia", NULL, gettext("Driver"), "drivers");
+ no_menuitems_i18n -= ui_no_menuitems_i18n;
+ menu_add(&(menuitems_i18n[ui_no_menuitems_i18n]), no_menuitems_i18n);
+ ui_no_menuitems_i18n += no_menuitems_i18n;
+}
+
+/* Registering driver items: */
+static menuitem *driveritems;
+static void ui_registermenus(void)
+{
+ int i;
+ menuitem *item;
+ menu_add(menuitems, NITEMS(menuitems));
+ driveritems = item = (menuitem *) malloc(sizeof(menuitem) * ndrivers);
+ for (i = 0; i < ndrivers; i++) {
+ item[i].menuname = "drivers";
+ item[i].shortname = drivers[i]->name;
+ item[i].key = NULL;
+ item[i].type = MENU_INT;
+ item[i].flags = MENUFLAG_RADIO | UI;
+ item[i].iparam = i;
+ item[i].name = drivers[i]->name;
+ item[i].function = (void (*)(void)) ui_setdriver;
+ item[i].control = (int (*)(void)) ui_driverselected;
+ }
+ menu_add(item, ndrivers);
+}
+
+static void ui_unregistermenus(void)
+{
+ menu_delete(menuitems, NITEMS(menuitems));
+ menu_delete(driveritems, ndrivers);
+ menu_delete(menuitems_i18n, ui_no_menuitems_i18n);
+ free(driveritems);
+}
+
+int number_six = 6;
+
+#ifdef SFFE_USING
+ /* parser variables vars */
+cmplx Z, C, pZ;
+#endif
+
+#define MAX_WELCOME 50
+
+void ui_init(int argc, char **argv)
+{
+ int i;
+ int width, height;
+ char welcome[MAX_WELCOME], language[11];
+#ifdef HAVE_GETTEXT
+ char *locale;
+#endif
+#ifdef DESTICKY
+ euid = geteuid();
+ egid = getegid();
+#endif
+#ifdef DESTICKY
+ seteuid(getuid()); /* Don't need supervisor rights anymore. */
+ setegid(getgid());
+#endif
+
+ strcpy(language, "english");
+#ifdef HAVE_GETTEXT
+ /* Setting all locales for XaoS: */
+ locale = setlocale(LC_ALL, "");
+ if (locale == NULL) {
+ printf
+ ("An error occured in your setlocale/gettext installation.\n");
+ printf("I18n menus will not be available.\n");
+ }
+#ifdef _WIN32
+ // x_message("%s",locale);
+ if (locale != NULL) {
+ if (strncmp(locale, "Hungarian", 9) == 0)
+ strcpy(language, "magyar");
+ if (strncmp(locale, "Czech", 5) == 0)
+ strcpy(language, "cesky");
+ if (strncmp(locale, "German", 6) == 0)
+ strcpy(language, "deutsch");
+ if (strncmp(locale, "Spanish", 7) == 0)
+ strcpy(language, "espanhol");
+ if (strncmp(locale, "French", 6) == 0)
+ strcpy(language, "francais");
+ if (strncmp(locale, "Romanian", 8) == 0)
+ strcpy(language, "romanian");
+ if (strncmp(locale, "Italian", 7) == 0)
+ strcpy(language, "italiano");
+ if (strncmp(locale, "Portuguese", 10) == 0)
+ strcpy(language, "portuguese");
+ }
+ // x_message("%s",language);
+#else
+ if ((locale == NULL) || (strcmp(locale, "C") == 0))
+ locale = getenv("LANG");
+ else
+ locale = setlocale(LC_MESSAGES, "");
+
+
+#ifdef DEBUG
+ printf("Trying to use locale settings for %s.\n", locale);
+#endif
+
+ if (locale != NULL) {
+ if (strlen(locale) > 2)
+ locale[2] = '\0';
+ if (strcmp(locale, "hu") == 0)
+ strcpy(language, "magyar");
+ if (strcmp(locale, "cs") == 0)
+ strcpy(language, "cesky");
+ if (strcmp(locale, "de") == 0)
+ strcpy(language, "deutsch");
+ if (strcmp(locale, "es") == 0)
+ strcpy(language, "espanhol");
+ if (strcmp(locale, "fr") == 0)
+ strcpy(language, "francais");
+ if (strcmp(locale, "ro") == 0)
+ strcpy(language, "romanian");
+ if (strcmp(locale, "it") == 0)
+ strcpy(language, "italiano");
+ if (strcmp(locale, "pt") == 0)
+ strcpy(language, "portuguese");
+ }
+#endif
+#ifdef DEBUG
+ printf("Using catalog file for %s language.\n", language);
+#endif
+ /* Without this some locales (e.g. the Hungarian) replaces "." to ","
+ in numerical format and this will cause an automatic truncation
+ at each parameter at certain places, e.g. drawing a new fractal. */
+ setlocale(LC_NUMERIC, "C");
+#ifdef DEBUG
+ printf("Text domain will be bound to directory %s.\n",
+#endif
+ bindtextdomain("xaos",
+#ifdef DOG_DRIVER
+ "..\\locale")
+#ifdef DEBUG
+ )
+#endif
+#else
+#ifdef _WIN32
+ "..\\locale")
+#ifdef DEBUG
+ )
+#endif
+#else
+#ifdef USE_LOCALEPATH
+ localepath)
+#else
+ "/usr/share/locale")
+#endif
+#ifdef DEBUG
+ )
+#endif
+#endif
+#endif
+ ;
+#ifndef _WIN32
+ bind_textdomain_codeset("xaos", "UTF-8");
+#endif
+ textdomain("xaos");
+ /* Done setting locales. */
+#endif
+ xio_init(argv[0]);
+ params_register(global_params);
+ params_register(ui_fractal_params);
+ uih_registermenudialogs_i18n(); /* Internationalized dialogs. */
+ /* Dialogs must be generated before menus because menu items
+ link to dialog pointers. */
+ uih_registermenus_i18n(); /* Internationalized menus. */
+ uih_registermenus();
+ ui_registermenus();
+ ui_registermenus_i18n(); /* Internationalized menus. */
+ for (i = 0; i < ndrivers; i++)
+ params_register(drivers[i]->params);
+#ifdef __alpha__
+#ifdef __linux__
+ extern void ieee_set_fp_control(unsigned long);
+ ieee_set_fp_control(1UL);
+#endif
+#endif
+ prog_argc = argc;
+ prog_argv = argv;
+ if (!params_parser(argc, argv)) {
+ ui_unregistermenus();
+ uih_unregistermenus();
+ xio_uninit();
+ exit_xaos(-1);
+ }
+#ifdef MEM_DEBUG
+ D_NORMAL;
+#endif
+#ifdef DEBUG
+ printf("Initializing driver\n");
+#endif
+#ifndef __BEOS__
+#ifndef _plan9_
+ signal(SIGFPE, SIG_IGN);
+#endif
+#endif
+ if (printconfig) {
+#define tostring(s) #s
+ x_message("XaoS configuration\n"
+ "Version: %s\n"
+ "Type size: %i\n" "integer size: %i\n" "configfile: %s\n"
+#ifndef _plan9_
+#ifdef HAVE_ALLOCA
+ "using alloca\n"
+#endif
+#ifdef HAVE_LONG_DOUBLE
+ "using long double\n"
+#endif
+#ifdef const
+ "const disabled\n"
+#endif
+#ifdef inline
+ "inline disabled\n"
+#endif
+#ifdef HAVE_GETTIMEOFDAY
+ "using gettimeofday\n"
+#endif
+#ifdef HAVE_FTIME
+ "using ftime\n"
+#endif
+#ifdef MITSHM
+ "using mitshm\n"
+#endif
+#ifdef HAVE_MOUSEMASK
+ "using ncurses mouse\n"
+#endif
+#ifdef DEBUG
+ "debug enabled\n"
+#endif
+#ifdef NDEBUG
+ "assertions disabled\n"
+#endif
+#ifdef STATISTICS
+ "statistics enabled\n"
+#endif
+#ifdef SFFE_USING
+ "user formula evaluation\n"
+#endif
+#endif
+ , XaoS_VERSION, (int) sizeof(FPOINT_TYPE),
+ (int) sizeof(int), CONFIGFILE);
+ }
+ if (deflist || printconfig) {
+ char s[256];
+ strcpy(s, "Available drivers: ");
+ for (i = 0; i < ndrivers; i++) {
+ strcat(s, drivers[i]->name);
+ if (i < ndrivers - 1)
+ strcat(s, ", ");
+ }
+ x_message(s);
+ ui_unregistermenus();
+ uih_unregistermenus();
+ xio_uninit();
+ exit_xaos(0);
+ }
+#ifndef _plan9_
+ xth_init(defthreads);
+#endif
+ {
+ int i = ui_dorender_params();
+ if (i) {
+ ui_unregistermenus();
+ uih_unregistermenus();
+ xio_uninit();
+ exit_xaos(i - 1);
+ }
+ }
+ if (defdriver != NULL) {
+ for (i = 0; i < ndrivers; i++) {
+ int y;
+ for (y = 0;
+ tolower(drivers[i]->name[y]) == tolower(defdriver[y])
+ && drivers[i]->name[y] != 0; y++);
+ if (drivers[i]->name[y] == 0) {
+ driver = drivers[i];
+ if (driver->init())
+ break;
+ else {
+ x_fatalerror("Can not initialize %s driver",
+ defdriver);
+ }
+ }
+ }
+ if (i == ndrivers) {
+ x_fatalerror("Unknown driver %s", defdriver);
+ }
+ } else {
+ for (i = 0; i < ndrivers; i++) {
+ driver = drivers[i];
+ if (driver->init())
+ break;
+ }
+ if (i == ndrivers) {
+ x_fatalerror("Can not initialize driver");
+ }
+ }
+#ifdef DEBUG
+ printf("Getting size\n");
+#endif
+ driver->getsize(&width, &height);
+#ifdef _plan9_
+ xth_init(defthreads); /*plan0 requires to initialize tasks after graphics */
+#endif
+ mousetype(WAITMOUSE);
+ driver->print(0, 0, "Initializing. Please wait");
+ driver->print(0, textheight1, "Creating framebuffer");
+ ui_flush();
+ ui_mkimages(width, height);
+
+ driver->print(0, textheight1 * 2, "Initializing fractal engine");
+ ui_flush();
+
+ /* gloabuih initialization moved into uih_mkcontext function : malczak */
+ uih =
+ uih_mkcontext(driver->flags, image, ui_passfunc, ui_message,
+ ui_updatemenus);
+
+ if (driver->gui_driver && driver->gui_driver->setrootmenu)
+ driver->gui_driver->setrootmenu(uih, uih->menuroot);
+ ui_flush();
+#ifdef HOMEDIR
+ if (getenv("HOME") != NULL) {
+ char home[256], *env = getenv("HOME");
+ int maxsize = 255 - (int) strlen(CONFIGFILE) - 1; /*Avoid buffer owerflow */
+ int i;
+ for (i = 0; i < maxsize && env[i]; i++)
+ home[i] = env[i];
+ home[i] = 0;
+ xio_addfname(configfile, home, CONFIGFILE);
+ } else
+#endif
+ xio_addfname(configfile, XIO_EMPTYPATH, CONFIGFILE);
+ ui_flush();
+ srand(time(NULL));
+ uih->fcontext->version++;
+ maintimer = tl_create_timer();
+ arrowtimer = tl_create_timer();
+ loopt = tl_create_timer();
+ driver->print(0, textheight1 * 3, "Loading message catalog");
+ ui_flush();
+ uih_loadcatalog(uih, language);
+ driver->print(0, textheight1 * 4, "Initializing timming system");
+ ui_flush();
+ uih_newimage(uih);
+ tl_update_time();
+ /*tl_process_group (syncgroup, NULL); */
+ tl_reset_timer(maintimer);
+ tl_reset_timer(arrowtimer);
+#ifdef COMPILE_PIPE
+ if (defpipe != NULL) {
+ driver->print(0, textheight1 * 5, "Initializing pipe");
+ ui_flush();
+ ui_pipe_init(defpipe);
+ }
+#else
+ if (defpipe != NULL) {
+ x_fatalerror("Pipe input not supported!");
+ }
+#endif
+ /*uih_constantframetime(uih,1000000/20); */
+ driver->print(0, textheight1 * 6, "Reading configuration file");
+ {
+ xio_file f = xio_ropen(configfile); /*load the configuration file */
+ if (f != XIO_FAILED) {
+ uih_load(uih, f, configfile);
+ if (uih->errstring) {
+ x_error("Configuration file %s load failed", configfile);
+ uih_printmessages(uih);
+ x_error("Hint:try to remove it :)");
+ ui_doquit(1);
+ }
+ }
+ }
+ driver->print(0, textheight1 * 7,
+ "Processing command line parameters");
+ ui_flush();
+ {
+ CONST menuitem *item;
+ dialogparam *d;
+ while ((item = menu_delqueue(&d)) != NULL) {
+ uih_saveundo(uih);
+ menu_activate(item, uih, d);
+ }
+ }
+#ifndef _plan9_
+ sprintf(welcome, gettext("Welcome to XaoS version %s"), XaoS_VERSION);
+ /*TYPE*/ uih_message(uih, welcome);
+#endif
+ uih_updatemenus(uih, driver->name);
+ if (printspeed) {
+ int c = 0;
+ int x, y, b, k;
+ int linesize = uih->image->bytesperpixel * uih->image->height;
+ int size = linesize * uih->image->height;
+ driver->print(0, textheight1 * 8, "Preparing for speedtest");
+ ui_flush();
+ uih->passfunc = NULL;
+ tl_sleep(1000000);
+ for (c = 0; c < 5; c++)
+ driver->display(), ui_flush();
+ driver->processevents(0, &x, &y, &b, &k);
+ driver->print(0, textheight1 * 9, "Measuring dislay speed");
+ ui_flush();
+ tl_sleep(1000000);
+ tl_update_time();
+ tl_reset_timer(maintimer);
+ c = 0;
+ while (tl_lookup_timer(maintimer) < 5000000)
+ driver->display(), ui_flush(), driver->processevents(0, &x, &y,
+ &b, &k),
+ tl_update_time(), c++;
+ x_message("Driver speed: %g FPS (%.4f MBPS)", c / 5.0,
+ c * (double) size / 5.0 / 1024 / 1024);
+
+ driver->print(0, textheight1 * 10, "Measuring memcpy speed");
+ ui_flush();
+ for (c = 0; c < 5; c++) {
+ for (x = 0; x < uih->image->height; x++)
+ memcpy(uih->image->currlines[y], uih->image->oldlines[y],
+ linesize);
+ }
+ tl_update_time();
+ tl_reset_timer(maintimer);
+ c = 0;
+ while (tl_lookup_timer(maintimer) < 5000000) {
+ for (x = 0; x < uih->image->height; x++)
+ memcpy(uih->image->currlines[y], uih->image->oldlines[y],
+ linesize);
+ tl_update_time(), c++;
+ }
+ x_message("Memcpy speed: %g FPS (%.4f MBPS)", c / 5.0,
+ c * (double) size / 5.0 / 1024 / 1024);
+
+ driver->print(0, textheight1 * 10,
+ "Measuring missaligned memcpy speed");
+ tl_update_time();
+ tl_reset_timer(maintimer);
+ c = 0;
+ while (tl_lookup_timer(maintimer) < 5000000) {
+ for (x = 0; x < uih->image->height; x++)
+ memcpy(uih->image->currlines[y] + 1,
+ uih->image->oldlines[y] + 2, linesize - 2);
+ tl_update_time(), c++;
+ }
+ x_message("Missaligned memcpy speed: %g FPS (%.4f MBPS)", c / 5.0,
+ c * (double) size / 5.0 / 1024 / 1024);
+
+ driver->print(0, textheight1 * 10, "Measuring size6 memcpy speed");
+ tl_update_time();
+ tl_reset_timer(maintimer);
+ c = 0;
+ while (tl_lookup_timer(maintimer) < 5000000) {
+ int x, y;
+ for (y = 0; y < uih->image->height; y++)
+ for (x = 0; x < linesize - 6; x += 6) {
+ memcpy(uih->image->currlines[y] + x,
+ uih->image->oldlines[y] + x, number_six);
+ }
+ tl_update_time(), c++;
+ }
+ x_message("Size 6 memcpy speed: %g FPS (%.4f MBPS)", c / 5.0,
+ c * (double) size / 5.0 / 1024 / 1024);
+
+ driver->display();
+ driver->print(0, textheight1 * 11, "Measuring calculation speed");
+ ui_flush();
+ speed_test(uih->fcontext, image);
+ driver->print(0, textheight1 * 12,
+ "Measuring new image calculation loop");
+ ui_flush();
+ uih_prepare_image(uih);
+ tl_update_time();
+ tl_reset_timer(maintimer);
+ for (c = 0; c < 5; c++)
+ uih_newimage(uih), uih->fcontext->version++,
+ uih_prepare_image(uih);
+ driver->display();
+ ui_flush();
+ x_message("New image caluclation took %g seconds (%.2g fps)",
+ tl_lookup_timer(maintimer) / 5.0 / 1000000.0,
+ 5000000.0 / tl_lookup_timer(maintimer));
+ tl_update_time();
+ for (c = 0; c < 5; c++)
+ uih_animate_image(uih), uih_prepare_image(uih), c++;
+ c = 0;
+ tl_update_time();
+ tl_reset_timer(maintimer);
+ driver->print(0, textheight1 * 13,
+ "Measuring zooming algorithm loop");
+ ui_flush();
+ while (tl_lookup_timer(maintimer) < 5000000)
+ uih_animate_image(uih), uih_prepare_image(uih),
+ tl_update_time(), c++;
+ x_message("Approximation loop speed: %g FPS", c / 5.0);
+ ui_doquit(0);
+ }
+#ifdef SFFE_USING
+ /*SFFE : malczak */
+ if (uih->parser->expression == NULL)
+ if (sffeform)
+ err = sffe_parse(&uih->parser, (char *) sffeform);
+ else
+ sffe_parse(&uih->parser, "z^2+c");
+
+ if (sffeinit) {
+ uih->pinit = sffe_alloc();
+ sffe_regvar(&uih->pinit, &pZ, 'p');
+ sffe_regvar(&uih->pinit, &C, 'c');
+ if (sffe_parse(&uih->pinit, (char *) sffeinit) > 0)
+ sffe_free(&uih->pinit);
+ };
+
+ if (err > 0)
+ sffe_parse(&uih->parser, "z^2+c");
+ /*SFFE*/
+#endif
+ driver->print(0, textheight1 * 8, "Entering main loop");
+ ui_flush();
+}
+
+#ifndef MAIN_FUNCTION
+#define MAIN_FUNCTION main
+#endif
+int MAIN_FUNCTION(int argc, char **argv)
+{
+ ui_init(argc, argv);
+ ui_mainloop(1);
+ ui_quit();
+
+ return (0);
+}
+
+static void ui_mkimages(int w, int h)
+{
+ struct palette *palette;
+ int scanline;
+ int width, height;
+ union paletteinfo info;
+ char *b1, *b2;
+ width = w;
+ height = h;
+ if (resizeregistered && !(driver->flags & RESIZE_COMMAND)) {
+ menu_delete(resizeitems, ui_no_resizeitems);
+ resizeregistered = 0;
+ } else {
+ if (!resizeregistered && (driver->flags & RESIZE_COMMAND)) {
+ add_resizeitems();
+ resizeregistered = 1;
+ }
+ }
+ if (!(scanline = driver->alloc_buffers(&b1, &b2))) {
+ driver->uninit();
+ x_error(gettext("Can not allocate buffers"));
+ ui_outofmem();
+ exit_xaos(-1);
+ }
+ info.truec.rmask = driver->rmask;
+ info.truec.gmask = driver->gmask;
+ info.truec.bmask = driver->bmask;
+ palette =
+ createpalette(driver->palettestart, driver->paletteend,
+ driver->imagetype,
+ (driver->
+ flags & RANDOM_PALETTE_SIZE) ? UNKNOWNENTRIES : 0,
+ driver->maxentries,
+ driver->set_color != NULL ? ui_alloccolor : NULL,
+ driver->set_range != NULL ? ui_setpalette : NULL,
+ NULL, NULL, &info);
+ if (!palette) {
+ driver->uninit();
+ x_error(gettext("Can not create palette"));
+ ui_outofmem();
+ exit_xaos(-1);
+ }
+ image =
+ create_image_cont(width, height, scanline, 2, (unsigned char *) b1,
+ (unsigned char *) b2, palette, ui_flip,
+ (driver->flags & AALIB) ? AAIMAGE : 0,
+ get_windowwidth(width) / width,
+ get_windowheight(height) / height);
+ if (!image) {
+ driver->uninit();
+ x_error(gettext("Can not create image"));
+ ui_outofmem();
+ exit_xaos(-1);
+ }
+}
+
+void ui_resize(void)
+{
+ int w, h;
+
+ /* Prevent crash on startup for Mac OS X */
+ if (!uih)
+ return;
+
+ if (uih->incalculation) {
+ uih_interrupt(uih);
+ return;
+ }
+ ui_closemenus();
+ ui_closedialog(0);
+ ui_close_help();
+ uih_clearwindows(uih);
+ uih_stoptimers(uih);
+ uih_cycling_stop(uih);
+ uih_savepalette(uih);
+ driver->getsize(&w, &h);
+ assert(w > 0 && w < 65000 && h > 0 && h < 65000);
+ if (w != uih->image->width || h != uih->image->height
+ || (driver->flags & UPDATE_AFTER_RESIZE)
+ || uih->palette->type != driver->imagetype) {
+ driver->free_buffers(NULL, NULL);
+ destroy_image(uih->image);
+ destroypalette(uih->palette);
+ ui_mkimages(w, h);
+ if (!uih_updateimage(uih, image)) {
+ driver->uninit();
+ x_error(gettext("Can not allocate tables"));
+ ui_outofmem();
+ exit_xaos(-1);
+ }
+ tl_process_group(syncgroup, NULL);
+ tl_reset_timer(maintimer);
+ tl_reset_timer(arrowtimer);
+ uih_newimage(uih);
+ }
+ uih_newimage(uih);
+ uih_restorepalette(uih);
+ /*uih_mkdefaultpalette(uih); */
+ uih->display = 1;;
+ uih_cycling_continue(uih);
+}
+
+static void ui_driver(int d)
+{
+ CONST struct ui_driver *driver1;
+ int width, height;
+ ui_closemenus();
+ ui_closedialog(0);
+ ui_close_help();
+ if (d < 0)
+ d = 0;
+ if (d >= ndrivers)
+ d = ndrivers - 1;
+ uih_stoptimers(uih);
+ driver1 = driver;
+ uih_clearwindows(uih);
+ uih_cycling_off(uih);
+ uih_savepalette(uih);
+ driver->free_buffers(NULL, NULL);
+ driver->uninit();
+ driver = drivers[d];
+ if (!driver->init()) {
+ driver = driver1;
+ uih_error(uih, gettext("Can not initialize driver"));
+ if (!driver1->init()) {
+ x_fatalerror(gettext
+ ("Can not return back to previous driver"));
+ } else
+ driver = driver1;
+ }
+ driver->getsize(&width, &height);
+ destroy_image(uih->image);
+ destroypalette(uih->palette);
+ uih->flags = driver->flags;
+ ui_mkimages(width, height);
+ if (!uih_updateimage(uih, image)) {
+ driver->uninit();
+ x_error(gettext("Can not allocate tables"));
+ ui_outofmem();
+ exit_xaos(-1);
+ }
+ if (driver->gui_driver && driver->gui_driver->setrootmenu)
+ driver->gui_driver->setrootmenu(uih, uih->menuroot);
+ tl_process_group(syncgroup, NULL);
+ tl_reset_timer(maintimer);
+ tl_reset_timer(arrowtimer);
+ uih->display = 1;
+ uih_newimage(uih);
+ uih_restorepalette(uih);
+ ui_updatestatus();
+ uih_updatemenus(uih, driver->name);
+}
+
+static void ui_mainloop(int loop)
+{
+ int inmovement = 1;
+ int x, y, b, k;
+ int time;
+ driver->processevents((!inmovement && !uih->inanimation), &x, &y, &b,
+ &k);
+ do {
+ mousetype(uih->play ? REPLAYMOUSE : uih->
+ inhibittextoutput ? VJMOUSE : NORMALMOUSE);
+ if (uih->display) {
+ uih_prepare_image(uih);
+ ui_updatestatus();
+ }
+ if ((time = tl_process_group(syncgroup, NULL)) != -1) {
+ if (!inmovement && !uih->inanimation) {
+ if (time > 1000000 / 50)
+ time = 1000000 / 50;
+ if (time > delaytime) {
+ tl_sleep(time - delaytime);
+ tl_update_time();
+ }
+ }
+ inmovement = 1;
+ }
+ if (delaytime || maxframerate) {
+ tl_update_time();
+ time = tl_lookup_timer(loopt);
+ tl_reset_timer(loopt);
+ time = 1000000 / maxframerate - time;
+ if (time < delaytime)
+ time = delaytime;
+ if (time) {
+ tl_sleep(time);
+ tl_update_time();
+ }
+ }
+ processbuffer();
+ driver->processevents((!inmovement && !uih->inanimation), &x, &y,
+ &b, &k);
+
+ inmovement = 0;
+ ui_mouse(x, y, b, k);
+ if (todriver)
+ ui_driver(todriver - 1), todriver = 0;
+ if (callresize)
+ ui_resize(), callresize = 0;
+ } while (loop);
+}
diff --git a/src/ui/ui.pri b/src/ui/ui.pri
new file mode 100644
index 0000000..75e2dff
--- /dev/null
+++ b/src/ui/ui.pri
@@ -0,0 +1,10 @@
+SOURCES += \
+ $$PWD/drivers.c \
+ $$PWD/ui.c \
+ $$PWD/uihelp.c \
+ $$PWD/param.c \
+ $$PWD/fparams.c \
+ $$PWD/filesel.c \
+ $$PWD/uimenu.c \
+ $$PWD/pipecmd.c \
+ $$PWD/dialog.c
diff --git a/src/ui/uihelp.c b/src/ui/uihelp.c
new file mode 100644
index 0000000..d597e25
--- /dev/null
+++ b/src/ui/uihelp.c
@@ -0,0 +1,486 @@
+#include <config.h>
+#ifdef _plan9_
+#include <u.h>
+#include <libc.h>
+#else
+#ifndef NO_MALLOC_H
+#include <malloc.h>
+#endif
+#include <string.h>
+#endif
+
+#include <fconfig.h>
+#include <filter.h>
+#include <fractal.h>
+#include <ui_helper.h>
+#include <ui.h>
+#include <xshl.h>
+#include <xmenu.h>
+#include <grlib.h>
+#include <misc-f.h>
+#include "uiint.h"
+#define HISTORYSIZE 10
+static int historypos;
+static struct xshl_line *lines;
+static int helpwidth, helpheight, helpx, helpy;
+static struct uih_window *helpw;
+static int textheight;
+static char *ui_helppage[HISTORYSIZE];
+static int ui_helppos[HISTORYSIZE];
+int helpvisible;
+
+static struct xshl_item *presseditem;
+static struct xshl_item *selecteditem;
+static int pressedline;
+static int selectedline;
+#define SCROOLSIZE 10
+#define XPOS(xp) (2 * BORDERWIDTH + (xp))
+#define YPOS(yp) (2*BORDERWIDTH+ (yp)-ui_helppos[historypos]+10)
+#define SCROOLSTART (helpx+helpwidth-WBORDERS)
+#define WBORDERS (4*BORDERWIDTH+SCROOLSIZE)
+#define HBORDERS (xtextheight(uih->font)+8*BORDERHEIGHT)
+#define WIDTH (uih->image->width-WBORDERS)
+#define HEIGHT (uih->image->height-HBORDERS)
+
+static int pressedbutton = -1;
+static int selectedbutton = -1;
+
+#define NBUTTONS 3
+CONST char *CONST names[] = { "OK", "Back", "Main" };
+
+#define BUTTONSTART(i) (helpx+BORDERWIDTH+(helpwidth-2*BORDERWIDTH)/NBUTTONS*(i))
+static void ui_build_help(char *name);
+static void ui_backhelp(void)
+{
+ historypos--;
+ if (historypos < 0)
+ historypos = HISTORYSIZE - 1;
+ ui_build_help(ui_helppage[historypos]);
+}
+
+static void do_button(int i)
+{
+ switch (i) {
+ case 0:
+ ui_close_help();
+ break;
+ case 1:
+ ui_backhelp();
+ break;
+ case 2:
+ ui_help("main");
+ break;
+ }
+}
+
+void ui_close_help(void)
+{
+ if (helpw != NULL) {
+ xshl_free(lines);
+ helpvisible = 0;
+ uih_removew(uih, helpw);
+ uih->display = 1;
+ helpw = NULL;
+ }
+}
+
+static int getwidth(void *data, int flags, CONST char *text)
+{
+ if (uih->image->flags & AAIMAGE)
+ return (xtextwidth(uih->font, text));
+ return (xtextwidth(uih->font, text) - 1);
+}
+
+static void
+helpsize(struct uih_context *c, int *x, int *y, int *width, int *height,
+ void
+ *data)
+{
+ *x = helpx;
+ *y = helpy;
+ *width = helpwidth;
+ *height = helpheight;
+}
+
+static void drawhelp(struct uih_context *c, void *data)
+{
+ int i = 0;
+ int y;
+ int percentx, percenty;
+ struct xshl_item *curritem;
+ uih_drawborder(uih, helpx + BORDERWIDTH, helpy + BORDERHEIGHT,
+ helpwidth - WBORDERS + SCROOLSIZE,
+ helpheight - HBORDERS, BORDER_PRESSED);
+
+ if (ui_helppos[historypos] > textheight - helpheight / 2 + HBORDERS)
+ ui_helppos[historypos] = textheight - helpheight / 2 + HBORDERS;
+ if (ui_helppos[historypos] < 0)
+ ui_helppos[historypos] = 0;
+
+ /*draw scroolbar */
+ percentx =
+ (helpheight - HBORDERS) * ui_helppos[historypos] / textheight;
+ percenty =
+ (helpheight - HBORDERS) * (ui_helppos[historypos] + helpheight -
+ HBORDERS) / textheight;
+ if (percentx < BORDERHEIGHT)
+ percentx = BORDERHEIGHT;
+ if (percenty < BORDERHEIGHT)
+ percenty = BORDERHEIGHT;
+ if (percentx > helpheight - HBORDERS - BORDERHEIGHT)
+ percentx = helpheight - HBORDERS - BORDERHEIGHT;
+ if (percenty > helpheight - HBORDERS - BORDERHEIGHT)
+ percenty = helpheight - HBORDERS - BORDERHEIGHT;
+ uih_drawborder(uih, SCROOLSTART, helpy + BORDERHEIGHT + percentx,
+ SCROOLSIZE - 1, percenty - percentx, 0);
+ for (i = 0; i < NBUTTONS; i++) {
+ ui_drawbutton(names[i], pressedbutton == i, selectedbutton == i,
+ BUTTONSTART(i) + BORDERWIDTH,
+ BUTTONSTART(i + 1) - BORDERWIDTH,
+ helpy + helpheight - BUTTONHEIGHT - BORDERHEIGHT);
+ }
+
+
+ i = 0;
+ while (YPOS(lines[i].y) < 2 * BORDERWIDTH) {
+ i++;
+ if (lines[i].y < 0)
+ return;
+ }
+ while ((y =
+ YPOS(lines[i].y)) <
+ helpheight - HBORDERS - xtextheight(uih->font)
+ && lines[i].y >= 0) {
+ curritem = lines[i].first;
+ while (curritem != NULL) {
+ unsigned int bgcolor = BGCOLOR(uih);
+ unsigned int fgcolor = /*FGCOLOR (uih) */ LIGHTGRAYCOLOR2(uih);
+ int flags = 0;
+ int x = XPOS(curritem->x);
+
+ if (curritem->c.flags & (XSHL_BIG | XSHL_RED))
+ fgcolor = SELCOLOR(uih);
+ else if (curritem->c.flags & (XSHL_EMPH | XSHL_MONOSPACE))
+ fgcolor =
+ uih->image->
+ flags & AAIMAGE ? SELCOLOR(uih) : FGCOLOR(uih);
+ else if (curritem->c.flags & (XSHL_BLACK))
+ bgcolor = fgcolor = BGCOLOR(uih), flags = TEXT_PRESSED;
+ else
+ bgcolor = fgcolor, flags |= TEXT_PRESSED;
+ if (uih->palette->type & BITMAPS) {
+ flags = TEXT_PRESSED;
+ fgcolor = BGCOLOR(uih);
+ }
+ if (curritem->c.linktext != NULL) {
+ if (uih->palette->type & BITMAPS) {
+ if (curritem == presseditem
+ || curritem == selecteditem)
+ fgcolor =
+ FGCOLOR(uih), xrectangle(uih->image, x + helpx,
+ y + helpy,
+ curritem->width,
+ xtextheight(uih->
+ font),
+ BGCOLOR(uih));
+ else
+ xhline(uih->image, x + helpx,
+ y + helpy + xtextheight(uih->font) - 1,
+ curritem->width, BGCOLOR(uih));
+ } else {
+ if (uih->image->flags & AAIMAGE)
+ fgcolor = curritem == presseditem
+ || curritem ==
+ selecteditem ? SELCOLOR(uih) : BGCOLOR(uih);
+ else {
+ int i;
+ i = strlen(curritem->c.linktext);
+ if (i > 3
+ && !strcmp(".xaf",
+ curritem->c.linktext + i - 4))
+ xhline(uih->image, x + helpx,
+ y + helpy + xtextheight(uih->font) - 1,
+ curritem->width, curritem == presseditem
+ || curritem ==
+ selecteditem ? SELCOLOR(uih) :
+ SELCOLOR(uih));
+ else
+ xhline(uih->image, x + helpx,
+ y + helpy + xtextheight(uih->font) - 1,
+ curritem->width, curritem == presseditem
+ || curritem ==
+ selecteditem ? SELCOLOR(uih) :
+ LIGHTGRAYCOLOR2(uih));
+ xhline(uih->image, x + helpx + 1,
+ y + helpy + xtextheight(uih->font) - 0,
+ curritem->width, BGCOLOR(uih));
+ }
+ flags = 0;
+ bgcolor = BGCOLOR(uih);
+ if (fgcolor == LIGHTGRAYCOLOR2(uih))
+ fgcolor = FGCOLOR(uih);
+ if (curritem == presseditem
+ || curritem == selecteditem)
+ fgcolor = SELCOLOR(uih);
+ }
+ }
+ xprint(uih->image, uih->font, x + helpx, y + helpy,
+ curritem->text, fgcolor, bgcolor, flags);
+ curritem = curritem->next;
+ }
+ i++;
+ }
+}
+
+int ui_helpkeys(int key)
+{
+ int i;
+ if (helpw == NULL)
+ return 0;
+ switch (key) {
+ case 'h':
+ ui_close_help();
+ ui_menu("tutor");
+ return 1;
+ case 'm':
+ ui_help("main");
+ return 1;
+ case UIKEY_DOWN:
+ case 'j':
+ ui_helppos[historypos] += 8, uih->display = 1;
+ presseditem = NULL;
+ selecteditem = NULL;
+ break;
+ case UIKEY_UP:
+ case 'k':
+ ui_helppos[historypos] -= 8, uih->display = 1;
+ presseditem = NULL;
+ selecteditem = NULL;
+ break;
+ case UIKEY_PGDOWN:
+ case '+':
+ case 'f':
+ case ' ':
+ ui_helppos[historypos] +=
+ helpheight - HBORDERS - 32, uih->display = 1;
+ presseditem = NULL;
+ selecteditem = NULL;
+ break;
+ case UIKEY_PGUP:
+ case '-':
+ ui_helppos[historypos] -=
+ helpheight - HBORDERS - 32, uih->display = 1;
+ presseditem = NULL;
+ selecteditem = NULL;
+ break;
+ case 'b':
+ case 1:
+ ui_backhelp();
+ break;
+ case UIKEY_ESC:
+ case 'q':
+ case 'c':
+ case 'o':
+ ui_close_help();
+ break;
+ case UIKEY_TAB:
+ case UIKEY_RIGHT:
+ uih->display = 1;
+ if (selectedbutton < 0 || selectedbutton == NBUTTONS - 1) {
+ if (selecteditem == NULL) {
+ i = 0;
+ while (YPOS(lines[i].y) < 2 * BORDERWIDTH) {
+ i++;
+ if (lines[i].y < 0)
+ break;
+ }
+ selecteditem = lines[i].first;
+ } else
+ i = selectedline, selecteditem = selecteditem->next;
+ for (;
+ lines[i].y >= 0
+ && YPOS(lines[i].y) < helpheight - HBORDERS; i++) {
+ selectedline = i;
+ while (selecteditem != NULL) {
+ if (selecteditem->c.linktext != NULL) {
+ selectedbutton = -1;
+ return 0;
+ }
+ selecteditem = selecteditem->next;
+ }
+ selecteditem = lines[i + 1].first;
+ }
+ selecteditem = NULL;
+ selectedbutton = 0;
+ } else
+ selectedbutton++;
+ break;
+ case 13:
+ case '\n':
+ if (selecteditem != NULL) {
+ ui_help(selecteditem->c.linktext);
+ return 1;
+ }
+ if (selectedbutton >= 0)
+ do_button(selectedbutton);
+ }
+ return 1;
+}
+
+int ui_helpmouse(int x, int y, int buttons, int flags)
+{
+ static int grabbed = 0;
+ int atpressed = 0;
+ if (helpw == NULL)
+ return 0;
+ if (x < helpx || y < helpy || x > helpx + helpwidth
+ || y > helpy + helpheight) {
+ if (flags & MOUSE_PRESS)
+ ui_close_help();
+ pressedbutton = -1;
+ if (pressedbutton != -1)
+ pressedbutton = -1, uih->display = 1;
+ return 1;
+ } else {
+ if (y > helpy + helpheight - BUTTONHEIGHT - 2 * BORDERHEIGHT) {
+ int button;
+ int i;
+ for (i = 0; i <= NBUTTONS; i++)
+ if (x < BUTTONSTART(i))
+ break;
+ button = i - 1;
+ if (flags & MOUSE_DRAG) {
+ if (pressedbutton != selectedbutton
+ || pressedbutton != button)
+ pressedbutton = selectedbutton = button, uih->display =
+ 1;
+ } else {
+ if (pressedbutton != -1)
+ pressedbutton = -1, uih->display = 1;
+ if (flags & MOUSE_RELEASE)
+ do_button(button);
+ }
+ return 1;
+ }
+ if (pressedbutton != -1)
+ pressedbutton = -1, uih->display = 1;
+ if (buttons
+ && ((x > SCROOLSTART && y < helpy + helpheight - HBORDERS)
+ || grabbed)) {
+ /*we are in scroolbar */
+ int pos = (y - helpy) * textheight / (helpheight - HBORDERS);
+ if (pos != ui_helppos[historypos])
+ ui_helppos[historypos] = pos, uih->display = 1;
+ grabbed = 1;
+ return 1;
+ } else
+ grabbed = 0;
+ y -= helpy + xtextheight(uih->font);
+ x -= 2 * BORDERWIDTH + helpx;
+ pressedbutton = -1;
+ if (presseditem != NULL) {
+ if (YPOS(lines[pressedline].y) + 1 >= y
+ && YPOS(lines[pressedline].y) <= y + xtextheight(uih->font)
+ && presseditem->x <= x
+ && presseditem->x + presseditem->width >= x)
+ atpressed = 1;
+ }
+ if (flags & MOUSE_PRESS || ((flags & MOUSE_DRAG) && !atpressed)) {
+ int i = 0;
+ for (i = 0;
+ lines[i].y >= 0 && (YPOS(lines[i].y) + 1 <= y
+ || YPOS(lines[i].y) >=
+ y + xtextheight(uih->font)); i++);
+ if (lines[i].y >= 0) {
+ struct xshl_item *item = lines[i].first;
+ while (item != NULL) {
+ if (item->c.linktext != NULL && item->x <= x
+ && item->x + item->width >= x)
+ break;
+ item = item->next;
+ }
+ if (item != NULL) {
+ uih->display = 1;
+ presseditem = item;
+ pressedline = i;
+ }
+ }
+ } else if (flags & MOUSE_MOVE) {
+ if (!atpressed && presseditem != NULL)
+ uih->display = 1, presseditem = 0;
+ } else if ((flags & MOUSE_RELEASE)) {
+ if (atpressed) {
+ ui_help(presseditem->c.linktext);
+ return 1;
+ }
+ if (presseditem != NULL)
+ presseditem = NULL, uih->display = 1;
+ /*odfajruj to! */
+ }
+ }
+ return 1;
+}
+
+static void ui_build_help(char *name)
+{
+ int i;
+ int width;
+ if (ui_nogui) {
+ printf("help \"%s\"\n", name);
+ return;
+ }
+ if (driver->gui_driver && driver->gui_driver->help) {
+ driver->gui_driver->help(uih, name);
+ return;
+ }
+ if (helpw != NULL)
+ ui_close_help();
+ pressedbutton = -1;
+ helpvisible = 1;
+ width = 80 * xtextwidth(uih->font, "w");
+ if (width > WIDTH)
+ width = WIDTH;
+ lines =
+ help_make(name ? name : "main", getwidth, width - 2,
+ xtextheight(uih->font), xtextheight(uih->font));
+ if (lines == NULL) {
+ lines =
+ help_make("main", getwidth, width - 2, xtextheight(uih->font),
+ xtextheight(uih->font));
+ if (lines == NULL) {
+ helpvisible = 0;
+ uih_message(uih, "Help file not found");
+ return;
+ }
+ }
+ width += WBORDERS;
+ uih->display = 1;
+ presseditem = selecteditem = NULL;
+ helpwidth = width;
+ helpx = (uih->image->width - width) / 2;
+ for (i = 0; lines[i].y >= 0; i++);
+ textheight = lines[i - 1].y + 4 * xtextheight(uih->font);
+ if (textheight < HEIGHT)
+ helpheight = textheight;
+ else
+ helpheight = HEIGHT;
+ helpheight += HBORDERS;
+ helpy = (uih->image->height - helpheight) / 2;
+ helpw = uih_registerw(uih, helpsize, drawhelp, 0, DRAWBORDER);
+}
+
+void ui_help(CONST char *name)
+{
+ if (strlen(name) > 4 && !strcmp(name + strlen(name) - 4, ".xaf")) {
+ uih_playtutorial(uih, name);
+ if (helpw != NULL)
+ ui_close_help();
+ /*FIXME!!!!!!! This needs to be queued! */
+ return;
+ }
+ historypos++;
+ historypos %= HISTORYSIZE;
+ ui_helppage[historypos] = mystrdup(name); /* NOTE we are not freeing this memory. I believe it is not problem. */
+ ui_helppos[historypos] = 0;
+ ui_build_help(ui_helppage[historypos]);
+}
diff --git a/src/ui/uiint.h b/src/ui/uiint.h
new file mode 100644
index 0000000..16223f1
--- /dev/null
+++ b/src/ui/uiint.h
@@ -0,0 +1,75 @@
+#ifndef UI_INT_H
+#define UI_INT_H
+
+#define MOUSE_PRESS 1
+#define MOUSE_RELEASE 2
+#define MOUSE_DRAG 4
+#define MOUSE_MOVE 8
+
+#define BORDERWIDTH 2
+#define BORDERHEIGHT 2
+
+#define BUTTONHEIGHT (xtextheight(uih->font)+2*BORDERWIDTH)
+
+struct ui_textdata {
+ int x, y, width;
+ char *text;
+ int size;
+ int cursor;
+ int cursorpos;
+ int start;
+ int ndisplayed;
+ int clear;
+};
+extern uih_context *uih;
+extern CONST struct ui_driver *driver;
+extern CONST int ndrivers;
+extern CONST struct ui_driver *CONST drivers[];
+extern int ui_nmenus;
+extern char *ui_helptext[];
+extern int ui_helpsize;
+extern CONST struct params ui_fractal_params[];
+extern int filevisible, helpvisible, dialogvisible, yesnodialogvisible;
+extern int ui_nogui;
+
+float ui_get_windowwidth(int width);
+float ui_get_windowheight(int height);
+
+void ui_updatetext(struct ui_textdata *d);
+struct ui_textdata *ui_opentext(int x, int y, int width, CONST char *def);
+void ui_drawtext(struct ui_textdata *d, int active);
+void ui_textmouse(struct ui_textdata *d, int x, int y);
+void ui_closetext(struct ui_textdata *d);
+int ui_textkey(struct ui_textdata *d, int key);
+
+int ui_menumouse(int x, int y, int mousebuttons, int flags);
+int ui_menukey(int key);
+int ui_menuwidth(void);
+void ui_closemenus(void);
+
+int ui_dorender_params(void);
+
+void ui_updatestarts(void);
+
+void ui_builddialog(CONST menuitem * d);
+void ui_close_help(void);
+void ui_closedialog(int call);
+int ui_dialogmouse(int x, int y, int mousebuttons, int flags);
+int ui_dialogkeys(int key);
+void ui_buildyesno(CONST char *question, void (*handler) (int yes));
+void ui_drawbutton(CONST char *text, int pressed, int selected, int x1,
+ int x2, int y);
+
+
+void ui_buildfilesel(CONST char *f, CONST char *m,
+ void (*c) (CONST char *, int));
+int ui_keyfilesel(int k);
+int ui_mousefilesel(int x, int y, int buttons, int flags);
+void ui_closefilesel(int succ);
+
+
+void ui_pipe_init(CONST char *name);
+int ui_helpkeys(int key);
+int ui_helpmouse(int x, int y, int buttons, int flags);
+
+#endif
diff --git a/src/ui/uimenu.c b/src/ui/uimenu.c
new file mode 100644
index 0000000..b920c48
--- /dev/null
+++ b/src/ui/uimenu.c
@@ -0,0 +1,572 @@
+/*
+ * XaoS, a fast portable realtime fractal zoomer
+ * Copyright (C) 1996 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.
+ */
+#undef _EFENCE_
+#ifdef _plan9_
+#include <u.h>
+#include <libc.h>
+#include <ctype.h>
+#else
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#endif
+#include <config.h>
+#include <fconfig.h>
+#ifndef _plan9_
+#include <assert.h>
+#endif
+#include <filter.h>
+#include <ui_helper.h>
+#include <ui.h>
+#include <timers.h>
+#include <xmenu.h>
+#include <grlib.h>
+#include "uiint.h"
+
+
+#define NMENUS 20
+struct ui_menuitems {
+ int x, y, width, height;
+ CONST menuitem *item;
+ int separator;
+};
+static struct ui_menu {
+ int x, y, width, height;
+ CONST char *name;
+ CONST char *fullname;
+ int namewidth;
+ int selected;
+ int n;
+ int flags;
+ struct ui_menuitems *items;
+ struct uih_window *window;
+ tl_timer *timer;
+} *ui_menus[NMENUS];
+int ui_nmenus;
+
+#define MENU_HORIZONTAL 1
+#define MENU_PRESSED 2
+#define MENU_AUTOHIDE 4
+
+#define SUBMENUWIDTH xtextwidth(uih->font, ">")
+#define MENUPAUSE xtextwidth(uih->font, "X")
+#define MENUWIDTH(a) (xtextwidth(uih->font, "w")+MENUPAUSE+xtextwidth(uih->font, a)+SUBMENUWIDTH)
+#define HMENUWIDTH(a) (xtextwidth(uih->font, a)+xtextwidth(uih->font, " "))
+
+#define SEPARATORSIZE 6
+static struct ui_menuitems *ui_getmenuitems(CONST char *name, int *width1,
+ int *height1, int *n1,
+ int horizontal)
+{
+ CONST menuitem *item;
+ int nseparators = 0;
+ int i;
+ int width = 0;
+ int n;
+ struct ui_menuitems *items;
+ for (n = 0; (item = menu_item(name, n)) != NULL; n++)
+ if (item->type == MENU_SEPARATOR)
+ nseparators++;
+ n -= nseparators;
+ *n1 = n;
+ *height1 = n * xtextheight(uih->font) + nseparators * SEPARATORSIZE;
+ items =
+ (struct ui_menuitems *) malloc(n * sizeof(struct ui_menuitems));
+ nseparators = 0;
+ for (i = 0; i < n; i++) {
+ int w;
+ int sbehind = -1;
+ nseparators--;
+ do {
+ nseparators++;
+ sbehind++;
+ item = menu_item(name, i + nseparators);
+ }
+ while (item->type == MENU_SEPARATOR);
+ items[i].item = item;
+ items[i].separator = sbehind;
+ if (horizontal) {
+ w = HMENUWIDTH(items[i].item->name);
+ if (items[i].item->key) {
+ char c[10];
+ sprintf(c, "(%s)", items[i].item->key);
+ w += xtextwidth(uih->font, c);
+ }
+ } else {
+ w = MENUWIDTH(items[i].item->name);
+ if (items[i].item->key) {
+ char c[10];
+ sprintf(c, " %s ", items[i].item->key);
+ w += xtextwidth(uih->font, c);
+ }
+ }
+ items[i].width = w;
+ items[i].height = xtextheight(uih->font) + 1;
+ if (w > width)
+ width = w;
+ }
+ *width1 = width;
+ return (items);
+}
+
+static void
+ui_menusize(uih_context * c, int *x, int *y, int *w, int *h, void *data)
+{
+ struct ui_menu *m = (struct ui_menu *) data;
+ *x = m->x;
+ *y = m->y;
+ *w = m->width;
+ *h = m->height;
+}
+
+static void ui_drawmenu(uih_context * c, void *data)
+{
+ struct ui_menu *m = (struct ui_menu *) data;
+ int i;
+ int width1 = xtextwidth(c->font, "w");
+ char s[2];
+ s[1] = 0;
+ if (!(m->flags & MENU_HORIZONTAL))
+ xprint(c->image, c->font, m->x + (m->width - m->namewidth) / 2,
+ m->y + BORDERWIDTH, m->fullname, SELCOLOR(c),
+ BGCOLOR(c), 0);
+ for (i = 0; i < m->n; i++) {
+ int color = (i == m->selected ? SELCOLOR(c) : FGCOLOR(c));
+ int pressed = 0;
+ if ((uih->palette->type & BITMAPS) && i == m->selected) {
+ pressed = TEXT_PRESSED;
+ color = BGCOLOR(c);
+ xrectangle(uih->image, m->items[i].x, m->items[i].y,
+ m->items[i].width, m->items[i].height, FGCOLOR(c));
+ }
+ if (!(m->flags & MENU_HORIZONTAL)) {
+ if (m->items[i].separator) {
+ xhline(c->image, m->x + 5,
+ m->items[i].y - 2 - SEPARATORSIZE / 2,
+ m->width - 10, BGCOLOR(c));
+ xhline(c->image, m->x + 5,
+ m->items[i].y - 1 - SEPARATORSIZE / 2,
+ m->width - 10, LIGHTGRAYCOLOR(c));
+ }
+ if (i < 10)
+ s[0] = '0' + (i == 9 ? 0 : i + 1);
+ else
+ s[0] = 'A' + (i - 10);
+ xprint(c->image, c->font, m->items[i].x, m->items[i].y, s,
+ color, BGCOLOR(c), pressed);
+ if (menu_enabled(m->items[i].item, uih)) {
+ xprint(c->image, c->font, m->items[i].x + width1,
+ m->items[i].y, "X", color, BGCOLOR(c),
+ pressed);
+ }
+ xprint(c->image, c->font, m->items[i].x + width1 + MENUPAUSE,
+ m->items[i].y, m->items[i].item->name,
+ color, BGCOLOR(c), pressed);
+ if (m->items[i].item->key) {
+ char ch[20];
+ sprintf(ch, " %s ", m->items[i].item->key);
+ xprint(c->image, c->font,
+ m->items[i].x + m->items[i].width - SUBMENUWIDTH -
+ xtextwidth(uih->font, ch), m->items[i].y, ch,
+ LIGHTGRAYCOLOR(c), BGCOLOR(c),
+ pressed);
+ }
+ if (m->items[i].item->type == MENU_SUBMENU)
+ xprint(c->image, c->font,
+ m->items[i].x + m->items[i].width - SUBMENUWIDTH,
+ m->items[i].y, ">", color, BGCOLOR(c),
+ pressed);
+ } else {
+ xprint(c->image, c->font, m->items[i].x, m->items[i].y,
+ m->items[i].item->name, color, BGCOLOR(c),
+ pressed);
+ if (m->items[i].item->key) {
+ char ch[20];
+ sprintf(ch, "%s", m->items[i].item->key);
+ xprint(c->image, c->font,
+ m->items[i].x + xtextwidth(uih->font,
+ m->items[i].item->name) +
+ 2, m->items[i].y, ch,
+ LIGHTGRAYCOLOR(c), BGCOLOR(c), pressed);
+ }
+ }
+ }
+}
+
+static struct ui_menu *ui_buildmenu(CONST char *name, int x, int y,
+ int flags)
+{
+ int shift = 0;
+ int width, height;
+ int textheight = xtextheight(uih->font);
+ struct ui_menu *menu;
+ int i;
+ menu = (struct ui_menu *) malloc(sizeof(*menu));
+ menu->timer = tl_create_timer();
+ tl_reset_timer(menu->timer);
+ menu->flags = flags;
+ menu->items =
+ ui_getmenuitems(name, &width, &height, &menu->n,
+ flags & MENU_HORIZONTAL);
+ menu->selected = -1;
+ menu->fullname = menu_fullname(name);
+ menu->name = name;
+ menu->namewidth = xtextwidth(uih->font, menu->fullname);
+ if (!(menu->flags & MENU_HORIZONTAL)) {
+ if (menu->namewidth > width)
+ width = menu->namewidth;
+ width += 2 * BORDERWIDTH;
+ height += 2 * BORDERHEIGHT + xtextheight(uih->font);
+ if (x + width > uih->image->width)
+ x = uih->image->width - width;
+ if (y + height > uih->image->height)
+ y = uih->image->height - height;
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+ shift = 0;
+ for (i = 0; i < menu->n; i++) {
+ shift += menu->items[i].separator * SEPARATORSIZE;
+ menu->items[i].x = x + BORDERWIDTH;
+ menu->items[i].y =
+ y + BORDERWIDTH + textheight * (i + 1) + shift;
+ menu->items[i].width = width - 2 * BORDERWIDTH;
+ menu->items[i].height = textheight;
+ }
+ } else {
+ int line = 0;
+ int xpos = BORDERWIDTH;
+ x = 0, width = uih->image->width;
+ for (i = 0; i < menu->n; i++) {
+ if (xpos + 2 * BORDERWIDTH + menu->items[i].width >
+ uih->image->width)
+ xpos = BORDERWIDTH, line++;
+ menu->items[i].x = xpos;
+ menu->items[i].y = y + BORDERWIDTH + line * textheight;
+ xpos += menu->items[i].width;
+ menu->items[i].height = textheight;
+ }
+ height = (line + 1) * textheight + 2 * BORDERWIDTH;
+ }
+ menu->selected = -1;
+ menu->window =
+ uih_registerw(uih, ui_menusize, ui_drawmenu, menu, DRAWBORDER);
+ uih->display = 1;
+ menu->x = x;
+ menu->y = y;
+ menu->width = width;
+ menu->height = height;
+ return (menu);
+}
+
+static void ui_closemenu(struct ui_menu *menu)
+{
+ free(menu->items);
+ tl_free_timer(menu->timer);
+ uih_removew(uih, menu->window);
+ uih->display = 1;
+ free(menu);
+}
+
+static void ui_openmenu(CONST char *name, int x, int y, int flags)
+{
+ if (ui_nogui) {
+ printf("menu \"%s\"\n", name);
+ return;
+ }
+ if (driver->gui_driver && driver->gui_driver->menu) {
+ driver->gui_driver->menu(uih, name);
+ return;
+ }
+ if (ui_nmenus > NMENUS)
+ return;
+ ui_menus[ui_nmenus] = ui_buildmenu(name, x, y, flags);
+ ui_nmenus++;
+ ui_updatestarts();
+}
+
+static void ui_closetopmenu(void)
+{
+ if (!ui_nmenus)
+ return;
+ ui_nmenus--;
+ ui_closemenu(ui_menus[ui_nmenus]);
+ ui_updatestarts();
+}
+
+void ui_closemenus(void)
+{
+ while (ui_nmenus)
+ ui_closetopmenu();
+}
+
+void ui_menu(CONST char *m)
+{
+ int mousex, mousey, buttons;
+ driver->getmouse(&mousex, &mousey, &buttons);
+ ui_openmenu(m, mousex, mousey, 0);
+}
+
+static void ui_menupress(int number)
+{
+ CONST menuitem *item;
+ if (number >= ui_menus[ui_nmenus - 1]->n)
+ return;
+ ui_menus[ui_nmenus - 1]->selected = number;
+ item = ui_menus[ui_nmenus - 1]->items[number].item;
+ if (item != NULL) {
+ uih->display = 1;
+ if (item->type == MENU_SUBMENU) {
+ int flags = 0;
+ int mousex, mousey, buttons;
+ driver->getmouse(&mousex, &mousey, &buttons);
+ if (buttons & BUTTON1)
+ flags |= MENU_PRESSED;
+ if ((ui_menus[ui_nmenus - 1]->flags & MENU_HORIZONTAL))
+ ui_openmenu(item->shortname,
+ ui_menus[ui_nmenus - 1]->items[number].x,
+ ui_menus[ui_nmenus - 1]->items[number].y +
+ ui_menus[ui_nmenus - 1]->items[number].height,
+ flags);
+ else
+ ui_openmenu(item->shortname,
+ ui_menus[ui_nmenus - 1]->items[number].x +
+ ui_menus[ui_nmenus - 1]->items[number].width,
+ ui_menus[ui_nmenus - 1]->items[number].y,
+ flags);
+ } else
+ ui_menuactivate(item, NULL);
+ }
+}
+
+int ui_menumouse(int x, int y, int mousebuttons, int flags)
+{
+ if (ui_nmenus) {
+ struct ui_menu *m = ui_menus[ui_nmenus - 1];
+ int place = -1;
+ int inmenu = 0;
+ if (x >= m->x && y >= m->y && x <= m->x + m->width
+ && y <= m->y + m->height) {
+ int i;
+ for (i = 0; i < m->n; i++) {
+ if (x >= m->items[i].x && y >= m->items[i].y
+ && x <= m->items[i].x + m->items[i].width
+ && y <= m->items[i].y + m->items[i].height) {
+ place = i;
+ break;
+ }
+ }
+ inmenu = 1;
+ } else {
+ if (ui_nmenus > 1) {
+ struct ui_menu *m2 = ui_menus[ui_nmenus - 2];
+ int i;
+ i = m2->selected;
+ if (x >= m2->items[i].x && y >= m2->items[i].y
+ && x <= m2->items[i].x + m2->items[i].width
+ && y <= m2->items[i].y + m2->items[i].height)
+ inmenu = 1;
+ }
+ }
+ if ((m->flags & MENU_AUTOHIDE) && !inmenu) {
+ ui_closetopmenu();
+ return (ui_menumouse(x, y, mousebuttons, flags));
+ }
+ if (flags & MOUSE_MOVE && m->selected != place)
+ m->selected = place, uih->display = 1;
+ if (m->flags & MENU_PRESSED) {
+ if (inmenu && place >= 0 && (m->flags & MENU_HORIZONTAL)
+ && (flags & MOUSE_DRAG)
+ && m->items[place].item->type == MENU_SUBMENU) {
+ ui_menupress(place);
+ return 1;
+ } else if (inmenu && place >= 0 && (flags & MOUSE_DRAG)
+ && m->items[place].item->type == MENU_SUBMENU
+ && x >
+ m->items[place].x + m->items[place].width -
+ 2 * SUBMENUWIDTH) {
+ ui_menupress(place);
+ return 1;
+ }
+ if (flags & MOUSE_RELEASE || !(flags & MOUSE_DRAG)) {
+ if (tl_lookup_timer(m->timer) < 300000) {
+ m->flags &= ~MENU_PRESSED;
+ return 1;
+ }
+ if (!inmenu || place < 0) {
+ ui_closetopmenu();
+ return (ui_menumouse(x, y, mousebuttons, flags));
+ }
+ ui_menupress(place);
+ return 1;
+ }
+ if (!inmenu) { /*Trace all menus back and look, if user selected some */
+ int nmenu;
+ for (nmenu = ui_nmenus - 2; nmenu > -1; nmenu--) {
+ struct ui_menu *m2 = ui_menus[nmenu];
+ if (x > m2->x && y > m2->y && x < m2->x + m2->width
+ && y < m2->y + m2->height) {
+ ui_closetopmenu();
+ m2->flags |= MENU_PRESSED;
+ return (ui_menumouse(x, y, mousebuttons, flags));
+ }
+ }
+ }
+ } else if (flags & MOUSE_PRESS) {
+ if (!inmenu || place < 0) {
+ ui_closetopmenu();
+ return (ui_menumouse(x, y, mousebuttons, flags));
+ }
+ ui_menupress(place);
+ }
+ return (1);
+ } else {
+ if (!ui_nogui &&
+ (!driver->gui_driver || !driver->gui_driver->setrootmenu) &&
+ (flags & MOUSE_MOVE) && y < xtextheight(uih->font) + 1
+ && !(mousebuttons))
+ ui_openmenu(uih->menuroot, 0, 0,
+ MENU_HORIZONTAL | MENU_AUTOHIDE);
+ }
+ return (0);
+}
+
+int ui_menukey(int key)
+{
+ int k;
+ if (!ui_nmenus) {
+ if (key == '\n' || key == 13) {
+ ui_closemenus();
+ ui_openmenu(uih->menuroot, 0, 0, MENU_HORIZONTAL);
+ return 1;
+ }
+ return 0;
+ } else {
+ struct ui_menu *menu = ui_menus[ui_nmenus - 1];
+ switch (key) {
+ case '\n':
+ case 13:
+ if (menu->selected >= 0)
+ ui_menupress(menu->selected);
+ return 1;
+ case 'h':
+ {
+ CONST menuitem *item = menu->items[menu->selected].item;
+ ui_closemenus();
+ if (menu->selected >= 0) {
+ ui_help(item->shortname);
+ } else
+ ui_help(menu->name);
+ return 1;
+ }
+ case UIKEY_LEFT:
+ if (menu->flags & MENU_HORIZONTAL) {
+ if (menu->selected == -1)
+ menu->selected = 0;
+ else
+ menu->selected--;
+ if (menu->selected < 0)
+ menu->selected = menu->n - 1;
+ uih->display = 1;
+ } else if (ui_nmenus == 2
+ && ui_menus[0]->flags & MENU_HORIZONTAL) {
+ ui_closetopmenu();
+ ui_menus[0]->selected--;
+ if (ui_menus[0]->selected < 0)
+ ui_menus[0]->selected = ui_menus[0]->n - 1;
+ ui_menupress(ui_menus[0]->selected);
+ } else
+ ui_closetopmenu();
+ return 1;
+ case UIKEY_RIGHT:
+ if (menu->flags & MENU_HORIZONTAL) {
+ if (menu->selected == -1)
+ menu->selected = 0;
+ else
+ menu->selected++;
+ menu->selected %= menu->n;
+ uih->display = 1;
+ } else if (menu->selected >= 0
+ && menu->items[menu->selected].item->type ==
+ MENU_SUBMENU) {
+ ui_menupress(menu->selected);
+ } else if (ui_nmenus == 2
+ && ui_menus[0]->flags & MENU_HORIZONTAL) {
+ ui_closetopmenu();
+ ui_menus[0]->selected++;
+ ui_menus[0]->selected %= ui_menus[0]->n;
+ ui_menupress(ui_menus[0]->selected);
+ }
+ return 1;
+ case UIKEY_DOWN:
+ if (menu->flags & MENU_HORIZONTAL) {
+ if (menu->selected >= 0)
+ ui_menupress(ui_menus[0]->selected);
+ } else {
+ if (menu->selected == -1)
+ menu->selected = 0;
+ else
+ menu->selected++;
+ menu->selected %= menu->n;
+ uih->display = 1;
+ }
+ return 1;
+ case UIKEY_ESC:
+ ui_closetopmenu();
+ return 1;
+ case UIKEY_UP:
+ if (menu->flags & MENU_HORIZONTAL) {
+ ui_closetopmenu();
+ } else {
+ if (menu->selected == -1)
+ menu->selected = 0;
+ else
+ menu->selected--;
+ if (menu->selected < 0)
+ menu->selected = menu->n - 1;
+ uih->display = 1;
+ }
+ return 1;
+ }
+ if (tolower(key) >= 'a'
+ && tolower(key) - 'a' < ui_menus[ui_nmenus - 1]->n - 10) {
+ ui_menupress(tolower(key) - 'a' + 10);
+ return 1;
+ }
+ if (key >= '0' && key <= '9') {
+ k = key - '1';
+ if (k == -1)
+ k = 9;
+ ui_menupress(k);
+ return 1;
+ }
+ return 0;
+ }
+}
+
+int ui_menuwidth(void)
+{
+ if (ui_nmenus && (ui_menus[0]->flags & MENU_HORIZONTAL))
+ return (ui_menus[0]->height);
+ return (0);
+}