1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2*f8ad1cf2SJürgen Schmidt<!--***********************************************************
3*f8ad1cf2SJürgen Schmidt *
4*f8ad1cf2SJürgen Schmidt * Licensed to the Apache Software Foundation (ASF) under one
5*f8ad1cf2SJürgen Schmidt * or more contributor license agreements.  See the NOTICE file
6*f8ad1cf2SJürgen Schmidt * distributed with this work for additional information
7*f8ad1cf2SJürgen Schmidt * regarding copyright ownership.  The ASF licenses this file
8*f8ad1cf2SJürgen Schmidt * to you under the Apache License, Version 2.0 (the
9*f8ad1cf2SJürgen Schmidt * "License"); you may not use this file except in compliance
10*f8ad1cf2SJürgen Schmidt * with the License.  You may obtain a copy of the License at
11*f8ad1cf2SJürgen Schmidt *
12*f8ad1cf2SJürgen Schmidt *   http://www.apache.org/licenses/LICENSE-2.0
13*f8ad1cf2SJürgen Schmidt *
14*f8ad1cf2SJürgen Schmidt * Unless required by applicable law or agreed to in writing,
15*f8ad1cf2SJürgen Schmidt * software distributed under the License is distributed on an
16*f8ad1cf2SJürgen Schmidt * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17*f8ad1cf2SJürgen Schmidt * KIND, either express or implied.  See the License for the
18*f8ad1cf2SJürgen Schmidt * specific language governing permissions and limitations
19*f8ad1cf2SJürgen Schmidt * under the License.
20*f8ad1cf2SJürgen Schmidt *
21*f8ad1cf2SJürgen Schmidt ***********************************************************-->
22cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
23cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="ScrollBar" script:language="StarBasic">REM  *****  BASIC  *****
24cdf0e10cSrcweir
25cdf0e10cSrcweirDim oDialog As Object
26cdf0e10cSrcweirConst Border = 5
27cdf0e10cSrcweir
28cdf0e10cSrcweirSub Main()
29cdf0e10cSrcweir
30cdf0e10cSrcweir	Dim oLibContainer As Object, oLib As Object
31cdf0e10cSrcweir	Dim oInputStreamProvider As Object
32cdf0e10cSrcweir	Dim oDialogModel As Object
33cdf0e10cSrcweir	Dim oScrollBarModel As Object
34cdf0e10cSrcweir	Dim oLabelModel As Object
35cdf0e10cSrcweir	Dim sLabel As String
36cdf0e10cSrcweir	Dim VisibleSize As Double
37cdf0e10cSrcweir
38cdf0e10cSrcweir	Const sLibName = &quot;ToolkitControls&quot;
39cdf0e10cSrcweir	Const sDialogName = &quot;ScrollBarDlg&quot;
40cdf0e10cSrcweir
41cdf0e10cSrcweir	REM load/get library and input stream provider
42cdf0e10cSrcweir	oLibContainer = DialogLibraries
43cdf0e10cSrcweir	oLibContainer.loadLibrary( sLibName )
44cdf0e10cSrcweir	oLib = oLibContainer.getByName( sLibName )
45cdf0e10cSrcweir	oInputStreamProvider = oLib.getByName( sDialogName )
46cdf0e10cSrcweir
47cdf0e10cSrcweir	REM create dialog control
48cdf0e10cSrcweir	oDialog = CreateUnoDialog( oInputStreamProvider )
49cdf0e10cSrcweir
50cdf0e10cSrcweir	REM set the label
51cdf0e10cSrcweir	sLabel = &quot;This Text exceeds the visible area of the dialog and can be&quot;
52cdf0e10cSrcweir	sLabel = sLabel + &quot; scrolled horizontally by clicking on the scroll bar.&quot;
53cdf0e10cSrcweir	oDialogModel = oDialog.Model
54cdf0e10cSrcweir	oLabelModel = oDialogModel.Label1
55cdf0e10cSrcweir	oLabelModel.Label = sLabel
56cdf0e10cSrcweir
57cdf0e10cSrcweir	REM scroll bar settings
58cdf0e10cSrcweir	oScrollBarModel = oDialog.Model.ScrollBar1
59cdf0e10cSrcweir	oScrollBarModel.ScrollValueMax = 100
60cdf0e10cSrcweir	VisibleSize = (oDialogModel.Width - Border - oLabelModel.PositionX) / oLabelModel.Width
61cdf0e10cSrcweir	VisibleSize = VisibleSize * oScrollBarModel.ScrollValueMax
62cdf0e10cSrcweir	oScrollBarModel.VisibleSize = VisibleSize
63cdf0e10cSrcweir	oScrollBarModel.BlockIncrement = oScrollBarModel.VisibleSize
64cdf0e10cSrcweir	oScrollBarModel.LineIncrement = oScrollBarModel.BlockIncrement / 20
65cdf0e10cSrcweir
66cdf0e10cSrcweir	REM show the dialog
67cdf0e10cSrcweir	oDialog.execute()
68cdf0e10cSrcweir
69cdf0e10cSrcweirEnd Sub
70cdf0e10cSrcweir
71cdf0e10cSrcweirSub AdjustmentHandler()
72cdf0e10cSrcweir
73cdf0e10cSrcweir	Dim oLabelModel As Object
74cdf0e10cSrcweir	Dim oScrollBarModel As Object
75cdf0e10cSrcweir	Dim ScrollValue As Long, ScrollValueMax As Long
76cdf0e10cSrcweir	Dim VisibleSize As Long
77cdf0e10cSrcweir	Dim Factor As Double
78cdf0e10cSrcweir
79cdf0e10cSrcweir	Static bInit As Boolean
80cdf0e10cSrcweir	Static PositionX0 As Long
81cdf0e10cSrcweir	Static Offset As Long
82cdf0e10cSrcweir
83cdf0e10cSrcweir	REM get the model of the label control
84cdf0e10cSrcweir	oLabelModel = oDialog.Model.Label1
85cdf0e10cSrcweir
86cdf0e10cSrcweir	REM on initialization remember the position of the label control and calculate offset
87cdf0e10cSrcweir	If bInit = False Then
88cdf0e10cSrcweir		bInit = True
89cdf0e10cSrcweir		PositionX0 = oLabelModel.PositionX
90cdf0e10cSrcweir		OffSet = PositionX0 + oLabelModel.Width - (oDialog.Model.Width - Border)
91cdf0e10cSrcweir	End If
92cdf0e10cSrcweir
93cdf0e10cSrcweir	REM get the model of the scroll bar control
94cdf0e10cSrcweir	oScrollBarModel = oDialog.Model.ScrollBar1
95cdf0e10cSrcweir
96cdf0e10cSrcweir	REM get the actual scroll value
97cdf0e10cSrcweir    ScrollValue = oScrollBarModel.ScrollValue
98cdf0e10cSrcweir
99cdf0e10cSrcweir	REM calculate and set new position of the label control
100cdf0e10cSrcweir	ScrollValueMax = oScrollBarModel.ScrollValueMax
101cdf0e10cSrcweir	VisibleSize = oScrollBarModel.VisibleSize
102cdf0e10cSrcweir	Factor = Offset / (ScrollValueMax - VisibleSize)
103cdf0e10cSrcweir	oLabelModel.PositionX = PositionX0 - Factor * ScrollValue
104cdf0e10cSrcweir
105cdf0e10cSrcweirEnd Sub
106cdf0e10cSrcweir</script:module>