Renamed Fl_Device::type() to Fl_Device::class_name() to avoid conflict or confusion

with Fl_Widget::type(). Added a setter function Fl_Device::class_name(const char *).

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8190 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2011-01-05 10:21:45 +00:00
parent 6320a7c680
commit 4beb3b88e8
21 changed files with 59 additions and 57 deletions

View File

@ -63,24 +63,26 @@ typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf);
\brief All graphical output devices and all graphics systems. \brief All graphical output devices and all graphics systems.
*/ */
class FL_EXPORT Fl_Device { class FL_EXPORT Fl_Device {
private:
const char *type_; // pointer to class name
protected: protected:
/** \brief The device type */ /** \brief Sets the class name */
const char *type_; inline void class_name(const char *name) { type_ = name;};
/** \brief A string that identifies each subclass of Fl_Device. /** \brief A string that identifies each subclass of Fl_Device.
*
Function type() applied to a device of this class returns this string. Function class_name() applied to a device of this class returns this string.
*/ */
static const char *device_type; static const char *class_id;
public: public:
/** /**
@brief An RTTI emulation of device classes. \brief Returns the name of the class of this object.
* *
The type of an instance of an Fl_Device subclass can be checked with code such as: The class of an instance of an Fl_Device subclass can be checked with code such as:
\code \code
if ( instance->type() == Fl_Printer::device_type ) { ... } if ( instance->class_name() == Fl_Printer::class_id ) { ... }
\endcode \endcode
*/ */
inline const char *type() {return type_;}; inline const char *class_name() {return type_;};
}; };
/** /**
@ -275,7 +277,7 @@ protected:
virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {}; virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {};
public: public:
static const char *device_type; static const char *class_id;
/** \brief The destructor */ /** \brief The destructor */
virtual ~Fl_Graphics_Driver() {}; virtual ~Fl_Graphics_Driver() {};
}; };
@ -289,8 +291,8 @@ public:
class FL_EXPORT Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver { class FL_EXPORT Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver {
public: public:
/** \brief The constructor. */ /** \brief The constructor. */
Fl_Quartz_Graphics_Driver() { type_ = device_type; }; Fl_Quartz_Graphics_Driver() { class_name( class_id); };
static const char *device_type; static const char *class_id;
void color(Fl_Color c); void color(Fl_Color c);
void color(uchar r, uchar g, uchar b); void color(uchar r, uchar g, uchar b);
void draw(const char* str, int n, int x, int y); void draw(const char* str, int n, int x, int y);
@ -315,8 +317,8 @@ public:
class FL_EXPORT Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver { class FL_EXPORT Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver {
public: public:
/** \brief The constructor. */ /** \brief The constructor. */
Fl_GDI_Graphics_Driver() { type_ = device_type; }; Fl_GDI_Graphics_Driver() { class_name ( class_id); };
static const char *device_type; static const char *class_id;
void color(Fl_Color c); void color(Fl_Color c);
void color(uchar r, uchar g, uchar b); void color(uchar r, uchar g, uchar b);
void draw(const char* str, int n, int x, int y); void draw(const char* str, int n, int x, int y);
@ -341,8 +343,8 @@ public:
class Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver { class Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver {
public: public:
/** \brief The constructor. */ /** \brief The constructor. */
Fl_Xlib_Graphics_Driver() { type_ = device_type; }; Fl_Xlib_Graphics_Driver() { class_name ( class_id); };
static const char *device_type; static const char *class_id;
void color(Fl_Color c); void color(Fl_Color c);
void color(uchar r, uchar g, uchar b); void color(uchar r, uchar g, uchar b);
void draw(const char* str, int n, int x, int y); void draw(const char* str, int n, int x, int y);
@ -369,7 +371,7 @@ protected:
/** \brief Constructor that sets the graphics driver to use for the created surface. */ /** \brief Constructor that sets the graphics driver to use for the created surface. */
Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver; }; Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver; };
public: public:
static const char *device_type; static const char *class_id;
virtual void set_current(void); virtual void set_current(void);
/** \brief Sets the graphics driver of this drawing surface. */ /** \brief Sets the graphics driver of this drawing surface. */
inline void driver(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver;}; inline void driver(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver;};
@ -386,9 +388,9 @@ public:
*/ */
class FL_EXPORT Fl_Display_Device : public Fl_Surface_Device { class FL_EXPORT Fl_Display_Device : public Fl_Surface_Device {
public: public:
static const char *device_type; static const char *class_id;
/** \brief A constructor that sets the graphics driver used by the display */ /** \brief A constructor that sets the graphics driver used by the display */
Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device( graphics_driver) { type_ = device_type; }; Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device( graphics_driver) { class_name( class_id); };
/** /**
@brief Returns the platform's display device. @brief Returns the platform's display device.
*/ */

View File

@ -130,11 +130,11 @@ protected:
void delete_image_list(); void delete_image_list();
#endif #endif
/** \brief The constructor */ /** \brief The constructor */
Fl_Paged_Device() : Fl_Surface_Device(NULL) {type_ = device_type;}; Fl_Paged_Device() : Fl_Surface_Device(NULL) {class_name( class_id);};
/** \brief The destructor */ /** \brief The destructor */
virtual ~Fl_Paged_Device() {}; virtual ~Fl_Paged_Device() {};
public: public:
static const char *device_type; static const char *class_id;
virtual int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); virtual int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
virtual int start_page(void); virtual int start_page(void);
virtual int printable_rect(int *w, int *h); virtual int printable_rect(int *w, int *h);

View File

@ -63,7 +63,7 @@
*/ */
class Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver { class Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
public: public:
static const char *device_type; static const char *class_id;
#ifndef FL_DOXYGEN #ifndef FL_DOXYGEN
public: public:
enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS}; enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
@ -227,7 +227,7 @@ class Fl_PostScript_File_Device : public Fl_Paged_Device {
protected: protected:
Fl_PostScript_Graphics_Driver *driver(); Fl_PostScript_Graphics_Driver *driver();
public: public:
static const char *device_type; static const char *class_id;
Fl_PostScript_File_Device(); Fl_PostScript_File_Device();
~Fl_PostScript_File_Device(); ~Fl_PostScript_File_Device();
int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,

View File

@ -73,7 +73,7 @@ private:
void absolute_printable_rect(int *x, int *y, int *w, int *h); void absolute_printable_rect(int *x, int *y, int *w, int *h);
#endif #endif
public: public:
static const char *device_type; static const char *class_id;
Fl_System_Printer(void); Fl_System_Printer(void);
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
int start_page (void); int start_page (void);
@ -101,7 +101,7 @@ public:
*/ */
class Fl_PostScript_Printer : public Fl_PostScript_File_Device { class Fl_PostScript_Printer : public Fl_PostScript_File_Device {
public: public:
static const char *device_type; static const char *class_id;
int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL); int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL);
}; };
@ -141,7 +141,7 @@ public:
*/ */
class Fl_Printer : public Fl_Paged_Device { class Fl_Printer : public Fl_Paged_Device {
public: public:
static const char *device_type; static const char *class_id;
/** \brief The constructor */ /** \brief The constructor */
Fl_Printer(void); Fl_Printer(void);
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);

2
FL/x.H
View File

@ -112,7 +112,7 @@ extern FL_EXPORT ulong fl_event_time;
typedef ulong Fl_Offscreen; typedef ulong Fl_Offscreen;
# define fl_create_offscreen(w,h) \ # define fl_create_offscreen(w,h) \
XCreatePixmap(fl_display, \ XCreatePixmap(fl_display, \
(fl_surface->type() == Fl_Display_Device::device_type ? \ (fl_surface->class_name() == Fl_Display_Device::class_id ? \
fl_window : fl_xid(Fl::first_window()) ) , \ fl_window : fl_xid(Fl::first_window()) ) , \
w, h, fl_visual->depth) w, h, fl_visual->depth)
// begin/end are macros that save the old state in local variables: // begin/end are macros that save the old state in local variables:

View File

@ -304,7 +304,7 @@ void Fl_GDI_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP,
HDC tempdc; HDC tempdc;
int save; int save;
BOOL use_print_algo = false; BOOL use_print_algo = false;
if (fl_surface->type() == Fl_Printer::device_type) { if (fl_surface->class_name() == Fl_Printer::class_id) {
static HMODULE hMod = NULL; static HMODULE hMod = NULL;
if (!hMod) { if (!hMod) {
hMod = LoadLibrary("MSIMG32.DLL"); hMod = LoadLibrary("MSIMG32.DLL");

View File

@ -29,18 +29,18 @@
#include <FL/Fl_Device.H> #include <FL/Fl_Device.H>
#include <FL/Fl_Image.H> #include <FL/Fl_Image.H>
const char *Fl_Device::device_type = "Fl_Device"; const char *Fl_Device::class_id = "Fl_Device";
const char *Fl_Surface_Device::device_type = "Fl_Surface_Device"; const char *Fl_Surface_Device::class_id = "Fl_Surface_Device";
const char *Fl_Display_Device::device_type = "Fl_Display_Device"; const char *Fl_Display_Device::class_id = "Fl_Display_Device";
const char *Fl_Graphics_Driver::device_type = "Fl_Graphics_Driver"; const char *Fl_Graphics_Driver::class_id = "Fl_Graphics_Driver";
#if defined(__APPLE__) || defined(FL_DOXYGEN) #if defined(__APPLE__) || defined(FL_DOXYGEN)
const char *Fl_Quartz_Graphics_Driver::device_type = "Fl_Quartz_Graphics_Driver"; const char *Fl_Quartz_Graphics_Driver::class_id = "Fl_Quartz_Graphics_Driver";
#endif #endif
#if defined(WIN32) || defined(FL_DOXYGEN) #if defined(WIN32) || defined(FL_DOXYGEN)
const char *Fl_GDI_Graphics_Driver::device_type = "Fl_GDI_Graphics_Driver"; const char *Fl_GDI_Graphics_Driver::class_id = "Fl_GDI_Graphics_Driver";
#endif #endif
#if !(defined(__APPLE__) || defined(WIN32)) #if !(defined(__APPLE__) || defined(WIN32))
const char *Fl_Xlib_Graphics_Driver::device_type = "Fl_Xlib_Graphics_Driver"; const char *Fl_Xlib_Graphics_Driver::class_id = "Fl_Xlib_Graphics_Driver";
#endif #endif

View File

@ -180,8 +180,8 @@ void fl_copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int src
BOOL alpha_ok = 0; BOOL alpha_ok = 0;
// first try to alpha blend // first try to alpha blend
// if to printer, always try alpha_blend // if to printer, always try alpha_blend
int to_display = Fl_Surface_Device::surface()->type() == Fl_Display_Device::device_type; // true iff display output int to_display = Fl_Surface_Device::surface()->class_name() == Fl_Display_Device::class_id; // true iff display output
if ( (to_display && fl_can_do_alpha_blending()) || Fl_Surface_Device::surface()->type() == Fl_Printer::device_type) { if ( (to_display && fl_can_do_alpha_blending()) || Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) {
alpha_ok = fl_alpha_blend(fl_gc, x, y, w, h, new_gc, srcx, srcy, w, h, blendfunc); alpha_ok = fl_alpha_blend(fl_gc, x, y, w, h, new_gc, srcx, srcy, w, h, blendfunc);
} }
// if that failed (it shouldn't), still copy the bitmap over, but now alpha is 1 // if that failed (it shouldn't), still copy the bitmap over, but now alpha is 1

View File

@ -36,7 +36,7 @@ extern HWND fl_window;
Fl_System_Printer::Fl_System_Printer(void) : Fl_Paged_Device() { Fl_System_Printer::Fl_System_Printer(void) : Fl_Paged_Device() {
hPr = NULL; hPr = NULL;
type_ = device_type; class_name(class_id);
driver(fl_graphics_driver); driver(fl_graphics_driver);
} }

View File

@ -32,7 +32,7 @@
#include <FL/Fl.H> #include <FL/Fl.H>
#include <FL/fl_draw.H> #include <FL/fl_draw.H>
const char *Fl_Paged_Device::device_type = "Fl_Paged_Device"; const char *Fl_Paged_Device::class_id = "Fl_Paged_Device";
/** /**

View File

@ -145,7 +145,7 @@ void Fl_GDI_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP
} }
fl_end_offscreen(); fl_end_offscreen();
} }
if (fl_surface->type() == Fl_Printer::device_type) { if (fl_surface->class_name() == Fl_Printer::class_id) {
typedef BOOL (WINAPI* fl_transp_func) (HDC,int,int,int,int,HDC,int,int,int,int,UINT); typedef BOOL (WINAPI* fl_transp_func) (HDC,int,int,int,int,HDC,int,int,int,int,UINT);
static HMODULE hMod = NULL; static HMODULE hMod = NULL;
static fl_transp_func fl_TransparentBlt = NULL; static fl_transp_func fl_TransparentBlt = NULL;

View File

@ -32,8 +32,8 @@
#include <FL/Fl_PostScript.H> #include <FL/Fl_PostScript.H>
#include <FL/Fl_Native_File_Chooser.H> #include <FL/Fl_Native_File_Chooser.H>
const char *Fl_PostScript_Graphics_Driver::device_type = "Fl_PostScript_Graphics_Driver"; const char *Fl_PostScript_Graphics_Driver::class_id = "Fl_PostScript_Graphics_Driver";
const char *Fl_PostScript_File_Device::device_type = "Fl_PostScript_File_Device"; const char *Fl_PostScript_File_Device::class_id = "Fl_PostScript_File_Device";
/** \brief Label of the PostScript file chooser window */ /** \brief Label of the PostScript file chooser window */
const char *Fl_PostScript_File_Device::file_chooser_title = "Select a .ps file"; const char *Fl_PostScript_File_Device::file_chooser_title = "Select a .ps file";
@ -47,7 +47,7 @@ Fl_PostScript_Graphics_Driver::Fl_PostScript_Graphics_Driver(void)
lang_level_ = 2; lang_level_ = 2;
mask = 0; mask = 0;
ps_filename_ = NULL; ps_filename_ = NULL;
type_ = device_type; class_name(class_id);
scale_x = scale_y = 1.; scale_x = scale_y = 1.;
bg_r = bg_g = bg_b = 255; bg_r = bg_g = bg_b = 255;
} }
@ -62,7 +62,7 @@ Fl_PostScript_Graphics_Driver::~Fl_PostScript_Graphics_Driver() {
*/ */
Fl_PostScript_File_Device::Fl_PostScript_File_Device(void) Fl_PostScript_File_Device::Fl_PostScript_File_Device(void)
{ {
type_ = device_type; class_name(class_id);
#ifdef __APPLE__ #ifdef __APPLE__
gc = fl_gc; // the display context is used by fl_text_extents() gc = fl_gc; // the display context is used by fl_text_extents()
#endif #endif

View File

@ -76,11 +76,11 @@ const char *Fl_Printer::property_save = "Save";
/** [this text may be customized at run-time] */ /** [this text may be customized at run-time] */
const char *Fl_Printer::property_cancel = "Cancel"; const char *Fl_Printer::property_cancel = "Cancel";
const char *Fl_Printer::device_type = "Fl_Printer"; const char *Fl_Printer::class_id = "Fl_Printer";
#if defined(__APPLE__) || defined(WIN32) #if defined(__APPLE__) || defined(WIN32)
const char *Fl_System_Printer::device_type = "Fl_Printer"; const char *Fl_System_Printer::class_id = "Fl_Printer";
#elif !defined(FL_DOXYGEN) #elif !defined(FL_DOXYGEN)
const char *Fl_PostScript_Printer::device_type = "Fl_Printer"; const char *Fl_PostScript_Printer::class_id = "Fl_Printer";
#endif #endif
#if defined(__APPLE__) || defined(WIN32) #if defined(__APPLE__) || defined(WIN32)

View File

@ -40,7 +40,7 @@ Fl_System_Printer::Fl_System_Printer(void)
x_offset = 0; x_offset = 0;
y_offset = 0; y_offset = 0;
scale_x = scale_y = 1.; scale_x = scale_y = 1.;
type_ = device_type; class_name(class_id);
gc = 0; gc = 0;
driver(fl_graphics_driver); driver(fl_graphics_driver);
} }

View File

@ -3256,7 +3256,7 @@ WindowRef Fl_X::window_ref()
// so a CGRect matches exactly what is denoted x,y,w,h for clipping purposes // so a CGRect matches exactly what is denoted x,y,w,h for clipping purposes
CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h) { CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h) {
if ( Fl_Surface_Device::surface()->type() == Fl_Printer::device_type ) return CGRectMake(x, y, w-1.5 , h-1.5 ); if ( Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id ) return CGRectMake(x, y, w-1.5 , h-1.5 );
return CGRectMake(x, y, w > 0 ? w - 0.9 : 0, h > 0 ? h - 0.9 : 0); return CGRectMake(x, y, w > 0 ? w - 0.9 : 0, h > 0 ? h - 0.9 : 0);
} }

View File

@ -1911,7 +1911,7 @@ void fl_cleanup_dc_list(void) { // clean up the list
} }
Fl_Region XRectangleRegion(int x, int y, int w, int h) { Fl_Region XRectangleRegion(int x, int y, int w, int h) {
if (Fl_Surface_Device::surface()->type() == Fl_Display_Device::device_type) return CreateRectRgn(x,y,x+w,y+h); if (Fl_Surface_Device::surface()->class_name() == Fl_Display_Device::class_id) return CreateRectRgn(x,y,x+w,y+h);
// because rotation may apply, the rectangle becomes a polygon in device coords // 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} }; POINT pt[4] = { {x, y}, {x + w, y}, {x + w, y + h}, {x, y + h} };
LPtoDP(fl_gc, pt, 4); LPtoDP(fl_gc, pt, 4);

View File

@ -255,7 +255,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
} }
} }
} }
if(Fl_Surface_Device::surface()->type() == Fl_Printer::device_type) { if(Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) {
// if print context, device and logical units are not equal, so SetDIBitsToDevice // if print context, device and logical units are not equal, so SetDIBitsToDevice
// does not do the expected job, whereas StretchDIBits does it. // does not do the expected job, whereas StretchDIBits does it.
StretchDIBits(fl_gc, x, y+j-k, w, k, 0, 0, w, k, StretchDIBits(fl_gc, x, y+j-k, w, k, 0, 0, w, k,

View File

@ -341,7 +341,7 @@ int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg) {
#endif #endif
#ifdef __APPLE_QUARTZ__ #ifdef __APPLE_QUARTZ__
if (fl_graphics_driver->type() == Fl_Quartz_Graphics_Driver::device_type ) { if (fl_graphics_driver->class_name() == Fl_Quartz_Graphics_Driver::class_id ) {
bool transparent = (transparent_index>=0); bool transparent = (transparent_index>=0);
transparent = true; transparent = true;
U32 *array = new U32[d.w * d.h], *q = array; U32 *array = new U32[d.w * d.h], *q = array;

View File

@ -250,7 +250,7 @@ static void on_printer_extents_update(int &dx, int &dy, int &w, int &h)
// if printer context, extents shd be converted to logical coords // if printer context, extents shd be converted to logical coords
#define EXTENTS_UPDATE(x,y,w,h) \ #define EXTENTS_UPDATE(x,y,w,h) \
if (Fl_Surface_Device::surface()->type() == Fl_Printer::device_type) { on_printer_extents_update(x,y,w,h); } if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { on_printer_extents_update(x,y,w,h); }
static unsigned short *ext_buff = NULL; // UTF-16 converted version of input UTF-8 string static unsigned short *ext_buff = NULL; // UTF-16 converted version of input UTF-8 string
static unsigned wc_len = 0; // current string buffer dimension static unsigned wc_len = 0; // current string buffer dimension

View File

@ -127,7 +127,7 @@ void Fl_Graphics_Driver::line_style(int style, int width, char* dashes) {
fl_quartz_line_width_ = (float)width; fl_quartz_line_width_ = (float)width;
fl_quartz_line_cap_ = Cap[(style>>8)&3]; fl_quartz_line_cap_ = Cap[(style>>8)&3];
// when printing kCGLineCapSquare seems better for solid lines // when printing kCGLineCapSquare seems better for solid lines
if ( Fl_Surface_Device::surface()->type() == Fl_Printer::device_type && style == FL_SOLID && dashes == NULL ) { if ( Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id && style == FL_SOLID && dashes == NULL ) {
fl_quartz_line_cap_ = kCGLineCapSquare; fl_quartz_line_cap_ = kCGLineCapSquare;
} }
fl_quartz_line_join_ = Join[(style>>12)&3]; fl_quartz_line_join_ = Join[(style>>12)&3];

View File

@ -49,7 +49,7 @@ extern int fl_line_width_;
#ifdef __APPLE_QUARTZ__ #ifdef __APPLE_QUARTZ__
extern float fl_quartz_line_width_; extern float fl_quartz_line_width_;
#define USINGQUARTZPRINTER (Fl_Surface_Device::surface()->type() == Fl_Printer::device_type) #define USINGQUARTZPRINTER (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id)
#endif #endif
#ifdef USE_X11 #ifdef USE_X11
@ -627,7 +627,7 @@ int Fl_Graphics_Driver::not_clipped(int x, int y, int w, int h) {
return XRectInRegion(r, x, y, w, h); return XRectInRegion(r, x, y, w, h);
#elif defined(WIN32) #elif defined(WIN32)
RECT rect; RECT rect;
if (Fl_Surface_Device::surface()->type() == Fl_Printer::device_type) { // in case of print context, convert coords from logical to device if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { // in case of print context, convert coords from logical to device
POINT pt[2] = { {x, y}, {x + w, y + h} }; POINT pt[2] = { {x, y}, {x + w, y + h} };
LPtoDP(fl_gc, pt, 2); LPtoDP(fl_gc, pt, 2);
rect.left = pt[0].x; rect.top = pt[0].y; rect.right = pt[1].x; rect.bottom = pt[1].y; rect.left = pt[0].x; rect.top = pt[0].y; rect.right = pt[1].x; rect.bottom = pt[1].y;
@ -687,7 +687,7 @@ int Fl_Graphics_Driver::clip_box(int x, int y, int w, int h, int& X, int& Y, int
} else { // partial intersection } else { // partial intersection
RECT rect; RECT rect;
GetRgnBox(temp, &rect); GetRgnBox(temp, &rect);
if(Fl_Surface_Device::surface()->type() == Fl_Printer::device_type) { // if print context, convert coords from device to logical if(Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { // if print context, convert coords from device to logical
POINT pt[2] = { {rect.left, rect.top}, {rect.right, rect.bottom} }; POINT pt[2] = { {rect.left, rect.top}, {rect.right, rect.bottom} };
DPtoLP(fl_gc, pt, 2); DPtoLP(fl_gc, pt, 2);
X = pt[0].x; Y = pt[0].y; W = pt[1].x - X; H = pt[1].y - Y; X = pt[0].x; Y = pt[0].y; W = pt[1].x - X; H = pt[1].y - Y;