DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New] Link: http://www.fltk.org/str.php?L1767 Version: 2.0-feature Currently, Fl_Check_Browser does not provide a mechanism to remove an arbitrary line. This is a feature request for a remove method to be added to the Fl_Check_Browser class. A remove method would add symmetry to the class (i.e. with add()) and would also allow for the contents of the Fl_Check_Browser to be fully dynamic. To facilitate the addition of this feature, I am including two diff output (diff -u) for a proposed implementation. These were generated against fltk-1.1.x-r5940. Thank you. Alvin -------- 8<--------------------- --- Fl_Check_Browser-5940.H 2006-04-20 00:53:41.000000000 -0300 +++ Fl_Check_Browser.H 2007-08-13 10:45:07.000000000 -0300 @@ -78,6 +78,8 @@ int add(const char *s) { return add((char *)s); } int add(const char *s, int b) { return add((char *)s, b); } + int remove(int item); // delete an item. Returns nitems() + void clear(); // delete all items int nitems() const { return nitems_; } int nchecked() const { return nchecked_; } -------- 8<--------------------- --- Fl_Check_Browser-5940.cxx 2006-06-09 13:16:34.000000000 -0300 +++ Fl_Check_Browser.cxx 2007-08-13 10:45:02.000000000 -0300 @@ -193,6 +193,47 @@ return (nitems_); } +int Fl_Check_Browser::remove(int item) { + cb_item *p = find_item(item); + cb_item *prev; + cb_item *next; + + // line at item exists + if(p) { + // fix checked count + if(p->checked) + --nchecked_; + + // remove the node + if(p == first) { + first = p->next; + + if(first) { + first->prev = 0; + } else { + last = 0; + } + } else if(p == last) { + last = p->prev; + last->next = 0; + } else { + prev = p->prev; + next = p->next; + + prev->next = next; + next->prev = prev; + } + + free(p->text); + free(p); + + --nitems_; + cached_item = -1; + } + + return (nitems_); +} + void Fl_Check_Browser::clear() { cb_item *p = first; cb_item *next; -------------->8------------------------ Link: http://www.fltk.org/str.php?L1767 Version: 2.0-feature _______________________________________________ fltk-dev mailing list fltk-dev@easysw.com http://lists.easysw.com/mailman/listinfo/fltk-dev