Fixed missing item handling in Fl_Chekc_Browser (STR #3480).
This commit is contained in:
parent
2ce406ab42
commit
e06c09fa25
@ -145,6 +145,7 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2019
|
||||
Bug Fixes
|
||||
|
||||
- (add new items here)
|
||||
- Fixed missing item handling in Fl_Chekc_Browser (STR #3480).
|
||||
- Fixed Delete key in Fl_Input deleting entire widgets in Fluid (STR #2841).
|
||||
- Reorganized Fluid Template feature (STR #3336).
|
||||
- Updated Fluid documentation and image (STR #3328).
|
||||
|
@ -30,8 +30,9 @@
|
||||
lines that may be selected and/or checked by the user.
|
||||
*/
|
||||
class FL_EXPORT Fl_Check_Browser : public Fl_Browser_ {
|
||||
/* required routines for Fl_Browser_ subclass: */
|
||||
|
||||
protected:
|
||||
/* required routines for Fl_Browser_ subclass: */
|
||||
void *item_first() const;
|
||||
void *item_next(void *) const;
|
||||
void *item_prev(void *) const;
|
||||
@ -40,6 +41,10 @@ class FL_EXPORT Fl_Check_Browser : public Fl_Browser_ {
|
||||
void item_draw(void *, int, int, int, int) const;
|
||||
void item_select(void *, int);
|
||||
int item_selected(void *) const;
|
||||
const char *item_text(void *item) const /* override */;
|
||||
void *item_at(int index) const /* override */;
|
||||
void item_swap(int ia, int ib) /* override */;
|
||||
void item_swap(void *a, void *b) /* override */;
|
||||
|
||||
/* private data */
|
||||
|
||||
|
@ -101,6 +101,76 @@ int Fl_Check_Browser::item_height(void *) const {
|
||||
return textsize() + 2;
|
||||
}
|
||||
|
||||
const char *Fl_Check_Browser::item_text(void *item) const {
|
||||
cb_item *i = (cb_item *)item;
|
||||
return i->text;
|
||||
}
|
||||
|
||||
void *Fl_Check_Browser::item_at(int index) const { // note: index is 1-based
|
||||
if (index < 1 || index > nitems())
|
||||
return 0L;
|
||||
cb_item *item = (cb_item *)item_first();
|
||||
for (int i = 1; i < index; i++)
|
||||
item = (cb_item *)(item_next(item));
|
||||
return (void *)item;
|
||||
}
|
||||
|
||||
void Fl_Check_Browser::item_swap(int ia, int ib) {
|
||||
item_swap(item_at(ia), item_at(ib));
|
||||
}
|
||||
|
||||
void Fl_Check_Browser::item_swap(void *a, void *b) {
|
||||
cb_item *ia = (cb_item *)a;
|
||||
cb_item *ib = (cb_item *)b;
|
||||
|
||||
cb_item *a_next = ia->next;
|
||||
cb_item *a_prev = ia->prev;
|
||||
|
||||
cb_item *b_next = ib->next;
|
||||
cb_item *b_prev = ib->prev;
|
||||
|
||||
if (a_next == ib) { // p - a - b - n => p - b - a - n
|
||||
if (a_prev)
|
||||
a_prev->next = ib;
|
||||
if (b_next)
|
||||
b_next->prev = ia;
|
||||
ib->prev = a_prev;
|
||||
ib->next = ia;
|
||||
ia->prev = ib;
|
||||
ia->next = b_next;
|
||||
} else if (a_prev == ib) { // p - b - a - n => p - a - b - n
|
||||
if (b_prev)
|
||||
b_prev->next = ia;
|
||||
if (a_next)
|
||||
a_next->prev = ib;
|
||||
ia->prev = b_prev;
|
||||
ia->next = ib;
|
||||
ib->prev = ia;
|
||||
ib->next = a_next;
|
||||
} else { // x - a - y - b - z => x - b - y - a - z
|
||||
if (a_prev)
|
||||
a_prev->next = ib;
|
||||
if (a_next)
|
||||
a_next->prev = ib;
|
||||
ia->next = b_next;
|
||||
ia->prev = b_prev;
|
||||
|
||||
if (b_prev)
|
||||
b_prev->next = ia;
|
||||
if (b_next)
|
||||
b_next->prev = ia;
|
||||
ib->next = a_next;
|
||||
ib->prev = a_prev;
|
||||
}
|
||||
if (first == ia)
|
||||
first = ib;
|
||||
if (last == ia)
|
||||
last = ib;
|
||||
// invalidate item cache
|
||||
cached_item = -1;
|
||||
cache = 0L;
|
||||
}
|
||||
|
||||
#define CHECK_SIZE (textsize()-2)
|
||||
|
||||
int Fl_Check_Browser::item_width(void *v) const {
|
||||
|
Loading…
Reference in New Issue
Block a user