diff --git a/CHANGES b/CHANGES index 22fab4bfa0dbe8fb39d707b696ba14549307414d..17c2187e1f1442b349a8745dd6b586167e5fd8a3 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,24 @@ CHANGES IN FLTK 1.1.0b7 when compiled for debugging under WIN32. - Added plastic box types to forms demo. - Added mousewheel to keyboard demo. + - The Fl_Text_Editor widget caused an infinite loop + when it received keyboard focus. + - filename_isdir() didn't properly handle drive letters + properly; WIN32 needs a trailing slash for drive + letters by themselves, but cannot have a trailing + slash for directory names, go figure... + - The Fl_Text_Buffer and Fl_Text_Display classes did not + initialize all of their members. + - fl_normal_label() had a totally redundant set of + if/else tests, which the new code handles all from + fl_draw(). + - The Fl_File_Chooser dialog contained two hotspots. + - The fl_draw_pixmap() function didn't free the 2-byte + color lookup table properly (delete instead of + delete[]). + - fl_draw() reset the text color under WIN32, causing + bitmaps to draw incorrectly. + - Fl::get_font_sizes() is now implemented under WIN32. CHANGES IN FLTK 1.1.0b6 diff --git a/FL/Fl_Text_Display.H b/FL/Fl_Text_Display.H index 880eab64afa687a0a0bce9eb7859dff3586750ab..5532388b1b9e8d6f25905820ad2bad6c231eab87 100644 --- a/FL/Fl_Text_Display.H +++ b/FL/Fl_Text_Display.H @@ -1,5 +1,5 @@ // -// "$Id: Fl_Text_Display.H,v 1.4.2.3 2001/10/29 03:44:31 easysw Exp $" +// "$Id: Fl_Text_Display.H,v 1.4.2.4 2001/12/03 18:29:49 easysw Exp $" // // Header file for Fl_Text_Display class. // @@ -191,8 +191,6 @@ class Fl_Text_Display: public Fl_Group { int mTopLineNumHint; /* Line number of top displayed line of file (first line of file is 1) */ int mHorizOffsetHint; /* Horizontal scroll pos. in pixels */ - int mVisibility; /* Window visibility (see XVisibility - event) */ int mNStyles; /* Number of entries in styleTable */ Style_Table_Entry *mStyleTable; /* Table of fonts and colors for coloring/syntax-highlighting */ @@ -225,5 +223,5 @@ class Fl_Text_Display: public Fl_Group { #endif // -// End of "$Id: Fl_Text_Display.H,v 1.4.2.3 2001/10/29 03:44:31 easysw Exp $". +// End of "$Id: Fl_Text_Display.H,v 1.4.2.4 2001/12/03 18:29:49 easysw Exp $". // diff --git a/documentation/Fl_Shared_Image.html b/documentation/Fl_Shared_Image.html index 010fcc73a341ab795b632b8da0833236adeedfdc..0e2d3a2b25b3d71f6cc852286a66484e4278a6fb 100644 --- a/documentation/Fl_Shared_Image.html +++ b/documentation/Fl_Shared_Image.html @@ -3,7 +3,7 @@ <!-- NEW PAGE --> -<H2><A name=Fl_Bitmap>class Fl_Bitmap</A></H2> +<H2><A name="Fl_Shared_Image">class Fl_Shared_Image</A></H2> <HR> <H3>Class Hierarchy</H3> @@ -11,41 +11,79 @@ <UL><PRE> <A href="Fl_Image.html">Fl_Image</A> | - +----<B>Fl_Bitmap</B> - | - +----<A href="Fl_XBM_Image.html">Fl_XBM_Image</A> + +----<B>Fl_Shared_Image</B> </PRE></UL> <H3>Include Files</H3> <UL><PRE> -#include <FL/Fl_Bitmap.H> +#include <FL/Fl_Shared_Image.H> </PRE></UL> <H3>Description</H3> -<P>The <TT>Fl_Bitmap</TT> class supports caching and drawing of mono-color -(bitmap) images. Images are drawn using the current color.</P> +<P>The <TT>Fl_Shared_Image</TT> class supports caching, loading, and +drawing of image files. </P> <H3>Methods</H3> <UL> - <LI><A href="#Fl_Bitmap.Fl_Bitmap">Fl_Bitmap</A></LI> + <LI><A href="#Fl_Shared_Image.Fl_Shared_Image">Fl_Shared_Image</A></LI> - <LI><A href="#Fl_Bitmap.~Fl_Bitmap">~Fl_Bitmap</A></LI> + <LI><A href="#Fl_Shared_Image.~Fl_Shared_Image">~Fl_Shared_Image</A></LI> + + <LI><A href="#Fl_Shared_Image.find">find</A></LI> + + <LI><A href="#Fl_Shared_Image.get">get</A></LI> + + <LI><A href="#Fl_Shared_Image.images">images</A></LI> + + <LI><A href="#Fl_Shared_Image.name">name</A></LI> + + <LI><A href="#Fl_Shared_Image.num_images">num_images</A></LI> + + <LI><A href="#Fl_Shared_Image.refcount">refcount</A></LI> + + <LI><A href="#Fl_Shared_Image.release">release</A></LI> + + <LI><A href="#Fl_Shared_Image.reload">reload</A></LI> </UL> -<H4><A name="Fl_Bitmap.Fl_Bitmap">Fl_Bitmap::Fl_Bitmap(const char *array, int W, int H);<BR> -Fl_Bitmap::Fl_Bitmap(const unsigned char *array, int W, int H);</A></H4> +<H4><A name="Fl_Shared_Image.Fl_Shared_Image">protected Fl_Shared_Image::Fl_Shared_Image();<BR> +protected Fl_Shared_Image::Fl_Shared_Image(const char *name, Fl_Image *img);</A></H4> + +<P>The constructors create a new shared image record in the +image cache. + +<P>The constructors are protected and cannot be used directly +from a program. Use the <A +HREF="#Fl_Shared_Image.get"><TT>get()</TT></A> method instead. + +<H4><A name="Fl_Shared_Image.~Fl_Shared_Image">protected Fl_Shared_Image::~Fl_Shared_Image();</A></H4> + +<P>The destructor free all memory and server resources that are +used by the image. The destructor is protected and cannot be +used directly from a program. Use the <A +HREF="#Fl_Shared_Image.release"><TT>release()</TT></A> method +instead. + +<H4><A NAME="Fl_Shared_Image.find">static Fl_Shared_Image *find(const char *n, int W = 0, int H = 0);</A></H4> + +<H4><A NAME="Fl_Shared_Image.get">static Fl_Shared_Image *get(const char *n, int W = 0, int H = 0);</A></H4> + +<H4><A NAME="Fl_Shared_Image.images">static Fl_Shared_Image **images();</A></H4> + +<H4><A NAME="Fl_Shared_Image.name">const char *name();</A></H4> + +<H4><A NAME="Fl_Shared_Image.num_images">static int num_images();</A></H4> -<P>The constructors create a new bitmap from the specified bitmap data.</P> +<H4><A NAME="Fl_Shared_Image.refcount">int refcount();</A></H4> -<H4><A name="Fl_Bitmap.~Fl_Bitmap">Fl_Bitmap::~Fl_Bitmap();</A></H4> +<H4><A NAME="Fl_Shared_Image.release">void release();</A></H4> -<P>The destructor free all memory and server resources that are used by -the bitmap.</P> +<H4><A NAME="Fl_Shared_Image.reload">void reload();</A></H4> </BODY> </HTML> diff --git a/documentation/Fl_Text_Display.html b/documentation/Fl_Text_Display.html index 68ddd6db93b90b6800c70cd6a80d4ec4b3e24f2e..1e74839e347fe1cfa599d78fcc395b251d3c92d6 100644 --- a/documentation/Fl_Text_Display.html +++ b/documentation/Fl_Text_Display.html @@ -3,7 +3,7 @@ <!-- NEW PAGE --> -<H2><A name=Fl_Input>class Fl_Input</A></H2> +<H2><A name="Fl_Text_Display">class Fl_Text_Display</A></H2> <HR> diff --git a/documentation/Fl_Tiled_Image.html b/documentation/Fl_Tiled_Image.html index 010fcc73a341ab795b632b8da0833236adeedfdc..4175cc780d9d5a0ecc53e95d05af8a926c313b7b 100644 --- a/documentation/Fl_Tiled_Image.html +++ b/documentation/Fl_Tiled_Image.html @@ -3,7 +3,7 @@ <!-- NEW PAGE --> -<H2><A name=Fl_Bitmap>class Fl_Bitmap</A></H2> +<H2><A name=Fl_Tiled_Image>class Fl_Tiled_Image</A></H2> <HR> <H3>Class Hierarchy</H3> @@ -11,41 +11,38 @@ <UL><PRE> <A href="Fl_Image.html">Fl_Image</A> | - +----<B>Fl_Bitmap</B> - | - +----<A href="Fl_XBM_Image.html">Fl_XBM_Image</A> + +----<B>Fl_Tiled_Image</B> </PRE></UL> <H3>Include Files</H3> <UL><PRE> -#include <FL/Fl_Bitmap.H> +#include <FL/Fl_Tiled_Image.H> </PRE></UL> <H3>Description</H3> -<P>The <TT>Fl_Bitmap</TT> class supports caching and drawing of mono-color -(bitmap) images. Images are drawn using the current color.</P> +<P>The <TT>Fl_Tiled_Image</TT> class supports tiling of images over a +specified area.</P> <H3>Methods</H3> <UL> - <LI><A href="#Fl_Bitmap.Fl_Bitmap">Fl_Bitmap</A></LI> + <LI><A href="#Fl_Tiled_Image.Fl_Tiled_Image">Fl_Tiled_Image</A></LI> - <LI><A href="#Fl_Bitmap.~Fl_Bitmap">~Fl_Bitmap</A></LI> + <LI><A href="#Fl_Tiled_Image.~Fl_Tiled_Image">~Fl_Tiled_Image</A></LI> </UL> -<H4><A name="Fl_Bitmap.Fl_Bitmap">Fl_Bitmap::Fl_Bitmap(const char *array, int W, int H);<BR> -Fl_Bitmap::Fl_Bitmap(const unsigned char *array, int W, int H);</A></H4> +<H4><A name="Fl_Tiled_Image.Fl_Tiled_Image">Fl_Tiled_Image::Fl_Tiled_Image(Fl_Image *img, int W, int H);</A></H4> -<P>The constructors create a new bitmap from the specified bitmap data.</P> +<P>The constructors create a new tiled image containing the specified image.</P> -<H4><A name="Fl_Bitmap.~Fl_Bitmap">Fl_Bitmap::~Fl_Bitmap();</A></H4> +<H4><A name="Fl_Tiled_Image.~Fl_Tiled_Image">Fl_Tiled_Image::~Fl_Tiled_Image();</A></H4> <P>The destructor free all memory and server resources that are used by -the bitmap.</P> +the tiled image.</P> </BODY> </HTML> diff --git a/src/Fl_File_Chooser.cxx b/src/Fl_File_Chooser.cxx index 51183ce6c91eb4d8005e1797634540da10c48aed..984b11a8c47b297c43f80a4292fcd943c78bdd5a 100644 --- a/src/Fl_File_Chooser.cxx +++ b/src/Fl_File_Chooser.cxx @@ -105,7 +105,6 @@ Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char { Fl_Window* o = window = new Fl_Window(375, 315, "Pick a File"); w = o; o->callback((Fl_Callback*)cb_window, (void*)(this)); - w->hotspot(o); { Fl_File_Browser* o = fileList = new Fl_File_Browser(10, 45, 355, 180); o->type(2); o->callback((Fl_Callback*)cb_fileList); diff --git a/src/Fl_File_Chooser.fl b/src/Fl_File_Chooser.fl index cfdd672da6b0cb999a9182f2403a7ee27a749de7..16a19fe2c2084f5dcb1e95f7e40713fb43514caa 100644 --- a/src/Fl_File_Chooser.fl +++ b/src/Fl_File_Chooser.fl @@ -16,7 +16,7 @@ class Fl_File_Chooser {open callback {fileList->deselect(); fileName->value(""); window->hide();} open - private xywh {99 225 375 315} resizable hotspot + private xywh {99 225 375 315} resizable code0 {if (title) window->label(title);} code1 {\#include <stdio.h>} code2 {\#include <stdlib.h>} diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx index fe03cedb8e434e318a23a2def2640ba143afec7b..5dd4a1f02492dceb39a8335ed507c734fecb9582 100644 --- a/src/Fl_Text_Buffer.cxx +++ b/src/Fl_Text_Buffer.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Text_Buffer.cxx,v 1.9.2.1 2001/08/04 12:21:33 easysw Exp $" +// "$Id: Fl_Text_Buffer.cxx,v 1.9.2.2 2001/12/03 18:29:49 easysw Exp $" // // Copyright Mark Edel. Permission to distribute under the LGPL for // the FLTK library granted by Mark Edel. @@ -92,6 +92,7 @@ Fl_Text_Buffer::Fl_Text_Buffer( int requestedSize ) { mNodifyProcs = NULL; mCbArgs = NULL; mNModifyProcs = 0; + mCursorPosHint = 0; mNullSubsChar = '\0'; #ifdef PURIFY { int i; for (i = mGapStart; i < mGapEnd; i++) mBuf[ i ] = '.'; } @@ -2283,5 +2284,5 @@ Fl_Text_Buffer::outputfile(const char *file, int start, int end, int buflen) { // -// End of "$Id: Fl_Text_Buffer.cxx,v 1.9.2.1 2001/08/04 12:21:33 easysw Exp $". +// End of "$Id: Fl_Text_Buffer.cxx,v 1.9.2.2 2001/12/03 18:29:49 easysw Exp $". // diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index efa519c414ca7ec0fa3006b389b1722e0027e46c..04e280d2e70319f3cecd4ced69575ea57519ad0a 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.3 2001/10/29 03:44:32 easysw Exp $" +// "$Id: Fl_Text_Display.cxx,v 1.12.2.4 2001/12/03 18:29:49 easysw Exp $" // // Copyright Mark Edel. Permission to distribute under the LGPL for // the FLTK library granted by Mark Edel. @@ -76,16 +76,18 @@ Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l) textcolor(FL_BLACK); textfont(FL_HELVETICA); - Fl_Group* current = Fl_Group::current(); - Fl_Group::current(this); + text_area.x = 0; + text_area.y = 0; + text_area.w = 0; + text_area.h = 0; - mVScrollBar = new Fl_Scrollbar(0,0,0,0); + mVScrollBar = new Fl_Scrollbar(0,0,1,1); mVScrollBar->callback((Fl_Callback*)v_scrollbar_cb, this); - mHScrollBar = new Fl_Scrollbar(0,0,0,0); + mHScrollBar = new Fl_Scrollbar(0,0,1,1); mHScrollBar->callback((Fl_Callback*)h_scrollbar_cb, this); mHScrollBar->type(FL_HORIZONTAL); - Fl_Group::current(current); + end(); scrollbar_width(16); scrollbar_align(FL_ALIGN_BOTTOM_RIGHT); @@ -112,6 +114,10 @@ Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l) mNVisibleLines = 1; mLineStarts = new int[mNVisibleLines]; mLineStarts[0] = 0; + + mUnfinishedStyle = 0; + mUnfinishedHighlightCB = 0; + mHighlightCBArg = 0; } /* @@ -1950,5 +1956,5 @@ int Fl_Text_Display::handle(int event) { // -// End of "$Id: Fl_Text_Display.cxx,v 1.12.2.3 2001/10/29 03:44:32 easysw Exp $". +// End of "$Id: Fl_Text_Display.cxx,v 1.12.2.4 2001/12/03 18:29:49 easysw Exp $". // diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx index 2a5f5272065f7597f4f2bb38efef9e718227ee02..af4b33ebf80e78c75a08919c36e1e5f6feff98ff 100644 --- a/src/Fl_Text_Editor.cxx +++ b/src/Fl_Text_Editor.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Text_Editor.cxx,v 1.9.2.2 2001/11/27 17:44:06 easysw Exp $" +// "$Id: Fl_Text_Editor.cxx,v 1.9.2.3 2001/12/03 18:29:49 easysw Exp $" // // Copyright Mark Edel. Permission to distribute under the LGPL for // the FLTK library granted by Mark Edel. @@ -409,7 +409,7 @@ int Fl_Text_Editor::handle(int event) { switch (event) { case FL_FOCUS: show_cursor(mCursorOn); // redraws the cursor - take_focus(); + Fl::focus(this); return 1; case FL_UNFOCUS: @@ -438,5 +438,5 @@ int Fl_Text_Editor::handle(int event) { } // -// End of "$Id: Fl_Text_Editor.cxx,v 1.9.2.2 2001/11/27 17:44:06 easysw Exp $". +// End of "$Id: Fl_Text_Editor.cxx,v 1.9.2.3 2001/12/03 18:29:49 easysw Exp $". // diff --git a/src/filename_isdir.cxx b/src/filename_isdir.cxx index 1d4d4cb0545bc393b347171b62f367c8d2589ed1..4620e29e62177a5c4cc9c79459527b54f3321dbc 100644 --- a/src/filename_isdir.cxx +++ b/src/filename_isdir.cxx @@ -1,5 +1,5 @@ // -// "$Id: filename_isdir.cxx,v 1.4.2.5 2001/01/22 15:13:40 easysw Exp $" +// "$Id: filename_isdir.cxx,v 1.4.2.5.2.1 2001/12/03 18:29:49 easysw Exp $" // // Directory detection routines for the Fast Light Tool Kit (FLTK). // @@ -25,28 +25,39 @@ // Used by fl_file_chooser -#include <config.h> -#include <FL/filename.H> +#include "flstring.h" #include <sys/stat.h> -#include <string.h> +#include <ctype.h> +#include <FL/filename.H> + int filename_isdir(const char* n) { struct stat s; + #ifdef WIN32 char fn[1024]; int length; // This workaround brought to you by the fine folks at Microsoft! // (read lots of sarcasm in that...) - strncpy(fn, n, sizeof(fn) - 1); - fn[sizeof(fn) - 1] = '\0'; - length = strlen(fn); - if (length > 0 && (fn[length - 1] == '/' || fn[length - 1] == '\\')) - fn[length - 1] = '\0'; // Strip trailing slash... - n = fn; + length = strlen(n); + if (length < (int)(sizeof(fn) - 1)) { + if (length < 4 && isletter(n[0]) && n[1] == ':') { + // 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] == '\\')) { + // Strip trailing slash from name... + strncpy(fn, n, sizeof(fn) - 1); + fn[length - 1] = '\0'; + n = fn; + } + } #endif + return !stat(n, &s) && (s.st_mode&0170000)==0040000; } // -// End of "$Id: filename_isdir.cxx,v 1.4.2.5 2001/01/22 15:13:40 easysw Exp $". +// End of "$Id: filename_isdir.cxx,v 1.4.2.5.2.1 2001/12/03 18:29:49 easysw Exp $". // diff --git a/src/fl_draw_pixmap.cxx b/src/fl_draw_pixmap.cxx index 65a766d3ab0303a50a98ae43d7a3b30c4e5a56ea..f2fdd5768b5c3f69664a24f376432ec9ff38c200 100644 --- a/src/fl_draw_pixmap.cxx +++ b/src/fl_draw_pixmap.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.4 2001/11/27 17:44:08 easysw Exp $" +// "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.5 2001/12/03 18:29:49 easysw Exp $" // // Pixmap drawing code for the Fast Light Tool Kit (FLTK). // @@ -268,10 +268,10 @@ int fl_draw_pixmap(const char*const* di, int x, int y, Fl_Color bg) { } fl_draw_image(chars_per_pixel==1 ? cb1 : cb2, &d, x, y, d.w, d.h, 4); - if (chars_per_pixel > 1) for (int i = 0; i < 256; i++) delete d.byte1[i]; + if (chars_per_pixel > 1) for (int i = 0; i < 256; i++) delete[] d.byte1[i]; return 1; } // -// End of "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.4 2001/11/27 17:44:08 easysw Exp $". +// End of "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.5 2001/12/03 18:29:49 easysw Exp $". // diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx index 61face7eec2c908ce76047f6215aefb3ada26f4f..a72a20aa7d03bd0cef31f21ae4fc4d96556a068f 100644 --- a/src/fl_font_win32.cxx +++ b/src/fl_font_win32.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_font_win32.cxx,v 1.9.2.3 2001/01/22 15:13:41 easysw Exp $" +// "$Id: fl_font_win32.cxx,v 1.9.2.3.2.1 2001/12/03 18:29:49 easysw Exp $" // // WIN32 font selection routines for the Fast Light Tool Kit (FLTK). // @@ -164,9 +164,10 @@ double fl_width(uchar c) { } void fl_draw(const char* str, int n, int x, int y) { - SetTextColor(fl_gc, fl_RGB()); + COLORREF oldColor = SetTextColor(fl_gc, fl_RGB()); SelectObject(fl_gc, fl_fontsize->fid); TextOut(fl_gc, x, y, str, n); + SetTextColor(fl_gc, oldColor); } void fl_draw(const char* str, int x, int y) { @@ -174,5 +175,5 @@ void fl_draw(const char* str, int x, int y) { } // -// End of "$Id: fl_font_win32.cxx,v 1.9.2.3 2001/01/22 15:13:41 easysw Exp $". +// End of "$Id: fl_font_win32.cxx,v 1.9.2.3.2.1 2001/12/03 18:29:49 easysw Exp $". // diff --git a/src/fl_labeltype.cxx b/src/fl_labeltype.cxx index 657bf40b383386e639789e54a4f719d6d9ac0bb8..6d848663c6dd7f507ad237c6eec6b5f2defe2f07 100644 --- a/src/fl_labeltype.cxx +++ b/src/fl_labeltype.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_labeltype.cxx,v 1.6.2.3.2.4 2001/10/29 03:44:33 easysw Exp $" +// "$Id: fl_labeltype.cxx,v 1.6.2.3.2.5 2001/12/03 18:29:49 easysw Exp $" // // Label drawing routines for the Fast Light Tool Kit (FLTK). // @@ -41,16 +41,7 @@ fl_normal_label(const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align) { fl_font(o->font, o->size); fl_color((Fl_Color)o->color); - if (o->image) { - if (align & FL_ALIGN_TEXT_OVER_IMAGE) { - fl_draw(o->value, X, Y, W, H, align, o->image); - } else { - fl_draw(o->value, X, Y, W, H, align, o->image); - } - } - else { - fl_draw(o->value, X, Y, W, H, align, o->image); - } + fl_draw(o->value, X, Y, W, H, align, o->image); } void @@ -136,5 +127,5 @@ void Fl_Widget::draw_label(int X, int Y, int W, int H, Fl_Align a) const { #include <FL/Fl_Input_.H> // -// End of "$Id: fl_labeltype.cxx,v 1.6.2.3.2.4 2001/10/29 03:44:33 easysw Exp $". +// End of "$Id: fl_labeltype.cxx,v 1.6.2.3.2.5 2001/12/03 18:29:49 easysw Exp $". // diff --git a/src/fl_set_fonts_win32.cxx b/src/fl_set_fonts_win32.cxx index b99e00d00a3d90dae67dc32aa538de4080d3c39f..d777f861cd9ea7ada52d3efa5041ad4a77868e8e 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.1 2001/11/26 20:13:29 easysw Exp $" +// "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5.2.2 2001/12/03 18:29:49 easysw Exp $" // // WIN32 font utilities for the Fast Light Tool Kit (FLTK). // @@ -23,7 +23,7 @@ // Please report all bugs and problems to "fltk-bugs@fltk.org". // -// This function fills in the fltk font table with all the fonts that +// This function fills in the FLTK font table with all the fonts that // are found on the X server. It tries to place the fonts into families // and to sort them so the first 4 in a family are normal, bold, italic, // and bold italic. @@ -57,19 +57,22 @@ const char* Fl::get_font_name(Fl_Font fnum, int* ap) { static int fl_free_font = FL_FREE_FONT; -static int CALLBACK enumcb(ENUMLOGFONT FAR *lpelf, - NEWTEXTMETRIC FAR *lpntm, int FontType, LPARAM p) { - if (!p && lpelf->elfLogFont.lfCharSet != ANSI_CHARSET) return 1; - char *n = (char*)(lpelf->elfFullName); +static int CALLBACK +enumcb(CONST LOGFONT *lpelf, + CONST TEXTMETRIC *lpntm, + int FontType, + LPARAM p) { + if (!p && lpelf->lfCharSet != ANSI_CHARSET) return 1; + char *n = (char*)(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[128]; + char buffer[LF_FACESIZE + 1]; strcpy(buffer+1, n); buffer[0] = ' '; Fl::set_font((Fl_Font)(fl_free_font++), strdup(buffer)); - if (lpelf->elfLogFont.lfWeight <= 400) + if (lpelf->lfWeight <= 400) buffer[0] = 'B', Fl::set_font((Fl_Font)(fl_free_font++), strdup(buffer)); buffer[0] = 'I'; Fl::set_font((Fl_Font)(fl_free_font++), strdup(buffer)); - if (lpelf->elfLogFont.lfWeight <= 400) + if (lpelf->lfWeight <= 400) buffer[0] = 'P', Fl::set_font((Fl_Font)(fl_free_font++), strdup(buffer)); return 1; } @@ -82,14 +85,62 @@ Fl_Font Fl::set_fonts(const char* xstarname) { return (Fl_Font)fl_free_font; } -int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) { - // pretend all fonts are scalable (most are and I don't know how - // to tell anyways) - static int array[1]; - sizep = array; - return 1; + +static int nbSize; +static int cyPerInch; +static int sizes[128]; + +static int CALLBACK +EnumSizeCb(CONST LOGFONT *lpelf, + CONST TEXTMETRIC *lpntm, + DWORD fontType, + LPARAM p) { + if ((fontType & RASTER_FONTTYPE) == 0) { + sizes[0] = 0; + nbSize = 1; + + // Scalable font + return 0; + } + + int add = lpntm->tmHeight - lpntm->tmInternalLeading; + add = MulDiv(add, 72, cyPerInch); + + int start = 0; + while ((start < nbSize) && (sizes[start] < add)) { + start++; + } + + if ((start < nbSize) && (sizes[start] == add)) { + return 1; + } + + for (int i=nbSize; i>start; i--) sizes[i] = sizes[i - 1]; + + sizes[start] = add; + nbSize++; + + // Stop enum if buffer overflow + return nbSize < 128; } + +int +Fl::get_font_sizes(Fl_Font fnum, int*& sizep) { + nbSize = 0; + Fl_Fontdesc *s = fl_fonts+fnum; + if (!s->name) s = fl_fonts; // empty slot in table, use entry 0 + + if (!fl_gc) fl_GetDC(0); + cyPerInch = GetDeviceCaps(fl_gc, LOGPIXELSY); + if (cyPerInch < 1) cyPerInch = 1; + EnumFontFamilies(fl_gc, s->name+1, EnumSizeCb, 0); + + sizep = sizes; + return nbSize; +} + + // -// End of "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5.2.1 2001/11/26 20:13:29 easysw Exp $". +// End of "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5.2.2 2001/12/03 18:29:49 easysw Exp $". //