Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with scrolling of XUL elements

2 views
Skip to first unread message

Thomas Benisch

unread,
May 3, 2006, 11:39:42 AM5/3/06
to
Hi,

I'm working on the Lightning calendar views and have a problem
concerning scrolling. Probably someone with more experience in XUL
can help me. A simplified layout of a view is shown below.

------------------------------------- ---
| main box | | |
| ----------- --------------------- | | |
| | spacer | column bar | | | v |
| | | -------- -------- | | | s |
| | | | col1 | col2 | | | | c |
| | | -------- -------- | | | r |
| ----------- --------------------- | | o |
| | row bar | content box | | | l |
| | ------- | -------- -------- | | | l |
| | | row1 | | | cont11 | cont12 | | | | b |
| | ------- | -------- -------- | | | a |
| | | row2 | | | cont21 | cont22 | | | | r |
| | ------- | -------- -------- | | | |
| --------------------------------- | | |
------------------------------------- ---
------------------------------------- ---
| hscrollbar | | |
------------------------------------- ---

This layout is basically a table with columns and rows. Each element
is made out of xul boxes. Due to the limited window size, not all
columns and rows can be displayed. Therefore by using the scrollbars
a contxy box can be scrolled into the visible area of the content box.
The column bar and the row bar should be always visible, but the
displayed coly or rowx boxes depend on the visible contxy boxes.
That means, if cont21 is visible, then the col1 box and the row2 box
should be visible and correctly aligned.

The first attempt was to use a xul scrollbox for the main box.
Although not all methods of the nsIScrollBoxObject are implemented
and some minor bugs, in principal a scrollbox works. But the
disadvantage is, that the column bar and the row bar are scrolled
out of the visible area.

The next attempt was to implement some kind of hand made scrolling.
The content of a box is scrolled by setting the css properties
margin-left and margin-top (A hint from a collegue of mine). The
scrollbars are drawn by using xul scrollbars.
The idea was to implement a generic scroll-container,
which consists of an outer xul box with style
"overflow: hidden; clip: rect(0px 0px 0px 0px);" and an inner xul box.
The visible size of the outer box can be obtained from boxObject.height
and boxObject.width. The virtual size of the inner box (which is typically
larger than the outer box) can also be obtained from the boxObject.
Now the problem is, that e.g. boxObject.height of the inner box gives
wrong values for some cases, e.g. if one of the children of the inner
box has the style "min-width: 1px; min-height: 1px" set.
Does anybody know, if this is a know bug or if the boxObject properties
are not relyable, if one of the parent boxes are clipped?

Another problem I have is to set the size of the scrollbar thumb.
As far as I found out, this should be done by setting the maxpos
and pageincrement attributes. In principal the size of the thumb
is dependent on those properties, but I have not found a way to
set the thumb size to a defined value, e.g. so that the thumb size
corresponds to pageincrement.

Any hints on the above mentioned problems are welcome.
Or probably someone has a better idea on how to implement scrolling
for the scenario mentioned above.

Thomas

Neil

unread,
May 3, 2006, 8:14:24 PM5/3/06
to
Thomas Benisch wrote:

> Another problem I have is to set the size of the scrollbar thumb. As
> far as I found out, this should be done by setting the maxpos and
> pageincrement attributes. In principal the size of the thumb is
> dependent on those properties, but I have not found a way to set the
> thumb size to a defined value, e.g. so that the thumb size corresponds
> to pageincrement.

The desired size of the thumb is equal to the slider size multiplied by
the pageincrement and divided by the sum of the maxpos and the
pageincrement. So for a vertical scrollbar that is 252 pixels high and
has a pageincrement of 10 and maxpos of 100 the slider will be 220
pixels and the thumb will be 20 pixels high, and as it happens each
curpos will correspond to two pixels.

--
Warning: May contain traces of nuts.

Thomas Benisch

unread,
May 4, 2006, 11:54:47 AM5/4/06
to
> The desired size of the thumb is equal to the slider size multiplied by
> the pageincrement and divided by the sum of the maxpos and the
> pageincrement. So for a vertical scrollbar that is 252 pixels high and
> has a pageincrement of 10 and maxpos of 100 the slider will be 220
> pixels and the thumb will be 20 pixels high, and as it happens each
> curpos will correspond to two pixels.

cool, that works,

thanks,

Thomas

0 new messages