+void init_rendering(void *obj, int pos)
+{
+ Area *a = (Area*)obj;
+
+ // initialize fixed position/size
+ GSList *l;
+ for (l = a->list; l ; l = l->next) {
+ Area *child = ((Area*)l->data);
+ if (panel_horizontal) {
+ child->posy = pos + a->bg->border.width + a->paddingy;
+ child->height = a->height - (2 * (a->bg->border.width + a->paddingy));
+ init_rendering(child, child->posy);
+ }
+ else {
+ child->posx = pos + a->bg->border.width + a->paddingy;
+ child->width = a->width - (2 * (a->bg->border.width + a->paddingy));
+ init_rendering(child, child->posx);
+ }
+ }
+}
+
+
+void rendering(void *obj)
+{
+ Panel *panel = (Panel*)obj;
+
+ size_by_content(&panel->area);
+ size_by_layout(&panel->area, 0, 0);
+
+ refresh(&panel->area);
+}
+
+
+void size_by_content (Area *a)
+{
+ // don't resize hiden objects
+ if (!a->on_screen) return;
+
+ // children node are resized before its parent
+ GSList *l;
+ for (l = a->list; l ; l = l->next)
+ size_by_content(l->data);
+
+ // calculate area's size
+ if (a->resize && a->size_mode == SIZE_BY_CONTENT) {
+ a->resize = 0;
+
+ if (a->_resize) {
+ if (a->_resize(a)) {
+ // 'size' changed => 'resize = 1' on the parent and redraw object
+ ((Area*)a->parent)->resize = 1;
+ }
+ a->redraw = 1;
+ }
+ }
+}
+
+
+void size_by_layout (Area *a, int pos, int level)
+{
+ // don't resize hiden objects
+ if (!a->on_screen) return;
+
+ // parent node is resized before its children
+ // calculate area's size
+ GSList *l;
+ if (a->resize && a->size_mode == SIZE_BY_LAYOUT) {
+ a->resize = 0;
+
+ if (a->_resize) {
+ if (a->_resize(a)) {
+ // if 'size' changed then 'resize = 1' on childs with SIZE_BY_LAYOUT
+ for (l = a->list; l ; l = l->next) {
+ if (((Area*)l->data)->size_mode == SIZE_BY_LAYOUT)
+ ((Area*)l->data)->resize = 1;
+ }
+ }
+ }
+ }
+
+ // update position of childs
+ pos += a->paddingxlr + a->bg->border.width;
+ int i=0;
+ for (l = a->list; l ; l = l->next) {
+ Area *child = ((Area*)l->data);
+ if (!child->on_screen) continue;
+ i++;
+
+ if (panel_horizontal) {
+ if (pos != child->posx) {
+ // pos changed => redraw
+ child->posx = pos;
+ child->redraw = 1;
+ }
+ }
+ else {
+ if (pos != child->posy) {
+ // pos changed => redraw
+ child->posy = pos;
+ child->redraw = 1;
+ }
+ }
+ //printf("level %d, object %d, pos %d\n", level, i, pos);
+
+ size_by_layout(child, pos, level+1);
+
+ if (panel_horizontal)
+ pos += child->width + a->paddingx;
+ else
+ pos += child->height + a->paddingx;
+ }
+}