mirror of
https://github.com/fltk/fltk.git
synced 2026-05-20 21:33:04 +08:00
Update GCC test in configure script.
Add range checking to BMP loader, and fix colormap + 4-bit BMP file loading. Copy 2.0 window position fix for XFree86 4.x and others. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2315 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
CHANGES IN FLTK 1.1.0
|
||||
|
||||
- Now translate the window coordinates when a window is
|
||||
shown, moved, or resized. This should fix the "menus
|
||||
showing up at the wrong position" bug under XFree86.
|
||||
- Fixed some more problems with the Fl_BMP_Image file
|
||||
loader.
|
||||
- BC++ fixes.
|
||||
- The pixmap_browser demo didn't check for a NULL image
|
||||
pointer.
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
dnl -*- sh -*-
|
||||
dnl the "configure" script is made from this by running GNU "autoconf"
|
||||
dnl
|
||||
dnl "$Id: configure.in,v 1.33.2.31.2.71 2002/06/08 12:51:38 easysw Exp $"
|
||||
dnl "$Id: configure.in,v 1.33.2.31.2.72 2002/06/24 02:04:54 easysw Exp $"
|
||||
dnl
|
||||
dnl Configuration script for the Fast Light Tool Kit (FLTK).
|
||||
dnl
|
||||
@@ -553,7 +553,7 @@ AC_SUBST(MAKEDEPEND)
|
||||
dnl Add warnings to compiler switches:
|
||||
dnl do this last so messing with switches does not break tests
|
||||
|
||||
if test -n "$GXX"; then
|
||||
if test -n "$GCC"; then
|
||||
# Starting with GCC 3.0, you must link C++ programs against either
|
||||
# libstdc++ (shared by default), or libsupc++ (always static). If
|
||||
# you care about binary portability between Linux distributions,
|
||||
@@ -748,5 +748,5 @@ dnl Make sure the fltk-config script is executable...
|
||||
chmod +x fltk-config
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: configure.in,v 1.33.2.31.2.71 2002/06/08 12:51:38 easysw Exp $".
|
||||
dnl End of "$Id: configure.in,v 1.33.2.31.2.72 2002/06/24 02:04:54 easysw Exp $".
|
||||
dnl
|
||||
|
||||
+64
-46
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_BMP_Image.cxx,v 1.1.2.6 2002/06/13 18:18:33 easysw Exp $"
|
||||
// "$Id: Fl_BMP_Image.cxx,v 1.1.2.7 2002/06/24 02:04:54 easysw Exp $"
|
||||
//
|
||||
// Fl_BMP_Image routines.
|
||||
//
|
||||
@@ -85,8 +85,13 @@ Fl_BMP_Image::Fl_BMP_Image(const char *bmp) // I - File to read
|
||||
if ((fp = fopen(bmp, "rb")) == NULL) return;
|
||||
|
||||
// Get the header...
|
||||
getc(fp); // Skip "BM" sync chars
|
||||
getc(fp);
|
||||
byte = getc(fp); // Check "BM" sync chars
|
||||
bit = getc(fp);
|
||||
if (byte != 'B' || bit != 'M') {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
read_dword(fp); // Skip size
|
||||
read_word(fp); // Skip reserved stuff
|
||||
read_word(fp);
|
||||
@@ -95,6 +100,8 @@ Fl_BMP_Image::Fl_BMP_Image(const char *bmp) // I - File to read
|
||||
// Then the bitmap information...
|
||||
info_size = read_dword(fp);
|
||||
|
||||
// printf("offbits = %ld, info_size = %d\n", offbits, info_size);
|
||||
|
||||
if (info_size < 40) {
|
||||
// Old Windows/OS2 BMP header...
|
||||
w(read_word(fp));
|
||||
@@ -121,19 +128,28 @@ Fl_BMP_Image::Fl_BMP_Image(const char *bmp) // I - File to read
|
||||
count = info_size - 40;
|
||||
}
|
||||
|
||||
// printf("w() = %d, h() = %d, depth = %d, compression = %d, colors_used = %d, count = %d\n",
|
||||
// w(), h(), depth, compression, colors_used, count);
|
||||
|
||||
// Skip remaining header bytes...
|
||||
while (count > 0) {
|
||||
getc(fp);
|
||||
count --;
|
||||
}
|
||||
|
||||
// Check header data...
|
||||
if (!w() || !h() || !depth) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get colormap...
|
||||
if (colors_used == 0 && depth <= 8)
|
||||
colors_used = 1 << depth;
|
||||
|
||||
for (count = 0; count < colors_used; count ++) {
|
||||
// Read BGR color...
|
||||
fread(colormap[count], colors_used, 3, fp);
|
||||
fread(colormap[count], 1, 3, fp);
|
||||
|
||||
// Skip pad byte for new BMP files...
|
||||
if (info_size > 12) getc(fp);
|
||||
@@ -141,7 +157,7 @@ Fl_BMP_Image::Fl_BMP_Image(const char *bmp) // I - File to read
|
||||
|
||||
// Setup image and buffers...
|
||||
d(3);
|
||||
fseek(fp, offbits, SEEK_SET);
|
||||
if (offbits) fseek(fp, offbits, SEEK_SET);
|
||||
|
||||
array = new uchar[w() * h() * d()];
|
||||
alloc_array = 1;
|
||||
@@ -187,58 +203,60 @@ Fl_BMP_Image::Fl_BMP_Image(const char *bmp) // I - File to read
|
||||
case 4 : // 16-color
|
||||
for (x = w(), bit = 0xf0; x > 0; x --) {
|
||||
// Get a new count as needed...
|
||||
if (compression != BI_RLE4 && count == 0) {
|
||||
count = 2;
|
||||
color = -1;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
while (align > 0) {
|
||||
align --;
|
||||
getc(fp);
|
||||
}
|
||||
if (compression != BI_RLE4) {
|
||||
count = 2;
|
||||
color = -1;
|
||||
} else {
|
||||
while (align > 0) {
|
||||
align --;
|
||||
getc(fp);
|
||||
}
|
||||
|
||||
if ((count = getc(fp)) == 0) {
|
||||
if ((count = getc(fp)) == 0) {
|
||||
// End of line...
|
||||
x ++;
|
||||
continue;
|
||||
} else if (count == 1) {
|
||||
// End of image...
|
||||
break;
|
||||
} else if (count == 2) {
|
||||
// Delta...
|
||||
count = getc(fp) * getc(fp) * w();
|
||||
color = 0;
|
||||
if ((count = getc(fp)) == 0) {
|
||||
// End of line...
|
||||
x ++;
|
||||
continue;
|
||||
} else if (count == 1) {
|
||||
// End of image...
|
||||
break;
|
||||
} else if (count == 2) {
|
||||
// Delta...
|
||||
count = getc(fp) * getc(fp) * w();
|
||||
color = 0;
|
||||
} else {
|
||||
// Absolute...
|
||||
color = -1;
|
||||
align = ((4 - (count & 3)) / 2) & 1;
|
||||
}
|
||||
} else {
|
||||
// Absolute...
|
||||
color = -1;
|
||||
align = ((4 - (count & 3)) / 2) & 1;
|
||||
color = getc(fp);
|
||||
}
|
||||
} else {
|
||||
color = getc(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get a new color as needed...
|
||||
count --;
|
||||
|
||||
if (bit == 0xf0) {
|
||||
if (color < 0) temp = getc(fp);
|
||||
else temp = color;
|
||||
// Get the next color byte as needed...
|
||||
if (color < 0) color = getc(fp);
|
||||
|
||||
// Copy the color value...
|
||||
*ptr++ = colormap[temp >> 4][2];
|
||||
*ptr++ = colormap[temp >> 4][1];
|
||||
*ptr++ = colormap[temp >> 4][0];
|
||||
bit = 0x0f;
|
||||
} else {
|
||||
// Copy the color value...
|
||||
*ptr++ = colormap[temp & 15][2];
|
||||
*ptr++ = colormap[temp & 15][1];
|
||||
*ptr++ = colormap[temp & 15][0];
|
||||
bit = 0xf0;
|
||||
// Extract the next pixel...
|
||||
if (bit == 0xf0) {
|
||||
temp = (color >> 4) & 15;
|
||||
bit = 0x0f;
|
||||
} else {
|
||||
temp = color & 15;
|
||||
bit = 0xf0;
|
||||
}
|
||||
|
||||
// printf("temp = %d\n", temp);
|
||||
|
||||
// Copy the color value...
|
||||
*ptr++ = colormap[temp][2];
|
||||
*ptr++ = colormap[temp][1];
|
||||
*ptr++ = colormap[temp][0];
|
||||
}
|
||||
|
||||
if (!compression) {
|
||||
@@ -375,5 +393,5 @@ read_long(FILE *fp) { // I - File to read from
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_BMP_Image.cxx,v 1.1.2.6 2002/06/13 18:18:33 easysw Exp $".
|
||||
// End of "$Id: Fl_BMP_Image.cxx,v 1.1.2.7 2002/06/24 02:04:54 easysw Exp $".
|
||||
//
|
||||
|
||||
+26
-20
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_x.cxx,v 1.24.2.24.2.21 2002/05/25 13:38:25 easysw Exp $"
|
||||
// "$Id: Fl_x.cxx,v 1.24.2.24.2.22 2002/06/24 02:04:54 easysw Exp $"
|
||||
//
|
||||
// X specific code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@@ -693,10 +693,6 @@ int fl_handle(const XEvent& xevent)
|
||||
}
|
||||
break;}
|
||||
|
||||
case MapNotify:
|
||||
event = FL_SHOW;
|
||||
break;
|
||||
|
||||
case UnmapNotify:
|
||||
event = FL_HIDE;
|
||||
break;
|
||||
@@ -858,21 +854,31 @@ int fl_handle(const XEvent& xevent)
|
||||
fl_xmousewin = 0;
|
||||
break;
|
||||
|
||||
case ConfigureNotify: {
|
||||
// We cannot rely on the x,y position in the configure notify event.
|
||||
// I now think this is an unavoidable problem with X: it is impossible
|
||||
// for a window manager to prevent the "real" notify event from being
|
||||
// sent when it resizes the contents, even though it can send an
|
||||
// artificial event with the correct position afterwards (and some
|
||||
// window managers do not send this fake event anyway)
|
||||
// So anyway, do a round trip to find the correct x,y:
|
||||
Window r, c; int X, Y, wX, wY; unsigned int m;
|
||||
XQueryPointer(fl_display, fl_xid(window), &r, &c, &X, &Y, &wX, &wY, &m);
|
||||
resize_bug_fix = window;
|
||||
window->resize(X-wX, Y-wY,
|
||||
xevent.xconfigure.width, xevent.xconfigure.height);
|
||||
return 1;}
|
||||
// We cannot rely on the x,y position in the configure notify event.
|
||||
// I now think this is an unavoidable problem with X: it is impossible
|
||||
// for a window manager to prevent the "real" notify event from being
|
||||
// sent when it resizes the contents, even though it can send an
|
||||
// artificial event with the correct position afterwards (and some
|
||||
// window managers do not send this fake event anyway)
|
||||
// So anyway, do a round trip to find the correct x,y:
|
||||
case MapNotify:
|
||||
event = FL_SHOW;
|
||||
|
||||
case ConfigureNotify: {
|
||||
if (window->parent()) break; // ignore child windows
|
||||
|
||||
// figure out where OS really put window
|
||||
XWindowAttributes actual;
|
||||
XGetWindowAttributes(fl_display, fl_xid(window), &actual);
|
||||
Window cr; int X, Y, W = actual.width, H = actual.height;
|
||||
XTranslateCoordinates(fl_display, fl_xid(window), actual.root,
|
||||
0, 0, &X, &Y, &cr);
|
||||
|
||||
// tell Fl_Window about it and set flag to prevent echoing:
|
||||
resize_bug_fix = window;
|
||||
window->resize(X, Y, W, H);
|
||||
break; // allow add_handler to do something too
|
||||
}
|
||||
}
|
||||
|
||||
return Fl::handle(event, window);
|
||||
@@ -1227,5 +1233,5 @@ void Fl_Window::make_current() {
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_x.cxx,v 1.24.2.24.2.21 2002/05/25 13:38:25 easysw Exp $".
|
||||
// End of "$Id: Fl_x.cxx,v 1.24.2.24.2.22 2002/06/24 02:04:54 easysw Exp $".
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user