diff options
Diffstat (limited to 'vncviewer/fltk')
-rw-r--r-- | vncviewer/fltk/Fl_Navigation.cxx | 12 | ||||
-rw-r--r-- | vncviewer/fltk/layout.h | 13 |
2 files changed, 23 insertions, 2 deletions
diff --git a/vncviewer/fltk/Fl_Navigation.cxx b/vncviewer/fltk/Fl_Navigation.cxx index d3117aae..be258ce5 100644 --- a/vncviewer/fltk/Fl_Navigation.cxx +++ b/vncviewer/fltk/Fl_Navigation.cxx @@ -31,6 +31,7 @@ #include <FL/Fl_Button.H> #include <FL/Fl_Scroll.H> +#include <FL/fl_draw.H> #include "Fl_Navigation.h" @@ -154,14 +155,21 @@ void Fl_Navigation::update_labels() for (i = 0;i < pages->children();i++) { Fl_Widget *page; Fl_Button *btn; + int w, h; page = pages->child(i); + w = labels->w() - page->labelsize() * 2; + fl_font(page->labelfont(), page->labelsize()); + fl_measure(page->label(), w, h); + h += page->labelsize() * 2; + btn = new Fl_Button(labels->x(), labels->y() + offset, - labels->w(), page->labelsize() * 3, + labels->w(), h, page->label()); btn->box(FL_FLAT_BOX); btn->type(FL_RADIO_BUTTON); + btn->align(btn->align() | FL_ALIGN_WRAP); btn->color(FL_BACKGROUND2_COLOR); btn->selection_color(FL_SELECTION_COLOR); btn->labelsize(page->labelsize()); @@ -171,7 +179,7 @@ void Fl_Navigation::update_labels() btn->callback(label_pressed, this); labels->add(btn); - offset += page->labelsize() * 3; + offset += h; } labels->size(labels->w(), offset); diff --git a/vncviewer/fltk/layout.h b/vncviewer/fltk/layout.h index 01dc73e6..9a74c234 100644 --- a/vncviewer/fltk/layout.h +++ b/vncviewer/fltk/layout.h @@ -24,6 +24,7 @@ #ifndef __FLTK_LAYOUT_H__ #define __FLTK_LAYOUT_H__ +#include <FL/Fl_Choice.H> #include <FL/fl_draw.H> /* Calculates the width of a string as printed by FLTK (pixels) */ @@ -38,6 +39,18 @@ static inline int gui_str_len(const char *str) return (int)(len + 0.5f); } +/* Adjusts an Fl_Choice so that all options are visible */ +static inline void fltk_adjust_choice(Fl_Choice *choice) +{ + int option_len; + + option_len = 0; + for (int i = 0; i < choice->size(); i++) + option_len = std::max(option_len, gui_str_len(choice->text(i))); + + choice->size(option_len + 30, choice->h()); +} + /**** MARGINS ****/ #define OUTER_MARGIN 15 |