summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNo Author <No Author>2001-08-01 21:24:49 +0000
committerNo Author <No Author>2001-08-01 21:24:49 +0000
commit3cb5ebe0e811f3db008085d985b7761725589a74 (patch)
tree0a7184a5f02fffe927af911758f3a9a4a2f4a37e /test
parent4477e166400f197bed50b09e01e695221cde96b6 (diff)
This commit was manufactured by cvs2svn to create branch 'branch-1.1'.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1513 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
-rw-r--r--test/tabs.cxx85
-rw-r--r--test/threads.cxx65
2 files changed, 150 insertions, 0 deletions
diff --git a/test/tabs.cxx b/test/tabs.cxx
new file mode 100644
index 000000000..4e2c0223a
--- /dev/null
+++ b/test/tabs.cxx
@@ -0,0 +1,85 @@
+// generated by Fast Light User Interface Designer (fluid) version 2.0001
+
+#include "tabs.h"
+
+Fl_Window *foo_window=(Fl_Window *)0;
+
+static void cb_cancel(Fl_Button*, void*) {
+ exit(1);
+
+}
+
+static void cb_OK(Fl_Return_Button*, void*) {
+ exit(0);
+
+}
+
+int main (int argc, char **argv) {
+
+ Fl_Window* w;
+ { Fl_Window* o = foo_window = new Fl_Window(321, 324);
+ w = o;
+ { Fl_Tabs* o = new Fl_Tabs(10, 10, 300, 200);
+ o->color((Fl_Color)47);
+ o->selection_color((Fl_Color)15);
+ { Fl_Group* o = new Fl_Group(0, 20, 300, 180, "Label1");
+ o->hide();
+ new Fl_Input(50, 20, 240, 40, "input:");
+ new Fl_Input(50, 60, 240, 30, "input2:");
+ new Fl_Input(50, 90, 240, 80, "input3:");
+ o->end();
+ Fl_Group::current()->resizable(o);
+ }
+ { Fl_Group* o = new Fl_Group(0, 20, 300, 180, "tab2");
+ o->hide();
+ new Fl_Button(10, 30, 100, 30, "button1");
+ new Fl_Input(130, 70, 100, 30, "input in box2");
+ new Fl_Button(20, 110, 260, 30, "This is stuff inside the Fl_Group \"tab2\"");
+ o->end();
+ }
+ { Fl_Group* o = new Fl_Group(0, 20, 300, 180, "tab3");
+ o->hide();
+ new Fl_Button(10, 30, 60, 80, "button2");
+ new Fl_Button(70, 30, 60, 80, "button");
+ new Fl_Button(130, 30, 60, 80, "button");
+ o->end();
+ }
+ { Fl_Group* o = new Fl_Group(0, 20, 300, 180, "tab4");
+ o->label_font(fl_fonts+2);
+ o->hide();
+ new Fl_Button(10, 20, 60, 110, "button2");
+ new Fl_Button(70, 20, 60, 110, "button");
+ new Fl_Button(130, 20, 60, 110, "button");
+ o->end();
+ }
+ { Fl_Group* o = new Fl_Group(0, 20, 300, 180, " tab5 ");
+ o->label_type(FL_ENGRAVED_LABEL);
+ new Fl_Button(10, 50, 60, 80, "button2");
+ new Fl_Button(80, 60, 60, 80, "button");
+ { Fl_Clock* o = new Fl_Clock(150, 20, 100, 100, "Make sure this clock does not use processor time when this tab is hidden or w\
+indow is iconized");
+ o->box(FL_OSHADOW_BOX);
+ o->label_font(fl_fonts+8);
+ o->color((Fl_Color)238);
+ o->label_size(10);
+ o->align(130);
+ }
+ o->end();
+ }
+ o->end();
+ Fl_Group::current()->resizable(o);
+ }
+ new Fl_Input(60, 220, 130, 30, "inputA:");
+ new Fl_Input(60, 250, 250, 30, "inputB:");
+ { Fl_Button* o = new Fl_Button(180, 290, 60, 30, "cancel");
+ o->callback((Fl_Callback*)cb_cancel);
+ }
+ { Fl_Return_Button* o = new Fl_Return_Button(250, 290, 60, 30, "OK");
+ o->shortcut(0xff0d);
+ o->callback((Fl_Callback*)cb_OK);
+ }
+ o->end();
+ }
+ w->show(argc, argv);
+ return Fl::run();
+}
diff --git a/test/threads.cxx b/test/threads.cxx
new file mode 100644
index 000000000..6aabed8f3
--- /dev/null
+++ b/test/threads.cxx
@@ -0,0 +1,65 @@
+#include <fltk/Fl.h>
+#include <fltk/Fl_Window.h>
+#include <fltk/Fl_Browser.h>
+#include <fltk/Fl_Threads.h>
+#include <stdio.h>
+
+Fl_Thread prime_thread;
+
+Fl_Browser *browser1, *browser2;
+
+void* prime_func(void* p)
+{
+ Fl_Browser* browser = (Fl_Browser*) p;
+
+ // very loosy prime number calculator !
+ for (int n=1000000; ; n++) {
+ int p;
+ for (p=2; p<n; p++) if ( n%p == 0 ) break;
+ if (p == n) {
+ char s[128];
+ sprintf(s, "%d", n);
+ Fl::lock();
+ browser->add(s);
+ Fl::unlock();
+ Fl::awake((void*) (browser == browser1? p:0)); // Cause the browser to redraw ...
+ }
+ }
+ return 0;
+}
+
+int main()
+{
+ Fl_Window* w = new Fl_Window(200, 300, "Multithread test");
+ browser1 = new Fl_Browser(0, 0, 200, 300);
+ w->end();
+ w->show();
+ w = new Fl_Window(200, 300, "Multithread test");
+ browser2 = new Fl_Browser(0, 0, 200, 300);
+ w->end();
+ w->show();
+
+ browser1->add("Prime numbers :");
+ browser2->add("Prime numbers :");
+
+ Fl::lock(); // you must do this before creating any threads!
+
+ // One thread displaying in one browser
+ fl_create_thread(prime_thread, prime_func, browser1);
+ // Several threads displaying in another browser
+ fl_create_thread(prime_thread, prime_func, browser2);
+ fl_create_thread(prime_thread, prime_func, browser2);
+ fl_create_thread(prime_thread, prime_func, browser2);
+ fl_create_thread(prime_thread, prime_func, browser2);
+ fl_create_thread(prime_thread, prime_func, browser2);
+ fl_create_thread(prime_thread, prime_func, browser2);
+
+ // Fl::run();
+ while (w->visible()) {
+ Fl::wait();
+ void* m = Fl::thread_message();
+ if (m) printf("Recieved message: %d\n", int(m));
+ }
+
+ return 0;
+}