xref: /trunk/main/wizards/source/tutorials/ShowInfoDialog.xba (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="ShowInfoDialog" script:language="StarBasic">REM  *****  BASIC  *****
4Dim oWnd As Object
5Dim oWnd2 As Object
6Dim oWnd3 As Object
7Dim oDoc as Object
8
9Sub ShowInfoMain
10    prop() = GetShowInfoPropeties()
11    Init(prop(0).Value, prop(1).Value, prop(2).Value, prop(3).Value, prop(4).Value, prop(5).Value, prop(6).Value, prop(7).Value, prop(8).Value)
12End Sub
13
14Sub Init(tFieldText As String, windowX, windowY, windowWidth, windowHeight, tFieldX, tFieldY, tFieldWidth, tFieldHeight)
15    toolkit = createUnoService(&quot;com.sun.star.awt.Toolkit&quot;)
16    Dim oWndDescr As new com.sun.star.awt.WindowDescriptor
17    Dim oBounds As new com.sun.star.awt.Rectangle
18    oWndDescr.Type = com.sun.star.awt.WindowClass.TOP
19    oWndDescr.WindowServiceName = &quot;&quot;
20    oWndDescr.ParentIndex = 0
21
22    &apos;officeX = StarDesktop.ActiveFrame.getContainerWindow().AccessibleContext.LocationOnScreen.X
23    &apos;officeY = StarDesktop.ActiveFrame.getContainerWindow().AccessibleContext.LocationOnScreen.Y
24    &apos;officeWidth  = StarDesktop.ActiveFrame.getContainerWindow().getPosSize().Width
25    &apos;officeHeight = StarDesktop.ActiveFrame.getContainerWindow().getPosSize().Height
26    officeWidth  = thisComponent.CurrentController.Frame.getContainerWindow().getPosSize().Width
27    officeHeight = thisComponent.CurrentController.Frame.getContainerWindow().getPosSize().Height
28
29    &apos;dialogWidth  = myTutoShowDialog.getPosSize().Width
30    &apos;dialogHeight = myTutoShowDialog.getPosSize().Height
31    X = officeWidth - windowWidth - windowX
32    Y = officeHeight - windowHeight - windowY
33
34    oBounds.X = X : oBounds.Y = Y
35    oBounds.Width = windowWidth : oBounds.Height = windowHeight
36    oWndDescr.Bounds = oBounds
37    oWndDescr.Parent = thisComponent.CurrentController.Frame.ContainerWindow
38    with com.sun.star.awt.WindowAttribute
39        oWndDescr.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
40    end with
41
42    oWnd = toolkit.createWindow(oWndDescr)
43
44    Dim oWndDescr3 As new com.sun.star.awt.WindowDescriptor
45    Dim oBounds3 As new com.sun.star.awt.Rectangle
46    oWndDescr3.Type = com.sun.star.awt.WindowClass.TOP
47    oWndDescr3.WindowServiceName = &quot;fixedimage&quot; &apos;&quot;fixedtext&quot;
48    oWndDescr3.ParentIndex = 0
49    oBounds3.X = 0 : oBounds3.Y = 0
50    oBounds3.Width = tFieldWidth : oBounds3.Height = tFieldHeight
51    oWndDescr3.Bounds = oBounds3
52    oWndDescr3.Parent = oWnd
53    with com.sun.star.awt.WindowAttribute
54        oWndDescr3.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
55    end with
56
57    oWnd3= toolkit.createWindow(oWndDescr3)
58    &apos;oWnd2.Text = tFieldText
59    &apos;printdbgInfo(oWnd3)
60    setImage(oWnd3)
61    &apos;oWnd3.Background = 16777215
62&apos;  oWnd2.SetBackGround(16776960)
63    oWnd.SetBackGround(16776960)
64&apos;  oWnd.FontDescriptors(0).Name = &quot;Albany&quot;
65&apos;  oWnd.FontDescriptors(0).StyleName = &quot;BOLD&quot;
66
67    Dim oWndDescr2 As new com.sun.star.awt.WindowDescriptor
68    Dim oBounds2 As new com.sun.star.awt.Rectangle
69    oWndDescr2.Type = com.sun.star.awt.WindowClass.TOP
70    oWndDescr2.WindowServiceName = &quot;fixedtext&quot;
71    oWndDescr2.ParentIndex = 0
72    oBounds2.X = tFieldX : oBounds2.Y = tFieldY
73    oBounds2.Width = tFieldWidth : oBounds2.Height = tFieldHeight
74    oWndDescr2.Bounds = oBounds2
75    oWndDescr2.Parent = oWnd3
76    with com.sun.star.awt.WindowAttribute
77        oWndDescr2.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
78    end with
79
80    oWnd2= toolkit.createWindow(oWndDescr2)
81    oWnd2.Text = tFieldText
82    oWnd2.Background = 268435455
83    &apos;printdbgInfo(oWnd2)
84
85    &apos;printdbgInfo oWnd.getPosSize()
86
87End Sub
88
89Function GetShowInfoPropeties()
90    stepText = GetStepTitle()
91    Dim Properties(8) As new com.sun.star.beans.NamedValue
92    Properties(0).Name = &quot;ShowInfoDialogText&quot;
93    Properties(0).Value = stepText &amp; &quot;Press [Esc] to abort.&quot;
94    Properties(1).Name = &quot;WindowX&quot;
95    Properties(1).Value = 20
96    Properties(2).Name = &quot;WindowY&quot;
97    Properties(2).Value = 40
98    Properties(3).Name = &quot;WindowWidth&quot;
99    Properties(3).Value = 190
100    Properties(4).Name = &quot;WindowHeight&quot;
101    Properties(4).Value = 50
102    Properties(5).Name = &quot;TFieldX&quot;
103    Properties(5).Value = 7
104    Properties(6).Name = &quot;TFieldY&quot;
105    Properties(6).Value = 8
106    Properties(7).Name = &quot;TFieldWidth&quot;
107    Properties(7).Value = 190
108    Properties(8).Name = &quot;TFieldHeight&quot;
109    Properties(8).Value = 50
110    GetShowInfoPropeties = Properties()
111End Function
112
113Sub setShowInfoText()
114    stepText = GetStepTitle()
115    oWnd2.Text = stepText &amp; &quot;Press [Esc] to abort.&quot;
116End Sub
117
118Sub ShowON()
119    setShowInfoText()
120    oWnd.setVisible(True)
121    oWnd3.setVisible(True)
122    oWnd2.setVisible(True)
123End Sub
124
125Sub ShowOFF()
126    &apos;On Local Error Goto NOPROPERTYSETINFO:
127        oWnd.setVisible(False)
128        oWnd2.setVisible(False)
129        oWnd3.setVisible(False)
130        &apos;oDoc.dispose()
131    Exit Sub
132    &apos;NOPROPERTYSETINFO:
133End Sub
134
135Sub DisposeIDialog()
136    &apos;On Local Error Goto NOPROPERTYSETINFO:
137        oWnd3.dispose
138        oWnd2.dispose
139        oWnd.dispose
140        oDoc.dispose()
141    Exit Sub
142    &apos;NOPROPERTYSETINFO:
143End Sub
144
145sub setImage(whatever as Object)
146
147    templatePath = GetPathSettings(&quot;Template&quot;,false, 0)
148    Dim bitmapPath As String
149    iPos = InStr(templatePath,&quot;/&quot;)
150    if(iPos &gt; 0) Then
151        bitmapPath = templatePath &amp; &quot;../wizard/bitmap/tutorial_background.gif&quot;
152    Else
153        bitmapPath = templatePath &amp; &quot;..\wizard\bitmap\tutorial_background.gif&quot;
154    End If
155
156    dim props(0) as new com.sun.star.beans.PropertyValue
157    props(0).Name = &quot;Hidden&quot;
158    props(0).Value = true
159    oDoc = StarDesktop.loadComponentFromUrl(&quot;private:factory/swriter&quot;,&quot;_blank&quot;,0,props())
160    oShape = addControlToDefaultForm(&quot;ImageButton&quot;, 1000, 1000, 2000, 1000)
161    imgControl = oShape.getControl()
162    &apos;imgControl.ImageUrl=&quot;file:///D:/Program%20Files/src680_m11_qwizards1_49_TEST/share/gallery/tutoItem.gif&quot;
163    imgControl.ImageUrl = bitmapPath
164    imgControl.addConsumer(whatever)
165    imgControl.startProduction()
166end sub
167
168Function createControlShape(cKind As String) As Object
169
170    Dim oControlShape As Object
171    Dim oControl As Object
172
173
174    oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
175    oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; &amp; cKind)
176    oControl.setPropertyValue(&quot;DefaultControl&quot;, &quot;com.sun.star.form.control.&quot; &amp; cKind)
177    oControlShape.setControl(oControl)
178
179
180    createControlShape() = oControlShape
181
182End Function
183
184Function createControlShapeWithDefaultControl(cKind As String) As Object
185
186    Dim oControlShape As Object
187    Dim oControl As Object
188
189
190    oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
191    oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; &amp; cKind)
192    oControlShape.setControl(oControl)
193
194
195    createControlShapeWithDefaultControl() = oControlShape
196
197End Function
198
199Function createUNOControlShape(cKind As String, defControl As String) As Object
200
201    Dim oControlShape As Object
202    Dim oControl As Object
203
204
205    oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
206    oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; &amp; cKind)
207    oControl.setPropertyValue(&quot;DefaultControl&quot;, &quot;com.sun.star.awt.&quot; &amp; defControl)
208    oControlShape.setControl(oControl)
209
210
211    createUNOControlShape() = oControlShape
212
213End Function
214
215Function addShape(oShape As Object) As Boolean
216
217    Dim vSize As New com.sun.star.awt.Size
218    Dim oDrawPage As Object
219    Dim oForms As Object
220    Dim oForm As Object
221
222    oDrawPage = oDoc.getDrawPage()
223    oForms = oDrawPage.getForms()
224
225    if oForms.Count = 0 then
226        oForm = oDoc.createInstance(&quot;com.sun.star.form.component.Form&quot;)
227        oForms.insertByIndex(0, oForm)
228    end if
229
230    vSize.Height = 2000 : vSize.Width = 2000
231    oShape.Size = vSize
232    oDrawPage.add(oShape)
233
234    addShape() = true
235
236End Function
237
238sub addControl(cKind as String)
239
240    Dim oDrawPage As Object
241    Dim oForm As Object, oForms As Object
242    Dim oControl As Object, oControlShape As Object
243    Dim aSz As Variant
244    Dim oText As Object
245
246    oDrawPage = oDoc.DrawPage
247    oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
248    oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; + cKind)
249    oForm = oDoc.createInstance(&quot;com.sun.star.form.component.Form&quot;)
250    oforms = oDrawPage.Forms
251    if oforms.count = 0 then
252            oforms.insertbyindex(0,oForm)
253    end if
254    oControlShape.Control = oControl
255    oDrawPage.add(oControlShape)
256
257End sub
258
259Function addControlToDefaultForm(cKind as String, x As Integer, y As Integer, width As Integer, height As Integer) As Object
260
261    Dim oDrawPage As Object
262    Dim oControl As Object, oControlShape As Object
263    Dim pos As New com.sun.star.awt.Point
264    Dim size As New com.sun.star.awt.Size
265
266    pos.X = x
267    pos.Y = y
268    size.Width = width
269    size.Height = height
270
271    oDrawPage = oDoc.DrawPage
272    oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
273    oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; + cKind)
274    oControlShape.Control = oControl
275    oControlShape.Position = pos
276    oControlShape.Size = size
277    oDrawPage.add(oControlShape)
278
279    addControlToDefaultForm() = oControlShape
280
281End Function
282
283Function addShapeToDrawDoc(oPage as Object, nPosX, nPosY as Integer, oType As String) As Object
284    Dim aPoint As New com.sun.star.awt.Point
285    Dim aSize As New com.sun.star.awt.Size
286    Dim oShape As Object
287    Dim servNames As Variant
288
289    aPoint.x = nPosX
290    aPoint.y = nPosY
291    aSize.Width = 2000
292    aSize.Height = 1000
293    oShape = oDoc.createInstance(&quot;com.sun.star.drawing.&quot;+oType+&quot;Shape&quot;)
294    oShape.Size = aSize
295    oShape.Position = aPoint
296
297    if oShape.getPropertySetInfo().hasPropertyByName(&quot;FillColor&quot;) then
298        oShape.FillColor = RGB(128, 255, 0)
299    End If
300
301    oPage.add(oShape)
302
303    addShapeToDrawDoc() = oShape
304End Function
305</script:module>