Better position of the Fl_Printer class in the Fl_Device class hierarchy.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8188 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
7b302635e7
commit
e11677bfaf
@ -44,13 +44,12 @@
|
||||
#include <commdlg.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(WIN32) || defined(FL_DOXYGEN)
|
||||
/**
|
||||
\brief Print support under MSWindows and Mac OS X.
|
||||
*
|
||||
#if defined(__APPLE__) || defined(WIN32)
|
||||
/*
|
||||
Print support under MSWindows and Mac OS X.
|
||||
|
||||
Class Fl_System_Printer is implemented only on the MSWindows and Mac OS X platforms.
|
||||
Use Fl_Printer instead that is cross-platform and has the same API.
|
||||
Fl_Printer is typedef'ed to Fl_System_Printer under MSWindows and Mac OS X.
|
||||
*/
|
||||
class Fl_System_Printer : public Fl_Paged_Device {
|
||||
private:
|
||||
@ -75,9 +74,6 @@ private:
|
||||
#endif
|
||||
public:
|
||||
static const char *device_type;
|
||||
/**
|
||||
@brief The constructor.
|
||||
*/
|
||||
Fl_System_Printer(void);
|
||||
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
|
||||
int start_page (void);
|
||||
@ -91,78 +87,28 @@ public:
|
||||
int end_page (void);
|
||||
void end_job (void);
|
||||
|
||||
/**
|
||||
@brief The destructor.
|
||||
*/
|
||||
~Fl_System_Printer(void);
|
||||
#ifndef FL_DOXYGEN
|
||||
public:
|
||||
static const char *dialog_title;
|
||||
static const char *dialog_printer;
|
||||
static const char *dialog_range;
|
||||
static const char *dialog_copies;
|
||||
static const char *dialog_all;
|
||||
static const char *dialog_pages;
|
||||
static const char *dialog_from;
|
||||
static const char *dialog_to;
|
||||
static const char *dialog_properties;
|
||||
static const char *dialog_copyNo;
|
||||
static const char *dialog_print_button;
|
||||
static const char *dialog_cancel_button;
|
||||
static const char *dialog_print_to_file;
|
||||
static const char *property_title;
|
||||
static const char *property_pagesize;
|
||||
static const char *property_mode;
|
||||
static const char *property_use;
|
||||
static const char *property_save;
|
||||
static const char *property_cancel;
|
||||
#endif // FL_DOXYGEN
|
||||
}; // class Fl_System_Printer
|
||||
|
||||
typedef Fl_System_Printer Fl_Printer;
|
||||
#endif
|
||||
|
||||
#if !(defined(__APPLE__) || defined(WIN32))
|
||||
/**
|
||||
\brief Print support under Unix/Linux.
|
||||
*
|
||||
#if !(defined(__APPLE__) || defined(WIN32) || defined(FL_DOXYGEN))
|
||||
/*
|
||||
Print support under Unix/Linux.
|
||||
|
||||
Class Fl_PostScript_Printer is implemented only on the Unix/Linux platform.
|
||||
Use Fl_Printer instead that is cross-platform and has the same API.
|
||||
Fl_Printer is typedef'ed to Fl_PostScript_Printer under Unix/Linux.
|
||||
*/
|
||||
class Fl_PostScript_Printer : public Fl_PostScript_File_Device {
|
||||
public:
|
||||
static const char *device_type;
|
||||
int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL);
|
||||
|
||||
#ifndef FL_DOXYGEN
|
||||
static const char *dialog_title;
|
||||
static const char *dialog_printer;
|
||||
static const char *dialog_range;
|
||||
static const char *dialog_copies;
|
||||
static const char *dialog_all;
|
||||
static const char *dialog_pages;
|
||||
static const char *dialog_from;
|
||||
static const char *dialog_to;
|
||||
static const char *dialog_properties;
|
||||
static const char *dialog_copyNo;
|
||||
static const char *dialog_print_button;
|
||||
static const char *dialog_cancel_button;
|
||||
static const char *dialog_print_to_file;
|
||||
static const char *property_title;
|
||||
static const char *property_pagesize;
|
||||
static const char *property_mode;
|
||||
static const char *property_use;
|
||||
static const char *property_save;
|
||||
static const char *property_cancel;
|
||||
#endif // FL_DOXYGEN
|
||||
};
|
||||
|
||||
typedef Fl_PostScript_Printer Fl_Printer;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief OS-independent print support.
|
||||
* \brief OS-independent print support.
|
||||
*
|
||||
Fl_Printer allows to use all FLTK drawing, color, text, and clip functions, and to have them operate
|
||||
on printed page(s). There are two main, non exclusive, ways to use it.
|
||||
@ -175,8 +121,6 @@ typedef Fl_PostScript_Printer Fl_Printer;
|
||||
In both cases, begin by start_job(), start_page(), printable_rect() and origin() calls
|
||||
and finish by end_page() and end_job() calls.
|
||||
<p><b>Platform specifics</b>
|
||||
<br>Fl_Printer is typedef'ed to Fl_PostScript_Printer under Unix/Linux
|
||||
and to Fl_System_Printer otherwise. Both classes have the same API.
|
||||
<ul>
|
||||
<li>Unix/Linux platforms:
|
||||
Class Fl_RGB_Image prints but loses its transparency if it has one.
|
||||
@ -195,12 +139,10 @@ typedef Fl_PostScript_Printer Fl_Printer;
|
||||
<li>Mac OS X platform: all graphics requests print as on display.
|
||||
</ul>
|
||||
*/
|
||||
#ifdef FL_DOXYGEN
|
||||
// this class is NOT compiled. It's here for Doxygen documentation purpose only
|
||||
class Fl_Printer : public Fl_System_Printer, Fl_PostScript_Printer {
|
||||
class Fl_Printer : public Fl_Paged_Device {
|
||||
public:
|
||||
static const char *device_type;
|
||||
/** @brief The constructor */
|
||||
/** \brief The constructor */
|
||||
Fl_Printer(void);
|
||||
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
|
||||
int start_page(void);
|
||||
@ -213,7 +155,7 @@ public:
|
||||
void untranslate(void);
|
||||
int end_page (void);
|
||||
void end_job (void);
|
||||
/** @brief The destructor */
|
||||
/** \brief The destructor */
|
||||
~Fl_Printer(void);
|
||||
|
||||
/** \name These attributes are effective under the Xlib platform only.
|
||||
@ -239,8 +181,13 @@ public:
|
||||
static const char *property_save;
|
||||
static const char *property_cancel;
|
||||
/** \} */
|
||||
};
|
||||
private:
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
Fl_System_Printer *printer;
|
||||
#else
|
||||
Fl_PostScript_Printer *printer;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // Fl_Printer_H
|
||||
|
||||
|
@ -34,13 +34,13 @@
|
||||
|
||||
extern HWND fl_window;
|
||||
|
||||
Fl_Printer::Fl_System_Printer(void) : Fl_Paged_Device() {
|
||||
Fl_System_Printer::Fl_System_Printer(void) : Fl_Paged_Device() {
|
||||
hPr = NULL;
|
||||
type_ = device_type;
|
||||
driver(fl_graphics_driver);
|
||||
}
|
||||
|
||||
Fl_Printer::~Fl_System_Printer(void) {
|
||||
Fl_System_Printer::~Fl_System_Printer(void) {
|
||||
if (hPr) end_job();
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ static void WIN_SetupPrinterDeviceContext(HDC prHDC)
|
||||
}
|
||||
|
||||
|
||||
int Fl_Printer::start_job (int pagecount, int *frompage, int *topage)
|
||||
int Fl_System_Printer::start_job (int pagecount, int *frompage, int *topage)
|
||||
// returns 0 iff OK
|
||||
{
|
||||
DWORD commdlgerr;
|
||||
@ -116,7 +116,7 @@ int Fl_Printer::start_job (int pagecount, int *frompage, int *topage)
|
||||
return err;
|
||||
}
|
||||
|
||||
void Fl_Printer::end_job (void)
|
||||
void Fl_System_Printer::end_job (void)
|
||||
{
|
||||
Fl_Display_Device::display_device()->set_current();
|
||||
if (hPr != NULL) {
|
||||
@ -137,7 +137,7 @@ void Fl_Printer::end_job (void)
|
||||
hPr = NULL;
|
||||
}
|
||||
|
||||
void Fl_Printer::absolute_printable_rect(int *x, int *y, int *w, int *h)
|
||||
void Fl_System_Printer::absolute_printable_rect(int *x, int *y, int *w, int *h)
|
||||
{
|
||||
POINT physPageSize;
|
||||
POINT pixelsPerInch;
|
||||
@ -163,7 +163,7 @@ void Fl_Printer::absolute_printable_rect(int *x, int *y, int *w, int *h)
|
||||
origin(x_offset, y_offset);
|
||||
}
|
||||
|
||||
void Fl_Printer::margins(int *left, int *top, int *right, int *bottom)
|
||||
void Fl_System_Printer::margins(int *left, int *top, int *right, int *bottom)
|
||||
{
|
||||
int x, y, w, h;
|
||||
absolute_printable_rect(&x, &y, &w, &h);
|
||||
@ -173,14 +173,14 @@ void Fl_Printer::margins(int *left, int *top, int *right, int *bottom)
|
||||
if (bottom) *bottom = y;
|
||||
}
|
||||
|
||||
int Fl_Printer::printable_rect(int *w, int *h)
|
||||
int Fl_System_Printer::printable_rect(int *w, int *h)
|
||||
{
|
||||
int x, y;
|
||||
absolute_printable_rect(&x, &y, w, h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Fl_Printer::start_page (void)
|
||||
int Fl_System_Printer::start_page (void)
|
||||
{
|
||||
int rsult, w, h;
|
||||
|
||||
@ -201,14 +201,14 @@ int Fl_Printer::start_page (void)
|
||||
return rsult;
|
||||
}
|
||||
|
||||
void Fl_Printer::origin (int deltax, int deltay)
|
||||
void Fl_System_Printer::origin (int deltax, int deltay)
|
||||
{
|
||||
SetWindowOrgEx(fl_gc, - left_margin - deltax, - top_margin - deltay, NULL);
|
||||
x_offset = deltax;
|
||||
y_offset = deltay;
|
||||
}
|
||||
|
||||
void Fl_Printer::scale (float scalex, float scaley)
|
||||
void Fl_System_Printer::scale (float scalex, float scaley)
|
||||
{
|
||||
int w, h;
|
||||
SetWindowExtEx(fl_gc, (int)(720 / scalex + 0.5), (int)(720 / scaley + 0.5), NULL);
|
||||
@ -216,7 +216,7 @@ void Fl_Printer::scale (float scalex, float scaley)
|
||||
origin(0, 0);
|
||||
}
|
||||
|
||||
void Fl_Printer::rotate (float rot_angle)
|
||||
void Fl_System_Printer::rotate (float rot_angle)
|
||||
{
|
||||
XFORM mat;
|
||||
float angle;
|
||||
@ -229,7 +229,7 @@ void Fl_Printer::rotate (float rot_angle)
|
||||
SetWorldTransform(fl_gc, &mat);
|
||||
}
|
||||
|
||||
int Fl_Printer::end_page (void)
|
||||
int Fl_System_Printer::end_page (void)
|
||||
{
|
||||
int rsult;
|
||||
|
||||
@ -261,7 +261,7 @@ static void do_translate(int x, int y)
|
||||
ModifyWorldTransform(fl_gc, &tr, MWT_LEFTMULTIPLY);
|
||||
}
|
||||
|
||||
void Fl_Printer::translate (int x, int y)
|
||||
void Fl_System_Printer::translate (int x, int y)
|
||||
{
|
||||
do_translate(x, y);
|
||||
if (translate_stack_depth < translate_stack_max) {
|
||||
@ -271,7 +271,7 @@ void Fl_Printer::translate (int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
void Fl_Printer::untranslate (void)
|
||||
void Fl_System_Printer::untranslate (void)
|
||||
{
|
||||
if (translate_stack_depth > 0) {
|
||||
translate_stack_depth--;
|
||||
|
@ -1471,7 +1471,7 @@ void Fl_PostScript_File_Device::end_job (void)
|
||||
}
|
||||
|
||||
#if ! (defined(__APPLE__) || defined(WIN32) )
|
||||
int Fl_Printer::start_job(int pages, int *firstpage, int *lastpage) {
|
||||
int Fl_PostScript_Printer::start_job(int pages, int *firstpage, int *lastpage) {
|
||||
enum Fl_Paged_Device::Page_Format format;
|
||||
enum Fl_Paged_Device::Page_Layout layout;
|
||||
|
||||
|
@ -77,6 +77,11 @@ const char *Fl_Printer::property_save = "Save";
|
||||
const char *Fl_Printer::property_cancel = "Cancel";
|
||||
|
||||
const char *Fl_Printer::device_type = "Fl_Printer";
|
||||
#if defined(__APPLE__) || defined(WIN32)
|
||||
const char *Fl_System_Printer::device_type = "Fl_Printer";
|
||||
#elif !defined(FL_DOXYGEN)
|
||||
const char *Fl_PostScript_Printer::device_type = "Fl_Printer";
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(WIN32)
|
||||
void Fl_System_Printer::set_current(void)
|
||||
@ -90,6 +95,75 @@ void Fl_System_Printer::set_current(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
Fl_Printer::Fl_Printer(void) {
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
printer = new Fl_System_Printer();
|
||||
#else
|
||||
printer = new Fl_PostScript_Printer();
|
||||
#endif
|
||||
}
|
||||
|
||||
int Fl_Printer::start_job(int pagecount, int *frompage, int *topage)
|
||||
{
|
||||
return printer->start_job(pagecount, frompage, topage);
|
||||
}
|
||||
|
||||
int Fl_Printer::start_page(void)
|
||||
{
|
||||
return printer->start_page();
|
||||
}
|
||||
|
||||
int Fl_Printer::printable_rect(int *w, int *h)
|
||||
{
|
||||
return printer->printable_rect(w, h);
|
||||
}
|
||||
|
||||
void Fl_Printer::margins(int *left, int *top, int *right, int *bottom)
|
||||
{
|
||||
printer->margins(left, top, right, bottom);
|
||||
}
|
||||
|
||||
void Fl_Printer::origin(int x, int y)
|
||||
{
|
||||
printer->origin(x, y);
|
||||
}
|
||||
|
||||
void Fl_Printer::scale(float scale_x, float scale_y)
|
||||
{
|
||||
printer->scale(scale_x, scale_y);
|
||||
}
|
||||
|
||||
void Fl_Printer::rotate(float angle)
|
||||
{
|
||||
printer->rotate(angle);
|
||||
}
|
||||
|
||||
void Fl_Printer::translate(int x, int y)
|
||||
{
|
||||
printer->translate(x, y);
|
||||
}
|
||||
|
||||
void Fl_Printer::untranslate(void)
|
||||
{
|
||||
printer->untranslate();
|
||||
}
|
||||
|
||||
int Fl_Printer::end_page (void)
|
||||
{
|
||||
return printer->end_page();
|
||||
}
|
||||
|
||||
void Fl_Printer::end_job (void)
|
||||
{
|
||||
printer->end_job();
|
||||
}
|
||||
|
||||
Fl_Printer::~Fl_Printer(void)
|
||||
{
|
||||
delete printer;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -47,7 +47,7 @@ Fl_System_Printer::Fl_System_Printer(void)
|
||||
|
||||
Fl_System_Printer::~Fl_System_Printer(void) {}
|
||||
|
||||
int Fl_Printer::start_job (int pagecount, int *frompage, int *topage)
|
||||
int Fl_System_Printer::start_job (int pagecount, int *frompage, int *topage)
|
||||
//printing using a Quartz graphics context
|
||||
//returns 0 iff OK
|
||||
{
|
||||
@ -139,7 +139,7 @@ int Fl_Printer::start_job (int pagecount, int *frompage, int *topage)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Fl_Printer::margins(int *left, int *top, int *right, int *bottom)
|
||||
void Fl_System_Printer::margins(int *left, int *top, int *right, int *bottom)
|
||||
{
|
||||
PMPaper paper;
|
||||
PMGetPageFormatPaper(pageFormat, &paper);
|
||||
@ -161,7 +161,7 @@ void Fl_Printer::margins(int *left, int *top, int *right, int *bottom)
|
||||
}
|
||||
}
|
||||
|
||||
int Fl_Printer::printable_rect(int *w, int *h)
|
||||
int Fl_System_Printer::printable_rect(int *w, int *h)
|
||||
//returns 0 iff OK
|
||||
{
|
||||
OSStatus status;
|
||||
@ -178,7 +178,7 @@ int Fl_Printer::printable_rect(int *w, int *h)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Fl_Printer::origin(int x, int y)
|
||||
void Fl_System_Printer::origin(int x, int y)
|
||||
{
|
||||
x_offset = x;
|
||||
y_offset = y;
|
||||
@ -191,7 +191,7 @@ void Fl_Printer::origin(int x, int y)
|
||||
CGContextSaveGState(fl_gc);
|
||||
}
|
||||
|
||||
void Fl_Printer::scale (float s_x, float s_y)
|
||||
void Fl_System_Printer::scale (float s_x, float s_y)
|
||||
{
|
||||
scale_x = s_x;
|
||||
scale_y = s_y;
|
||||
@ -204,7 +204,7 @@ void Fl_Printer::scale (float s_x, float s_y)
|
||||
CGContextSaveGState(fl_gc);
|
||||
}
|
||||
|
||||
void Fl_Printer::rotate (float rot_angle)
|
||||
void Fl_System_Printer::rotate (float rot_angle)
|
||||
{
|
||||
angle = - rot_angle * M_PI / 180.;
|
||||
CGContextRestoreGState(fl_gc);
|
||||
@ -216,20 +216,20 @@ void Fl_Printer::rotate (float rot_angle)
|
||||
CGContextSaveGState(fl_gc);
|
||||
}
|
||||
|
||||
void Fl_Printer::translate(int x, int y)
|
||||
void Fl_System_Printer::translate(int x, int y)
|
||||
{
|
||||
CGContextSaveGState(fl_gc);
|
||||
CGContextTranslateCTM(fl_gc, x, y );
|
||||
CGContextSaveGState(fl_gc);
|
||||
}
|
||||
|
||||
void Fl_Printer::untranslate(void)
|
||||
void Fl_System_Printer::untranslate(void)
|
||||
{
|
||||
CGContextRestoreGState(fl_gc);
|
||||
CGContextRestoreGState(fl_gc);
|
||||
}
|
||||
|
||||
int Fl_Printer::start_page (void)
|
||||
int Fl_System_Printer::start_page (void)
|
||||
{
|
||||
OSStatus status = PMSessionBeginPageNoDialog(printSession, pageFormat, NULL);
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
@ -278,7 +278,7 @@ int Fl_Printer::start_page (void)
|
||||
return status != noErr;
|
||||
}
|
||||
|
||||
int Fl_Printer::end_page (void)
|
||||
int Fl_System_Printer::end_page (void)
|
||||
{
|
||||
CGContextFlush(fl_gc);
|
||||
CGContextRestoreGState(fl_gc);
|
||||
@ -289,7 +289,7 @@ int Fl_Printer::end_page (void)
|
||||
return status != noErr;
|
||||
}
|
||||
|
||||
void Fl_Printer::end_job (void)
|
||||
void Fl_System_Printer::end_job (void)
|
||||
{
|
||||
OSStatus status;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user