diff options
| author | Greg Ercolano <erco@seriss.com> | 2009-09-08 01:43:57 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2009-09-08 01:43:57 +0000 |
| commit | 0e29d4a553cd28049c4ba03b2d79f25fcab0edeb (patch) | |
| tree | 85e17a8026cff95ee8298be5e5542af3fb90c64d /src/Fl_Browser.cxx | |
| parent | e60b85f94cdf4058c1a9e2b5d5133e2d9b46ca44 (diff) | |
Added Albrecht's patch to solve height calculation problem.
Added replacing() call to handle horiz scroll calculations.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6852 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Browser.cxx')
| -rw-r--r-- | src/Fl_Browser.cxx | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/src/Fl_Browser.cxx b/src/Fl_Browser.cxx index 1933f1d1c..ac4970341 100644 --- a/src/Fl_Browser.cxx +++ b/src/Fl_Browser.cxx @@ -864,20 +864,27 @@ void Fl_Browser::swap(int a, int b) { If NULL, any previous icon is removed. */ void Fl_Browser::icon(int line, Fl_Image* icon) { - if (icon==0) { - remove_icon(line); - } else if (line>0 && line<=lines) { - // Update full_height_ - FL_BLINE* l = find_line(line); - int dh = icon->h() - item_height(l) + 2; // leave 2px above/below - l->icon = icon; // define icon AFTER item_height() check - if (dh>0) { - full_height_ += dh; - redraw(); // icon larger than item? must redraw widget - } else { - redraw_line(l); // icon same or smaller? can redraw just this line - } + + if (line<1 || line > lines) return; + + FL_BLINE* bl = find_line(line); + + int old_h = bl->icon ? bl->icon->h()+2 : 0; // init with *old* icon height + bl->icon = 0; // remove icon, if any + int th = item_height(bl); // height of text only + int new_h = icon ? icon->h()+2 : 0; // init with *new* icon height + if (th > old_h) old_h = th; + if (th > new_h) new_h = th; + int dh = new_h - old_h; + full_height_ += dh; // do this *always* + + bl->icon = icon; // set new icon + if (dh>0) { + redraw(); // icon larger than item? must redraw widget + } else { + redraw_line(bl); // icon same or smaller? can redraw just this line } + replacing(bl,bl); // recalc Fl_Browser_::max_width et al } /** @@ -897,20 +904,7 @@ Fl_Image* Fl_Browser::icon(int line) const { \param[in] line The line whose icon is to be removed. */ void Fl_Browser::remove_icon(int line) { - if (line>0 && line<=lines) { - FL_BLINE* bl = find_line(line); - if (!bl->icon) return; - int dh = bl->icon->h()+2; // leave 2px above/below - bl->icon=0; - // update_full_height_ - dh -= item_height(bl); - if (dh>0) { - full_height_ -= dh; - redraw(); // if icon was larger, must redraw window - } else { - redraw_line(bl); // if icon same size or smaller, can just redraw line - } - } + icon(line,0); } // |
