aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorjcid <devnull@localhost>2008-09-24 18:44:40 +0200
committerjcid <devnull@localhost>2008-09-24 18:44:40 +0200
commitc377e06400f138325a9a9d43d91a9272691867a1 (patch)
tree49f3ca1c46af11a058a68714899d4137ec717618 /test
parent642f9b3e747859a7256ea12fab9f9ed50aa9253a (diff)
- Moved the dw2 tree into dillo2's tree.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am153
-rw-r--r--test/dw_anchors_test.cc162
-rw-r--r--test/dw_border_test.cc125
-rw-r--r--test/dw_example.cc103
-rw-r--r--test/dw_find_test.cc151
-rw-r--r--test/dw_images_scaled.cc153
-rw-r--r--test/dw_images_scaled2.cc148
-rw-r--r--test/dw_images_simple.cc151
-rw-r--r--test/dw_imgbuf_mem_test.cc114
-rw-r--r--test/dw_links.cc158
-rw-r--r--test/dw_links2.cc186
-rw-r--r--test/dw_lists.cc134
-rw-r--r--test/dw_resource_test.cc98
-rw-r--r--test/dw_table.cc115
-rw-r--r--test/dw_table_aligned.cc119
-rw-r--r--test/dw_ui_test.cc241
-rw-r--r--test/fltk_browser.cc47
-rw-r--r--test/form.cc264
-rw-r--r--test/form.hh164
-rw-r--r--test/shapes.cc41
20 files changed, 2827 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 00000000..bde2b0f8
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,153 @@
+AM_CFLAGS = @LIBFLTK_CFLAGS@
+AM_CXXFLAGS = @LIBFLTK_CXXFLAGS@
+
+noinst_PROGRAMS = \
+ dw-anchors-test \
+ dw-example \
+ dw-find-test \
+ dw-links \
+ dw-links2 \
+ dw-images-simple \
+ dw-images-scaled \
+ dw-images-scaled2 \
+ dw-lists \
+ dw-table-aligned \
+ dw-table \
+ dw-border-test \
+ dw-imgbuf-mem-test \
+ dw-resource-test \
+ dw-ui-test \
+ fltk-browser \
+ shapes
+
+dw_anchors_test_SOURCES = dw_anchors_test.cc
+dw_anchors_test_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_example_SOURCES = dw_example.cc
+dw_example_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_find_test_SOURCES = dw_find_test.cc
+dw_find_test_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_links_SOURCES = dw_links.cc
+dw_links_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_links2_SOURCES = dw_links2.cc
+dw_links2_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_images_simple_SOURCES = dw_images_simple.cc
+dw_images_simple_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_images_scaled_SOURCES = dw_images_scaled.cc
+dw_images_scaled_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_images_scaled2_SOURCES = dw_images_scaled2.cc
+dw_images_scaled2_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_lists_SOURCES = dw_lists.cc
+dw_lists_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_table_aligned_SOURCES = dw_table_aligned.cc
+dw_table_aligned_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_table_SOURCES = dw_table.cc
+dw_table_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_border_test_SOURCES = dw_border_test.cc
+dw_border_test_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+
+dw_imgbuf_mem_test_SOURCES = dw_imgbuf_mem_test.cc
+dw_imgbuf_mem_test_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_resource_test_SOURCES = dw_resource_test.cc
+dw_resource_test_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+dw_ui_test_SOURCES = \
+ dw_ui_test.cc \
+ form.cc \
+ form.hh
+dw_ui_test_LDADD = \
+ ../dw/libDw-widgets.a \
+ ../dw/libDw-fltk.a \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a \
+ @LIBFLTK_LIBS@
+
+fltk_browser_SOURCES = fltk_browser.cc
+fltk_browser_LDADD = @LIBFLTK_LIBS@
+
+shapes_SOURCES = shapes.cc
+shapes_LDADD = \
+ ../dw/libDw-core.a \
+ ../lout/liblout.a
diff --git a/test/dw_anchors_test.cc b/test/dw_anchors_test.cc
new file mode 100644
index 00000000..8615439e
--- /dev/null
+++ b/test/dw_anchors_test.cc
@@ -0,0 +1,162 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <ctype.h>
+#include <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+
+using namespace lout::container::typed;
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+static FltkPlatform *platform;
+static Layout *layout;
+static ::fltk::Window *window;
+static FltkViewport *viewport;
+static Style *topWidgetStyle, *widgetStyle, *wordStyle, *headingStyle;
+static Textblock *topTextblock = NULL;
+static int textblockNo = 0;
+
+static const char *numbers[10] = {
+ "one", "two", "three", "four", "five",
+ "six", "seven", "eight", "nine", "ten"
+};
+
+static void anchorCallback (::fltk::Widget *widget, void *data)
+{
+ layout->setAnchor (numbers[(long)data]);
+}
+
+static void textTimeout (void *data)
+{
+ Textblock *oldTop = topTextblock;
+ topTextblock = new Textblock (false);
+
+ if (oldTop) {
+ oldTop->addLinebreak (wordStyle);
+ oldTop->addWidget (topTextblock, widgetStyle);
+ } else {
+ topTextblock->setStyle (topWidgetStyle);
+ layout->setWidget (topTextblock);
+ }
+
+ topTextblock->addAnchor (numbers[textblockNo], headingStyle);
+
+ char buf[16];
+ strcpy (buf, numbers[textblockNo]);
+ buf[0] = toupper (buf[0]);
+ topTextblock->addText (buf, headingStyle);
+ topTextblock->addParbreak (5, headingStyle);
+
+ for (int i = 0; i < 30; i++) {
+ strcpy (buf, numbers[textblockNo]);
+ if (i == 0)
+ buf[0] = toupper (buf[0]);
+ strcat (buf, i == 29 ? "." : ",");
+
+ topTextblock->addText (buf, wordStyle);
+ topTextblock->addSpace (wordStyle);
+ }
+
+ topTextblock->flush ();
+
+ textblockNo++;
+ if (textblockNo < 10)
+ ::fltk::repeat_timeout (1, textTimeout, NULL);
+
+}
+
+int main(int argc, char **argv)
+{
+ char *buttonLabel[10];
+
+ platform = new FltkPlatform ();
+ layout = new Layout (platform);
+
+ window = new ::fltk::Window(250, 200, "Dw Find Test");
+ window->begin();
+
+ viewport = new FltkViewport (50, 0, 200, 200);
+ layout->attachView (viewport);
+
+ for (int i = 0; i < 10; i++) {
+ char buf[16];
+ strcpy (buf, numbers[i]);
+ buf[0] = toupper (buf[0]);
+ buttonLabel[i] = strdup(buf);
+ ::fltk::Button *button =
+ new ::fltk::Button(0, 20 * i, 50, 20, buttonLabel[i]);
+ button->callback (anchorCallback, (void*)i);
+ button->when (::fltk::WHEN_RELEASE);
+ }
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+ styleAttrs.margin.setVal (5);
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+ topWidgetStyle = Style::create (layout, &styleAttrs);
+
+ styleAttrs.margin.left = 20;
+ styleAttrs.margin.right = 0;
+ styleAttrs.backgroundColor = NULL;
+ widgetStyle = Style::create (layout, &styleAttrs);
+
+ styleAttrs.margin.left = 0;
+ wordStyle = Style::create (layout, &styleAttrs);
+
+ fontAttrs.size = 28;
+ fontAttrs.weight = 700;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+ headingStyle = Style::create (layout, &styleAttrs);
+
+ ::fltk::add_timeout (0, textTimeout, NULL);
+
+ window->resizable(viewport);
+ window->show();
+
+ int errorCode = ::fltk::run();
+
+ topWidgetStyle->unref ();
+ widgetStyle->unref ();
+ wordStyle->unref ();
+ headingStyle->unref ();
+ for (int i = 0; i < 10; i++)
+ delete buttonLabel[i];
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_border_test.cc b/test/dw_border_test.cc
new file mode 100644
index 00000000..0c2b7783
--- /dev/null
+++ b/test/dw_border_test.cc
@@ -0,0 +1,125 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+#include "../dw/listitem.hh"
+
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+int main(int argc, char **argv)
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(200, 300, "Dw Border Test");
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 200, 300);
+ layout->attachView (viewport);
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+ styleAttrs.borderWidth.setVal (2);
+ styleAttrs.setBorderColor (Color::createShaded (layout, 0xffffff));
+ styleAttrs.setBorderStyle (BORDER_INSET);
+ styleAttrs.padding.setVal (5);
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+
+ Style *widgetStyle1 = Style::create (layout, &styleAttrs);
+
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffff80);
+ styleAttrs.margin.setVal (0);
+ styleAttrs.borderWidth.setVal (1);
+ styleAttrs.setBorderColor (Color::createSimple (layout, 0x4040ff));
+ styleAttrs.setBorderStyle (BORDER_SOLID);
+ styleAttrs.padding.setVal (1);
+
+ Style *widgetStyle2 = Style::create (layout, &styleAttrs);
+
+ Textblock *textblock1 = new Textblock (false);
+ textblock1->setStyle (widgetStyle1);
+ layout->setWidget (textblock1);
+
+ widgetStyle1->unref();
+
+ styleAttrs.borderWidth.setVal (0);
+ styleAttrs.padding.setVal (0);
+ styleAttrs.backgroundColor = NULL;
+ styleAttrs.cursor = CURSOR_TEXT;
+
+ Style *wordStyle = Style::create (layout, &styleAttrs);
+
+ const char *words1[] = { "Some", "random", "text.", NULL };
+ const char *words2[] = { "A", "nested", "paragraph.", NULL };
+
+ for(int i = 0; words1[i]; i++) {
+ if(i != 0)
+ textblock1->addSpace (wordStyle);
+ textblock1->addText (words1[i], wordStyle);
+ }
+
+ for(int i = 0; i < 1; i++) {
+ textblock1->addParbreak(0, wordStyle);
+
+ Textblock *textblock2 = new Textblock (false);
+ textblock1->addWidget (textblock2, widgetStyle2);
+
+ for(int j = 0; words2[j]; j++) {
+ if(j != 0)
+ textblock2->addSpace (wordStyle);
+ textblock2->addText (words2[j], wordStyle);
+ }
+
+ textblock2->flush ();
+ }
+
+ textblock1->flush ();
+
+ window->resizable(viewport);
+ window->show();
+ int errorCode = ::fltk::run();
+
+ widgetStyle2->unref();
+ wordStyle->unref();
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_example.cc b/test/dw_example.cc
new file mode 100644
index 00000000..75b891e2
--- /dev/null
+++ b/test/dw_example.cc
@@ -0,0 +1,103 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+
+
+int main(int argc, char **argv)
+{
+ dw::fltk::FltkPlatform *platform = new dw::fltk::FltkPlatform ();
+ dw::core::Layout *layout = new dw::core::Layout (platform);
+
+ fltk::Window *window = new fltk::Window(200, 300, "Dw Example");
+ window->begin();
+
+ dw::fltk::FltkViewport *viewport =
+ new dw::fltk::FltkViewport (0, 0, 200, 300);
+ layout->attachView (viewport);
+
+ dw::core::style::StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+
+ dw::core::style::FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = dw::core::style::FONT_STYLE_NORMAL;
+ styleAttrs.font = dw::core::style::Font::create (layout, &fontAttrs);
+
+ styleAttrs.color =
+ dw::core::style::Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor =
+ dw::core::style::Color::createSimple (layout, 0xffffff);
+
+ dw::core::style::Style *widgetStyle =
+ dw::core::style::Style::create (layout, &styleAttrs);
+
+ dw::Textblock *textblock = new dw::Textblock (false);
+ textblock->setStyle (widgetStyle);
+ layout->setWidget (textblock);
+
+ widgetStyle->unref();
+
+ styleAttrs.margin.setVal (0);
+ styleAttrs.backgroundColor = NULL;
+
+ dw::core::style::Style *wordStyle =
+ dw::core::style::Style::create (layout, &styleAttrs);
+
+ for(int i = 1; i <= 10; i++) {
+ char buf[4];
+ sprintf(buf, "%d.", i);
+
+ const char *words[] = { "This", "is", "the", buf, "paragraph.",
+ "Here", "comes", "some", "more", "text",
+ "to", "demonstrate", "word", "wrapping.",
+ NULL };
+
+ for(int j = 0; words[j]; j++) {
+ textblock->addText(words[j], wordStyle);
+ textblock->addSpace(wordStyle);
+ }
+
+ textblock->addParbreak(10, wordStyle);
+ }
+
+ wordStyle->unref();
+
+ textblock->flush ();
+
+ window->resizable(viewport);
+ window->show();
+ int errorCode = fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_find_test.cc b/test/dw_find_test.cc
new file mode 100644
index 00000000..a43b4e59
--- /dev/null
+++ b/test/dw_find_test.cc
@@ -0,0 +1,151 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+
+using namespace lout::container::typed;
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+static FltkPlatform *platform;
+static Layout *layout;
+static ::fltk::Window *window;
+static FltkViewport *viewport;
+static ::fltk::Button *findButton, *resetButton;
+static ::fltk::Widget *resultLabel;
+
+static void findCallback (::fltk::Widget *widget, void *data)
+{
+ //switch(layout->search ("worm", true)) {
+ switch(layout->search ("WORM", false)) {
+ case FindtextState::SUCCESS:
+ resultLabel->label("SUCCESS");
+ break;
+
+ case FindtextState::RESTART:
+ resultLabel->label("RESTART");
+ break;
+
+ case FindtextState::NOT_FOUND:
+ resultLabel->label("NOT_FOUND");
+ break;
+ }
+
+ resultLabel->redraw ();
+}
+
+static void resetCallback (::fltk::Widget *widget, void *data)
+{
+ layout->resetSearch ();
+ resultLabel->label("---");
+ resultLabel->redraw ();
+}
+
+int main(int argc, char **argv)
+{
+ platform = new FltkPlatform ();
+ layout = new Layout (platform);
+
+ window = new ::fltk::Window(200, 300, "Dw Find Test");
+ window->begin();
+
+ viewport = new FltkViewport (0, 0, 200, 280);
+ layout->attachView (viewport);
+
+ findButton = new ::fltk::Button(0, 280, 50, 20, "Find");
+ findButton->callback (findCallback, NULL);
+ findButton->when (::fltk::WHEN_RELEASE);
+
+ resetButton = new ::fltk::Button(50, 280, 50, 20, "Reset");
+ resetButton->callback (resetCallback, NULL);
+ resetButton->when (::fltk::WHEN_RELEASE);
+
+ resultLabel = new ::fltk::Widget(100, 280, 100, 20, "---");
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+ styleAttrs.margin.setVal (10);
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+ Style *topWidgetStyle = Style::create (layout, &styleAttrs);
+
+ styleAttrs.margin.setVal (0);
+ styleAttrs.margin.left = 30;
+ styleAttrs.backgroundColor = NULL;
+ Style *widgetStyle = Style::create (layout, &styleAttrs);
+
+ styleAttrs.margin.left = 0;
+ Style *wordStyle = Style::create (layout, &styleAttrs);
+
+ Textblock *textblock = new Textblock (false);
+ textblock->setStyle (topWidgetStyle);
+ layout->setWidget (textblock);
+
+ Stack <Textblock> *stack = new Stack <Textblock> (false);
+ stack->push (textblock);
+
+ for(int i = 0; i < 10; i++)
+ for(int j = 0; j < 10; j++) {
+ Textblock *current;
+ if(j < 5) {
+ current = new Textblock (false);
+ stack->getTop()->addWidget (current, widgetStyle);
+ stack->push (current);
+ } else {
+ stack->getTop()->flush ();
+ stack->pop ();
+ current = stack->getTop ();
+ }
+
+ current->addText ((i == j ? "worm" : "apple"), wordStyle);
+ current->addLinebreak (wordStyle);
+ }
+
+ stack->getTop()->flush ();
+
+ topWidgetStyle->unref ();
+ widgetStyle->unref ();
+ wordStyle->unref ();
+
+ window->resizable(viewport);
+ window->show();
+ int errorCode = ::fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_images_scaled.cc b/test/dw_images_scaled.cc
new file mode 100644
index 00000000..dfaf57b9
--- /dev/null
+++ b/test/dw_images_scaled.cc
@@ -0,0 +1,153 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+#include "../dw/image.hh"
+
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+static Layout *layout;
+static Image *image;
+static core::Imgbuf *imgbuf = NULL;
+static int imgRow = 0;
+
+static void imageInitTimeout (void *data)
+{
+ //imgbuf = layout->createImgbuf (Imgbuf::RGBA, 400, 200);
+ imgbuf = layout->createImgbuf (Imgbuf::RGB, 400, 200);
+ image->setBuffer (imgbuf);
+}
+
+/*
+static void imageDrawTimeout (void *data)
+{
+ if (imgbuf) {
+ for (int i = 0; i < 1; i++) {
+ byte buf[4 * 400];
+ for(int x = 0; x < 400; x++) {
+ buf[4 * x + 0] = x * 255 / 399;
+ buf[4 * x + 1] = (399 - x) * 255 / 399;
+ buf[4 * x + 2] = imgRow * 255 / 199;
+ buf[4 * x + 3] = (199 - imgRow) * 255 / 199;
+ }
+
+ imgbuf->copyRow (imgRow, buf);
+ image->drawRow (imgRow);
+ imgRow++;
+ }
+ }
+
+ if(imgRow < 200)
+ ::fltk::repeat_timeout (0.5, imageDrawTimeout, NULL);
+}
+*/
+
+static void imageDrawTimeout (void *data)
+{
+ if (imgbuf) {
+ for (int i = 0; i < 1; i++) {
+ byte buf[3 * 400];
+ for(int x = 0; x < 400; x++) {
+ buf[3 * x + 0] = x * 255 / 399;
+ buf[3 * x + 1] = (399 - x) * 255 / 399;
+ buf[3 * x + 2] = imgRow * 255 / 199;
+ }
+
+ imgbuf->copyRow (imgRow, buf);
+ image->drawRow (imgRow);
+ imgRow++;
+ }
+ }
+
+ if(imgRow < 200)
+ ::fltk::repeat_timeout (0.5, imageDrawTimeout, NULL);
+}
+
+int main(int argc, char **argv)
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(410, 210, "Dw Scaled Image");
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 410, 210);
+ layout->attachView (viewport);
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+ styleAttrs.width = createPerLength (1.0);
+ styleAttrs.height = createPerLength (1.0);
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+
+ Style *widgetStyle = Style::create (layout, &styleAttrs);
+
+ Textblock *textblock = new Textblock (false);
+ textblock->setStyle (widgetStyle);
+ layout->setWidget (textblock);
+
+ widgetStyle->unref();
+
+ styleAttrs.margin.setVal (0);
+ styleAttrs.backgroundColor = NULL;
+
+ Style *imageStyle = Style::create (layout, &styleAttrs);
+
+ image = new dw::Image ("");
+ textblock->addWidget (image, imageStyle);
+ textblock->addSpace (imageStyle);
+
+ imageStyle->unref();
+
+ textblock->flush ();
+
+ window->resizable(viewport);
+ window->show();
+
+ ::fltk::add_timeout (2.0, imageInitTimeout, NULL);
+ ::fltk::add_timeout (0.1, imageDrawTimeout, NULL);
+
+ int errorCode = ::fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_images_scaled2.cc b/test/dw_images_scaled2.cc
new file mode 100644
index 00000000..39c55046
--- /dev/null
+++ b/test/dw_images_scaled2.cc
@@ -0,0 +1,148 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+#include "../dw/image.hh"
+
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+static Layout *layout;
+static Image *image1, *image2;
+static core::Imgbuf *imgbuf = NULL;
+static int imgRow = 0;
+
+static void imageInitTimeout (void *data)
+{
+ imgbuf = layout->createImgbuf (Imgbuf::RGB, 400, 200);
+ image1->setBuffer (imgbuf);
+ image2->setBuffer (imgbuf);
+}
+
+static void imageDrawTimeout (void *data)
+{
+ if (imgbuf) {
+ for (int i = 0; i < 1; i++) {
+ byte buf[3 * 400];
+ for(int x = 0; x < 400; x++) {
+ buf[3 * x + 0] = x * 255 / 399;
+ buf[3 * x + 1] = (399 - x) * 255 / 399;
+ buf[3 * x + 2] = imgRow * 255 / 199;
+ }
+
+ imgbuf->copyRow (imgRow, buf);
+ image1->drawRow (imgRow);
+ image2->drawRow (imgRow);
+ imgRow++;
+ }
+ }
+
+ if(imgRow < 200)
+ ::fltk::repeat_timeout (0.5, imageDrawTimeout, NULL);
+}
+
+int main(int argc, char **argv)
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(410, 210, "Dw Scaled Image 2");
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 410, 210);
+ layout->attachView (viewport);
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+
+ Style *widgetStyle = Style::create (layout, &styleAttrs);
+
+ Textblock *textblock = new Textblock (false);
+ textblock->setStyle (widgetStyle);
+ layout->setWidget (textblock);
+
+ widgetStyle->unref();
+
+ styleAttrs.margin.setVal (0);
+ styleAttrs.borderWidth.setVal (0);
+ styleAttrs.padding.setVal (0);
+ styleAttrs.backgroundColor = NULL;
+
+ Style *wordStyle = Style::create (layout, &styleAttrs);
+
+ styleAttrs.borderWidth.setVal (1);
+ styleAttrs.setBorderColor (Color::createShaded (layout, 0x000080));
+ styleAttrs.setBorderStyle (BORDER_SOLID);
+ styleAttrs.padding.setVal (1);
+ styleAttrs.backgroundColor = NULL;
+ styleAttrs.width = createPerLength (0.5);
+ styleAttrs.height = createPerLength (0.5);
+
+ Style *imageStyle1 = Style::create (layout, &styleAttrs);
+ image1 = new dw::Image ("A longer ALT Text to demonstrate clipping.");
+ textblock->addWidget (image1, imageStyle1);
+ imageStyle1->unref();
+
+ textblock->addParbreak (10, wordStyle);
+
+ styleAttrs.width = LENGTH_AUTO;
+ styleAttrs.height = LENGTH_AUTO;
+
+ Style *imageStyle2 = Style::create (layout, &styleAttrs);
+ image2 = new dw::Image ("A longer ALT Text to demonstrate clipping.");
+ textblock->addWidget (image2, imageStyle2);
+ imageStyle2->unref();
+
+ wordStyle->unref ();
+ textblock->flush ();
+
+ window->resizable(viewport);
+ window->show();
+
+ ::fltk::add_timeout (3.0, imageInitTimeout, NULL);
+ ::fltk::add_timeout (0.1, imageDrawTimeout, NULL);
+
+ int errorCode = ::fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_images_simple.cc b/test/dw_images_simple.cc
new file mode 100644
index 00000000..78629d55
--- /dev/null
+++ b/test/dw_images_simple.cc
@@ -0,0 +1,151 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+#include "../dw/image.hh"
+
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+static Layout *layout;
+static Image *image;
+static core::Imgbuf *imgbuf = NULL;
+static int imgRow = 0;
+
+static void imageInitTimeout (void *data)
+{
+ //imgbuf = layout->createImgbuf (Imgbuf::RGBA, 400, 200);
+ imgbuf = layout->createImgbuf (Imgbuf::RGB, 400, 200);
+ image->setBuffer (imgbuf);
+}
+
+/*
+static void imageDrawTimeout (void *data)
+{
+ if (imgbuf) {
+ for (int i = 0; i < 1; i++) {
+ byte buf[4 * 400];
+ for(int x = 0; x < 400; x++) {
+ buf[4 * x + 0] = x * 255 / 399;
+ buf[4 * x + 1] = (399 - x) * 255 / 399;
+ buf[4 * x + 2] = imgRow * 255 / 199;
+ buf[4 * x + 3] = (199 - imgRow) * 255 / 199;
+ }
+
+ imgbuf->copyRow (imgRow, buf);
+ image->drawRow (imgRow);
+ imgRow++;
+ }
+ }
+
+ if(imgRow < 200)
+ ::fltk::repeat_timeout (0.5, imageDrawTimeout, NULL);
+}
+*/
+
+static void imageDrawTimeout (void *data)
+{
+ if (imgbuf) {
+ for (int i = 0; i < 1; i++) {
+ byte buf[3 * 400];
+ for(int x = 0; x < 400; x++) {
+ buf[3 * x + 0] = x * 255 / 399;
+ buf[3 * x + 1] = (399 - x) * 255 / 399;
+ buf[3 * x + 2] = imgRow * 255 / 199;
+ }
+
+ imgbuf->copyRow (imgRow, buf);
+ image->drawRow (imgRow);
+ imgRow++;
+ }
+ }
+
+ if(imgRow < 200)
+ ::fltk::repeat_timeout (0.5, imageDrawTimeout, NULL);
+}
+
+int main(int argc, char **argv)
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(410, 210, "Dw Simple Image");
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 410, 210);
+ layout->attachView (viewport);
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+
+ Style *widgetStyle = Style::create (layout, &styleAttrs);
+
+ Textblock *textblock = new Textblock (false);
+ textblock->setStyle (widgetStyle);
+ layout->setWidget (textblock);
+
+ widgetStyle->unref();
+
+ styleAttrs.margin.setVal (0);
+ styleAttrs.backgroundColor = NULL;
+
+ Style *imageStyle = Style::create (layout, &styleAttrs);
+
+ image = new dw::Image ("");
+ textblock->addWidget (image, imageStyle);
+ textblock->addSpace (imageStyle);
+
+ imageStyle->unref();
+
+ textblock->flush ();
+
+ window->resizable(viewport);
+ window->show();
+
+ ::fltk::add_timeout (2.0, imageInitTimeout, NULL);
+ ::fltk::add_timeout (0.1, imageDrawTimeout, NULL);
+
+ int errorCode = ::fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_imgbuf_mem_test.cc b/test/dw_imgbuf_mem_test.cc
new file mode 100644
index 00000000..897e47f8
--- /dev/null
+++ b/test/dw_imgbuf_mem_test.cc
@@ -0,0 +1,114 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+
+using namespace lout::signal;
+using namespace dw::core;
+using namespace dw::fltk;
+
+void solution1 ()
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ Imgbuf *rootbuf = layout->createImgbuf (Imgbuf::RGB, 100, 100);
+ rootbuf->ref (); // Extra reference by the dicache.
+ printf ("=== Can be deleted? %s.\n",
+ rootbuf->lastReference () ? "Yes" : "No");
+ Imgbuf *scaledbuf = rootbuf->getScaledBuf (50, 50);
+ printf ("=== Can be deleted? %s.\n",
+ rootbuf->lastReference () ? "Yes" : "No");
+ rootbuf->unref ();
+ printf ("=== Can be deleted? %s.\n",
+ rootbuf->lastReference () ? "Yes" : "No");
+ scaledbuf->unref ();
+ printf ("=== Can be deleted? %s.\n",
+ rootbuf->lastReference () ? "Yes" : "No");
+ rootbuf->unref (); // Extra reference by the dicache.
+
+ delete layout;
+}
+
+void solution2 ()
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ Imgbuf *rootbuf = layout->createImgbuf (Imgbuf::RGB, 100, 100);
+ rootbuf->setDeleteOnUnref (false);
+ printf ("=== Can be deleted? %s.\n",
+ !rootbuf->isReferred () ? "Yes" : "No");
+ Imgbuf *scaledbuf = rootbuf->getScaledBuf (50, 50);
+ printf ("=== Can be deleted? %s.\n",
+ !rootbuf->isReferred () ? "Yes" : "No");
+ rootbuf->unref ();
+ printf ("=== Can be deleted? %s.\n",
+ !rootbuf->isReferred () ? "Yes" : "No");
+ scaledbuf->unref ();
+ printf ("=== Can be deleted? %s.\n",
+ !rootbuf->isReferred () ? "Yes" : "No");
+ delete rootbuf;
+
+ delete layout;
+}
+
+class RootbufDeletionReceiver: public ObservedObject::DeletionReceiver
+{
+ void deleted (ObservedObject *object);
+};
+
+void RootbufDeletionReceiver::deleted (ObservedObject *object)
+{
+ printf ("=== Is deleted now.\n");
+ delete this;
+}
+
+void solution3 ()
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ Imgbuf *rootbuf = layout->createImgbuf (Imgbuf::RGB, 100, 100);
+ rootbuf->connectDeletion (new RootbufDeletionReceiver ());
+ Imgbuf *scaledbuf = rootbuf->getScaledBuf (50, 50);
+ rootbuf->unref ();
+ scaledbuf->unref ();
+
+ delete layout;
+}
+
+int main (int argc, char **argv)
+{
+ printf ("========== SOLUTION 1 ==========\n");
+ solution1 ();
+ printf ("========== SOLUTION 2 ==========\n");
+ solution2 ();
+ printf ("========== SOLUTION 3 ==========\n");
+ solution3 ();
+
+ return 0;
+}
diff --git a/test/dw_links.cc b/test/dw_links.cc
new file mode 100644
index 00000000..4d15d520
--- /dev/null
+++ b/test/dw_links.cc
@@ -0,0 +1,158 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+class LinkTestReceiver: public Widget::LinkReceiver
+{
+ bool enter (Widget *widget, int link, int x, int y);
+ bool press (Widget *widget, int link, int x, int y, EventButton *event);
+ bool release (Widget *widget, int link, int x, int y, EventButton *event);
+ bool click (Widget *widget, int link, int x, int y, EventButton *event);
+};
+
+bool LinkTestReceiver::enter (Widget *widget, int link, int x, int y)
+{
+ printf ("enter: %d\n", link);
+ return true;
+}
+
+bool LinkTestReceiver::press (Widget *widget, int link, int x, int y,
+ EventButton *event)
+{
+ printf ("press: %d\n", link);
+ return true;
+}
+
+bool LinkTestReceiver::release (Widget *widget, int link, int x, int y,
+ EventButton *event)
+{
+ printf ("release: %d\n", link);
+ return true;
+}
+
+bool LinkTestReceiver::click (Widget *widget, int link, int x, int y,
+ EventButton *event)
+{
+ printf ("click: %d\n", link);
+ return true;
+}
+
+int main(int argc, char **argv)
+{
+ LinkTestReceiver linkTestReceiver;
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(200, 300, "Dw Links");
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 200, 300);
+ layout->attachView (viewport);
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+
+ Style *widgetStyle = Style::create (layout, &styleAttrs);
+
+ Textblock *textblock = new Textblock (false);
+ textblock->setStyle (widgetStyle);
+ layout->setWidget (textblock);
+
+ textblock->connectLink (&linkTestReceiver);
+
+ widgetStyle->unref();
+
+ styleAttrs.margin.setVal (0);
+ styleAttrs.backgroundColor = NULL;
+ styleAttrs.cursor = CURSOR_TEXT;
+
+ Style *wordStyle = Style::create (layout, &styleAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x0000ff);
+ styleAttrs.textDecoration = TEXT_DECORATION_UNDERLINE;
+ styleAttrs.cursor = CURSOR_POINTER;
+
+ for(int i = 1; i <= 10; i++) {
+ char buf[4];
+ sprintf(buf, "%d.", i);
+
+ const char *words1[] = {
+ "This", "is", "the", buf, "paragraph.",
+ "Here", "comes", "some", "more", "text",
+ "to", "demonstrate", "word", "wrapping.",
+ NULL };
+ const char *words2[] = {
+ "Click", "here", "for", "more..", NULL };
+
+ for(int j = 0; words1[j]; j++) {
+ textblock->addText(words1[j], wordStyle);
+ textblock->addSpace(wordStyle);
+ }
+
+ styleAttrs.x_link = i;
+ Style *linkStyle = Style::create (layout, &styleAttrs);
+
+ for(int j = 0; words2[j]; j++) {
+ textblock->addText(words2[j], linkStyle);
+ textblock->addSpace(wordStyle);
+ }
+
+ linkStyle->unref ();
+
+ textblock->addParbreak(10, wordStyle);
+ }
+
+ wordStyle->unref();
+
+ textblock->flush ();
+
+ window->resizable(viewport);
+ window->show();
+ int errorCode = ::fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_links2.cc b/test/dw_links2.cc
new file mode 100644
index 00000000..e1db9011
--- /dev/null
+++ b/test/dw_links2.cc
@@ -0,0 +1,186 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+class LinkTestReceiver: public Widget::LinkReceiver
+{
+ bool enter (Widget *widget, int link, int x, int y);
+ bool press (Widget *widget, int link, int x, int y, EventButton *event);
+ bool release (Widget *widget, int link, int x, int y, EventButton *event);
+ bool click (Widget *widget, int link, int x, int y, EventButton *event);
+};
+
+bool LinkTestReceiver::enter (Widget *widget, int link, int x, int y)
+{
+ printf ("enter: %d\n", link);
+ return true;
+}
+
+bool LinkTestReceiver::press (Widget *widget, int link, int x, int y,
+ EventButton *event)
+{
+ printf ("press: %d\n", link);
+ return true;
+}
+
+bool LinkTestReceiver::release (Widget *widget, int link, int x, int y,
+ EventButton *event)
+{
+ printf ("release: %d\n", link);
+ return true;
+}
+
+bool LinkTestReceiver::click (Widget *widget, int link, int x, int y,
+ EventButton *event)
+{
+ printf ("click: %d\n", link);
+ return true;
+}
+
+int main(int argc, char **argv)
+{
+ int MainIdx;
+ int ww = 200, wh = 300, lh = 24;
+
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(200, 300, "Dw Links");
+ window->begin();
+ ::fltk::Widget *Panel = new ::fltk::Widget(0, 0, ww, lh, "CONTROL PANEL");
+
+ Panel->color(::fltk::GRAY15);
+ Panel->labelcolor(::fltk::WHITE);
+ ::fltk::Widget *Main =
+ new ::fltk::Widget(0, lh, ww, wh - 2*lh, "MAIN RENDERING AREA");
+ Main->color(::fltk::GRAY20);
+ Main->labelcolor(::fltk::WHITE);
+ MainIdx = window->find(Main);
+ /* status bar */
+ ::fltk::Widget *Bar =
+ new ::fltk::Widget(0, wh - lh, 200, lh, "STATUS BAR...");
+ Bar->color(::fltk::GRAY15);
+ Bar->labelcolor(::fltk::WHITE);
+
+ window->resizable(Main);
+ window->end();
+
+ //
+ // Create the main Dw and add some text there.
+ //
+ window->remove(MainIdx);
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, lh, ww, wh - 2*lh);
+ layout->attachView (viewport);
+
+ window->end();
+
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+
+ Style *widgetStyle = Style::create (layout, &styleAttrs);
+
+ Textblock *textblock = new Textblock (false);
+ textblock->setStyle (widgetStyle);
+ layout->setWidget (textblock);
+
+ textblock->connectLink (new LinkTestReceiver ());
+
+ widgetStyle->unref();
+
+ styleAttrs.margin.setVal (0);
+ styleAttrs.backgroundColor = NULL;
+ styleAttrs.cursor = CURSOR_TEXT;
+
+ Style *wordStyle = Style::create (layout, &styleAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x0000ff);
+ styleAttrs.textDecoration = TEXT_DECORATION_UNDERLINE;
+ styleAttrs.cursor = CURSOR_POINTER;
+
+ for(int i = 1; i <= 30; i++) {
+ char buf[4];
+ sprintf(buf, "%d.", i);
+
+ const char *words1[] = {
+ "This", "is", "the", buf, "paragraph.",
+ "Here", "comes", "some", "more", "text",
+ "to", "demonstrate", "word", "wrapping.",
+ NULL };
+ const char *words2[] = {
+ "Click", "here", "for", "more..", NULL };
+
+ for(int j = 0; words1[j]; j++) {
+ textblock->addText (words1[j], wordStyle);
+ textblock->addSpace(wordStyle);
+ }
+
+ styleAttrs.x_link = i;
+ Style *linkStyle = Style::create (layout, &styleAttrs);
+
+ for(int j = 0; words2[j]; j++) {
+ textblock->addText (words2[j], linkStyle);
+ textblock->addSpace(wordStyle);
+ }
+
+ linkStyle->unref ();
+
+ textblock->addParbreak(10, wordStyle);
+ }
+
+ wordStyle->unref();
+
+ textblock->flush ();
+
+ window->resizable(viewport);
+ window->show();
+ int errorCode = ::fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_lists.cc b/test/dw_lists.cc
new file mode 100644
index 00000000..99e78149
--- /dev/null
+++ b/test/dw_lists.cc
@@ -0,0 +1,134 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+#include "../dw/listitem.hh"
+
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+int main(int argc, char **argv)
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(200, 300, "Dw Lists");
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 200, 300);
+ layout->attachView (viewport);
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+
+ Style *widgetStyle = Style::create (layout, &styleAttrs);
+
+ Textblock *textblock = new Textblock (false);
+ textblock->setStyle (widgetStyle);
+ layout->setWidget (textblock);
+
+ widgetStyle->unref();
+
+ styleAttrs.margin.setVal (0);
+ styleAttrs.backgroundColor = NULL;
+ styleAttrs.cursor = CURSOR_TEXT;
+
+ Style *wordStyle = Style::create (layout, &styleAttrs);
+
+ styleAttrs.margin.setVal (5);
+ styleAttrs.padding.setVal (5);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffff40);
+ styleAttrs.setBorderColor (Color::createSimple (layout, 0x000000));
+ styleAttrs.setBorderStyle (BORDER_SOLID);
+ styleAttrs.borderWidth.setVal (1);
+
+ Style *itemStyle = Style::create (layout, &styleAttrs);
+
+ const char *wordsPar[] = {
+ "This", "is", "a", "normal", "paragraph.", "And",
+ "some", "list", "items", "follow:", NULL };
+ const char *wordsItem[] = {
+ "This", "is", "a", "list", "item.", "Here",
+ "comes", "some", "more", "text", "to",
+ "demonstrate", "word", "wrapping.", NULL };
+
+
+ for(int i = 0; wordsPar[i]; i++) {
+ if(i != 0)
+ textblock->addSpace (wordStyle);
+ textblock->addText (wordsPar[i], wordStyle);
+ }
+ textblock->addParbreak (5, wordStyle);
+
+ ListItem *refItem = NULL;
+
+ for(int i = 1; i <= 100; i++) {
+ ListItem *listItem = new ListItem (refItem, false);
+ refItem = listItem;
+
+ textblock->addWidget (listItem, itemStyle);
+ textblock->addParbreak (2, wordStyle);
+
+ char buf[16];
+ sprintf (buf, "%d.", i);
+ listItem->initWithText (strdup (buf), wordStyle);
+
+ for(int j = 0; wordsItem[j]; j++) {
+ if(j != 0)
+ listItem->addSpace (wordStyle);
+ listItem->addText (wordsItem[j], wordStyle);
+ }
+
+ listItem->flush ();
+ }
+
+ wordStyle->unref();
+
+ textblock->flush ();
+
+ window->resizable(viewport);
+ window->show();
+ int errorCode = ::fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_resource_test.cc b/test/dw_resource_test.cc
new file mode 100644
index 00000000..fc825836
--- /dev/null
+++ b/test/dw_resource_test.cc
@@ -0,0 +1,98 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/textblock.hh"
+#include "../dw/ui.hh"
+
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::core::ui;
+using namespace dw::fltk;
+
+int main(int argc, char **argv)
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(410, 210, "Dw Simple Image");
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 410, 210);
+ layout->attachView (viewport);
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+
+ Style *widgetStyle = Style::create (layout, &styleAttrs);
+
+ Textblock *textblock = new Textblock (false);
+ textblock->setStyle (widgetStyle);
+ layout->setWidget (textblock);
+
+ widgetStyle->unref();
+
+ styleAttrs.margin.setVal (0);
+ styleAttrs.backgroundColor = NULL;
+
+ SelectionResource *res = layout->getResourceFactory()->createListResource
+ (ListResource::SELECTION_AT_MOST_ONE);
+ //SelectionResource *res =
+ // layout->getResourceFactory()->createOptionMenuResource ();
+
+ Embed *embed = new Embed (res);
+ textblock->addWidget (embed, widgetStyle);
+ textblock->addSpace (widgetStyle);
+
+ widgetStyle->unref();
+
+ for(int i = 0; i < 50; i++)
+ res->addItem ("Hello, world!", true, false);
+
+ textblock->flush ();
+
+ window->resizable(viewport);
+ window->show();
+
+ int errorCode = ::fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_table.cc b/test/dw_table.cc
new file mode 100644
index 00000000..d269d551
--- /dev/null
+++ b/test/dw_table.cc
@@ -0,0 +1,115 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/table.hh"
+#include "../dw/tablecell.hh"
+
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+int main(int argc, char **argv)
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(300, 300, "Dw Table");
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 300, 300);
+ layout->attachView (viewport);
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+ styleAttrs.padding.setVal (0);
+ styleAttrs.borderWidth.setVal (1);
+ styleAttrs.setBorderStyle (BORDER_OUTSET);
+ styleAttrs.setBorderColor (Color::createShaded (layout, 0xffffff));
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+ styleAttrs.hBorderSpacing = 5;
+ styleAttrs.vBorderSpacing = 5;
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ Style *tableStyle = Style::create (layout, &styleAttrs);
+
+ Table *table = new Table (false);
+ table->setStyle (tableStyle);
+ layout->setWidget (table);
+
+ tableStyle->unref();
+
+ styleAttrs.setBorderStyle (BORDER_INSET);
+ styleAttrs.backgroundColor = NULL;
+ styleAttrs.margin.setVal (0);
+ styleAttrs.padding.setVal (5);
+
+ Style *cellStyle = Style::create (layout, &styleAttrs);
+
+ styleAttrs.borderWidth.setVal (0);
+ styleAttrs.margin.setVal (0);
+ styleAttrs.cursor = CURSOR_TEXT;
+ styleAttrs.textAlignChar = '.';
+
+ Style *wordStyle = Style::create (layout, &styleAttrs);
+
+ for (int i = 0; i < 4; i++) {
+ table->addRow (wordStyle);
+
+ for (int j = 0; j < 4; j++) {
+ Textblock *cell = new Textblock (false);
+ cell->setStyle (cellStyle);
+ table->addCell (cell, 1, 1);
+
+ char buf[10];
+ sprintf (buf, "cell %c", 'A' + 4 * i + j);
+
+ cell->addText (buf, wordStyle);
+ cell->flush ();
+ }
+ }
+
+ wordStyle->unref();
+ cellStyle->unref();
+
+ window->resizable(viewport);
+ window->show();
+ int errorCode = ::fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_table_aligned.cc b/test/dw_table_aligned.cc
new file mode 100644
index 00000000..beb8525d
--- /dev/null
+++ b/test/dw_table_aligned.cc
@@ -0,0 +1,119 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/table.hh"
+#include "../dw/tablecell.hh"
+
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::fltk;
+
+int main(int argc, char **argv)
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(200, 300, "Dw Table Aligned");
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 200, 300);
+ layout->attachView (viewport);
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+ styleAttrs.borderWidth.setVal (1);
+ styleAttrs.setBorderStyle (BORDER_OUTSET);
+ styleAttrs.setBorderColor (Color::createShaded (layout, 0x808080));
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Bitstream Charter";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xa0a0a0);
+ styleAttrs.hBorderSpacing = 5;
+ styleAttrs.vBorderSpacing = 5;
+
+ Style *tableStyle = Style::create (layout, &styleAttrs);
+
+ Table *table = new Table (false);
+ table->setStyle (tableStyle);
+ layout->setWidget (table);
+
+ tableStyle->unref();
+
+ styleAttrs.borderWidth.setVal (1);
+ styleAttrs.setBorderStyle (BORDER_INSET);
+
+ Style *cellStyle = Style::create (layout, &styleAttrs);
+
+ styleAttrs.borderWidth.setVal (0);
+ styleAttrs.margin.setVal (0);
+ styleAttrs.backgroundColor = NULL;
+ styleAttrs.cursor = CURSOR_TEXT;
+ styleAttrs.textAlignChar = '.';
+
+ Style *wordStyle = Style::create (layout, &styleAttrs);
+
+ TableCell *ref = NULL;
+ for(int i = 0; i < 10; i++) {
+ //for(int i = 0; i < 1; i++) {
+ TableCell *cell = new TableCell (ref, false);
+ cell->setStyle (cellStyle);
+ ref = cell;
+ table->addRow (wordStyle);
+ table->addCell (cell, 1, 1);
+
+ char buf[16];
+ for(int j = 0; j < i; j++)
+ buf[j] = '0' + j;
+ buf[i] = '.';
+ for(int j = i + 1; j < 11; j++)
+ buf[j] = '0' + (j - 1);
+ buf[11] = 0;
+
+ cell->addText (buf, wordStyle);
+ cell->flush ();
+ }
+
+ wordStyle->unref();
+ cellStyle->unref();
+
+ window->resizable(viewport);
+ window->show();
+ int errorCode = ::fltk::run();
+
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/dw_ui_test.cc b/test/dw_ui_test.cc
new file mode 100644
index 00000000..5ce949ef
--- /dev/null
+++ b/test/dw_ui_test.cc
@@ -0,0 +1,241 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "../dw/core.hh"
+#include "../dw/fltkcore.hh"
+#include "../dw/fltkviewport.hh"
+#include "../dw/table.hh"
+#include "../dw/textblock.hh"
+#include "../dw/ui.hh"
+#include "form.hh"
+
+using namespace lout::object;
+using namespace lout::container::typed;
+using namespace dw;
+using namespace dw::core;
+using namespace dw::core::style;
+using namespace dw::core::ui;
+using namespace dw::fltk;
+
+int main(int argc, char **argv)
+{
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ ::fltk::Window *window = new ::fltk::Window(400, 400, "Dw UI Test");
+ window->begin();
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 400, 400);
+ layout->attachView (viewport);
+
+ StyleAttrs styleAttrs;
+ styleAttrs.initValues ();
+ styleAttrs.margin.setVal (5);
+ styleAttrs.color = Color::createSimple (layout, 0x000000);
+ styleAttrs.backgroundColor = Color::createSimple (layout, 0xffffff);
+
+ FontAttrs fontAttrs;
+ fontAttrs.name = "Helvetica";
+ fontAttrs.size = 14;
+ fontAttrs.weight = 400;
+ fontAttrs.style = FONT_STYLE_NORMAL;
+ styleAttrs.font = Font::create (layout, &fontAttrs);
+
+ Style *tableStyle = Style::create (layout, &styleAttrs);
+
+ Table *table = new Table (false);
+ table->setStyle (tableStyle);
+ layout->setWidget (table);
+
+ tableStyle->unref();
+
+ styleAttrs.backgroundColor = NULL;
+ styleAttrs.margin.setVal (0);
+
+ Style *cellStyle = Style::create (layout, &styleAttrs);
+
+ // First of all, the resources. Later, they are embedded into the
+ // widget tree.
+ EntryResource *entryres1 =
+ layout->getResourceFactory()->createEntryResource (10, false);
+ entryres1->setText ("Hi!");
+ EntryResource *entryres2 =
+ layout->getResourceFactory()->createEntryResource (10, true);
+ MultiLineTextResource *textres =
+ layout->getResourceFactory()->createMultiLineTextResource (15,3);
+ RadioButtonResource *radiores1 =
+ layout->getResourceFactory()->createRadioButtonResource (NULL, false);
+ RadioButtonResource *radiores2 =
+ layout->getResourceFactory()->createRadioButtonResource (radiores1,
+ false);
+ CheckButtonResource *checkres =
+ layout->getResourceFactory()->createCheckButtonResource (true);
+ SelectionResource *selres[2];
+ selres[0] = layout->getResourceFactory()->createOptionMenuResource ();
+ selres[1] = layout->getResourceFactory()->createListResource
+ (ListResource::SELECTION_AT_MOST_ONE);
+ LabelButtonResource *buttonres =
+ layout->getResourceFactory()->createLabelButtonResource ("Run!");
+
+ // Note on complex buttons: before any operations on the widget, which
+ // need a layout, the complex button resource should be created, since
+ // then, a layout and a platform are instanciated.
+ Textblock *cbuttontext = new Textblock(false);
+ ComplexButtonResource *cbuttonres =
+ layout->getResourceFactory()->createComplexButtonResource (cbuttontext,
+ true);
+ cbuttontext->setStyle (cellStyle);
+ cbuttontext->addText ("Run (complex)!", cellStyle);
+ cbuttontext->flush ();
+
+ // The entry resources are put into a special handler, which is
+ // also a receiver for the button resources.
+ form::Form *form = new form::Form();
+ form->addTextResource ("val1", entryres1);
+ form->addTextResource ("val2", entryres2);
+ form->addTextResource ("text", textres);
+ const char *radiovalues[] = { "radio1", "radio2", NULL };
+ form->addRadioButtonResource ("val3", radiores1, radiovalues);
+ form->addCheckButtonResource ("check", checkres);
+ const char *selvalues[] = { "i1", "i11", "i12", "i13", "i2",
+ "i21", "i22", "i23", "i3", NULL };
+ form->addSelectionResource ("val4", selres[0], selvalues);
+ form->addSelectionResource ("val5", selres[1], selvalues);
+ form->addButtonResource ("button", buttonres, "Run!");
+ form->addButtonResource ("cbutton", cbuttonres, "cbuttonval");
+
+ // Create the widgets.
+ table->addRow (cellStyle);
+
+ Textblock *label1 = new Textblock(false);
+ label1->setStyle (cellStyle);
+ table->addCell (label1, 1, 1);
+ label1->addText ("val1 = ", cellStyle);
+ label1->flush ();
+
+ Embed *input1 = new Embed (entryres1);
+ input1->setStyle (cellStyle);
+ table->addCell (input1, 1, 1);
+
+ table->addRow (cellStyle);
+
+ Textblock *label2 = new Textblock(false);
+ label2->setStyle (cellStyle);
+ table->addCell (label2, 1, 1);
+ label2->addText ("val2 = ", cellStyle);
+ label2->flush ();
+
+ Embed *input2 = new Embed (entryres2);
+ input2->setStyle (cellStyle);
+ table->addCell (input2, 1, 1);
+
+ table->addRow (cellStyle);
+
+ Textblock *label = new Textblock(false);
+ label->setStyle (cellStyle);
+ table->addCell (label, 1, 1);
+ label->addText ("text = ", cellStyle);
+ label->flush ();
+
+ Embed *text = new Embed (textres);
+ textres->setText("Hi textarea");
+ text->setStyle (cellStyle);
+ table->addCell (text, 1, 1);
+
+ table->addRow (cellStyle);
+
+ Textblock *radiolabel1 = new Textblock(false);
+ radiolabel1->setStyle (cellStyle);
+ table->addCell (radiolabel1, 2, 1);
+ Embed *radio1 = new Embed (radiores1);
+ radiolabel1->addWidget (radio1, cellStyle);
+ radiolabel1->addText (" radio1", cellStyle);
+ radiolabel1->flush ();
+
+ table->addRow (cellStyle);
+ Textblock *radiolabel2 = new Textblock(false);
+ radiolabel2->setStyle (cellStyle);
+ table->addCell (radiolabel2, 2, 1);
+ Embed *radio2 = new Embed (radiores2);
+ radiolabel2->addWidget (radio2, cellStyle);
+ radiolabel2->addText (" radio2", cellStyle);
+ radiolabel2->flush ();
+
+ table->addRow (cellStyle);
+ Textblock *checklabel = new Textblock(false);
+ checklabel->setStyle (cellStyle);
+ table->addCell (checklabel, 2, 1);
+ Embed *check = new Embed (checkres);
+ checklabel->addWidget (check, cellStyle);
+ checklabel->addText (" check", cellStyle);
+ checklabel->flush ();
+
+ for(int i = 0; i < 2; i++) {
+ table->addRow (cellStyle);
+
+ Embed *sel = new Embed (selres[i]);
+ sel->setStyle (cellStyle);
+ table->addCell (sel, 2, 1);
+
+ selres[i]->addItem("item 1", true, false);
+
+ selres[i]->pushGroup("group 1", true);
+ selres[i]->addItem("item 1/1", true, false);
+ selres[i]->addItem("item 1/2", true, true);
+ selres[i]->addItem("item 1/3", false, false);
+ selres[i]->popGroup();
+
+ selres[i]->addItem("item 2", true, i == 1);
+
+ selres[i]->pushGroup("group 2", false);
+ selres[i]->addItem("item 2/1", true, false);
+ selres[i]->addItem("item 2/2", true, false);
+ selres[i]->addItem("item 2/3", false, false);
+ selres[i]->popGroup();
+
+ selres[i]->addItem("item 3", false, false);
+ }
+
+ table->addRow (cellStyle);
+ Embed *button = new Embed (buttonres);
+ button->setStyle (cellStyle);
+ table->addCell (button, 2, 1);
+
+ table->addRow (cellStyle);
+ Embed *cbutton = new Embed (cbuttonres);
+ cbutton->setStyle (cellStyle);
+ table->addCell (cbutton, 2, 1);
+
+ cellStyle->unref();
+
+ window->resizable(viewport);
+ window->show();
+ int errorCode = ::fltk::run();
+
+ delete form;
+ delete layout;
+
+ return errorCode;
+}
diff --git a/test/fltk_browser.cc b/test/fltk_browser.cc
new file mode 100644
index 00000000..4186156e
--- /dev/null
+++ b/test/fltk_browser.cc
@@ -0,0 +1,47 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 <fltk/Window.h>
+#include <fltk/Browser.h>
+#include <fltk/MultiBrowser.h>
+#include <fltk/Item.h>
+#include <fltk/run.h>
+
+using namespace fltk;
+
+int main (int argc, char *argv[])
+{
+ Window *window = new Window (300, 300, "FLTK Browser");
+ window->begin ();
+ Browser *browser = new MultiBrowser (0, 0, 300, 300);
+ browser->begin ();
+
+ for (int i = 0; i < 10; i++) {
+ new Item ("first");
+ new Item ("second");
+ new Item ("third");
+ }
+
+ window->resizable(browser);
+ window->show();
+ return run();
+}
diff --git a/test/form.cc b/test/form.cc
new file mode 100644
index 00000000..5e8e0471
--- /dev/null
+++ b/test/form.cc
@@ -0,0 +1,264 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 "form.hh"
+
+namespace form {
+
+using namespace dw::core::ui;
+
+Form::ResourceDecorator::ResourceDecorator (const char *name)
+{
+ this->name = strdup (name);
+}
+
+Form::ResourceDecorator::~ResourceDecorator ()
+{
+ delete name;
+}
+
+Form::TextResourceDecorator::TextResourceDecorator (const char *name,
+ TextResource *resource):
+ Form::ResourceDecorator (name)
+{
+ this->resource = resource;
+}
+
+const char *Form::TextResourceDecorator::getValue ()
+{
+ return resource->getText ();
+}
+
+Form::RadioButtonResourceDecorator::RadioButtonResourceDecorator
+ (const char *name, RadioButtonResource *resource, const char **values):
+ Form::ResourceDecorator (name)
+{
+ this->resource = resource;
+
+ int n = 0;
+ while (values[n])
+ n++;
+ this->values = new const char*[n + 1];
+ for(int i = 0; i < n; i++)
+ this->values[i] = strdup (values[i]);
+ values[n] = 0;
+}
+
+Form::RadioButtonResourceDecorator::~RadioButtonResourceDecorator ()
+{
+ for(int i = 0; values[i]; i++)
+ delete values[i];
+ delete[] values;
+}
+
+const char *Form::RadioButtonResourceDecorator::getValue ()
+{
+ RadioButtonResource::GroupIterator *it;
+ int i;
+ for (it = resource->groupIterator (), i = 0; it->hasNext (); i++) {
+ RadioButtonResource *resource = it->getNext ();
+ if(resource->isActivated ()) {
+ it->unref ();
+ return values[i];
+ }
+ }
+
+ it->unref ();
+ return NULL;
+}
+
+Form::CheckButtonResourceDecorator::CheckButtonResourceDecorator
+ (const char *name, CheckButtonResource *resource):
+ Form::ResourceDecorator (name)
+{
+ this->resource = resource;
+}
+
+const char *Form::CheckButtonResourceDecorator::getValue ()
+{
+ return resource->isActivated () ? "true" : NULL;
+}
+
+Form::SelectionResourceDecorator::SelectionResourceDecorator
+ (const char *name, SelectionResource *resource, const char **values):
+ Form::ResourceDecorator (name)
+{
+ this->resource = resource;
+
+ int n = 0;
+ while (values[n])
+ n++;
+ this->values = new const char*[n + 1];
+ for(int i = 0; i < n; i++)
+ this->values[i] = strdup (values[i]);
+ this->values[n] = 0;
+}
+
+Form::SelectionResourceDecorator::~SelectionResourceDecorator ()
+{
+ for(int i = 0; values[i]; i++)
+ delete values[i];
+ delete[] values;
+}
+
+const char *Form::SelectionResourceDecorator::getValue ()
+{
+ valueBuf.clear();
+ int n = resource->getNumberOfItems ();
+ bool first = true;
+ for (int i = 0; i < n; i++) {
+ if (resource->isSelected (i)) {
+ if (!first)
+ valueBuf.append (", ");
+ valueBuf.append (values[i]);
+ first = false;
+ }
+ }
+
+ return valueBuf.getChars ();
+}
+
+void Form::FormActivateReceiver::activate (Resource *resource)
+{
+ form->send (NULL, NULL, -1, -1);
+}
+
+void Form::FormActivateReceiver::enter (Resource *resource)
+{
+}
+
+void Form::FormActivateReceiver::leave (Resource *resource)
+{
+}
+
+Form::FormClickedReceiver::FormClickedReceiver (Form *form, const char *name,
+ const char *value)
+{
+ this->form = form;
+ this->name = strdup (name);
+ this->value = strdup (value);
+}
+
+Form::FormClickedReceiver::~FormClickedReceiver ()
+{
+ delete name;
+ delete[] value;
+}
+
+void Form::FormClickedReceiver::clicked (ButtonResource *resource,
+ int buttonNo, int x, int y)
+{
+ form->send (name, value, x, y);
+}
+
+Form::Form ()
+{
+ resources = new lout::container::typed::List <ResourceDecorator> (true);
+ activateReceiver = new FormActivateReceiver (this);
+ clickedReceivers =
+ new lout::container::typed::List <FormClickedReceiver> (true);
+}
+
+Form::~Form ()
+{
+ delete resources;
+ delete activateReceiver;
+ delete clickedReceivers;
+}
+
+/**
+ * \brief Adds an instance of dw::core::ui::TextResource.
+ */
+void Form::addTextResource (const char *name,
+ dw::core::ui::TextResource *resource)
+{
+ resources->append (new TextResourceDecorator (name, resource));
+ resource->connectActivate (activateReceiver);
+}
+
+/**
+ * \brief Adds an instance of dw::core::ui::RadioButtonResource.
+ *
+ * This method has to be called only once for a group of radio buttons.
+ */
+void Form::addRadioButtonResource (const char *name,
+ dw::core::ui::RadioButtonResource *resource,
+ const char **values)
+{
+ resources->append (new RadioButtonResourceDecorator (name, resource,
+ values));
+ resource->connectActivate (activateReceiver);
+}
+
+/**
+ * \brief Adds an instance of dw::core::ui::CheckButtonResource.
+ */
+void Form::addCheckButtonResource (const char *name,
+ dw::core::ui::CheckButtonResource *resource)
+{
+ resources->append (new CheckButtonResourceDecorator (name, resource));
+ resource->connectActivate (activateReceiver);
+}
+
+/**
+ * \brief Adds an instance of dw::core::ui::SelectionResource.
+ */
+void Form::addSelectionResource (const char *name,
+ dw::core::ui::SelectionResource *resource,
+ const char **values)
+{
+ resources->append (new SelectionResourceDecorator (name, resource, values));
+ resource->connectActivate (activateReceiver);
+}
+
+/**
+ * \todo Comment this;
+ */
+void Form::addButtonResource (const char *name,
+ dw::core::ui::ButtonResource *resource,
+ const char *value)
+{
+ FormClickedReceiver *receiver =
+ new FormClickedReceiver (this, name, value);
+ resource->connectClicked (receiver);
+ clickedReceivers->append (receiver);
+}
+
+/**
+ * \todo Comment this;
+ */
+void Form::send (const char *buttonName, const char *buttonValue, int x, int y)
+{
+ for (lout::container::typed::Iterator <ResourceDecorator> it =
+ resources->iterator ();
+ it.hasNext (); ) {
+ ResourceDecorator *resource = it.getNext ();
+ const char *value = resource->getValue ();
+ if (value)
+ printf ("%s = %s; x=%d y=%d\n", resource->getName (), value, x, y);
+ }
+
+ if(buttonName && buttonValue)
+ printf ("%s = %s\n", buttonName, buttonValue);
+}
+
+} // namespace form
diff --git a/test/form.hh b/test/form.hh
new file mode 100644
index 00000000..a04460f4
--- /dev/null
+++ b/test/form.hh
@@ -0,0 +1,164 @@
+#ifndef __TEST_FORM_HH__
+#define __TEST_FORM_HH__
+
+#include "../dw/core.hh"
+#include "../dw/ui.hh"
+
+namespace form {
+
+/**
+ * \brief Handles HTML form data.
+ *
+ * Add resources by calling the respective add...Resource method. Furtermore,
+ * this class impelements dw::core::ui::ButtonResource::ClickedReceiver, the
+ * form data is printed to stdout, when the "clicked" signal is received.
+ *
+ * \todo wrong comment
+ */
+class Form
+{
+private:
+ /**
+ * \brief Decorates instances of dw::core::ui::Resource.
+ *
+ * This is the abstract base class, sub classes have to be defined to
+ * decorate specific sub interfaces of dw::core::ui::Resource.
+ */
+ class ResourceDecorator: public lout::object::Object
+ {
+ private:
+ const char *name;
+
+ protected:
+ ResourceDecorator (const char *name);
+ ~ResourceDecorator ();
+
+ public:
+ inline const char *getName () { return name; }
+ virtual const char *getValue () = 0;
+ };
+
+ /**
+ * \brief Decorates instances of dw::core::ui::TextResource.
+ */
+ class TextResourceDecorator: public ResourceDecorator
+ {
+ private:
+ dw::core::ui::TextResource *resource;
+
+ public:
+ TextResourceDecorator (const char *name,
+ dw::core::ui::TextResource *resource);
+ const char *getValue ();
+ };
+
+ /**
+ * \brief Decorates instances of dw::core::ui::RadioButtonResource.
+ *
+ * This class has to be instanciated only once for a group of radio
+ * buttons.
+ */
+ class RadioButtonResourceDecorator: public ResourceDecorator
+ {
+ private:
+ dw::core::ui::RadioButtonResource *resource;
+ const char **values;
+
+ public:
+ RadioButtonResourceDecorator (const char *name,
+ dw::core::ui::RadioButtonResource
+ *resource,
+ const char **values);
+ ~RadioButtonResourceDecorator ();
+ const char *getValue ();
+ };
+
+ /**
+ * \brief Decorates instances of dw::core::ui::CheckButtonResource.
+ */
+ class CheckButtonResourceDecorator: public ResourceDecorator
+ {
+ private:
+ dw::core::ui::CheckButtonResource *resource;
+
+ public:
+ CheckButtonResourceDecorator (const char *name,
+ dw::core::ui::CheckButtonResource
+ *resource);
+ const char *getValue ();
+ };
+
+ /**
+ * \brief Decorates instances of dw::core::ui::SelectionResource.
+ */
+ class SelectionResourceDecorator: public ResourceDecorator
+ {
+ private:
+ dw::core::ui::SelectionResource *resource;
+ const char **values;
+ lout::misc::StringBuffer valueBuf;
+
+ public:
+ SelectionResourceDecorator (const char *name,
+ dw::core::ui::SelectionResource *resource,
+ const char **values);
+ ~SelectionResourceDecorator ();
+ const char *getValue ();
+ };
+
+ class FormActivateReceiver: public dw::core::ui::Resource::ActivateReceiver
+ {
+ private:
+ Form *form;
+
+ public:
+ inline FormActivateReceiver (Form *form) { this->form = form; }
+
+ void activate (dw::core::ui::Resource *resource);
+ void enter (dw::core::ui::Resource *resource);
+ void leave (dw::core::ui::Resource *resource);
+ };
+
+ class FormClickedReceiver:
+ public dw::core::ui::ButtonResource::ClickedReceiver
+ {
+ private:
+ Form *form;
+ const char *name, *value;
+
+ public:
+ FormClickedReceiver (Form *form, const char *name, const char *value);
+ ~FormClickedReceiver ();
+
+ void clicked (dw::core::ui::ButtonResource *resource, int buttonNo,
+ int x, int y);
+ };
+
+ lout::container::typed::List <ResourceDecorator> *resources;
+ FormActivateReceiver *activateReceiver;
+ lout::container::typed::List <FormClickedReceiver> *clickedReceivers;
+
+public:
+ Form ();
+ ~Form ();
+
+ void addTextResource (const char *name,
+ dw::core::ui::TextResource *resource);
+ void addRadioButtonResource (const char *name,
+ dw::core::ui::RadioButtonResource *resource,
+ const char **values);
+ void addCheckButtonResource (const char *name,
+ dw::core::ui::CheckButtonResource *resource);
+ void addSelectionResource (const char *name,
+ dw::core::ui::SelectionResource *resource,
+ const char **values);
+ void addButtonResource (const char *name,
+ dw::core::ui::ButtonResource *resource,
+ const char *value);
+
+ void send (const char *buttonName, const char *buttonValue, int x, int y);
+};
+
+} // namespace form
+
+#endif // __TEST_FORM_HH__
diff --git a/test/shapes.cc b/test/shapes.cc
new file mode 100644
index 00000000..8d33152b
--- /dev/null
+++ b/test/shapes.cc
@@ -0,0 +1,41 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * 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 3 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 "../dw/core.hh"
+
+using namespace dw::core;
+using namespace misc;
+
+int main()
+{
+ Polygon poly;
+ poly.addPoint (50, 10);
+ poly.addPoint (90, 90);
+ poly.addPoint (10, 90);
+
+ printf("first test\n");
+ assert (poly.isPointWithin (50, 50));
+ printf("second test\n");
+ assert (!poly.isPointWithin (10, 10));
+ printf("third test\n");
+ assert (!poly.isPointWithin (90, 50));
+}