+ int numregions = 0, numregions_v = 0;
+ //#repeat col/row colspan/rowspan contentwidth/contentheight width/height HSHRINK/VSHRINK numregions/numregions_v \
+ // maxwidth/maxheight cols/rows minwidth/minheight lp_h/lp lp_h/lp easy_width/easy_height regions/regions_v
+ if (cols > 1) do {
+ /* boolean easy_width = contentwidth >= width; */
+
+ // FIXME: numboxes^2, and damn ugly to boot
+ for(Box c = firstPackedChild(); c != null; c = c.nextPackedSibling()) {
+ int target = c.col;
+ for(boolean stop = false;;) {
+ for(int i=0; i<=numregions; i++) {
+ if (i == numregions) { regions[numregions++] = target; break; }
+ if (target == regions[i]) break;
+ if (target < regions[i]) { int tmp = target; target = regions[i]; regions[i] = tmp; }
+ }
+ if (stop) break;
+ stop = true;
+ target = min(cols, c.col+c.colspan);
+ }
+ }
+ if (regions[numregions-1] == cols) numregions--;
+ else regions[numregions] = cols;
+
+ /*
+ for(Box c = firstPackedChild(); easy_width && c != null; c = c.nextPackedSibling()) {
+ if (c.contentwidth == c.maxwidth) continue;
+ if (c.maxwidth == Integer.MAX_VALUE) continue;
+ easy_width = false;
+ }
+ if (easy_width) for(int i=0; i<cols; i++) {
+ easy_width = false;
+ boolean good = true;
+ for(Box c = firstPackedChild(); good && c != null; c = c.nextPackedSibling())
+ if (c.col <= i && c.col + c.colspan > i && c.maxwidth < Integer.MAX_VALUE)
+ good = false;
+ if (good) { easy_width = true; break; }
+ }
+ if (easy_width) break;
+ */
+ int nc = numregions * 2 + numkids + 1;