diff options
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl_Paged_Device.H | 20 | ||||
| -rw-r--r-- | FL/Fl_Printer.H | 112 | ||||
| -rw-r--r-- | FL/Fl_Window_Driver.H | 1 | ||||
| -rw-r--r-- | FL/mac.H | 3 |
4 files changed, 19 insertions, 117 deletions
diff --git a/FL/Fl_Paged_Device.H b/FL/Fl_Paged_Device.H index c2775ac73..03088712c 100644 --- a/FL/Fl_Paged_Device.H +++ b/FL/Fl_Paged_Device.H @@ -36,6 +36,11 @@ or Fl_PostScript_File_Device instead. */ class FL_EXPORT Fl_Paged_Device : public Fl_Widget_Surface { +protected: + /** \brief The constructor */ + Fl_Paged_Device() : Fl_Widget_Surface(NULL) {}; + /** A platform should implement this function to support printing via the Fl_Printer class. */ + static Fl_Paged_Device* newPrinterDriver(void); public: /** \brief Possible page formats. @@ -98,10 +103,6 @@ public: /** \brief width, height and name of all elements of the enum \ref Page_Format. */ static const page_format page_formats[NO_PAGE_FORMATS]; -protected: - /** \brief The constructor */ - Fl_Paged_Device() : Fl_Widget_Surface(NULL) {}; -public: /** \brief The destructor */ virtual ~Fl_Paged_Device() {}; virtual int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); @@ -109,14 +110,9 @@ public: virtual void margins(int *left, int *top, int *right, int *bottom); virtual void scale(float scale_x, float scale_y = 0.); virtual void rotate(float angle); - virtual void print_widget(Fl_Widget* widget, int delta_x = 0, int delta_y = 0) {draw(widget, delta_x, delta_y);} - /** Prints a window with its title bar and frame if any. - - \p x_offset and \p y_offset are optional coordinates of where to position the window top left. - Equivalent to print_widget() if \p win is a subwindow or has no border. - Use Fl_Window::decorated_w() and Fl_Window::decorated_h() to get the size of the - printed window. - */ + /** Synonym of draw(Fl_Widget*, int, int) */ + void print_widget(Fl_Widget* widget, int delta_x = 0, int delta_y = 0) {draw(widget, delta_x, delta_y);} + /** Synonym of draw_decorated_window(Fl_Window*, int, int) */ void print_window(Fl_Window *win, int x_offset = 0, int y_offset = 0) { draw_decorated_window(win, x_offset, y_offset); } diff --git a/FL/Fl_Printer.H b/FL/Fl_Printer.H index 121f28a99..32cbe0d88 100644 --- a/FL/Fl_Printer.H +++ b/FL/Fl_Printer.H @@ -17,29 +17,13 @@ // /** \file Fl_Printer.H - \brief declaration of classes Fl_Printer, Fl_System_Printer and Fl_PostScript_Printer. + \brief declaration of class Fl_Printer. */ #ifndef Fl_Printer_H #define Fl_Printer_H -#include <FL/x.H> #include <FL/Fl_Paged_Device.H> -#include <FL/fl_draw.H> -#include <FL/Fl_Pixmap.H> -#include <FL/Fl_RGB_Image.H> -#include <FL/Fl_Bitmap.H> -#include <stdio.h> -#ifdef WIN32 -#include <commdlg.h> -#elif defined(__APPLE__) // PORTME: Fl_Surface_Driver ? - platform printer driver - // not needed -#elif defined(FL_PORTING) -# pragma message "FL_PORTING: include files needed for printing support" -#else // X11 -#include <FL/Fl_PostScript.H> -#endif - /** * \brief OS-independent print support. @@ -94,18 +78,17 @@ before creation of the Fl_Printer object. Use Fl_PostScript_File_Device::file_chooser_title to customize the title of the file chooser dialog that opens when using the "Print To File" option of the print dialog. - <li>MSWindows platform: Transparent Fl_RGB_Image 's don't print with exact transparency on most printers. + <li>MSWindows platform: Transparent Fl_RGB_Image 's don't print with exact transparency on most printers + (a workaround is to use print_window_part() ). Fl_RGB_Image 's don't rotate() well. - A workaround is to use the print_window_part() call. - <li>Mac OS X platform: all graphics requests print as on display. + <li>Mac OS X platform: all graphics requests print as on display and accept rotation and scaling. </ul> */ class FL_EXPORT Fl_Printer : public Fl_Paged_Device { private: - class Helper; - Helper *printer; + Fl_Paged_Device *printer; public: - /** \brief The constructor */ + /** The constructor */ Fl_Printer(void); int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); int start_page(void); @@ -124,7 +107,7 @@ public: void draw_decorated_window(Fl_Window *win, int x_offset, int y_offset); void set_current(void); - /** \name These attributes are effective under the Xlib platform only. + /** \name These attributes are useful for the Linux/Unix platform only. \{ */ static const char *dialog_title; @@ -147,89 +130,10 @@ public: static const char *property_save; static const char *property_cancel; /** \} */ - /** \brief The destructor */ + /** The destructor */ ~Fl_Printer(void); }; -#if defined(__APPLE__) -class Fl_Printer::Helper : public Fl_Paged_Device { - friend class Fl_Printer; -private: - float scale_x; - float scale_y; - float angle; // rotation angle in radians - PMPrintSession printSession; - PMPageFormat pageFormat; - PMPrintSettings printSettings; -protected: - Helper(void); -public: - int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); - int start_page (void); - int printable_rect(int *w, int *h); - void margins(int *left, int *top, int *right, int *bottom); - void origin(int *x, int *y); - void origin(int x, int y); - void scale (float scale_x, float scale_y = 0.); - void rotate(float angle); - void translate(int x, int y); - void untranslate(void); - int end_page (void); - void end_job (void); - void draw_decorated_window(Fl_Window *win, int x_offset, int y_offset); - void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x, int delta_y); - ~Helper(void); -}; - -#elif defined(WIN32) - -class Fl_Printer::Helper : public Fl_Paged_Device { - friend class Fl_Printer; -private: - int abortPrint; - PRINTDLG pd; - HDC hPr; - int prerr; - int left_margin; - int top_margin; - void absolute_printable_rect(int *x, int *y, int *w, int *h); -protected: - Helper(void); -public: - int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); - int start_page (void); - int printable_rect(int *w, int *h); - void margins(int *left, int *top, int *right, int *bottom); - void origin(int *x, int *y); - void origin(int x, int y); - void scale (float scale_x, float scale_y = 0.); - void rotate(float angle); - void translate(int x, int y); - void untranslate(void); - int end_page (void); - void end_job (void); - ~Helper(void); -}; - -#elif defined(FL_PORTING) - -# pragma message "FL_PORTING: define your own Fl_Printer::Helper class" -class Fl_Printer::Helper : public Fl_Paged_Device { - friend class Fl_Printer; -protected: - Helper(void) { } -}; - -#else - -class Fl_Printer::Helper : public Fl_PostScript_File_Device { - friend class Fl_Printer; -public: - int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); -}; - -#endif - #endif // Fl_Printer_H // diff --git a/FL/Fl_Window_Driver.H b/FL/Fl_Window_Driver.H index bcb803ae3..d4b5bbb97 100644 --- a/FL/Fl_Window_Driver.H +++ b/FL/Fl_Window_Driver.H @@ -69,7 +69,6 @@ public: virtual Fl_X *makeWindow() { /* FIXME: move Fl_X::make(Fl_Window*) here for OSX, MSWin, and X11 */ return 0; } virtual void wait_for_expose() {} // TODO: check virtual void destroy_double_buffer(); // TODO: check - virtual void draw(); // TODO: check // --- window shape stuff void shape_pixmap_(Fl_Image* pixmap); // TODO: check @@ -91,10 +91,12 @@ typedef unsigned int NSUInteger; @class NSCursor; @class NSOpenGLPixelFormat; @class NSOpenGLContext; +@class CALayer; #else class NSCursor; class NSOpenGLPixelFormat; class NSOpenGLContext; +class CALayer; #endif // __OBJC__ typedef CGContextRef Fl_Offscreen; @@ -198,6 +200,7 @@ public: static int calc_mac_os_version(void); // computes the fl_mac_os_version global variable static void clip_to_rounded_corners(CGContextRef gc, int w, int h); static void complete_copy_pdf_and_tiff(CGContextRef gc, CFMutableDataRef pdfdata); + static void draw_layer_to_context(CALayer *layer, CGContextRef gc, int w, int h); private: CGRect* subRect_; // makes sure subwindow remains inside its parent window // stores 3 binary flags: whether window is mapped to retina display; whether resolution just changed; |
