diff options
author | corvid <corvid@lavabit.com> | 2011-01-29 03:00:02 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2011-01-29 03:00:02 +0000 |
commit | f48b62538ce6b1d1108b268067b9fda8cf34a6ab (patch) | |
tree | 47aa18f059334de5266a340a7ee8cfb1d3077ee5 /dw/fltkui.cc | |
parent | 8d9b931926b1803d9e7bc46384a3e3db2fe5bdb6 (diff) |
OptionMenu size
Diffstat (limited to 'dw/fltkui.cc')
-rw-r--r-- | dw/fltkui.cc | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc index d7f525c1..974bb240 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -917,28 +917,39 @@ void FltkOptionMenuResource::widgetCallback (Fl_Widget *widget, { } +int FltkOptionMenuResource::getMaxStringWidth() +{ + int i, max = 0; + + for (i = 0; i < itemsUsed; i++) { + int width = 0; + const char *str = menu[i].text; + + if (str) { + width = fl_width(str); + if (width > max) + max = width; + } + } + return max; +} + void FltkOptionMenuResource::sizeRequest (core::Requisition *requisition) { -#if 0 if (style) { FltkFont *font = (FltkFont*)style->font; - ::fltk::setfont(font->font,font->size); + fl_font(font->font, font->size); int maxStringWidth = getMaxStringWidth (); requisition->ascent = font->ascent + RELIEF_Y_THICKNESS; requisition->descent = font->descent + RELIEF_Y_THICKNESS; requisition->width = maxStringWidth - + (requisition->ascent + requisition->descent) * 4 / 5 + + (requisition->ascent + requisition->descent) + 2 * RELIEF_X_THICKNESS; } else { requisition->width = 1; requisition->ascent = 1; requisition->descent = 0; } -#else - requisition->width = 100; - requisition->ascent = 11 + RELIEF_Y_THICKNESS; - requisition->descent = 3 + RELIEF_Y_THICKNESS; -#endif } void FltkOptionMenuResource::enlargeMenu () |