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
This commit is contained in:
Matthias Melcher 2007-11-19 15:46:03 +00:00
parent faf6126897
commit 2217ab964b
1 changed files with 34 additions and 0 deletions

View File

@ -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;