+const char *
+cl_base::set_name(const char *new_name, const char *def_name)
+{
+ char *def;
+
+ if (!def_name ||
+ *def_name == '\0')
+ def= strdup("");
+ else
+ def= strdup(def_name);
+ if (name)
+ free(name);
+ if (!new_name)
+ name= def;
+ else if (*new_name)
+ name= strdup(new_name);
+ else
+ name= def;
+ return(name);
+}
+
+bool
+cl_base::is_named(const char *the_name)
+{
+ if (!name ||
+ !*name ||
+ !the_name ||
+ !*the_name)
+ return(DD_FALSE);
+ return(strcmp(name, the_name) == 0);
+}
+
+bool
+cl_base::is_inamed(const char *the_name)
+{
+ if (!name ||
+ !*name ||
+ !the_name ||
+ !*the_name)
+ return(DD_FALSE);
+ return(strcasecmp(name, the_name) == 0);
+}
+
+
+int
+cl_base::nuof_children(void)
+{
+ if (!children)
+ return(0);
+ return(children->count);
+}
+
+void
+cl_base::add_child(class cl_base *child)
+{
+ if (!children)
+ {
+ char *s;
+ s= (char*)malloc(strlen(get_name("?"))+100);
+ sprintf(s, "childs of %s", get_name("?"));
+ children= new cl_list(1, 1, s);
+ free(s);
+ }
+ if (child)
+ {
+ children->add(child);
+ child->parent= this;
+ }
+}
+
+void
+cl_base::remove_child(class cl_base *child)
+{
+ if (child &&
+ children)
+ {
+ child->unlink();
+ children->disconn(child);
+ }
+}
+
+void
+cl_base::remove_from_chain(void)
+{
+ if (parent)
+ parent->remove_child(this);
+}
+
+void
+cl_base::unlink(void)
+{
+ parent= 0;
+}
+
+class cl_base *
+cl_base::first_child(void)
+{
+ if (!children ||
+ children->count == 0)
+ return(0);
+ return(dynamic_cast<class cl_base *>(children->object_at(0)));
+}
+
+class cl_base *
+cl_base::next_child(class cl_base *child)
+{
+ if (!children ||
+ !child)
+ return(0);
+ return((class cl_base *)(children->next(child)));
+}
+
+
+bool
+cl_base::handle_event(class cl_event &event)
+{
+ return(pass_event_down(event));
+}
+
+bool
+cl_base::pass_event_down(class cl_event &event)
+{
+ int i;
+ if (!children)
+ return(DD_FALSE);
+ for (i= 0; i < children->count; i++)
+ {
+ class cl_base *child=
+ dynamic_cast<class cl_base *>(children->object_at(i));
+ if (child)
+ {
+ child->handle_event(event);
+ if (event.is_handled())
+ return(DD_TRUE);
+ }
+ }
+ return(DD_FALSE);
+}
+
+
+/*
+ * Event
+ */
+
+cl_event::cl_event(enum event what_event):
+ cl_base()
+{
+ handled= DD_FALSE;
+ what= what_event;
+}
+
+cl_event::~cl_event(void)
+{
+}
+