+ bool needScrollers;
+
+ bool NeedScrollers(int width, int height)
+ {
+ bool result = false;
+ if(bits.scrollable && bits.endButtons)
+ {
+ int y = margin, c;
+ bool r = bits.reverse;
+ int inc = bits.reverse ? -1 : 1;
+ Window flip = null;
+
+ for(c = r ? controls.count-1 : 0; c<controls.count && c>-1; c += inc)
+ {
+ Window child = controls[c];
+ if(flip && child == flip) break;
+ if(child.nonClient || !child.visible) continue;
+ if(direction == vertical)
+ y += child.size.h + gap;
+ else
+ y += child.size.w + gap;
+
+ // If this child is the flipper, we flip
+ if(flipper && !flip && child == flipper)
+ {
+ flip = child;
+ if(r) { r = false; inc = 1; c = -1; }
+ else { r = true; inc =-1; c = controls.count; }
+ y = margin;
+ }
+ }
+ result = (y > ((direction == horizontal) ? width : height));
+ }
+ return result;
+ }