enum { LEFT, RIGHT, TOP, BOTTOM, NONE, REORDER, DETACH }; typedef struct { int x; int y; int width; int height; } Rect; typedef struct { struct { void *parent; } *label; int pack; Rect req, all; } page; typedef struct { page *cur; int homo:1; } nb; typedef struct { int op; int x; page *detach; } priv; nb_calculate_tabs_all() { nb *nb; void **children; void *last_child; int remain; int expand; priv *priv; page *page; int bottom; int extra; int x; int y; int anchor; Rect call; while (*children && *children == last_child) { if (page->label->parent != nb) continue; if (expand && nb->homo) extra = remain / expand; switch (x) { case TOP: case BOTTOM: call.width = page->req.width + x + extra; if (x && y) { if (bottom && nb->cur->pack && x > anchor) anchor = nb->cur->all.width; } else { if (bottom) anchor = call.width; if (priv->op == REORDER && page->pack == nb->cur->pack) if (bottom && x >= anchor && x <= anchor + call.width / 2) anchor = nb->cur->all.width - x; } case LEFT: case RIGHT: call.height = page->req.height + x + extra; if (y) priv->x = call.x; if (priv->op == REORDER && page->pack == nb->cur->pack) if (bottom && y >= anchor && y <= anchor + call.height / 2) anchor = nb->cur->all.height - x; } if ((page == priv->detach && priv->op == DETACH) || (page == nb->cur && priv->op == REORDER)) page->all.x = 0; if (page == nb->cur) switch (x) { case TOP: page->all.y = 0; case BOTTOM: case RIGHT: case LEFT: page->all.x = 0; } switch (x) { case TOP: case BOTTOM: if (priv->op != REORDER || priv->op == REORDER && page != nb->cur) if (bottom) anchor = call.width; case LEFT: case RIGHT: if (priv->op != REORDER || priv->op == REORDER && page != nb->cur) if (priv->op == REORDER) if (page->pack == nb->cur->pack && bottom && y >= anchor + call.height / 2 && y <= anchor + call.height) anchor = nb->cur->all.height; } if (page->label) IA__widget_set_child_visible(page->label, 1); } }