Make virtual member function Fl_Image::draw_scaled(int X, int Y, int W, int H) protected rather than private.

Consequently, remove the trailing _ from its name reserved for private class members.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12433 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2017-09-09 12:35:06 +00:00
parent ae983b74f2
commit 8e558595e6
9 changed files with 22 additions and 17 deletions

View File

@ -34,7 +34,6 @@ struct Fl_Menu_Item;
class FL_EXPORT Fl_Bitmap : public Fl_Image {
friend class Fl_Graphics_Driver;
public:
/** pointer to raw bitmap data */
const uchar *array;
/** Non-zero if array points to bitmap data allocated internally */
@ -46,10 +45,11 @@ private:
/** for internal use */
fl_uintptr_t id_;
float cache_scale_; // graphics scaling value when id_ was computed
virtual int draw_scaled_(int X, int Y, int W, int H);
protected:
virtual int draw_scaled(int X, int Y, int W, int H);
public:
/** The constructors create a new bitmap from the specified bitmap data */
Fl_Bitmap(const uchar *bits, int W, int H) :
Fl_Image(W,H,0), array(bits), alloc_array(0), id_(0), cache_scale_(1) {data((const char **)&array, 1);}

View File

@ -69,7 +69,6 @@ private:
// Forbid use of copy constructor and assign operator
Fl_Image & operator=(const Fl_Image &);
Fl_Image(const Fl_Image &);
virtual int draw_scaled_(int X, int Y, int W, int H);
protected:
@ -105,6 +104,7 @@ protected:
static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la);
static void measure(const Fl_Label *lo, int &lw, int &lh);
virtual int draw_scaled(int X, int Y, int W, int H);
public:
@ -225,7 +225,9 @@ private:
fl_uintptr_t id_;
fl_uintptr_t mask_;
float cache_scale_; // graphics scaling value when id_ was computed
virtual int draw_scaled_(int X, int Y, int W, int H);
protected:
virtual int draw_scaled(int X, int Y, int W, int H);
public:

View File

@ -42,11 +42,10 @@ class FL_EXPORT Fl_Pixmap : public Fl_Image {
void set_data(const char * const *p);
int prepare(int XP, int YP, int WP, int HP, int &cx, int &cy,
int &X, int &Y, int &W, int &H);
virtual int draw_scaled_(int X, int Y, int W, int H);
protected:
void measure();
virtual int draw_scaled(int X, int Y, int W, int H);
public:

View File

@ -59,8 +59,9 @@ private:
float svg_scaling_(int W, int H);
void rasterize_(int W, int H);
void init_(const char *filename, char *filedata, Fl_SVG_Image *copy_source);
virtual int draw_scaled_(int X, int Y, int W, int H);
Fl_SVG_Image(Fl_SVG_Image *source);
protected:
virtual int draw_scaled(int X, int Y, int W, int H);
public:
/** Set this to \c false to allow image re-scaling that alters the image aspect ratio.
Upon object creation, \c proportional is set to \c true, and the aspect ratio is kept constant.*/

View File

@ -232,7 +232,7 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
}
int Fl_Bitmap::draw_scaled_(int X, int Y, int W, int H) {
int Fl_Bitmap::draw_scaled(int X, int Y, int W, int H) {
return (W <= w() && H <= h()) ? fl_graphics_driver->draw_scaled(this, X, Y, W, H) : 0;
}

View File

@ -196,7 +196,7 @@ void Fl_Graphics_Driver::draw(Fl_Shared_Image *shared, int X, int Y) {
shared->image_->draw(X, Y, shared->w(), shared->h(), 0, 0);
return;
}
if ( shared->image_->draw_scaled_(X, Y, shared->w(), shared->h()) ) return;
if ( shared->image_->draw_scaled(X, Y, shared->w(), shared->h()) ) return;
if (shared->scaled_image_ && (shared->scaled_image_->w() != shared->w() || shared->scaled_image_->h() != shared->h())) {
delete shared->scaled_image_;
shared->scaled_image_ = NULL;

View File

@ -578,14 +578,17 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) {
m->label(_FL_IMAGE_LABEL, (const char*)this);
}
int Fl_RGB_Image::draw_scaled_(int X, int Y, int W, int H) {
int Fl_RGB_Image::draw_scaled(int X, int Y, int W, int H) {
return fl_graphics_driver->draw_scaled(this, X, Y, W, H);
}
// Draws the image scaled to W and H, and returns 1,
// or returns 0 if scaled drawing is not implemented for this image.
// Image classes can re-implement this function for specific image types.
int Fl_Image::draw_scaled_(int X, int Y, int W, int H) {
/** Attempts to draw the image to the current drawing surface rescaled to a given width and height.
This virtual member function is mostly intended for use by the FLTK library.
\param X,Y position of the image's top-left
\param W,H width and height for the drawn image
\return 0 if scaled drawing is not implemented for this image, non-zero if it is implemented.
*/
int Fl_Image::draw_scaled(int X, int Y, int W, int H) {
return 0;
}

View File

@ -394,7 +394,7 @@ void Fl_Pixmap::desaturate() {
}
}
int Fl_Pixmap::draw_scaled_(int X, int Y, int W, int H) {
int Fl_Pixmap::draw_scaled(int X, int Y, int W, int H) {
return (W <= w() && H <= h()) ? fl_graphics_driver->draw_scaled(this, X, Y, W, H) : 0;
}

View File

@ -205,7 +205,7 @@ void Fl_SVG_Image::color_average(Fl_Color c, float i) {
}
int Fl_SVG_Image::draw_scaled_(int X, int Y, int W, int H) {
int Fl_SVG_Image::draw_scaled(int X, int Y, int W, int H) {
w(W);
h(H);
draw(X, Y, W, H, 0, 0);