diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Menu.cxx | 11 | ||||
| -rw-r--r-- | src/fl_draw.cxx | 2 | ||||
| -rw-r--r-- | src/fl_font.cxx | 2 | ||||
| -rw-r--r-- | src/fl_font_win32.cxx | 15 |
4 files changed, 23 insertions, 7 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index 68e60fb02..bf6e4b4bf 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -80,7 +80,7 @@ const Fl_Menu_Item* Fl_Menu_Item::next(int n) const { } // appearance of current menus are pulled from this parent widget: -static const Fl_Menu_* button; +static const Fl_Menu_* button=0; //////////////////////////////////////////////////////////////// @@ -320,7 +320,8 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp, if (t) Wtitle = t->measure(&Htitle, button) + 12; int W = 0; if (m) for (; m->text; m = m->next()) { - int hh; int w1 = m->measure(&hh, button); + int hh; + int w1 = m->measure(&hh, button); if (hh+LEADING>itemheight) itemheight = hh+LEADING; if (m->flags&(FL_SUBMENU|FL_SUBMENU_POINTER)) w1 += 14; if (w1 > W) W = w1; @@ -541,7 +542,7 @@ struct menustate { menuwindow* fakemenu; // kludge for buttons in menubar int is_inside(int mx, int my); }; -static menustate* p; +static menustate* p=0; // return 1 if the coordinates are inside any of the menuwindows int menustate::is_inside(int mx, int my) { @@ -826,7 +827,7 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown( if (pp.current_item == oldi) continue;} // only do rest if item changes: - delete pp.fakemenu; pp.fakemenu = 0; // turn off "menubar button" + if(pp.fakemenu) {delete pp.fakemenu; pp.fakemenu = 0;} // turn off "menubar button" if (!pp.current_item) { // pointing at nothing // turn off selection in deepest menu, but don't erase other menus: @@ -834,7 +835,7 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown( continue; } - delete pp.fakemenu; pp.fakemenu = 0; + if(pp.fakemenu) {delete pp.fakemenu; pp.fakemenu = 0;} initial_item = 0; // stop the startup code pp.p[pp.menu_number]->autoscroll(pp.item_number); diff --git a/src/fl_draw.cxx b/src/fl_draw.cxx index d4b42cec7..142d72d5e 100644 --- a/src/fl_draw.cxx +++ b/src/fl_draw.cxx @@ -368,7 +368,7 @@ void fl_measure(const char* str, int& w, int& h, int draw_symbols) { char buf[MAXBUF]; int buflen; int lines; - double width; + double width=0; int W = 0; char symbol[2][255], *symptr; int symwidth[2], symtotal; diff --git a/src/fl_font.cxx b/src/fl_font.cxx index 20bdc198b..6f9a1e0f6 100644 --- a/src/fl_font.cxx +++ b/src/fl_font.cxx @@ -26,7 +26,9 @@ // #ifdef WIN32 +#ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN +#endif /* We require Windows 2000 features such as GetGlyphIndices */ # if !defined(WINVER) || (WINVER < 0x0500) # define WINVER 0x0500 diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx index 42ca214d3..0155dfcea 100644 --- a/src/fl_font_win32.cxx +++ b/src/fl_font_win32.cxx @@ -182,11 +182,24 @@ double fl_width(unsigned int c) { fl_fontsize->width[r] = (int*) malloc(sizeof(int) * 0x0400); SIZE s; unsigned short i = 0, ii = r * 0x400; + // The following code is a best effort algorithm to further a valid fl_gc + // if no fl_gc is available at the time we call fl_width() + // We first choose a gc from the first fltk window, + // if it is null then the gc from the current screen (GetDC(NULL)). + // This should solve STR #2086 + HDC gc = fl_gc; + HWND hWnd = 0; + if (!gc) { + gc = GetDC(hWnd); + } + if (!gc) + Fl::fatal("Invalid graphic context: fl_width() failed because no valid HDC was found!"); for (; i < 0x400; i++) { - GetTextExtentPoint32W(fl_gc, (WCHAR*)&ii, 1, &s); + GetTextExtentPoint32W(gc, (WCHAR*)&ii, 1, &s); fl_fontsize->width[r][i] = s.cx; ii++; } + if (gc && gc!=fl_gc) ReleaseDC(hWnd, gc); } return (double) fl_fontsize->width[r][c & 0x03FF]; } |
