diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_GIF_Image.cxx | 13 | ||||
| -rw-r--r-- | src/Fl_Gl_Choice.cxx | 10 | ||||
| -rw-r--r-- | src/Fl_Group.cxx | 7 | ||||
| -rw-r--r-- | src/Fl_Help_View.cxx | 8 | ||||
| -rw-r--r-- | src/Fl_Image.cxx | 21 | ||||
| -rw-r--r-- | src/Fl_PNM_Image.cxx | 6 | ||||
| -rw-r--r-- | src/Fl_Shared_Image.cxx | 10 | ||||
| -rw-r--r-- | src/Fl_Text_Display.cxx | 7 | ||||
| -rw-r--r-- | src/Fl_Tiled_Image.cxx | 26 | ||||
| -rw-r--r-- | src/Fl_Widget.cxx | 6 | ||||
| -rw-r--r-- | src/filename_absolute.cxx | 9 | ||||
| -rw-r--r-- | src/filename_isdir.cxx | 14 | ||||
| -rwxr-xr-x | src/fl_set_fonts_win32.cxx | 10 |
13 files changed, 79 insertions, 68 deletions
diff --git a/src/Fl_GIF_Image.cxx b/src/Fl_GIF_Image.cxx index 5d6e469de..b6260d111 100644 --- a/src/Fl_GIF_Image.cxx +++ b/src/Fl_GIF_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_GIF_Image.cxx,v 1.1.2.6 2001/12/11 16:03:12 easysw Exp $" +// "$Id: Fl_GIF_Image.cxx,v 1.1.2.7 2001/12/19 18:15:33 easysw Exp $" // // Fl_GIF_Image routines. // @@ -92,8 +92,8 @@ Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) { return; /* quit on eof */ } if (b[0]!='G' || b[1]!='I' || b[2] != 'F') { - Fl::error("%s is not a GIF file.\n", infname); fclose(GifFile); + Fl::error("%s is not a GIF file.\n", infname); return; } if (b[3]!='8' || b[4]>'9' || b[5]!= 'a') @@ -135,8 +135,8 @@ Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) { int i = NEXTBYTE; if (i<0) { - Fl::error("%s: unexpected EOF",infname); fclose(GifFile); + Fl::error("%s: unexpected EOF",infname); return; } int blocklen; @@ -193,11 +193,6 @@ Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) { } uchar *Image = new uchar[Width*Height]; - if (!Image) { - Fl::fatal("Insufficient memory for %s.", infname); - fclose(GifFile); - return; - } int YC = 0, Pass = 0; /* Used to de-interlace the picture */ uchar *p = Image; @@ -378,5 +373,5 @@ Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) { // -// End of "$Id: Fl_GIF_Image.cxx,v 1.1.2.6 2001/12/11 16:03:12 easysw Exp $". +// End of "$Id: Fl_GIF_Image.cxx,v 1.1.2.7 2001/12/19 18:15:33 easysw Exp $". // diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx index 8e3842269..52cbd66fb 100644 --- a/src/Fl_Gl_Choice.cxx +++ b/src/Fl_Gl_Choice.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.5 2001/12/18 11:00:09 matthiaswm Exp $" +// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.6 2001/12/19 18:15:34 easysw Exp $" // // OpenGL visual selection code for the Fast Light Tool Kit (FLTK). // @@ -160,7 +160,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int mode, const int *alist) { if (!DescribePixelFormat(fl_gc, i, sizeof(pfd), &pfd)) break; // continue if it does not satisfy our requirements: if (~pfd.dwFlags & (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL)) continue; - if (pfd.iPixelType != ((mode&FL_INDEX)?1:0)) continue; + if (pfd.iPixelType != ((mode&FL_INDEX)?PFD_TYPE_COLORINDEX:PFD_TYPE_RGBA)) continue; if ((mode & FL_ALPHA) && !pfd.cAlphaBits) continue; if ((mode & FL_ACCUM) && !pfd.cAccumBits) continue; if ((!(mode & FL_DOUBLE)) != (!(pfd.dwFlags & PFD_DOUBLEBUFFER))) continue; @@ -217,9 +217,9 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay HDC hdc = i->private_dc; if (!hdc) { hdc = i->private_dc = GetDCEx(i->xid, 0, DCX_CACHE); - SetPixelFormat(i->private_dc, g->pixelformat, (PIXELFORMATDESCRIPTOR*)(&g->pfd)); + SetPixelFormat(hdc, g->pixelformat, (PIXELFORMATDESCRIPTOR*)(&g->pfd)); #if USE_COLORMAP - if (fl_palette) SelectPalette(i->private_dc, fl_palette, FALSE); + if (fl_palette) SelectPalette(hdc, fl_palette, FALSE); #endif } GLContext context = @@ -309,5 +309,5 @@ void fl_delete_gl_context(GLContext context) { #endif // -// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.5 2001/12/18 11:00:09 matthiaswm Exp $". +// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.6 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx index 4ef1c7367..182d325cd 100644 --- a/src/Fl_Group.cxx +++ b/src/Fl_Group.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Group.cxx,v 1.8.2.8.2.5 2001/08/04 12:21:33 easysw Exp $" +// "$Id: Fl_Group.cxx,v 1.8.2.8.2.6 2001/12/19 18:15:34 easysw Exp $" // // Group widget for the Fast Light Tool Kit (FLTK). // @@ -306,8 +306,7 @@ void Fl_Group::clear() { Fl_Widget*const* a = old_array; for (int i=old_children; i--;) { Fl_Widget* o = *a++; - // test the parent to see if child already destructed: - if (o->parent() == this) delete o; + delete o; } if (old_children > 1) free((void*)old_array); } @@ -552,5 +551,5 @@ void Fl_Group::draw_outside_label(const Fl_Widget& w) const { } // -// End of "$Id: Fl_Group.cxx,v 1.8.2.8.2.5 2001/08/04 12:21:33 easysw Exp $". +// End of "$Id: Fl_Group.cxx,v 1.8.2.8.2.6 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/Fl_Help_View.cxx b/src/Fl_Help_View.cxx index ad8b1b3ba..832a206b4 100644 --- a/src/Fl_Help_View.cxx +++ b/src/Fl_Help_View.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Help_View.cxx,v 1.1.2.22 2001/12/19 15:59:51 easysw Exp $" +// "$Id: Fl_Help_View.cxx,v 1.1.2.23 2001/12/19 18:15:34 easysw Exp $" // // Fl_Help_View widget routines. // @@ -94,7 +94,7 @@ static void hscrollbar_callback(Fl_Widget *s, void *); // Fl_Help_Block * // O - Pointer to new block -Fl_Help_View::add_block(const char *s, // I - Pointer to start of block text +Fl_Help_View::add_block(const char *s, // I - Pointer to start of block text int xx, // I - X position of block int yy, // I - Y position of block int ww, // I - Right margin of block @@ -118,7 +118,9 @@ Fl_Help_View::add_block(const char *s, // I - Pointer to start of block text } temp = blocks_ + nblocks_; + memset(temp, 0, sizeof(Fl_Help_Block)); temp->start = s; + temp->end = s; temp->x = xx; temp->y = yy; temp->w = ww; @@ -2567,5 +2569,5 @@ hscrollbar_callback(Fl_Widget *s, void *) // -// End of "$Id: Fl_Help_View.cxx,v 1.1.2.22 2001/12/19 15:59:51 easysw Exp $". +// End of "$Id: Fl_Help_View.cxx,v 1.1.2.23 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index 7fc8857a5..e431e9157 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.11 2001/11/27 17:44:06 easysw Exp $" +// "$Id: Fl_Image.cxx,v 1.5.2.3.2.12 2001/12/19 18:15:34 easysw Exp $" // // Image drawing code for the Fast Light Tool Kit (FLTK). // @@ -73,8 +73,12 @@ Fl_RGB_Image::~Fl_RGB_Image() { } Fl_Image *Fl_RGB_Image::copy(int W, int H) { - // Optimize the simple copy where the width and height are the same... - if (W == w() && H == h()) return new Fl_RGB_Image(array, w(), h(), d(), ld()); + // 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()); + } // OK, need to resize the image data; allocate memory and Fl_RGB_Image *new_image; // New RGB image @@ -128,6 +132,9 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) { } void Fl_RGB_Image::color_average(Fl_Color c, float i) { + // Don't average an empty image... + if (!w() || !h() || !d() || !array) return; + // Delete any existing pixmap/mask objects... if (id) { fl_delete_offscreen(id); @@ -191,6 +198,9 @@ void Fl_RGB_Image::color_average(Fl_Color c, float i) { } void Fl_RGB_Image::desaturate() { + // Don't desaturate an empty image... + if (!w() || !h() || !d() || !array) return; + // Can only desaturate color images... if (d() < 3) return; @@ -234,7 +244,8 @@ void Fl_RGB_Image::desaturate() { } void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) { - if (!array) { + // Don't draw an empty image... + if (!d() || !array) { draw_empty(XP, YP); return; } @@ -367,5 +378,5 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) { // -// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.11 2001/11/27 17:44:06 easysw Exp $". +// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.12 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/Fl_PNM_Image.cxx b/src/Fl_PNM_Image.cxx index 0f5801f0b..459b5ea85 100644 --- a/src/Fl_PNM_Image.cxx +++ b/src/Fl_PNM_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_PNM_Image.cxx,v 1.1.2.3 2001/12/11 16:03:12 easysw Exp $" +// "$Id: Fl_PNM_Image.cxx,v 1.1.2.4 2001/12/19 18:15:34 easysw Exp $" // // Fl_PNM_Image routines. // @@ -75,8 +75,8 @@ Fl_PNM_Image::Fl_PNM_Image(const char *name) // I - File to read lineptr = fgets(line, sizeof(line), fp); if (!lineptr) { - Fl::error("Early end-of-file in PNM file \"%s\"!", name); fclose(fp); + Fl::error("Early end-of-file in PNM file \"%s\"!", name); return; } @@ -166,5 +166,5 @@ Fl_PNM_Image::Fl_PNM_Image(const char *name) // I - File to read // -// End of "$Id: Fl_PNM_Image.cxx,v 1.1.2.3 2001/12/11 16:03:12 easysw Exp $". +// End of "$Id: Fl_PNM_Image.cxx,v 1.1.2.4 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/Fl_Shared_Image.cxx b/src/Fl_Shared_Image.cxx index 86d381515..b6ed21abc 100644 --- a/src/Fl_Shared_Image.cxx +++ b/src/Fl_Shared_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Shared_Image.cxx,v 1.23.2.4 2001/12/11 16:03:12 easysw Exp $" +// "$Id: Fl_Shared_Image.cxx,v 1.23.2.5 2001/12/19 18:15:34 easysw Exp $" // // Shared image code for the Fast Light Tool Kit (FLTK). // @@ -363,6 +363,12 @@ Fl_Shared_Image::get(const char *n, int W, int H) { if ((temp = find(n)) == NULL) { temp = new Fl_Shared_Image(n); + + if (!temp->image_) { + delete temp; + return NULL; + } + temp->add(); } @@ -376,5 +382,5 @@ Fl_Shared_Image::get(const char *n, int W, int H) { // -// End of "$Id: Fl_Shared_Image.cxx,v 1.23.2.4 2001/12/11 16:03:12 easysw Exp $". +// End of "$Id: Fl_Shared_Image.cxx,v 1.23.2.5 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index b6eabfb8b..0992efd4a 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Text_Display.cxx,v 1.12.2.8 2001/12/17 15:01:38 easysw Exp $" +// "$Id: Fl_Text_Display.cxx,v 1.12.2.9 2001/12/19 18:15:34 easysw Exp $" // // Copyright Mark Edel. Permission to distribute under the LGPL for // the FLTK library granted by Mark Edel. @@ -127,9 +127,6 @@ Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l) ** freed, nor are the style buffer or style table. */ Fl_Text_Display::~Fl_Text_Display() { - delete mVScrollBar; - delete mHScrollBar; - if (mBuffer) mBuffer->remove_modify_callback(buffer_modified_cb, this); delete[] mLineStarts; } @@ -1960,5 +1957,5 @@ int Fl_Text_Display::handle(int event) { // -// End of "$Id: Fl_Text_Display.cxx,v 1.12.2.8 2001/12/17 15:01:38 easysw Exp $". +// End of "$Id: Fl_Text_Display.cxx,v 1.12.2.9 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/Fl_Tiled_Image.cxx b/src/Fl_Tiled_Image.cxx index c331265bd..119801cc6 100644 --- a/src/Fl_Tiled_Image.cxx +++ b/src/Fl_Tiled_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Tiled_Image.cxx,v 1.1.2.3 2001/12/11 16:03:12 easysw Exp $" +// "$Id: Fl_Tiled_Image.cxx,v 1.1.2.4 2001/12/19 18:15:34 easysw Exp $" // // Tiled image code for the Fast Light Tool Kit (FLTK). // @@ -74,15 +74,12 @@ Fl_Tiled_Image::copy(int W, // I - New width void Fl_Tiled_Image::color_average(Fl_Color c, // I - Color to blend with float i) { // I - Blend fraction - if (alloc_image_) image_->color_average(c, i); - else { - Fl_Image *temp = image_->copy(); - - temp->color_average(c, i); - - image_ = temp; + if (!alloc_image_) { + image_ = image_->copy(); alloc_image_ = 1; } + + image_->color_average(c, i); } @@ -92,15 +89,12 @@ Fl_Tiled_Image::color_average(Fl_Color c, // I - Color to blend with void Fl_Tiled_Image::desaturate() { - if (alloc_image_) image_->desaturate(); - else { - Fl_Image *temp = image_->copy(); - - temp->desaturate(); - - image_ = temp; + if (!alloc_image_) { + image_ = image_->copy(); alloc_image_ = 1; } + + image_->desaturate(); } @@ -139,5 +133,5 @@ Fl_Tiled_Image::draw(int X, // I - Starting X position // -// End of "$Id: Fl_Tiled_Image.cxx,v 1.1.2.3 2001/12/11 16:03:12 easysw Exp $". +// End of "$Id: Fl_Tiled_Image.cxx,v 1.1.2.4 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx index 6092229c8..1b9a9816f 100644 --- a/src/Fl_Widget.cxx +++ b/src/Fl_Widget.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.10 2001/12/14 16:48:13 easysw Exp $" +// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.11 2001/12/19 18:15:34 easysw Exp $" // // Base widget class for the Fast Light Tool Kit (FLTK). // @@ -126,7 +126,7 @@ extern void fl_throw_focus(Fl_Widget*); // in Fl_x.cxx // However, it is only legal to destroy a "root" such as an Fl_Window, // and automatic destructors may be called. Fl_Widget::~Fl_Widget() { - parent_ = 0; // kludge to prevent ~Fl_Group from destroying again + if (parent_) parent_->remove(this); fl_throw_focus(this); } @@ -248,5 +248,5 @@ int Fl_Widget::contains(const Fl_Widget *o) const { } // -// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.10 2001/12/14 16:48:13 easysw Exp $". +// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.11 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/filename_absolute.cxx b/src/filename_absolute.cxx index 2eeca49e3..a7ed164c9 100644 --- a/src/filename_absolute.cxx +++ b/src/filename_absolute.cxx @@ -1,5 +1,5 @@ // -// "$Id: filename_absolute.cxx,v 1.5.2.4.2.3 2001/12/11 16:03:12 easysw Exp $" +// "$Id: filename_absolute.cxx,v 1.5.2.4.2.4 2001/12/19 18:15:34 easysw Exp $" // // Filename expansion routines for the Fast Light Tool Kit (FLTK). // @@ -68,6 +68,7 @@ int filename_absolute(char *to, int tolen, const char *from) { if (!a) { strncpy(to, from, tolen - 1); to[tolen - 1] = '\0'; + delete[] temp; return 0; } #if defined(WIN32) || defined(__EMX__) && !defined(__CYGWIN__) @@ -134,7 +135,11 @@ filename_relative(char *to, // O - Relative filename *slash != '\0' && *newslash != '\0'; slash ++, newslash ++) if (isdirsep(*slash) && isdirsep(*newslash)) continue; +#if defined(WIN32) || defined(__EMX__) || defined(__APPLE__) + else if (tolower(*slash) != tolower(*newslash)) break; +#else else if (*slash != *newslash) break; +#endif // WIN32 || __EMX__ || __APPLE__ while (!isdirsep(*slash) && slash > from) slash --; @@ -167,5 +172,5 @@ filename_relative(char *to, // O - Relative filename // -// End of "$Id: filename_absolute.cxx,v 1.5.2.4.2.3 2001/12/11 16:03:12 easysw Exp $". +// End of "$Id: filename_absolute.cxx,v 1.5.2.4.2.4 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/filename_isdir.cxx b/src/filename_isdir.cxx index 486823b6f..612241fd7 100644 --- a/src/filename_isdir.cxx +++ b/src/filename_isdir.cxx @@ -1,5 +1,5 @@ // -// "$Id: filename_isdir.cxx,v 1.4.2.5.2.2 2001/12/04 19:04:15 easysw Exp $" +// "$Id: filename_isdir.cxx,v 1.4.2.5.2.3 2001/12/19 18:15:34 easysw Exp $" // // Directory detection routines for the Fast Light Tool Kit (FLTK). // @@ -41,15 +41,17 @@ int filename_isdir(const char* n) { // (read lots of sarcasm in that...) length = strlen(n); if (length < (int)(sizeof(fn) - 1)) { - if (length < 4 && isalpha(n[0]) && n[1] == ':') { + if (length < 4 && isalpha(n[0]) && n[1] == ':' && + (isdirsep(n[2]) || !n[2])) { // Always use D:/ for drive letters fn[0] = n[0]; strcpy(fn + 1, ":/"); n = fn; - } else if (length > 0 && (n[length - 1] == '/' || n[length - 1] == '\\')) { + } else if (length > 0 && isdirsep(n[length - 1])) { // Strip trailing slash from name... - strncpy(fn, n, sizeof(fn) - 1); - fn[length - 1] = '\0'; + length --; + memcpy(fn, n, length); + fn[length] = '\0'; n = fn; } } @@ -59,5 +61,5 @@ int filename_isdir(const char* n) { } // -// End of "$Id: filename_isdir.cxx,v 1.4.2.5.2.2 2001/12/04 19:04:15 easysw Exp $". +// End of "$Id: filename_isdir.cxx,v 1.4.2.5.2.3 2001/12/19 18:15:34 easysw Exp $". // diff --git a/src/fl_set_fonts_win32.cxx b/src/fl_set_fonts_win32.cxx index d777f861c..463c87d12 100755 --- a/src/fl_set_fonts_win32.cxx +++ b/src/fl_set_fonts_win32.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5.2.2 2001/12/03 18:29:49 easysw Exp $" +// "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5.2.3 2001/12/19 18:15:34 easysw Exp $" // // WIN32 font utilities for the Fast Light Tool Kit (FLTK). // @@ -60,10 +60,10 @@ static int fl_free_font = FL_FREE_FONT; static int CALLBACK enumcb(CONST LOGFONT *lpelf, CONST TEXTMETRIC *lpntm, - int FontType, + DWORD FontType, LPARAM p) { if (!p && lpelf->lfCharSet != ANSI_CHARSET) return 1; - char *n = (char*)(lpelf->lfFaceName); + const char *n = lpelf->lfFaceName; for (int i=0; i<FL_FREE_FONT; i++) // skip if one of our built-in fonts if (!strcmp(Fl::get_font_name((Fl_Font)i),n)) return 1; char buffer[LF_FACESIZE + 1]; @@ -80,7 +80,7 @@ enumcb(CONST LOGFONT *lpelf, Fl_Font Fl::set_fonts(const char* xstarname) { if (fl_free_font == FL_FREE_FONT) {// if not already been called if (!fl_gc) fl_GetDC(0); - EnumFontFamilies(fl_gc, NULL, (FONTENUMPROC)enumcb, xstarname != 0); + EnumFontFamilies(fl_gc, NULL, enumcb, xstarname != 0); } return (Fl_Font)fl_free_font; } @@ -142,5 +142,5 @@ Fl::get_font_sizes(Fl_Font fnum, int*& sizep) { // -// End of "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5.2.2 2001/12/03 18:29:49 easysw Exp $". +// End of "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5.2.3 2001/12/19 18:15:34 easysw Exp $". // |
