diff --git a/CHANGES b/CHANGES index a6d94d23d..69f77a6b9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ CHANGES IN FLTK 1.1.0rc1 + - Implemented Fl_Menu_Item image labels using older + 1.0.x labeltype method. - Updated the PNG library check to support both png.h and libpng/png.h. - Fixed a recursion bug in tooltips that was causing diff --git a/FL/Enumerations.H b/FL/Enumerations.H index fe76d36d9..cbf81f1f9 100644 --- a/FL/Enumerations.H +++ b/FL/Enumerations.H @@ -1,5 +1,5 @@ // -// "$Id: Enumerations.H,v 1.18.2.14.2.22 2002/04/11 10:46:19 easysw Exp $" +// "$Id: Enumerations.H,v 1.18.2.14.2.23 2002/04/26 11:32:37 easysw Exp $" // // Enumerations for the Fast Light Tool Kit (FLTK). // @@ -213,6 +213,7 @@ enum Fl_Labeltype { // labeltypes: _FL_EMBOSSED_LABEL, _FL_MULTI_LABEL, _FL_ICON_LABEL, + _FL_IMAGE_LABEL, FL_FREE_LABELTYPE }; @@ -388,5 +389,5 @@ enum Fl_Damage { #endif // -// End of "$Id: Enumerations.H,v 1.18.2.14.2.22 2002/04/11 10:46:19 easysw Exp $". +// End of "$Id: Enumerations.H,v 1.18.2.14.2.23 2002/04/26 11:32:37 easysw Exp $". // diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H index 95a465278..2ab513f8c 100644 --- a/FL/Fl_Image.H +++ b/FL/Fl_Image.H @@ -1,5 +1,5 @@ // -// "$Id: Fl_Image.H,v 1.5.2.3.2.11 2002/01/07 20:40:02 easysw Exp $" +// "$Id: Fl_Image.H,v 1.5.2.3.2.12 2002/04/26 11:32:37 easysw Exp $" // // Image header file for the Fast Light Tool Kit (FLTK). // @@ -48,6 +48,9 @@ class FL_EXPORT Fl_Image { void data(const char * const *p, int c) {data_ = p; count_ = c;} void draw_empty(int X, int Y); + 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); + public: int w() const {return w_;} @@ -95,5 +98,5 @@ class FL_EXPORT Fl_RGB_Image : public Fl_Image { #endif // -// End of "$Id: Fl_Image.H,v 1.5.2.3.2.11 2002/01/07 20:40:02 easysw Exp $". +// End of "$Id: Fl_Image.H,v 1.5.2.3.2.12 2002/04/26 11:32:37 easysw Exp $". // diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx index 03ba1828b..f7a254dd7 100644 --- a/src/Fl_Bitmap.cxx +++ b/src/Fl_Bitmap.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.14 2002/04/15 20:52:26 easysw Exp $" +// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.15 2002/04/26 11:32:37 easysw Exp $" // // Bitmap drawing routines for the Fast Light Tool Kit (FLTK). // @@ -393,6 +393,8 @@ void Fl_Bitmap::label(Fl_Widget* w) { } void Fl_Bitmap::label(Fl_Menu_Item* m) { + Fl::set_labeltype(_FL_IMAGE_LABEL, labeltype, measure); + m->label(_FL_IMAGE_LABEL, (const char*)this); } Fl_Image *Fl_Bitmap::copy(int W, int H) { @@ -464,5 +466,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) { // -// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.14 2002/04/15 20:52:26 easysw Exp $". +// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.15 2002/04/26 11:32:37 easysw Exp $". // diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index b46a1321b..ae2c62f16 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Image.cxx,v 1.5.2.3.2.19 2002/04/15 17:18:48 easysw Exp $" +// "$Id: Fl_Image.cxx,v 1.5.2.3.2.20 2002/04/26 11:32:37 easysw Exp $" // // Image drawing code for the Fast Light Tool Kit (FLTK). // @@ -32,7 +32,11 @@ #include "flstring.h" -void fl_restore_clip(); // in fl_rect.cxx +void fl_restore_clip(); // from fl_rect.cxx + +// +// Base image class... +// Fl_Image::~Fl_Image() { } @@ -65,8 +69,52 @@ void Fl_Image::label(Fl_Widget* w) { } void Fl_Image::label(Fl_Menu_Item* m) { + Fl::set_labeltype(_FL_IMAGE_LABEL, labeltype, measure); + m->label(_FL_IMAGE_LABEL, (const char*)this); } +void +Fl_Image::labeltype(const Fl_Label *lo, // I - Label + int lx, // I - X position + int ly, // I - Y position + int lw, // I - Width of label + int lh, // I - Height of label + Fl_Align la) { // I - Alignment + Fl_Image *img; // Image pointer + int cx, cy; // Image position + + img = (Fl_Image *)(lo->value); + + if (la & FL_ALIGN_LEFT) cx = 0; + else if (la & FL_ALIGN_RIGHT) cx = img->w() - lw; + else cx = (img->w() - lw) / 2; + + if (la & FL_ALIGN_TOP) cy = 0; + else if (la & FL_ALIGN_BOTTOM) cy = img->h() - lh; + else cy = (img->h() - lh) / 2; + + fl_color((Fl_Color)lo->color); + + img->draw(lx, ly, lw, lh, cx, cy); +} + +void +Fl_Image::measure(const Fl_Label *lo, // I - Label + int &lw, // O - Width of image + int &lh) { // O - Height of image + Fl_Image *img; // Image pointer + + img = (Fl_Image *)(lo->value); + + lw = img->w(); + lh = img->h(); +} + + +// +// RGB image class... +// + Fl_RGB_Image::~Fl_RGB_Image() { if (id) fl_delete_offscreen((Fl_Offscreen)id); if (mask) fl_delete_bitmask(mask); @@ -339,9 +387,11 @@ void Fl_RGB_Image::label(Fl_Widget* w) { } void Fl_RGB_Image::label(Fl_Menu_Item* m) { + Fl::set_labeltype(_FL_IMAGE_LABEL, labeltype, measure); + m->label(_FL_IMAGE_LABEL, (const char*)this); } // -// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.19 2002/04/15 17:18:48 easysw Exp $". +// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.20 2002/04/26 11:32:37 easysw Exp $". // diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx index 728cc9ffa..4444d5ae3 100644 --- a/src/Fl_Pixmap.cxx +++ b/src/Fl_Pixmap.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.16 2002/04/14 21:26:06 easysw Exp $" +// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.17 2002/04/26 11:32:37 easysw Exp $" // // Pixmap drawing code for the Fast Light Tool Kit (FLTK). // @@ -156,6 +156,8 @@ void Fl_Pixmap::label(Fl_Widget* w) { } void Fl_Pixmap::label(Fl_Menu_Item* m) { + Fl::set_labeltype(_FL_IMAGE_LABEL, labeltype, Fl_Image::measure); + m->label(_FL_IMAGE_LABEL, (const char*)this); } void Fl_Pixmap::copy_data() { @@ -463,5 +465,5 @@ void Fl_Pixmap::desaturate() { } // -// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.16 2002/04/14 21:26:06 easysw Exp $". +// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.17 2002/04/26 11:32:37 easysw Exp $". //