summaryrefslogtreecommitdiff
path: root/test/mandelbrot.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2010-03-14 18:07:24 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2010-03-14 18:07:24 +0000
commit998cc6df521a115454727d1ecf6bc7d4fee96f68 (patch)
tree70a1c9afffb294a75bd38484c2e6e4a042ac3426 /test/mandelbrot.cxx
parent5bc66fafc348c547870bbf51c9c4a7215ad4ff25 (diff)
Merge of branch-1.3-Fl_Printer, with the following main changes:
(1) adding Fl_Device class (and more) for device abstraction (2) adding Fl_Pinter class (and more) for printing support. Todo: Code cleanup, update dependencies, remove/replace test print window. I'm looking into converting the test window popup in a global shortcut that would pop up the print dialog now... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7263 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test/mandelbrot.cxx')
-rw-r--r--test/mandelbrot.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/mandelbrot.cxx b/test/mandelbrot.cxx
index c274658c6..7599057be 100644
--- a/test/mandelbrot.cxx
+++ b/test/mandelbrot.cxx
@@ -27,6 +27,8 @@
#include "mandelbrot_ui.h"
#include <FL/fl_draw.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Printer.H>
#include <stdio.h>
#include <stdlib.h>
@@ -43,8 +45,30 @@ void set_idle() {
static void window_callback(Fl_Widget*, void*) {exit(0);}
+static void print(Fl_Widget *o, void *data)
+{
+ Fl_Printer printer;
+ Fl_Window *win = o->window();
+ if(!win->visible()) return;
+ win->make_current();
+ uchar *image_data = fl_read_image(NULL, 0, 0, win->w(), win->h(), 0);
+ if( printer.start_job(1) ) return;
+ if( printer.start_page() ) return;
+ printer.scale(.7,.7);
+ fl_draw_image(image_data, 0,0, win->w(), win->h());
+ printer.end_page();
+ delete image_data;
+ printer.end_job();
+}
+
int main(int argc, char **argv) {
mbrot.make_window();
+ mbrot.window->begin();
+ Fl_Button* o = new Fl_Button(0, 0, 0, 0, NULL);
+ o->callback(print,NULL);
+ o->shortcut(FL_CTRL+'p');
+ mbrot.window->end();
+
mbrot.d->X = -.75;
mbrot.d->scale = 2.5;
mbrot.update_label();