mirror of
https://github.com/fltk/fltk.git
synced 2026-05-31 22:04:26 +08:00
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
This commit is contained in:
+21
-27
@@ -864,20 +864,27 @@ void Fl_Browser::swap(int a, int b) {
|
|||||||
If NULL, any previous icon is removed.
|
If NULL, any previous icon is removed.
|
||||||
*/
|
*/
|
||||||
void Fl_Browser::icon(int line, Fl_Image* icon) {
|
void Fl_Browser::icon(int line, Fl_Image* icon) {
|
||||||
if (icon==0) {
|
|
||||||
remove_icon(line);
|
if (line<1 || line > lines) return;
|
||||||
} else if (line>0 && line<=lines) {
|
|
||||||
// Update full_height_
|
FL_BLINE* bl = find_line(line);
|
||||||
FL_BLINE* l = find_line(line);
|
|
||||||
int dh = icon->h() - item_height(l) + 2; // leave 2px above/below
|
int old_h = bl->icon ? bl->icon->h()+2 : 0; // init with *old* icon height
|
||||||
l->icon = icon; // define icon AFTER item_height() check
|
bl->icon = 0; // remove icon, if any
|
||||||
if (dh>0) {
|
int th = item_height(bl); // height of text only
|
||||||
full_height_ += dh;
|
int new_h = icon ? icon->h()+2 : 0; // init with *new* icon height
|
||||||
redraw(); // icon larger than item? must redraw widget
|
if (th > old_h) old_h = th;
|
||||||
} else {
|
if (th > new_h) new_h = th;
|
||||||
redraw_line(l); // icon same or smaller? can redraw just this line
|
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.
|
\param[in] line The line whose icon is to be removed.
|
||||||
*/
|
*/
|
||||||
void Fl_Browser::remove_icon(int line) {
|
void Fl_Browser::remove_icon(int line) {
|
||||||
if (line>0 && line<=lines) {
|
icon(line,0);
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user