Now look for 8 bits of alpha when the developer has requested

FL_RGB8 (STR #541)

The last line in an Fl_Help_View widget was not aligned properly
(STR #536)

The "search" symbol looked like a Q (STR #536)

Changed Fl_Help_View::get_color() to use a lookup table to avoid
serious Borland C++ 5.5 compiler bugs (STR #533)

Fixed Watcom compiler warnings with FL/Fl_Widget.H (STR #540)

The image class copy() methods did not always make a separate
copy of the image data (STR #539)


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3844 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2004-09-24 16:00:11 +00:00
parent 44a7ad2c48
commit 18ad096722
11 changed files with 125 additions and 103 deletions

14
CHANGES
View File

@ -3,6 +3,20 @@ CHANGES IN FLTK 1.1.5rc3
- Documentation updates (STR #505, STR #513)
- Updated PNG library source to 1.2.7.
- Updated ZLIB library source to 1.2.1.
- Fixed VC++ project file problems (STR #476, STR #478,
STR #520, STR #527, STR #537)
- Now look for 8 bits of alpha when the developer has
requested FL_RGB8 (STR #541)
- The last line in an Fl_Help_View widget was not
aligned properly (STR #536)
- The "search" symbol looked like a Q (STR #536)
- Changed Fl_Help_View::get_color() to use a lookup
table to avoid serious Borland C++ 5.5 compiler bugs
(STR #533)
- Fixed Watcom compiler warnings with FL/Fl_Widget.H
(STR #540)
- The image class copy() methods did not always make a
separate copy of the image data (STR #539)
- Fixed an edge case in fl_old_shortcut() that could
cause it to read beyond then end of the shortcut
string (used for XForms named shortcuts)

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget.H,v 1.6.2.4.2.24 2004/07/27 16:02:18 easysw Exp $"
// "$Id: Fl_Widget.H,v 1.6.2.4.2.25 2004/09/24 16:00:08 easysw Exp $"
//
// Widget header file for the Fast Light Tool Kit (FLTK).
//
@ -81,10 +81,10 @@ protected:
Fl_Widget(int,int,int,int,const char* =0);
void x(int v) {x_ = v;}
void y(int v) {y_ = v;}
void w(int v) {w_ = v;}
void h(int v) {h_ = v;}
void x(int v) {x_ = (short)v;}
void y(int v) {y_ = (short)v;}
void w(int v) {w_ = (short)v;}
void h(int v) {h_ = (short)v;}
int flags() const {return flags_;}
void set_flag(int c) {flags_ |= c;}
@ -217,5 +217,5 @@ public:
#endif
//
// End of "$Id: Fl_Widget.H,v 1.6.2.4.2.24 2004/07/27 16:02:18 easysw Exp $".
// End of "$Id: Fl_Widget.H,v 1.6.2.4.2.25 2004/09/24 16:00:08 easysw Exp $".
//

View File

@ -858,8 +858,7 @@ image, and this area is left unchanged.
<H4>void draw(int x, int y)</H4>
<P>Draws the image with the upper-left corner at <TT>x,y</TT>.
This is the same as doing
<TT>draw(x,y,img->w(),img->h(),0,0)</TT>.
This is the same as doing <TT>draw(x,y,img->w(),img->h(),0,0)</TT>.
</BODY>
</HTML>

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.26 2004/08/31 22:00:47 matthiaswm Exp $"
// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.27 2004/09/24 16:00:10 easysw Exp $"
//
// Bitmap drawing routines for the Fast Light Tool Kit (FLTK).
//
@ -432,14 +432,23 @@ void Fl_Bitmap::label(Fl_Menu_Item* m) {
}
Fl_Image *Fl_Bitmap::copy(int W, int H) {
Fl_Bitmap *new_image; // New RGB image
uchar *new_array; // New array for image data
// Optimize the simple copy where the width and height are the same...
if (W == w() && H == h()) return new Fl_Bitmap(array, w(), h());
if (W == w() && H == h()) {
new_array = new uchar [H * ((W + 7) / 8)];
memcpy(new_array, array, H * ((W + 7) / 8));
new_image = new Fl_Bitmap(new_array, W, H);
new_image->alloc_array = 1;
return new_image;
}
if (W <= 0 || H <= 0) return 0;
// OK, need to resize the image data; allocate memory and
Fl_Bitmap *new_image; // New RGB image
uchar *new_array, // New array for image data
*new_ptr, // Pointer into new array
uchar *new_ptr, // Pointer into new array
new_bit, // Bit for new array
old_bit; // Bit for old array
const uchar *old_ptr; // Pointer into old array
@ -457,11 +466,11 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
ystep = h() / H;
// Allocate memory for the new image...
new_array = new uchar [H * (W + 7) / 8];
new_array = new uchar [H * ((W + 7) / 8)];
new_image = new Fl_Bitmap(new_array, W, H);
new_image->alloc_array = 1;
memset(new_array, 0, H * (W + 7) / 8);
memset(new_array, 0, H * ((W + 7) / 8));
// Scale the image using a nearest-neighbor algorithm...
for (dy = H, sy = 0, yerr = H, new_ptr = new_array; dy > 0; dy --) {
@ -501,5 +510,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
//
// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.26 2004/08/31 22:00:47 matthiaswm Exp $".
// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.27 2004/09/24 16:00:10 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.21 2004/09/09 21:34:46 matthiaswm Exp $"
// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.22 2004/09/24 16:00:10 easysw Exp $"
//
// OpenGL visual selection code for the Fast Light Tool Kit (FLTK).
//
@ -66,7 +66,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
list[n++] = (m & FL_RGB8) ? 8 : 1;
if (m & FL_ALPHA) {
list[n++] = AGL_ALPHA_SIZE;
list[n++] = 1;
list[n++] = (m & FL_RGB8) ? 8 : 1;
}
if (m & FL_ACCUM) {
list[n++] = AGL_ACCUM_GREEN_SIZE;
@ -116,7 +116,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
list[n++] = (m & FL_RGB8) ? 8 : 1;
if (m & FL_ALPHA) {
list[n++] = AGL_ALPHA_SIZE;
list[n++] = 1;
list[n++] = (m & FL_RGB8) ? 8 : 1;
}
if (m & FL_ACCUM) {
list[n++] = AGL_ACCUM_GREEN_SIZE;
@ -166,7 +166,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
list[n++] = (m & FL_RGB8) ? 8 : 1;
if (m & FL_ALPHA) {
list[n++] = GLX_ALPHA_SIZE;
list[n++] = 1;
list[n++] = (m & FL_RGB8) ? 8 : 1;
}
if (m & FL_ACCUM) {
list[n++] = GLX_ACCUM_GREEN_SIZE;
@ -439,5 +439,5 @@ void fl_delete_gl_context(GLContext context) {
//
// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.21 2004/09/09 21:34:46 matthiaswm Exp $".
// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.22 2004/09/24 16:00:10 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Help_View.cxx,v 1.1.2.53 2004/07/27 16:02:20 easysw Exp $"
// "$Id: Fl_Help_View.cxx,v 1.1.2.54 2004/09/24 16:00:10 easysw Exp $"
//
// Fl_Help_View widget routines.
//
@ -1508,7 +1508,7 @@ Fl_Help_View::format()
}
}
if (s > buf && !pre && !head)
if (s > buf && !head)
{
*s = '\0';
ww = (int)fl_width(buf);
@ -1538,16 +1538,15 @@ Fl_Help_View::format()
add_link(linkdest, xx, yy - fsize, ww, fsize);
xx += ww;
if ((fsize + 2) > hh)
hh = fsize + 2;
needspace = 0;
}
do_align(block, line, xx, newalign, links);
block->end = ptr;
size_ = yy + hh;
}
if (ntargets_ > 1)
qsort(targets_, ntargets_, sizeof(Fl_Help_Target),
(compare_func_t)compare_targets);
@ -2125,66 +2124,57 @@ Fl_Color // O - Color value
Fl_Help_View::get_color(const char *n, // I - Color name
Fl_Color c) // I - Default color value
{
int i; // Looping var
int rgb, r, g, b; // RGB values
static const struct { // Color name table
const char *name;
int r, g, b;
} colors[] = {
{ "black", 0x00, 0x00, 0x00 },
{ "red", 0xff, 0x00, 0x00 },
{ "green", 0x00, 0x80, 0x00 },
{ "yellow", 0xff, 0xff, 0x00 },
{ "blue", 0x00, 0x00, 0xff },
{ "magenta", 0xff, 0x00, 0xff },
{ "fuchsia", 0xff, 0x00, 0xff },
{ "cyan", 0x00, 0xff, 0xff },
{ "aqua", 0x00, 0xff, 0xff },
{ "white", 0xff, 0xff, 0xff },
{ "gray", 0x80, 0x80, 0x80 },
{ "grey", 0x80, 0x80, 0x80 },
{ "lime", 0x00, 0xff, 0x00 },
{ "maroon", 0x80, 0x00, 0x00 },
{ "navy", 0x00, 0x00, 0x80 },
{ "olive", 0x80, 0x80, 0x00 },
{ "purple", 0x80, 0x00, 0x80 },
{ "silver", 0xc0, 0xc0, 0xc0 },
{ "teal", 0x00, 0x80, 0x80 }
};
if (!n || !n[0])
return (c);
if (!n || !n[0]) return c;
if (n[0] == '#')
{
if (n[0] == '#') {
// Do hex color lookup
rgb = strtol(n + 1, NULL, 16);
r = rgb >> 16;
g = (rgb >> 8) & 255;
b = rgb & 255;
if (strlen(n) > 4) {
r = rgb >> 16;
g = (rgb >> 8) & 255;
b = rgb & 255;
} else {
r = (rgb >> 8) * 17;
g = ((rgb >> 4) & 15) * 17;
b = (rgb & 15) * 17;
}
return (fl_rgb_color((uchar)r, (uchar)g, (uchar)b));
} else {
for (i = 0; i < (int)(sizeof(colors) / sizeof(colors[0])); i ++)
if (!strcasecmp(n, colors[i].name)) {
return fl_rgb_color(colors[i].r, colors[i].g, colors[i].b);
}
return c;
}
else if (strcasecmp(n, "black") == 0)
return (FL_BLACK);
else if (strcasecmp(n, "red") == 0)
return (FL_RED);
#ifdef __BORLANDC__ // Workaround for compiler bug...
else if (strcasecmp(n, "green") == 0) {
r = 0;
g = 0x80;
b = 0;
return (fl_rgb_color(r, g, b));
}
#else
else if (strcasecmp(n, "green") == 0)
return (fl_rgb_color(0, 0x80, 0));
#endif // __BORLANDC__
else if (strcasecmp(n, "yellow") == 0)
return (FL_YELLOW);
else if (strcasecmp(n, "blue") == 0)
return (FL_BLUE);
else if (strcasecmp(n, "magenta") == 0 || strcasecmp(n, "fuchsia") == 0)
return (FL_MAGENTA);
else if (strcasecmp(n, "cyan") == 0 || strcasecmp(n, "aqua") == 0)
return (FL_CYAN);
else if (strcasecmp(n, "white") == 0)
return (FL_WHITE);
else if (strcasecmp(n, "gray") == 0 || strcasecmp(n, "grey") == 0)
return (fl_rgb_color(0x80, 0x80, 0x80));
else if (strcasecmp(n, "lime") == 0)
return (FL_GREEN);
else if (strcasecmp(n, "maroon") == 0)
return (fl_rgb_color(0x80, 0, 0));
else if (strcasecmp(n, "navy") == 0)
return (fl_rgb_color(0, 0, 0x80));
else if (strcasecmp(n, "olive") == 0)
return (fl_rgb_color(0x80, 0x80, 0));
else if (strcasecmp(n, "purple") == 0)
return (fl_rgb_color(0x80, 0, 0x80));
else if (strcasecmp(n, "silver") == 0)
return (fl_rgb_color(0xc0, 0xc0, 0xc0));
else if (strcasecmp(n, "teal") == 0)
return (fl_rgb_color(0, 0x80, 0x80));
else
return (c);
}
@ -2811,5 +2801,5 @@ hscrollbar_callback(Fl_Widget *s, void *)
//
// End of "$Id: Fl_Help_View.cxx,v 1.1.2.53 2004/07/27 16:02:20 easysw Exp $".
// End of "$Id: Fl_Help_View.cxx,v 1.1.2.54 2004/09/24 16:00:10 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Image.cxx,v 1.5.2.3.2.37 2004/08/31 22:00:47 matthiaswm Exp $"
// "$Id: Fl_Image.cxx,v 1.5.2.3.2.38 2004/09/24 16:00:10 easysw Exp $"
//
// Image drawing code for the Fast Light Tool Kit (FLTK).
//
@ -141,18 +141,28 @@ void Fl_RGB_Image::uncache() {
}
Fl_Image *Fl_RGB_Image::copy(int W, int H) {
Fl_RGB_Image *new_image; // New RGB image
uchar *new_array; // New array for image data
// Optimize the simple copy where the width and height are the same,
// or when we are copying an empty image...
if ((W == w() && H == h()) ||
!w() || !h() || !d() || !array) {
return new Fl_RGB_Image(array, w(), h(), d(), ld());
if (array) {
// Make a copy of the image data and return a new Fl_RGB_Image...
new_array = new uchar[w() * h() * d()];
memcpy(new_array, array, w() * h() * d());
new_image = new Fl_RGB_Image(new_array, w(), h(), d(), ld());
new_image->alloc_array = 1;
return new_image;
} else return new Fl_RGB_Image(array, w(), h(), d(), ld());
}
if (W <= 0 || H <= 0) return 0;
// OK, need to resize the image data; allocate memory and
Fl_RGB_Image *new_image; // New RGB image
uchar *new_array, // New array for image data
*new_ptr; // Pointer into new array
uchar *new_ptr; // Pointer into new array
const uchar *old_ptr; // Pointer into old array
int c, // Channel number
sy, // Source coordinate
@ -418,5 +428,5 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) {
//
// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.37 2004/08/31 22:00:47 matthiaswm Exp $".
// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.38 2004/09/24 16:00:10 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.32 2004/08/31 22:00:47 matthiaswm Exp $"
// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.33 2004/09/24 16:00:10 easysw Exp $"
//
// Pixmap drawing code for the Fast Light Tool Kit (FLTK).
//
@ -233,12 +233,18 @@ void Fl_Pixmap::copy_data() {
}
Fl_Image *Fl_Pixmap::copy(int W, int H) {
Fl_Pixmap *new_image; // New pixmap
// Optimize the simple copy where the width and height are the same...
if (W == w() && H == h()) return new Fl_Pixmap(data());
if (W == w() && H == h()) {
// Make an exact copy of the image and return it...
new_image = new Fl_Pixmap(data());
new_image->copy_data();
return new_image;
}
if (W <= 0 || H <= 0) return 0;
// OK, need to resize the image data; allocate memory and
Fl_Pixmap *new_image; // New pixmap
char **new_data, // New array for image data
**new_row, // Pointer to row in image data
*new_ptr, // Pointer into new array
@ -473,5 +479,5 @@ void Fl_Pixmap::desaturate() {
}
//
// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.32 2004/08/31 22:00:47 matthiaswm Exp $".
// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.33 2004/09/24 16:00:10 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Shared_Image.cxx,v 1.23.2.20 2004/04/11 04:38:58 easysw Exp $"
// "$Id: Fl_Shared_Image.cxx,v 1.23.2.21 2004/09/24 16:00:11 easysw Exp $"
//
// Shared image code for the Fast Light Tool Kit (FLTK).
//
@ -269,12 +269,6 @@ Fl_Shared_Image::copy(int W, int H) {
Fl_Image *temp_image; // New image file
Fl_Shared_Image *temp_shared; // New shared image
// See if the new and old sizes are the same...
if (image_ && image_->w() == W && image_->h() == H) {
refcount_ ++;
return (this);
}
// Make a copy of the image we're sharing...
if (!image_) temp_image = 0;
else temp_image = image_->copy(W, H);
@ -466,5 +460,5 @@ Fl_Shared_Image::remove_handler(Fl_Shared_Handler f) {
//
// End of "$Id: Fl_Shared_Image.cxx,v 1.23.2.20 2004/04/11 04:38:58 easysw Exp $".
// End of "$Id: Fl_Shared_Image.cxx,v 1.23.2.21 2004/09/24 16:00:11 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Tooltip.cxx,v 1.38.2.30 2004/09/12 20:26:23 easysw Exp $"
// "$Id: Fl_Tooltip.cxx,v 1.38.2.31 2004/09/24 16:00:11 easysw Exp $"
//
// Tooltip source file for the Fast Light Tool Kit (FLTK).
//
@ -186,7 +186,7 @@ Fl_Tooltip::exit_(Fl_Widget *w) {
printf(" widget=%p, window=%p\n", widget_, window);
#endif // DEBUG
if (!widget_) return;
if (!widget_ || w == window) return;
widget_ = 0;
Fl::remove_timeout(tooltip_timeout);
Fl::remove_timeout(recent_timeout);
@ -254,5 +254,5 @@ void Fl_Widget::tooltip(const char *tt) {
}
//
// End of "$Id: Fl_Tooltip.cxx,v 1.38.2.30 2004/09/12 20:26:23 easysw Exp $".
// End of "$Id: Fl_Tooltip.cxx,v 1.38.2.31 2004/09/24 16:00:11 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: fl_symbols.cxx,v 1.8.2.3.2.10 2004/07/04 23:21:52 easysw Exp $"
// "$Id: fl_symbols.cxx,v 1.8.2.3.2.11 2004/09/24 16:00:11 easysw Exp $"
//
// Symbol drawing code for the Fast Light Tool Kit (FLTK).
//
@ -213,7 +213,7 @@ static void draw_search(Fl_Color col)
BP; vv(.4, .13); vv(1.0, .73); vv(.73, 1.0); vv(.13, .4); EP;
set_outline_color(col);
fl_line_style(FL_SOLID, 3, 0);
BC; fl_circle(-.2, -.2, .8); EC;
BC; fl_circle(-.2, -.2, .7); EC;
fl_line_style(FL_SOLID, 1, 0);
BC; vv(.4, .13); vv(1.0, .73); vv(.73, 1.0); vv(.13, .4); EC;
}
@ -410,5 +410,5 @@ static void fl_init_symbols(void) {
}
//
// End of "$Id: fl_symbols.cxx,v 1.8.2.3.2.10 2004/07/04 23:21:52 easysw Exp $".
// End of "$Id: fl_symbols.cxx,v 1.8.2.3.2.11 2004/09/24 16:00:11 easysw Exp $".
//