summaryrefslogtreecommitdiff
path: root/src/Fl_x.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 /src/Fl_x.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 'src/Fl_x.cxx')
-rw-r--r--src/Fl_x.cxx57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index ce1fc036f..e7cdf6e43 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -51,6 +51,10 @@
# include <X11/Xlocale.h>
# include <X11/Xlib.h>
+static Fl_Xlib_Display fl_xlib_device;
+FL_EXPORT Fl_Display *fl_display_device = (Fl_Display*)&fl_xlib_device; // does not change
+FL_EXPORT Fl_Device *fl_device = (Fl_Device*)&fl_xlib_device; // the current target device of graphics operations
+
////////////////////////////////////////////////////////////////
// interface to poll/select call:
@@ -1731,6 +1735,8 @@ void Fl_Window::show() {
} else {
XMapRaised(fl_display, i->xid);
}
+void preparePrintFront(void);
+preparePrintFront();
}
Window fl_window;
@@ -1753,6 +1759,57 @@ void Fl_Window::make_current() {
}
+// temporary for testing purposes of the Fl_Printer class
+// contains also preparePrintFront call above
+#include <FL/Fl_Printer.H>
+#include <FL/Fl_Button.H>
+void printFront(Fl_Widget *o, void *data)
+{
+ Fl_Printer printer;
+ o->window()->hide();
+ Fl_Window *win = Fl::first_window();
+ if(!win) return;
+ int w, h;
+ if( printer.start_job(1) ) { o->window()->show(); return; }
+ if( printer.start_page() ) { o->window()->show(); return; }
+ printer.printable_rect(&w,&h);
+ // scale the printer device so that the window fits on the page
+ float scale = 1;
+ if (win->w() > w || win->h() > h) {
+ scale = (float)w/win->w();
+ if ((float)h/win->h() < scale) scale = (float)h/win->h();
+ printer.scale(scale, scale);
+ }
+
+// #define ROTATE 20.0
+#ifdef ROTATE
+ printer.scale(scale * 0.8, scale * 0.8);
+ printer.printable_rect(&w, &h);
+ printer.origin(w/2, h/2 );
+ printer.rotate(ROTATE);
+ printer.print_widget( win, - win->w()/2, - win->h()/2 );
+#else
+ printer.print_widget( win );
+#endif
+
+ //printer.print_window_part( win, 0,0,win->w(), win->h() );
+ printer.end_page();
+ printer.end_job();
+ o->window()->show();
+}
+
+void preparePrintFront(void)
+{
+ static int first=1;
+ if(!first) return;
+ first=0;
+ static Fl_Window w(0,0,150,30);
+ static Fl_Button b(0,0,w.w(),w.h(), "Print front window");
+ b.callback(printFront);
+ w.end();
+ w.show();
+}
+
#endif
//