| <?xml version="1.0" encoding="UTF-8"?> |
| <!--*********************************************************** |
| * |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| * |
| ***********************************************************--> |
| <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> |
| <script:module xmlns:script="http://openoffice.org/2000/script" script:name="ProgressBar" script:language="StarBasic">REM ***** BASIC ***** |
| |
| Dim oDialog As Object |
| |
| Sub Main() |
| |
| Dim oLibContainer As Object, oLib As Object |
| Dim oInputStreamProvider As Object |
| Dim oProgressBar As Object |
| |
| Const sLibName = "ToolkitControls" |
| Const sDialogName = "ProgressBarDlg" |
| |
| REM load/get library and input stream provider |
| oLibContainer = DialogLibraries |
| oLibContainer.loadLibrary( sLibName ) |
| oLib = oLibContainer.getByName( sLibName ) |
| oInputStreamProvider = oLib.getByName( sDialogName ) |
| |
| REM create dialog control |
| oDialog = CreateUnoDialog( oInputStreamProvider ) |
| |
| REM hide progress bar |
| oProgressBar = oDialog.getControl("ProgressBar1") |
| oProgressBar.setVisible( False ) |
| |
| REM show the dialog |
| oDialog.execute() |
| |
| End Sub |
| |
| Sub ProgressBarDemo() |
| |
| Dim oProgressBar As Object, oProgressBarModel As Object |
| Dim oCancelButtonModel As Object |
| Dim oStartButtonModel As Object |
| Dim ProgressValue As Long |
| |
| REM progress bar settings |
| Const ProgressValueMin = 0 |
| Const ProgressValueMax = 50 |
| Const ProgressStep = 1 |
| |
| REM set minimum and maximum progress value |
| oProgressBarModel = oDialog.Model.ProgressBar1 |
| oProgressBarModel.ProgressValueMin = ProgressValueMin |
| oProgressBarModel.ProgressValueMax = ProgressValueMax |
| |
| REM disable cancel and start button |
| oCancelButtonModel = oDialog.Model.CommandButton1 |
| oCancelButtonModel.Enabled = False |
| oStartButtonModel = oDialog.Model.CommandButton2 |
| oStartButtonModel.Enabled = False |
| |
| REM show progress bar |
| oProgressBar = oDialog.getControl("ProgressBar1") |
| oProgressBar.setVisible( True ) |
| |
| REM increase progress value every second |
| For ProgressValue = ProgressValueMin To ProgressValueMax Step ProgressStep |
| oProgressBarModel.ProgressValue = ProgressValue |
| Wait 40 |
| Next ProgressValue |
| |
| REM hide progress bar |
| oProgressBar.setVisible( False ) |
| |
| REM enable cancel and start button |
| oCancelButtonModel.Enabled = True |
| oStartButtonModel.Enabled = True |
| |
| End Sub |
| |
| </script:module> |