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:
parent
6320a7c680
commit
4beb3b88e8
@ -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.
|
||||
*/
|
||||
class FL_EXPORT Fl_Device {
|
||||
private:
|
||||
const char *type_; // pointer to class name
|
||||
protected:
|
||||
/** \brief The device type */
|
||||
const char *type_;
|
||||
/** \brief Sets the class name */
|
||||
inline void class_name(const char *name) { type_ = name;};
|
||||
/** \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:
|
||||
/**
|
||||
@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
|
||||
if ( instance->type() == Fl_Printer::device_type ) { ... }
|
||||
if ( instance->class_name() == Fl_Printer::class_id ) { ... }
|
||||
\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) {};
|
||||
|
||||
public:
|
||||
static const char *device_type;
|
||||
static const char *class_id;
|
||||
/** \brief The destructor */
|
||||
virtual ~Fl_Graphics_Driver() {};
|
||||
};
|
||||
@ -289,8 +291,8 @@ public:
|
||||
class FL_EXPORT Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver {
|
||||
public:
|
||||
/** \brief The constructor. */
|
||||
Fl_Quartz_Graphics_Driver() { type_ = device_type; };
|
||||
static const char *device_type;
|
||||
Fl_Quartz_Graphics_Driver() { class_name( class_id); };
|
||||
static const char *class_id;
|
||||
void color(Fl_Color c);
|
||||
void color(uchar r, uchar g, uchar b);
|
||||
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 {
|
||||
public:
|
||||
/** \brief The constructor. */
|
||||
Fl_GDI_Graphics_Driver() { type_ = device_type; };
|
||||
static const char *device_type;
|
||||
Fl_GDI_Graphics_Driver() { class_name ( class_id); };
|
||||
static const char *class_id;
|
||||
void color(Fl_Color c);
|
||||
void color(uchar r, uchar g, uchar b);
|
||||
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 {
|
||||
public:
|
||||
/** \brief The constructor. */
|
||||
Fl_Xlib_Graphics_Driver() { type_ = device_type; };
|
||||
static const char *device_type;
|
||||
Fl_Xlib_Graphics_Driver() { class_name ( class_id); };
|
||||
static const char *class_id;
|
||||
void color(Fl_Color c);
|
||||
void color(uchar r, uchar g, uchar b);
|
||||
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. */
|
||||
Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver; };
|
||||
public:
|
||||
static const char *device_type;
|
||||
static const char *class_id;
|
||||
virtual void set_current(void);
|
||||
/** \brief Sets the graphics driver of this drawing surface. */
|
||||
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 {
|
||||
public:
|
||||
static const char *device_type;
|
||||
static const char *class_id;
|
||||
/** \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.
|
||||
*/
|
||||
|
@ -130,11 +130,11 @@ protected:
|
||||
void delete_image_list();
|
||||
#endif
|
||||
/** \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 */
|
||||
virtual ~Fl_Paged_Device() {};
|
||||
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_page(void);
|
||||
virtual int printable_rect(int *w, int *h);
|
||||
|
@ -63,7 +63,7 @@
|
||||
*/
|
||||
class Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
|
||||
public:
|
||||
static const char *device_type;
|
||||
static const char *class_id;
|
||||
#ifndef FL_DOXYGEN
|
||||
public:
|
||||
enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
|
||||
@ -227,7 +227,7 @@ class Fl_PostScript_File_Device : public Fl_Paged_Device {
|
||||
protected:
|
||||
Fl_PostScript_Graphics_Driver *driver();
|
||||
public:
|
||||
static const char *device_type;
|
||||
static const char *class_id;
|
||||
Fl_PostScript_File_Device();
|
||||
~Fl_PostScript_File_Device();
|
||||
int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
|
||||
|
@ -73,7 +73,7 @@ private:
|
||||
void absolute_printable_rect(int *x, int *y, int *w, int *h);
|
||||
#endif
|
||||
public:
|
||||
static const char *device_type;
|
||||
static const char *class_id;
|
||||
Fl_System_Printer(void);
|
||||
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
|
||||
int start_page (void);
|
||||
@ -101,7 +101,7 @@ public:
|
||||
*/
|
||||
class Fl_PostScript_Printer : public Fl_PostScript_File_Device {
|
||||
public:
|
||||
static const char *device_type;
|
||||
static const char *class_id;
|
||||
int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL);
|
||||
};
|
||||
|
||||
@ -141,7 +141,7 @@ public:
|
||||
*/
|
||||
class Fl_Printer : public Fl_Paged_Device {
|
||||
public:
|
||||
static const char *device_type;
|
||||
static const char *class_id;
|
||||
/** \brief The constructor */
|
||||
Fl_Printer(void);
|
||||
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
|
||||
|
2
FL/x.H
2
FL/x.H
@ -112,7 +112,7 @@ extern FL_EXPORT ulong fl_event_time;
|
||||
typedef ulong Fl_Offscreen;
|
||||
# define fl_create_offscreen(w,h) \
|
||||
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()) ) , \
|
||||
w, h, fl_visual->depth)
|
||||
// begin/end are macros that save the old state in local variables:
|
||||
|
@ -304,7 +304,7 @@ void Fl_GDI_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP,
|
||||
HDC tempdc;
|
||||
int save;
|
||||
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;
|
||||
if (!hMod) {
|
||||
hMod = LoadLibrary("MSIMG32.DLL");
|
||||
|
@ -29,18 +29,18 @@
|
||||
#include <FL/Fl_Device.H>
|
||||
#include <FL/Fl_Image.H>
|
||||
|
||||
const char *Fl_Device::device_type = "Fl_Device";
|
||||
const char *Fl_Surface_Device::device_type = "Fl_Surface_Device";
|
||||
const char *Fl_Display_Device::device_type = "Fl_Display_Device";
|
||||
const char *Fl_Graphics_Driver::device_type = "Fl_Graphics_Driver";
|
||||
const char *Fl_Device::class_id = "Fl_Device";
|
||||
const char *Fl_Surface_Device::class_id = "Fl_Surface_Device";
|
||||
const char *Fl_Display_Device::class_id = "Fl_Display_Device";
|
||||
const char *Fl_Graphics_Driver::class_id = "Fl_Graphics_Driver";
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
|
||||
|
||||
|
@ -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;
|
||||
// first try to 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
|
||||
if ( (to_display && fl_can_do_alpha_blending()) || Fl_Surface_Device::surface()->type() == Fl_Printer::device_type) {
|
||||
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()->class_name() == Fl_Printer::class_id) {
|
||||
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
|
||||
|
@ -36,7 +36,7 @@ extern HWND fl_window;
|
||||
|
||||
Fl_System_Printer::Fl_System_Printer(void) : Fl_Paged_Device() {
|
||||
hPr = NULL;
|
||||
type_ = device_type;
|
||||
class_name(class_id);
|
||||
driver(fl_graphics_driver);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <FL/Fl.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";
|
||||
|
||||
|
||||
/**
|
||||
|
@ -145,7 +145,7 @@ void Fl_GDI_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP
|
||||
}
|
||||
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);
|
||||
static HMODULE hMod = NULL;
|
||||
static fl_transp_func fl_TransparentBlt = NULL;
|
||||
|
@ -32,8 +32,8 @@
|
||||
#include <FL/Fl_PostScript.H>
|
||||
#include <FL/Fl_Native_File_Chooser.H>
|
||||
|
||||
const char *Fl_PostScript_Graphics_Driver::device_type = "Fl_PostScript_Graphics_Driver";
|
||||
const char *Fl_PostScript_File_Device::device_type = "Fl_PostScript_File_Device";
|
||||
const char *Fl_PostScript_Graphics_Driver::class_id = "Fl_PostScript_Graphics_Driver";
|
||||
const char *Fl_PostScript_File_Device::class_id = "Fl_PostScript_File_Device";
|
||||
/** \brief Label of the PostScript file chooser window */
|
||||
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;
|
||||
mask = 0;
|
||||
ps_filename_ = NULL;
|
||||
type_ = device_type;
|
||||
class_name(class_id);
|
||||
scale_x = scale_y = 1.;
|
||||
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)
|
||||
{
|
||||
type_ = device_type;
|
||||
class_name(class_id);
|
||||
#ifdef __APPLE__
|
||||
gc = fl_gc; // the display context is used by fl_text_extents()
|
||||
#endif
|
||||
|
@ -76,11 +76,11 @@ const char *Fl_Printer::property_save = "Save";
|
||||
/** [this text may be customized at run-time] */
|
||||
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)
|
||||
const char *Fl_System_Printer::device_type = "Fl_Printer";
|
||||
const char *Fl_System_Printer::class_id = "Fl_Printer";
|
||||
#elif !defined(FL_DOXYGEN)
|
||||
const char *Fl_PostScript_Printer::device_type = "Fl_Printer";
|
||||
const char *Fl_PostScript_Printer::class_id = "Fl_Printer";
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(WIN32)
|
||||
|
@ -40,7 +40,7 @@ Fl_System_Printer::Fl_System_Printer(void)
|
||||
x_offset = 0;
|
||||
y_offset = 0;
|
||||
scale_x = scale_y = 1.;
|
||||
type_ = device_type;
|
||||
class_name(class_id);
|
||||
gc = 0;
|
||||
driver(fl_graphics_driver);
|
||||
}
|
||||
|
@ -3256,7 +3256,7 @@ WindowRef Fl_X::window_ref()
|
||||
|
||||
// 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) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
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
|
||||
POINT pt[4] = { {x, y}, {x + w, y}, {x + w, y + h}, {x, y + h} };
|
||||
LPtoDP(fl_gc, pt, 4);
|
||||
|
@ -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
|
||||
// does not do the expected job, whereas StretchDIBits does it.
|
||||
StretchDIBits(fl_gc, x, y+j-k, w, k, 0, 0, w, k,
|
||||
|
@ -341,7 +341,7 @@ int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg) {
|
||||
#endif
|
||||
|
||||
#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);
|
||||
transparent = true;
|
||||
U32 *array = new U32[d.w * d.h], *q = array;
|
||||
|
@ -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
|
||||
#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 wc_len = 0; // current string buffer dimension
|
||||
|
@ -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_cap_ = Cap[(style>>8)&3];
|
||||
// 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_join_ = Join[(style>>12)&3];
|
||||
|
@ -49,7 +49,7 @@ extern int fl_line_width_;
|
||||
|
||||
#ifdef __APPLE_QUARTZ__
|
||||
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
|
||||
|
||||
#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);
|
||||
#elif defined(WIN32)
|
||||
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} };
|
||||
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;
|
||||
@ -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
|
||||
RECT 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} };
|
||||
DPtoLP(fl_gc, pt, 2);
|
||||
X = pt[0].x; Y = pt[0].y; W = pt[1].x - X; H = pt[1].y - Y;
|
||||
|
Loading…
Reference in New Issue
Block a user