2 * listbox.c - box, a container
4 * Written by Joshua Davis
5 * Copyright (c) Josh Davis 2008
16 void tx_box_adjust(TXObj
*obj
) {
17 int dyn
, sta
, size
, start
, left
;
20 dyn
= (obj
->flags
& TX_BOX_VERT
) ? obj
->h
: obj
->w
;
21 sta
= (obj
->flags
& TX_BOX_VERT
) ? obj
->w
: obj
->h
;
22 start
= (obj
->flags
& TX_BOX_VERT
) ? obj
->y
: obj
->x
;
25 list_for_each_entry(entry
, &box
->node
, node
) {
26 size
= (entry
->size_cb
) ? entry
->size_cb(entry
, sta
, dyn
) : dyn
/ left
;
27 if (obj
->flags
& TX_BOX_VERT
) tx_obj_size_set(entry
, obj
->x
, start
, obj
->w
, size
);
28 if (obj
->flags
& TX_BOX_HORZ
) tx_obj_size_set(entry
, start
, obj
->y
, size
, obj
->h
);
29 //tx_obj_resize(entry);
36 void tx_box_add(TXObj
*obj
, TXObj
*add
) {
39 list_add_tail(&add
->node
, &box
->node
);
43 int tx_box_draw(TXObj
*obj
) {
47 list_for_each_entry(entry
, &box
->node
, node
) {
48 entry
->draw_cb(entry
);
54 void tx_box_rsze(TXObj
*obj
) {
58 void tx_box_init(TXObj
*obj
) {
59 obj
->extend
= calloc(1, sizeof(TXBox
));
61 obj
->draw_cb
= tx_box_draw
;
62 obj
->rsze_cb
= tx_box_rsze
;
63 list_init(&box
->node
);