From 4beb3b88e88c3ea070d0437d28b732a6f9d41174 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Wed, 5 Jan 2011 10:21:45 +0000 Subject: 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 --- FL/Fl_Device.H | 40 +++++++++++++++++++++------------------- FL/Fl_Paged_Device.H | 4 ++-- FL/Fl_PostScript.H | 4 ++-- FL/Fl_Printer.H | 6 +++--- FL/x.H | 2 +- 5 files changed, 29 insertions(+), 27 deletions(-) (limited to 'FL') diff --git a/FL/Fl_Device.H b/FL/Fl_Device.H index bb369d917..e128108dc 100644 --- a/FL/Fl_Device.H +++ b/FL/Fl_Device.H @@ -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. */ diff --git a/FL/Fl_Paged_Device.H b/FL/Fl_Paged_Device.H index 1efb2aed1..99ac9e332 100644 --- a/FL/Fl_Paged_Device.H +++ b/FL/Fl_Paged_Device.H @@ -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); diff --git a/FL/Fl_PostScript.H b/FL/Fl_PostScript.H index 96ac6fb08..f6c4fdd55 100644 --- a/FL/Fl_PostScript.H +++ b/FL/Fl_PostScript.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, diff --git a/FL/Fl_Printer.H b/FL/Fl_Printer.H index 50628e5db..ebb02095b 100644 --- a/FL/Fl_Printer.H +++ b/FL/Fl_Printer.H @@ -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); diff --git a/FL/x.H b/FL/x.H index 92ffc24c6..fc0222e14 100644 --- a/FL/x.H +++ b/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: -- cgit v1.2.3