Difference between revisions of "Documentation/DevGuide/Basic/HorizontalVertical Scroll Bar"
OOoWikiBot (Talk | contribs) m (Robot: Changing Category:Documentation/Developers Guide/Basic and Dialogs) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
|NextPage=Documentation/DevGuide/Basic/Group Box | |NextPage=Documentation/DevGuide/Basic/Group Box | ||
}} | }} | ||
− | {{DISPLAYTITLE:Horizontal/Vertical Scroll Bar}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Basic/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Horizontal/Vertical Scroll Bar}} | ||
If the visible area in a dialog is smaller than the displayable content, the scroll bar control <idl>com.sun.star.awt.UnoControlScrollBar</idl> provides navigation through the content by scrolling horizontally or vertically. In addition, the scroll bar control is used to provide scrolling to controls that do not have a built-in scroll bar. | If the visible area in a dialog is smaller than the displayable content, the scroll bar control <idl>com.sun.star.awt.UnoControlScrollBar</idl> provides navigation through the content by scrolling horizontally or vertically. In addition, the scroll bar control is used to provide scrolling to controls that do not have a built-in scroll bar. | ||
The orientation of a scroll bar is specified by the <code>Orientation</code> property and can be horizontal or vertical. A scroll bar has a thumb (scroll box) that the user can drag with the mouse to any position along the scroll bar. The position of the thumb is controlled by the <code>ScrollValue</code> property. For a horizontal scroll bar, the left-most position corresponds to the minimum scroll value of 0 and the right-most position to the maximum scroll value defined by the <code>ScrollValueMax</code> property. A scroll bar also has arrows at its end that when clicked or held, incrementally moves the thumb along the scroll bar to increase or decrease the scroll value. The change of the scroll value per mouse click on an arrow is specified by the <code>LineIncrement</code> property. When clicking in a scroll bar in the region between the thumb and the arrows, the scroll value increases or decreases by the value set for the <code>BlockIncrement</code> property. The thumb position represents the portion of the displayable content that is currently visible in a dialog. The visible size of the thumb is set by the <code>VisibleSize</code> property and represents the percentage of the currently visible content and the total displayable content. | The orientation of a scroll bar is specified by the <code>Orientation</code> property and can be horizontal or vertical. A scroll bar has a thumb (scroll box) that the user can drag with the mouse to any position along the scroll bar. The position of the thumb is controlled by the <code>ScrollValue</code> property. For a horizontal scroll bar, the left-most position corresponds to the minimum scroll value of 0 and the right-most position to the maximum scroll value defined by the <code>ScrollValueMax</code> property. A scroll bar also has arrows at its end that when clicked or held, incrementally moves the thumb along the scroll bar to increase or decrease the scroll value. The change of the scroll value per mouse click on an arrow is specified by the <code>LineIncrement</code> property. When clicking in a scroll bar in the region between the thumb and the arrows, the scroll value increases or decreases by the value set for the <code>BlockIncrement</code> property. The thumb position represents the portion of the displayable content that is currently visible in a dialog. The visible size of the thumb is set by the <code>VisibleSize</code> property and represents the percentage of the currently visible content and the total displayable content. | ||
− | + | <syntaxhighlight lang="oobas"> | |
oScrollBarModel = oDialog.Model.ScrollBar1 | oScrollBarModel = oDialog.Model.ScrollBar1 | ||
oScrollBarModel.ScrollValueMax = 100 | oScrollBarModel.ScrollValueMax = 100 | ||
Line 16: | Line 17: | ||
oScrollBarModel.LineIncrement = 5 | oScrollBarModel.LineIncrement = 5 | ||
oScrollBarModel.VisibleSize = 20 | oScrollBarModel.VisibleSize = 20 | ||
− | + | </syntaxhighlight> | |
The scroll bar control uses the adjustment event <idl>com.sun.star.awt.AdjustmentEvent</idl> to monitor the movement of the thumb along the scroll bar. In an event handler for adjustment events the developer may change the position of the visible content on the dialog as a function of the <code>ScrollValue</code> property. In the following example, the size of a label field exceeds the size of the dialog. Each time the user clicks on the scrollbar, the macro <code>AdjustmentHandler()</code> is called and the position of the label field in the dialog is changed according to the scroll value. | The scroll bar control uses the adjustment event <idl>com.sun.star.awt.AdjustmentEvent</idl> to monitor the movement of the thumb along the scroll bar. In an event handler for adjustment events the developer may change the position of the visible content on the dialog as a function of the <code>ScrollValue</code> property. In the following example, the size of a label field exceeds the size of the dialog. Each time the user clicks on the scrollbar, the macro <code>AdjustmentHandler()</code> is called and the position of the label field in the dialog is changed according to the scroll value. | ||
<!--[SOURCE:BasicAndDialogs/ToolkitControls/ScrollBar.xba]--> | <!--[SOURCE:BasicAndDialogs/ToolkitControls/ScrollBar.xba]--> | ||
− | + | <syntaxhighlight lang="oobas"> | |
Sub AdjustmentHandler() | Sub AdjustmentHandler() | ||
Dim oLabelModel As Object | Dim oLabelModel As Object | ||
Line 47: | Line 48: | ||
oLabelModel.PositionX = PositionX0 - Factor * ScrollValue | oLabelModel.PositionX = PositionX0 - Factor * ScrollValue | ||
End Sub | End Sub | ||
− | + | </syntaxhighlight> | |
{{PDL1}} | {{PDL1}} | ||
[[Category:Documentation/Developer's Guide/Basic and Dialogs]] | [[Category:Documentation/Developer's Guide/Basic and Dialogs]] |
Latest revision as of 12:43, 21 December 2020
If the visible area in a dialog is smaller than the displayable content, the scroll bar control com.sun.star.awt.UnoControlScrollBar provides navigation through the content by scrolling horizontally or vertically. In addition, the scroll bar control is used to provide scrolling to controls that do not have a built-in scroll bar.
The orientation of a scroll bar is specified by the Orientation
property and can be horizontal or vertical. A scroll bar has a thumb (scroll box) that the user can drag with the mouse to any position along the scroll bar. The position of the thumb is controlled by the ScrollValue
property. For a horizontal scroll bar, the left-most position corresponds to the minimum scroll value of 0 and the right-most position to the maximum scroll value defined by the ScrollValueMax
property. A scroll bar also has arrows at its end that when clicked or held, incrementally moves the thumb along the scroll bar to increase or decrease the scroll value. The change of the scroll value per mouse click on an arrow is specified by the LineIncrement
property. When clicking in a scroll bar in the region between the thumb and the arrows, the scroll value increases or decreases by the value set for the BlockIncrement
property. The thumb position represents the portion of the displayable content that is currently visible in a dialog. The visible size of the thumb is set by the VisibleSize
property and represents the percentage of the currently visible content and the total displayable content.
oScrollBarModel = oDialog.Model.ScrollBar1 oScrollBarModel.ScrollValueMax = 100 oScrollBarModel.BlockIncrement = 20 oScrollBarModel.LineIncrement = 5 oScrollBarModel.VisibleSize = 20
The scroll bar control uses the adjustment event com.sun.star.awt.AdjustmentEvent to monitor the movement of the thumb along the scroll bar. In an event handler for adjustment events the developer may change the position of the visible content on the dialog as a function of the ScrollValue
property. In the following example, the size of a label field exceeds the size of the dialog. Each time the user clicks on the scrollbar, the macro AdjustmentHandler()
is called and the position of the label field in the dialog is changed according to the scroll value.
Sub AdjustmentHandler() Dim oLabelModel As Object Dim oScrollBarModel As Object Dim ScrollValue As Long, ScrollValueMax As Long Dim VisibleSize As Long Dim Factor As Double Static bInit As Boolean Static PositionX0 As Long Static Offset As Long REM get the model of the label control oLabelModel = oDialog.Model.Label1 REM on initialization remember the position of the label control and calculate offset If bInit = False Then bInit = True PositionX0 = oLabelModel.PositionX OffSet = PositionX0 + oLabelModel.Width - (oDialog.Model.Width - Border) End If REM get the model of the scroll bar control oScrollBarModel = oDialog.Model.ScrollBar1 REM get the actual scroll value ScrollValue = oScrollBarModel.ScrollValue REM calculate and set new position of the label control ScrollValueMax = oScrollBarModel.ScrollValueMax VisibleSize = oScrollBarModel.VisibleSize Factor = Offset / (ScrollValueMax - VisibleSize) oLabelModel.PositionX = PositionX0 - Factor * ScrollValue End Sub
Content on this page is licensed under the Public Documentation License (PDL). |