4 * Copyright (c) Tuomo Valkonen 1999-2001.
5 * See the included file LICENSE for details.
18 IMPLOBJ(WThing
, WObj
, NULL
)
24 static void do_destroy_thing(WThing
*t
)
30 /* Make sure that any command sequence doesn't try to
31 * access this thing anymore.
33 query_check_function_thing(t
);
38 CALL_FUNTAB(p
, WThingFuntab
, remove_child_fn
)(p
, t
);
44 CALL_FUNTAB(t
, WThingFuntab
, deinit_fn
)(t
);
48 if(wglobal
.focus_next
==t
)
49 wglobal
.focus_next
=NULL
;
50 if(wglobal
.grab_holder
==t
)
51 wglobal
.grab_holder
=NULL
;
52 if(wglobal
.previous
==t
)
57 void destroy_thing(WThing
*t
)
68 if(!(p
->flags
&WTHING_DESTREMPTY
) || p
->t_children
!=NULL
)
76 void destroy_subthings(WThing
*parent
)
78 WThing
*t
, *prev
=NULL
;
80 assert(!(parent
->flags
&WTHING_SUBDEST
));
82 parent
->flags
|=WTHING_SUBDEST
;
84 /* destroy children */
94 parent
->flags
&=~WTHING_SUBDEST
;
104 void link_thing(WThing
*parent
, WThing
*thing
)
106 LINK_ITEM(parent
->t_children
, thing
, t_next
, t_prev
);
107 thing
->t_parent
=parent
;
111 /*void link_thing_before(WThing *before, WThing *thing)
113 WThing *parent=before->t_parent;
114 LINK_ITEM_BEFORE(parent->t_children, before, thing, t_next, t_prev);
115 thing->t_parent=parent;
119 void link_thing_after(WThing
*after
, WThing
*thing
)
121 WThing
*parent
=after
->t_parent
;
122 LINK_ITEM_AFTER(parent
->t_children
, after
, thing
, t_next
, t_prev
);
123 thing
->t_parent
=parent
;
127 void unlink_thing(WThing
*thing
)
129 WThing
*parent
=thing
->t_parent
;
134 UNLINK_ITEM(parent
->t_children
, thing
, t_next
, t_prev
);
135 thing
->t_parent
=NULL
;
145 static WThing
*get_next_thing(WThing
*first
, const WObjDescr
*descr
)
148 if(wobj_is((WObj
*)first
, descr
))
157 static WThing
*get_prev_thing(WThing
*first
, const WObjDescr
*descr
)
164 if(first
->t_next
==NULL
)
166 if(wobj_is((WObj
*)first
, descr
))
174 WThing
*next_thing(WThing
*first
, const WObjDescr
*descr
)
179 return get_next_thing(first
->t_next
, descr
);
183 WThing
*prev_thing(WThing
*first
, const WObjDescr
*descr
)
188 return get_prev_thing(first
, descr
);
192 WThing
*first_thing(WThing
*parent
, const WObjDescr
*descr
)
197 return get_next_thing(parent
->t_children
, descr
);
201 WThing
*last_thing(WThing
*parent
, const WObjDescr
*descr
)
208 p
=parent
->t_children
;
215 if(wobj_is((WObj
*)p
, descr
))
218 return get_prev_thing(p
, descr
);
222 WThing
*find_parent(WThing
*p
, const WObjDescr
*descr
)
225 if(wobj_is((WObj
*)p
, descr
))
234 WThing
*nth_thing(WThing
*parent
, int n
, const WObjDescr
*descr
)
241 p
=first_thing(parent
, descr
);
243 while(n
-- && p
!=NULL
)
244 p
=next_thing(p
, descr
);