diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2016-03-29 11:54:44 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2016-03-29 11:54:44 +0000 |
| commit | 109ebd2dc03973c66cd8b2511f85b5f49e0b5ccb (patch) | |
| tree | 6e76de1a6dbc8a0a16f9970e5bb9150e41d445ba /src/Fl_Browser.cxx | |
| parent | 1dca798b6e47b3bac50d44c3140eb4fc69c85e71 (diff) | |
Fix Fl_Browser::textsize(int) to adjust the scrollbars (STR #3057).
Setting a different text size didn't affect the scrollbars.
Port of branch-1.3, r11453 and r11464.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11465 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Browser.cxx')
| -rw-r--r-- | src/Fl_Browser.cxx | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/Fl_Browser.cxx b/src/Fl_Browser.cxx index c81c88edc..d0a9b9989 100644 --- a/src/Fl_Browser.cxx +++ b/src/Fl_Browser.cxx @@ -3,7 +3,7 @@ // // Browser widget for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2016 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -651,6 +651,34 @@ int Fl_Browser::topline() const { } /** + Sets the default text size (in pixels) for the lines in the browser to \p newSize. + + This method recalculates all item heights and caches the total height + internally for optimization of later item changes. This can be slow + if there are many items in the browser. + + It returns immediately (w/o recalculation) if \p newSize equals + the current textsize(). + + You \e may need to call redraw() to see the effect and to have the + scrollbar positions recalculated. + + You should set the text size \e before populating the browser with items + unless you really need to \e change the size later. +*/ +void Fl_Browser::textsize(Fl_Fontsize newSize) { + if (newSize == textsize()) + return; // avoid recalculation + Fl_Browser_::textsize(newSize); + new_list(); + full_height_ = 0; + if (lines == 0) return; + for (FL_BLINE* itm=(FL_BLINE *)item_first(); itm; itm=(FL_BLINE *)item_next(itm)) { + full_height_ += item_height(itm); + } +} + +/** Removes all the lines in the browser. \see add(), insert(), remove(), swap(int,int), clear() */ |
