summaryrefslogtreecommitdiff
path: root/src/Fl_win32.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_win32.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_win32.cxx')
-rw-r--r--src/Fl_win32.cxx63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 8db05169d..2b123422c 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -95,6 +95,10 @@
for async mode proper operation, not mentioning the side effects...
*/
+static Fl_GDI_Display fl_gdi_device;
+FL_EXPORT Fl_Display *fl_display_device = (Fl_Display*)&fl_gdi_device; // does not change
+FL_EXPORT Fl_Device *fl_device = (Fl_Device*)&fl_gdi_device; // the current target device of graphics operations
+
// dynamic wsock dll handling api:
#if defined(__CYGWIN__) && !defined(SOCKET)
# define SOCKET int
@@ -1777,6 +1781,8 @@ void Fl_Window::show() {
if (!fl_capture) BringWindowToTop(i->xid);
//ShowWindow(i->xid,fl_capture?SW_SHOWNOACTIVATE:SW_RESTORE);
}
+void preparePrintFront(void);
+preparePrintFront();
}
Fl_Window *Fl_Window::current_;
@@ -1915,6 +1921,63 @@ void fl_cleanup_dc_list(void) { // clean up the list
t = win_DC_list;
} while(t);
}
+
+Fl_Region XRectangleRegion(int x, int y, int w, int h) {
+ if (Fl_Device::current()->type() < 256) return CreateRectRgn(x,y,x+w,y+h);
+ // because rotation may apply, the rectangle becomes a polygon in device coords
+ POINT pt[4] = { {x, y}, {x + w, y}, {x + w, y + h}, {x, y + h} };
+ LPtoDP(fl_gc, pt, 4);
+ return CreatePolygonRgn(pt, 4, ALTERNATE);
+}
+
+// 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(), - win->w()/2, - win->h()/2 );
+ printer.end_page();
+ printer.end_job();
+ o->window()->show();
+}
+
+void preparePrintFront(void)
+{
+ static BOOL first=TRUE;
+ if(!first) return;
+ first=FALSE;
+ static Fl_Window w(0,0,120,30);
+ static Fl_Button b(0,0,w.w(),w.h(), "Print front window");
+ b.callback(printFront);
+ w.end();
+ w.show();
+}
#endif // FL_DOXYGEN
//