+ if (a->on_changed) {
+ // pos/size changed
+ a->redraw = 1;
+ if (a->_on_change_layout)
+ a->_on_change_layout (a);
+ }
+}
+
+
+void refresh (Area *a)
+{
+ // don't draw and resize hide objects
+ if (!a->on_screen) return;
+
+ // don't draw transparent objects (without foreground and without background)
+ if (a->redraw) {
+ a->redraw = 0;
+ // force redraw of child
+ //GSList *l;
+ //for (l = a->list ; l ; l = l->next)
+ //((Area*)l->data)->redraw = 1;
+
+ //printf("draw area posx %d, width %d\n", a->posx, a->width);
+ draw(a);
+ }
+
+ // draw current Area
+ if (a->pix == 0) printf("empty area posx %d, width %d\n", a->posx, a->width);
+ XCopyArea (server.dsp, a->pix, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
+
+ // and then refresh child object
+ GSList *l;
+ for (l = a->list; l ; l = l->next)
+ refresh(l->data);
+}
+
+
+int resize_by_layout(void *obj, int maximum_size)
+{
+ Area *child, *a = (Area*)obj;
+ int size, nb_by_content=0, nb_by_layout=0;
+
+ if (panel_horizontal) {
+ // detect free size for SIZE_BY_LAYOUT's Area
+ size = a->width - (2 * (a->paddingxlr + a->bg->border.width));
+ GSList *l;
+ for (l = a->list ; l ; l = l->next) {
+ child = (Area*)l->data;
+ if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) {
+ size -= child->width;
+ nb_by_content++;
+ }
+ if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT)
+ nb_by_layout++;
+ }
+ //printf(" resize_by_layout Deb %d, %d\n", nb_by_content, nb_by_layout);
+ if (nb_by_content+nb_by_layout)
+ size -= ((nb_by_content+nb_by_layout-1) * a->paddingx);
+
+ int width=0, modulo=0, old_width;
+ if (nb_by_layout) {
+ width = size / nb_by_layout;
+ modulo = size % nb_by_layout;
+ if (width > maximum_size && maximum_size != 0) {
+ width = maximum_size;
+ modulo = 0;
+ }
+ }
+
+ // resize SIZE_BY_LAYOUT objects
+ for (l = a->list ; l ; l = l->next) {
+ child = (Area*)l->data;
+ if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) {
+ old_width = child->width;
+ child->width = width;
+ if (modulo) {
+ child->width++;
+ modulo--;
+ }
+ if (child->width != old_width)
+ child->on_changed = 1;
+ }
+ }
+ }
+ else {
+ // detect free size for SIZE_BY_LAYOUT's Area
+ size = a->height - (2 * (a->paddingxlr + a->bg->border.width));
+ GSList *l;
+ for (l = a->list ; l ; l = l->next) {
+ child = (Area*)l->data;
+ if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) {
+ size -= child->height;
+ nb_by_content++;
+ }
+ if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT)
+ nb_by_layout++;
+ }
+ if (nb_by_content+nb_by_layout)
+ size -= ((nb_by_content+nb_by_layout-1) * a->paddingx);
+
+ int height=0, modulo=0, old_height;
+ if (nb_by_layout) {
+ height = size / nb_by_layout;
+ modulo = size % nb_by_layout;
+ if (height > maximum_size && maximum_size != 0) {
+ height = maximum_size;
+ modulo = 0;
+ }
+ }
+
+ // resize SIZE_BY_LAYOUT objects
+ for (l = a->list ; l ; l = l->next) {
+ child = (Area*)l->data;
+ if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) {
+ old_height = child->height;
+ child->height = height;
+ if (modulo) {
+ child->height++;
+ modulo--;
+ }
+ if (child->height != old_height)
+ child->on_changed = 1;
+ }
+ }
+ }
+ return 0;
+}
+
+
+void set_redraw (Area *a)
+{
+ a->redraw = 1;
+
+ GSList *l;
+ for (l = a->list ; l ; l = l->next)
+ set_redraw(l->data);
+}
+
+void hide(Area *a)
+{
+ Area *parent = (Area*)a->parent;
+
+ a->on_screen = 0;
+ parent->resize = 1;
+ if (panel_horizontal)
+ a->width = 0;
+ else
+ a->height = 0;
+}
+
+void show(Area *a)
+{
+ Area *parent = (Area*)a->parent;
+
+ a->on_screen = 1;
+ parent->resize = 1;
+ a->resize = 1;
+}
+
+void draw (Area *a)
+{
+ if (a->pix) XFreePixmap (server.dsp, a->pix);
+ a->pix = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth);
+
+ // add layer of root pixmap (or clear pixmap if real_transparency==true)
+ if (server.real_transparency)
+ clear_pixmap(a->pix, 0 ,0, a->width, a->height);
+ XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, a->pix, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
+
+ cairo_surface_t *cs;
+ cairo_t *c;
+
+ cs = cairo_xlib_surface_create (server.dsp, a->pix, server.visual, a->width, a->height);
+ c = cairo_create (cs);
+
+ draw_background (a, c);
+
+ if (a->_draw_foreground)
+ a->_draw_foreground(a, c);
+
+ cairo_destroy (c);
+ cairo_surface_destroy (cs);