DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L1895
Version: 1.2-current
Link: http://www.fltk.org/str.php?L1895
Version: 1.2-current
--- FL/Fl_Scroll.H.original 2007-01-18 15:23:24.000000000 -0400
+++ FL/Fl_Scroll.H 2008-03-13 08:44:05.000000000 -0300
@@ -43,6 +43,7 @@
protected:
+ void init_scrollbars();
void bbox(int&,int&,int&,int&);
void draw();
--- src/Fl_Scroll.cxx.original 2006-11-16 19:17:13.000000000 -0400
+++ src/Fl_Scroll.cxx 2008-03-13 12:03:31.000000000 -0300
@@ -107,6 +107,77 @@
}
}
+void Fl_Scroll::init_scrollbars() {
+ // Need to fix scrollbar order.
+ // Shouldn't this be done in Fl_Scroll::end() and Fl_Scroll::add()???
+ fix_scrollbar_order();
+ int X,Y,W,H; bbox(X,Y,W,H);
+
+ // accumulate bounding box of children:
+ int l = X; int r = X; int t = Y; int b = Y;
+ Fl_Widget*const* a = array();
+ for (int i=children()-2; i--;) {
+ Fl_Object* o = *a++;
+ if (o->x() < l) l = o->x();
+ if (o->y() < t) t = o->y();
+ if (o->x()+o->w() > r) r = o->x()+o->w();
+ if (o->y()+o->h() > b) b = o->y()+o->h();
+ }
+
+ // turn the scrollbars on and off as necessary:
+ // See if children would fit if we had no scrollbars...
+ X = x()+Fl::box_dx(box());
+ Y = y()+Fl::box_dy(box());
+ W = w()-Fl::box_dw(box());
+ H = h()-Fl::box_dh(box());
+ int vneeded = 0;
+ int hneeded = 0;
+ if (type() & VERTICAL) {
+ if ((type() & ALWAYS_ON) || t < Y || b > Y+H) {
+ vneeded = 1;
+ W -= scrollbar.w();
+ if (scrollbar.align() & FL_ALIGN_LEFT) X += scrollbar.w();
+ }
+ }
+ if (type() & HORIZONTAL) {
+ if ((type() & ALWAYS_ON) || l < X || r > X+W) {
+ hneeded = 1;
+ H -= hscrollbar.h();
+ if (scrollbar.align() & FL_ALIGN_TOP) Y += hscrollbar.h();
+ // recheck vertical since we added a horizontal scrollbar
+ if (!vneeded && (type() & VERTICAL)) {
+ if ((type() & ALWAYS_ON) || t < Y || b > Y+H) {
+ vneeded = 1;
+ W -= scrollbar.w();
+ if (scrollbar.align() & FL_ALIGN_LEFT) X += scrollbar.w();
+ }
+ }
+ }
+ }
+ // Now that we know what's needed, make it so.
+ if (vneeded && !scrollbar.visible()) {
+ scrollbar.set_visible();
+ }
+ else if (!vneeded && scrollbar.visible()) {
+ scrollbar.clear_visible();
+ }
+ if (hneeded && !hscrollbar.visible()) {
+ hscrollbar.set_visible();
+ }
+ else if (!hneeded && hscrollbar.visible()) {
+ hscrollbar.clear_visible();
+ }
+
+ scrollbar.resize(scrollbar.align()&FL_ALIGN_LEFT ? X-scrollbar.w() : X+W,
+ Y, scrollbar.w(), H);
+ scrollbar.value(oldy = yposition_ = (Y-t), H, 0, b-t);
+
+ hscrollbar.resize(X,
+ scrollbar.align()&FL_ALIGN_TOP ? Y-hscrollbar.h() : Y+H,
+ W, hscrollbar.h());
+ hscrollbar.value(oldx = xposition_ = (X-l), W, 0, r-l);
+}
+
void Fl_Scroll::draw() {
fix_scrollbar_order();
int X,Y,W,H; bbox(X,Y,W,H);
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs