I've managed to get native scrollbars working with a horrible hack, but that's
really just
due to my lack of understanding.
I need help with the following (additions/corrections):
1. areawin->width/height - that's the size of the viewport in GUI (X11,
whatnot) units
2. [top]object->bbox.width/height - size of a bounding box enclosing all
elements, in workspace units
3. areawin->pcorner - ??? (what does it point to, and in what units)
4. areawin->v/hscale - ratio of what to what?
5. [top]object->bbox.lowerleft - is "left" towards smaller x, and "lower"
towards smaller y??
Thanks, Kuba
PS. The hack is as follows, done in drawhbar/drawvbar (the repaint handler for
the scrollbars):
First your original code calculating scrollbar position:
float frac;
long rleft, rright, rmid;
if (topobject->bbox.width > 0) {
frac = (float) areawin->width / (float) topobject->bbox.width;
rleft = (long)(frac * (float)(areawin->pcorner.x
- topobject->bbox.lowerleft.x));
rright = rleft + (long)(frac * (float)areawin->width / areawin->vscale);
}
else {
rleft = 0L;
rright = (long)areawin->width;
}
rmid = (rright + rleft) >> 1;
if (rleft < 0) rleft = 0;
if (rright > areawin->width) rright = areawin->width;
Then I approximate that with QScrollBar's min/max/pageSize/value settings:
const int pageStep = rright - rleft;
const int min = 0;
const int max = areawin->width - pageStep;
const int val = rleft;
And if anything is different, I update it:
if (pageStep != hbar->pageStep()) hbar->setPageStep(pageStep);
if (min != hbar->minimum()) hbar->setMinimum(min);
if (max != hbar->maximum()) hbar->setMaximum(max);
if (abs(val - hbar->value())>1) hbar->setValue(val);
This forces the QScrollBar to schedule updating itself as soon as control
returns
to the event loop, which will call this code *again*, but then as nothing has
further
changed, it won't be called again until something changes.
Finally, I call original QScrollBar painting code.
panhbar/panvbar rely on similar hack, too (sigh).
_______________________________________________
Xcircuit-dev mailing list
[email protected]
http://www.opencircuitdesign.com/mailman/listinfo/xcircuit-dev