Skip to content

Commit

Permalink
STR #1767: Adding "remove" function for the Fl_Check_Browser
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5978 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Matthias Melcher committed Nov 19, 2007
1 parent faf6126 commit 2217ab9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Fl_Check_Browser.cxx
Expand Up @@ -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;
Expand Down

0 comments on commit 2217ab9

Please sign in to comment.