Scrolling in windows
and user objects
For scrolling purposes, PowerBuilder divides the window content into
100 lines and 100 columns. Lines, columns, and pages for scrolling do not
correlate with any visible aspect of the window (such as the viewable
area).
A line or a column is the amount scrolled by clicking a scroll bar
arrow. There are 100 lines and 100 columns in the control being scrolled,
regardless of the area occupied by the content of the window or user
object. To get to the end of the scroll bar, the user can click 100 times
on the scroll bar arrow.
A page is the amount scrolled by clicking in the scroll bar, not on
the scroll bar arrows.
Vertical versus horizontal
scrolling
The procedures in the following sections define vertical scrolling,
determined by the UnitsPerLine and LinesPerPage properties, but the same
formulas apply to horizontal scrolling, determined by the UnitsPerColumn
and ColumnsPerPage properties.
Relating scrolling to height of
content
If you want the bottommost content in the window to be visible when
the user reaches the end of the scroll bar, you need to set the value of
the control’s UnitsPerLine property so that 100 lines cover the entire
contents.
To determine the value for UnitsPerLine:
-
Resize the window to include all the contents.
-
Look at the value of the Height option on the Position tab page
of the window’s Properties view.The height is shown in PowerBuilder units (PBUs).
-
Divide 75% of the value of the Height option by 100 to get the
number of PBUs each line should include:1UnitsPerLine = height * .75 / 100Using 75% of the total height in this calculation keeps the end
of the contents visible when the scroll bar reaches the end, instead
of scrolling just out of sight.
Relating scrolling to page
size
When the user clicks in the scroll bar, not on the scroll bar
arrows, the control scrolls by a page. The page size is calculated using
this formula:
|
1 |
pagesize = LinesPerPage * UnitsPerLine |
Therefore, you can use the LinesPerPage property in conjunction with
the UnitsPerLine property to set the page size for scrolling.
To determine the value for LinesPerPage
-
Calculate the value of the UnitsPerLine property, as shown
above. -
Size the window to its desired final size.
-
Determine the height of the visible window area by looking at
the value of the Height option on the Position tab page of the
window’s Properties view. -
Decide how much of the window you want to have scroll every time
the scroll bar is clicked. This will give you the page size in
PBUs.For example, if the visible window area height is 1200 PBUs and
you want 1/4 of the window to scroll with each click, then the page
size should be 300 PBUs. -
Calculate the value of the LinesPerPage property.
For example:
|
1 |
LinesPerPage = 300 / UnitsPerLine |
Scrolling using a fixed number of
clicks
Alternatively, if you want to let the user get to the bottom of the
content in a given number of clicks, regardless of the visible window
area, set LinesPerPage using this formula:
|
1 |
LinesPerPage = 100 / number of clicks |