From 2217ab964b4e3d9a80c331cf604a3c30caf2528d Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Mon, 19 Nov 2007 15:46:03 +0000 Subject: [PATCH] STR #1767: Adding "remove" function for the Fl_Check_Browser git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5978 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Check_Browser.cxx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Fl_Check_Browser.cxx b/src/Fl_Check_Browser.cxx index aada7b4f9..799d09cbb 100644 --- a/src/Fl_Check_Browser.cxx +++ b/src/Fl_Check_Browser.cxx @@ -193,6 +193,40 @@ int Fl_Check_Browser::add(char *s, int b) { 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) { + // tell the Browser_ what we will do + deleting(p); + + // fix checked count + if(p->checked) + --nchecked_; + + // remove the node + if (p->prev) + p->prev->next = p->next; + else + first = p->next; + if (p->next) + p->next->prev = p->prev; + else + last = p->prev; + + free(p->text); + free(p); + + --nitems_; + cached_item = -1; + } + + return (nitems_); +} + void Fl_Check_Browser::clear() { cb_item *p = first; cb_item *next;