Fl_Device: removed class_name(char *) member function and set class_name(void) virtual.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8467 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy
2011-02-23 14:36:18 +00:00
parent 5a6da14af3
commit d8822aa74a
8 changed files with 21 additions and 27 deletions
+12 -19
View File
@@ -82,26 +82,19 @@ typedef short COORD_T;
\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: public:
const char *type_; // pointer to class name /** A string that identifies each subclass of Fl_Device.
protected: Function class_name() applied to a device of this class returns this string.
/** \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 class_name() applied to a device of this class returns this string.
*/ */
static const char *class_id; static const char *class_id;
public:
/** /**
\brief Returns the name of the class of this object. Returns the name of the class of this object.
*
The class 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->class_name() == Fl_Printer::class_id ) { ... } if ( instance->class_name() == Fl_Printer::class_id ) { ... }
\endcode \endcode
*/ */
inline const char *class_name() {return type_;}; virtual const char *class_name() {return class_id;};
}; };
/** /**
@@ -369,6 +362,7 @@ protected:
public: public:
static const char *class_id; static const char *class_id;
virtual const char *class_name() {return class_id;};
/** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */ /** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */
virtual void font(Fl_Font face, Fl_Fontsize size) {font_ = face; size_ = size;} virtual void font(Fl_Font face, Fl_Fontsize size) {font_ = face; size_ = size;}
/** \brief see fl_font(void). */ /** \brief see fl_font(void). */
@@ -403,9 +397,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. */
Fl_Quartz_Graphics_Driver() { class_name( class_id); };
static const char *class_id; static const char *class_id;
const char *class_name() {return 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);
@@ -437,9 +430,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. */
Fl_GDI_Graphics_Driver() { class_name ( class_id); };
static const char *class_id; static const char *class_id;
const char *class_name() {return 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);
@@ -468,9 +460,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. */
Fl_Xlib_Graphics_Driver() { class_name ( class_id); };
static const char *class_id; static const char *class_id;
const char *class_name() {return 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);
@@ -504,6 +495,7 @@ protected:
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 *class_id; static const char *class_id;
const char *class_name() {return 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;};
@@ -522,8 +514,9 @@ class FL_EXPORT Fl_Display_Device : public Fl_Surface_Device {
static Fl_Display_Device *_display; // the platform display device static Fl_Display_Device *_display; // the platform display device
public: public:
static const char *class_id; static const char *class_id;
const char *class_name() {return 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) { class_name( class_id); }; Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device( graphics_driver) { };
/** Returns the platform display device. */ /** Returns the platform display device. */
static inline Fl_Display_Device *display_device() {return _display;}; static inline Fl_Display_Device *display_device() {return _display;};
}; };
+2 -1
View File
@@ -115,11 +115,12 @@ protected:
/** \brief vertical offset to the origin of graphics coordinates */ /** \brief vertical offset to the origin of graphics coordinates */
int y_offset; int y_offset;
/** \brief The constructor */ /** \brief The constructor */
Fl_Paged_Device() : Fl_Surface_Device(NULL) {class_name( class_id);}; Fl_Paged_Device() : Fl_Surface_Device(NULL) {};
/** \brief The destructor */ /** \brief The destructor */
virtual ~Fl_Paged_Device() {}; virtual ~Fl_Paged_Device() {};
public: public:
static const char *class_id; static const char *class_id;
const char *class_name() {return 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);
+2
View File
@@ -64,6 +64,7 @@
class Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver { class Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
public: public:
static const char *class_id; static const char *class_id;
const char *class_name() {return class_id;};
Fl_PostScript_Graphics_Driver(); Fl_PostScript_Graphics_Driver();
#ifndef FL_DOXYGEN #ifndef FL_DOXYGEN
enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS}; enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
@@ -224,6 +225,7 @@ protected:
Fl_PostScript_Graphics_Driver *driver(); Fl_PostScript_Graphics_Driver *driver();
public: public:
static const char *class_id; static const char *class_id;
const char *class_name() {return 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,
+5 -2
View File
@@ -79,6 +79,7 @@ protected:
Fl_System_Printer(void); Fl_System_Printer(void);
public: public:
static const char *class_id; static const char *class_id;
const char *class_name() {return class_id;};
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);
int printable_rect(int *w, int *h); int printable_rect(int *w, int *h);
@@ -108,10 +109,11 @@ public:
class Fl_PostScript_Printer : public Fl_PostScript_File_Device { class Fl_PostScript_Printer : public Fl_PostScript_File_Device {
friend class Fl_Printer; friend class Fl_Printer;
protected: protected:
/** \brief The constructor */ /** The constructor */
Fl_PostScript_Printer(void) {class_name(class_id);}; Fl_PostScript_Printer(void) {};
public: public:
static const char *class_id; static const char *class_id;
const char *class_name() {return class_id;};
int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL); int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL);
}; };
@@ -152,6 +154,7 @@ public:
class Fl_Printer : public Fl_Paged_Device { class Fl_Printer : public Fl_Paged_Device {
public: public:
static const char *class_id; static const char *class_id;
const char *class_name() {return 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);
-1
View File
@@ -36,7 +36,6 @@ 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;
class_name(class_id);
driver(Fl_Display_Device::display_device()->driver()); driver(Fl_Display_Device::display_device()->driver());
} }
-2
View File
@@ -54,7 +54,6 @@ 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;
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;
} }
@@ -69,7 +68,6 @@ 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)
{ {
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
-1
View File
@@ -108,7 +108,6 @@ Fl_Printer::Fl_Printer(void) {
#else #else
printer = new Fl_PostScript_Printer(); printer = new Fl_PostScript_Printer();
#endif #endif
class_name(class_id);
} }
int Fl_Printer::start_job(int pagecount, int *frompage, int *topage) int Fl_Printer::start_job(int pagecount, int *frompage, int *topage)
-1
View File
@@ -40,7 +40,6 @@ 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.;
class_name(class_id);
gc = 0; gc = 0;
driver(Fl_Display_Device::display_device()->driver()); driver(Fl_Display_Device::display_device()->driver());
} }