Added the text-width tester into the development library.

This commit is contained in:
依瑪貓 2017-05-05 11:42:03 +08:00
parent c503a08cb8
commit 34c397e276
5 changed files with 291 additions and 3 deletions

View File

@ -1,4 +1,4 @@
' 8Registry: Utilities used from other modules to access to PokemonGoIV private configuration ' 7Registry: Utilities used from other modules to access to PokemonGoIV private configuration
' Taken from TextToColumns, 2016-12-07 ' Taken from TextToColumns, 2016-12-07
Option Explicit Option Explicit

142
PokemonGoIV/8Width.vb Normal file
View File

@ -0,0 +1,142 @@
' Copyright (c) 2017 imacat.
'
' Licensed 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.
' 8Width: The dialog text width tester.
' by imacat <imacat@mail.imacat.idv.tw>, 2017-02-22
Option Explicit
' subTestWidth: Tests the width of the dialog text
Sub subTestWidth
Dim oDialog As Object, oDialogModel As Object
Dim oTextModel As Object, oListModel As Object
Dim oEditModel As Object, oNumModel As Object
Dim oButtonModel As Object
Dim mItems () As String, oListener As Object
' Creates a dialog
oDialogModel = CreateUnoService ( _
"com.sun.star.awt.UnoControlDialogModel")
oDialogModel.setPropertyValue ("PositionX", 100)
oDialogModel.setPropertyValue ("PositionY", 100)
oDialogModel.setPropertyValue ("Height", 65)
oDialogModel.setPropertyValue ("Width", 200)
oDialogModel.setPropertyValue ("Title", _
"Localization Text Width Test")
' Adds a text label.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 5)
oTextModel.setPropertyValue ("PositionY", 6)
oTextModel.setPropertyValue ("Height", 8)
oTextModel.setPropertyValue ("Width", 190)
oTextModel.setPropertyValue ("BackgroundColor", RGB (0, 255, 0))
oDialogModel.insertByName ("txtText", oTextModel)
' Adds a drop down list.
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 5)
oListModel.setPropertyValue ("PositionY", 19)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 50)
oListModel.setPropertyValue ("TabIndex", 0)
oListModel.setPropertyValue ("Dropdown", True)
oDialogModel.insertByName ("lstStat", oListModel)
' Adds a text input field.
oEditModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlEditModel")
oEditModel.setPropertyValue ("PositionX", 5)
oEditModel.setPropertyValue ("PositionY", 34)
oEditModel.setPropertyValue ("Height", 12)
oEditModel.setPropertyValue ("Width", 150)
oEditModel.setPropertyValue ("TabIndex", 1)
oDialogModel.insertByName ("edtText", oEditModel)
' Adds a numeric input field.
oNumModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlNumericFieldModel")
oNumModel.setPropertyValue ("PositionX", 160)
oNumModel.setPropertyValue ("PositionY", 34)
oNumModel.setPropertyValue ("Height", 12)
oNumModel.setPropertyValue ("Width", 35)
oNumModel.setPropertyValue ("TabIndex", 2)
oNumModel.setPropertyValue ("Value", _
oTextModel.getPropertyValue ("Width"))
oNumModel.setPropertyValue ("ValueMax", 190)
oNumModel.setPropertyValue ("ValueMin", 1)
oNumModel.setPropertyValue ("DecimalAccuracy", 0)
oNumModel.setPropertyValue ("Spin", True)
oDialogModel.insertByName ("numWidth", oNumModel)
' Adds a button.
oButtonModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlButtonModel")
oButtonModel.setPropertyValue ("PositionX", 5)
oButtonModel.setPropertyValue ("PositionY", 49)
oButtonModel.setPropertyValue ("Height", 12)
oButtonModel.setPropertyValue ("Width", 50)
oButtonModel.setPropertyValue ("PushButtonType", _
com.sun.star.awt.PushButtonType.OK)
oButtonModel.setPropertyValue ("DefaultButton", True)
oDialogModel.insertByName ("btnClose", oButtonModel)
' Adds the dialog model to the control and runs it.
oDialog = CreateUnoService ("com.sun.star.awt.UnoControlDialog")
oDialog.setModel (oDialogModel)
oDialog.setVisible (True)
oListener = CreateUnoListener ("subTextChanged_", "com.sun.star.awt.XTextListener")
oDialog.getControl ("edtText").addTextListener (oListener)
oDialog.getControl ("edtText").setFocus
oListener = CreateUnoListener ("subWidthChanged_", "com.sun.star.awt.XTextListener")
oDialog.getControl ("numWidth").addTextListener (oListener)
oDialog.execute
End Sub
' subTextChanged_disposing: When the text input box is disposed.
Sub subTextChanged_disposing (oEvent As object)
End Sub
' subTextChanged_textChanged: When the text is changed.
Sub subTextChanged_textChanged (oEvent As object)
Dim oEdit As Object, oText As Object, oDropdown As Object
oEdit = oEvent.Source
oText = oEdit.getContext.getControl ("txtText")
oText.setText (oEdit.getText)
oDropdown = oEdit.getContext.getControl ("lstStat")
oDropdown.removeItems (0, oDropdown.getItemCount)
oDropdown.addItem (oEdit.getText, 0)
oDropdown.selectItemPos (0, True)
End Sub
' subWidthChanged_disposing: When the width input box is disposed.
Sub subWidthChanged_disposing (oEvent As object)
End Sub
' subWidthChanged_textChanged: When the width is changed.
Sub subWidthChanged_textChanged (oEvent As object)
Dim oEdit As Object, oText As Object, oDropdown As Object
oEdit = oEvent.Source
oText = oEdit.getContext.getControl ("txtText")
oText.getModel.setPropertyValue ("Width", oEdit.getValue)
oDropdown = oEdit.getContext.getControl ("lstStat")
oDropdown.getModel.setPropertyValue ("Width", oEdit.getValue)
End Sub

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="8Registry" script:language="StarBasic">&apos; 8Registry: Utilities used from other modules to access to PokemonGoIV private configuration <script:module xmlns:script="http://openoffice.org/2000/script" script:name="7Registry" script:language="StarBasic">&apos; 7Registry: Utilities used from other modules to access to PokemonGoIV private configuration
&apos; Taken from TextToColumns, 2016-12-07 &apos; Taken from TextToColumns, 2016-12-07
Option Explicit Option Explicit

145
oxt/PokemonGoIV/8Width.xba Normal file
View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="8Width" script:language="StarBasic">&apos; Copyright (c) 2017 imacat.
&apos;
&apos; Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
&apos; you may not use this file except in compliance with the License.
&apos; You may obtain a copy of the License at
&apos;
&apos; http://www.apache.org/licenses/LICENSE-2.0
&apos;
&apos; Unless required by applicable law or agreed to in writing, software
&apos; distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
&apos; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
&apos; See the License for the specific language governing permissions and
&apos; limitations under the License.
&apos; 8Width: The dialog text width tester.
&apos; by imacat &lt;imacat@mail.imacat.idv.tw&gt;, 2017-02-22
Option Explicit
&apos; subTestWidth: Tests the width of the dialog text
Sub subTestWidth
Dim oDialog As Object, oDialogModel As Object
Dim oTextModel As Object, oListModel As Object
Dim oEditModel As Object, oNumModel As Object
Dim oButtonModel As Object
Dim mItems () As String, oListener As Object
&apos; Creates a dialog
oDialogModel = CreateUnoService ( _
&quot;com.sun.star.awt.UnoControlDialogModel&quot;)
oDialogModel.setPropertyValue (&quot;PositionX&quot;, 100)
oDialogModel.setPropertyValue (&quot;PositionY&quot;, 100)
oDialogModel.setPropertyValue (&quot;Height&quot;, 65)
oDialogModel.setPropertyValue (&quot;Width&quot;, 200)
oDialogModel.setPropertyValue (&quot;Title&quot;, _
&quot;Localization Text Width Test&quot;)
&apos; Adds a text label.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 5)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 6)
oTextModel.setPropertyValue (&quot;Height&quot;, 8)
oTextModel.setPropertyValue (&quot;Width&quot;, 190)
oTextModel.setPropertyValue (&quot;BackgroundColor&quot;, RGB (0, 255, 0))
oDialogModel.insertByName (&quot;txtText&quot;, oTextModel)
&apos; Adds a drop down list.
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 5)
oListModel.setPropertyValue (&quot;PositionY&quot;, 19)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 50)
oListModel.setPropertyValue (&quot;TabIndex&quot;, 0)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oDialogModel.insertByName (&quot;lstStat&quot;, oListModel)
&apos; Adds a text input field.
oEditModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlEditModel&quot;)
oEditModel.setPropertyValue (&quot;PositionX&quot;, 5)
oEditModel.setPropertyValue (&quot;PositionY&quot;, 34)
oEditModel.setPropertyValue (&quot;Height&quot;, 12)
oEditModel.setPropertyValue (&quot;Width&quot;, 150)
oEditModel.setPropertyValue (&quot;TabIndex&quot;, 1)
oDialogModel.insertByName (&quot;edtText&quot;, oEditModel)
&apos; Adds a numeric input field.
oNumModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlNumericFieldModel&quot;)
oNumModel.setPropertyValue (&quot;PositionX&quot;, 160)
oNumModel.setPropertyValue (&quot;PositionY&quot;, 34)
oNumModel.setPropertyValue (&quot;Height&quot;, 12)
oNumModel.setPropertyValue (&quot;Width&quot;, 35)
oNumModel.setPropertyValue (&quot;TabIndex&quot;, 2)
oNumModel.setPropertyValue (&quot;Value&quot;, _
oTextModel.getPropertyValue (&quot;Width&quot;))
oNumModel.setPropertyValue (&quot;ValueMax&quot;, 190)
oNumModel.setPropertyValue (&quot;ValueMin&quot;, 1)
oNumModel.setPropertyValue (&quot;DecimalAccuracy&quot;, 0)
oNumModel.setPropertyValue (&quot;Spin&quot;, True)
oDialogModel.insertByName (&quot;numWidth&quot;, oNumModel)
&apos; Adds a button.
oButtonModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlButtonModel&quot;)
oButtonModel.setPropertyValue (&quot;PositionX&quot;, 5)
oButtonModel.setPropertyValue (&quot;PositionY&quot;, 49)
oButtonModel.setPropertyValue (&quot;Height&quot;, 12)
oButtonModel.setPropertyValue (&quot;Width&quot;, 50)
oButtonModel.setPropertyValue (&quot;PushButtonType&quot;, _
com.sun.star.awt.PushButtonType.OK)
oButtonModel.setPropertyValue (&quot;DefaultButton&quot;, True)
oDialogModel.insertByName (&quot;btnClose&quot;, oButtonModel)
&apos; Adds the dialog model to the control and runs it.
oDialog = CreateUnoService (&quot;com.sun.star.awt.UnoControlDialog&quot;)
oDialog.setModel (oDialogModel)
oDialog.setVisible (True)
oListener = CreateUnoListener (&quot;subTextChanged_&quot;, &quot;com.sun.star.awt.XTextListener&quot;)
oDialog.getControl (&quot;edtText&quot;).addTextListener (oListener)
oDialog.getControl (&quot;edtText&quot;).setFocus
oListener = CreateUnoListener (&quot;subWidthChanged_&quot;, &quot;com.sun.star.awt.XTextListener&quot;)
oDialog.getControl (&quot;numWidth&quot;).addTextListener (oListener)
oDialog.execute
End Sub
&apos; subTextChanged_disposing: When the text input box is disposed.
Sub subTextChanged_disposing (oEvent As object)
End Sub
&apos; subTextChanged_textChanged: When the text is changed.
Sub subTextChanged_textChanged (oEvent As object)
Dim oEdit As Object, oText As Object, oDropdown As Object
oEdit = oEvent.Source
oText = oEdit.getContext.getControl (&quot;txtText&quot;)
oText.setText (oEdit.getText)
oDropdown = oEdit.getContext.getControl (&quot;lstStat&quot;)
oDropdown.removeItems (0, oDropdown.getItemCount)
oDropdown.addItem (oEdit.getText, 0)
oDropdown.selectItemPos (0, True)
End Sub
&apos; subWidthChanged_disposing: When the width input box is disposed.
Sub subWidthChanged_disposing (oEvent As object)
End Sub
&apos; subWidthChanged_textChanged: When the width is changed.
Sub subWidthChanged_textChanged (oEvent As object)
Dim oEdit As Object, oText As Object, oDropdown As Object
oEdit = oEvent.Source
oText = oEdit.getContext.getControl (&quot;txtText&quot;)
oText.getModel.setPropertyValue (&quot;Width&quot;, oEdit.getValue)
oDropdown = oEdit.getContext.getControl (&quot;lstStat&quot;)
oDropdown.getModel.setPropertyValue (&quot;Width&quot;, oEdit.getValue)
End Sub
</script:module>

View File

@ -4,6 +4,7 @@
<library:element library:name="0Main"/> <library:element library:name="0Main"/>
<library:element library:name="2Data"/> <library:element library:name="2Data"/>
<library:element library:name="9Load"/> <library:element library:name="9Load"/>
<library:element library:name="8Registry"/> <library:element library:name="8Width"/>
<library:element library:name="1Dialog"/> <library:element library:name="1Dialog"/>
<library:element library:name="7Registry"/>
</library:library> </library:library>