Images in menu items...

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2109 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2002-04-26 11:32:37 +00:00
parent b3f01efb17
commit ee5fdc99ce
6 changed files with 71 additions and 11 deletions

View File

@ -1,5 +1,7 @@
CHANGES IN FLTK 1.1.0rc1 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 - Updated the PNG library check to support both png.h
and libpng/png.h. and libpng/png.h.
- Fixed a recursion bug in tooltips that was causing - Fixed a recursion bug in tooltips that was causing

View File

@ -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). // Enumerations for the Fast Light Tool Kit (FLTK).
// //
@ -213,6 +213,7 @@ enum Fl_Labeltype { // labeltypes:
_FL_EMBOSSED_LABEL, _FL_EMBOSSED_LABEL,
_FL_MULTI_LABEL, _FL_MULTI_LABEL,
_FL_ICON_LABEL, _FL_ICON_LABEL,
_FL_IMAGE_LABEL,
FL_FREE_LABELTYPE FL_FREE_LABELTYPE
}; };
@ -388,5 +389,5 @@ enum Fl_Damage {
#endif #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 $".
// //

View File

@ -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). // 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 data(const char * const *p, int c) {data_ = p; count_ = c;}
void draw_empty(int X, int Y); 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: public:
int w() const {return w_;} int w() const {return w_;}
@ -95,5 +98,5 @@ class FL_EXPORT Fl_RGB_Image : public Fl_Image {
#endif #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 $".
// //

View File

@ -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). // 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) { 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) { 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 $".
// //

View File

@ -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). // Image drawing code for the Fast Light Tool Kit (FLTK).
// //
@ -32,7 +32,11 @@
#include "flstring.h" #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() { Fl_Image::~Fl_Image() {
} }
@ -65,8 +69,52 @@ void Fl_Image::label(Fl_Widget* w) {
} }
void Fl_Image::label(Fl_Menu_Item* m) { 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() { Fl_RGB_Image::~Fl_RGB_Image() {
if (id) fl_delete_offscreen((Fl_Offscreen)id); if (id) fl_delete_offscreen((Fl_Offscreen)id);
if (mask) fl_delete_bitmask(mask); 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) { 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 $".
// //

View File

@ -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). // 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) { 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() { 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 $".
// //