タブ2
LibreOffice 3.4 では OOoBasic/Dialog/TabControl で説明したタブがうまく動作しません。一方で、LO 3.4 には別のタブの実装があります。 タブコンテナに com.sun.star.awt.UnoMultiPageModel サービスを、タブページには com.sun.star.awt.UnoPageModel サービスを利用します。 Sub CreateTab2 dlg = CreateUnoDialog(DialogLibraries.Standard.Dialog1) model = dlg.getModel() ' タブコンテナを作成 tab_model = model.createInstance("com.sun.star.awt.UnoMultiPageModel") With tab_model .PositionX = 0 .PositionY = 0 .Width = 150 .Height = 150 End With model.insertByName("tab", tab_model) tab = dlg.getControl("tab") page_model1 = AddTabPage(tab, "page1", "Page 1") page_model2 = AddTabPage(tab, "page2", "Page 2") btn_model = page_model1.createInstance("com.sun.star.awt.UnoControlButtonModel") With btn_model .PositionX = 10 .PositionY = 10 .Width = 30 .Height = 15 .Label = "btn 1" End With page_model1.insertByName("btn", btn_model) dlg.execute() dlg.dispose() End Sub ' ページの作成 Function AddTabPage(tab, name, title) Dim args As New com.sun.star.beans.NamedValue args.Name = "Title" args.Value = title tab_model = tab.getModel() page_model = tab_model.createInstance("com.sun.star.awt.UnoPageModel") tab_model.insertByName(name, page_model) n = UBound(tab_model.getElementNames()) tab.setTabProps(n+1, Array(args)) AddTabPage = page_model End Function うまく切り替えれば OOo 3.4 と LO 3.4 の両方でタブを利用できます。 xdl ファイル
ダイアログの xdl ファイルでタブコントロールを作成するには、次の様にします。LO 3.5 現在ではダイアログエディタで作成できません。 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd"> <dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="Dialog1" dlg:left="96" dlg:top="30" dlg:width="168" dlg:height="129" dlg:closeable="true" dlg:moveable="true"> <dlg:bulletinboard> <dlg:button dlg:id="CommandButton1" dlg:tab-index="0" dlg:left="17" dlg:top="110" dlg:width="62" dlg:height="14" dlg:value="CommandButton1"/> <!-- dlg:value is number of tab pages. --> <dlg:multipage dlg:id="Multipage" dlg:tab-index="1" dlg:left="3" dlg:top="3" dlg:width="150" dlg:height="100" dlg:withtabs="true" dlg:value="2"> <dlg:bulletinboard> <dlg:page dlg:id="Multipage1" dlg:tab-index="2" dlg:left="3" dlg:top="3" dlg:width="150" dlg:height="100" dlg:title="Foo" dlg:visible="true"> <dlg:bulletinboard> <dlg:button dlg:id="Button1" dlg:tab-index="0" dlg:left="17" dlg:top="51" dlg:width="62" dlg:height="14" dlg:value="Button 1"/> </dlg:bulletinboard> </dlg:page> <dlg:page dlg:id="Multipage2" dlg:tab-index="3" dlg:left="13" dlg:top="3" dlg:width="150" dlg:height="100" dlg:title="Bar"> <dlg:bulletinboard> <dlg:button dlg:id="Button2" dlg:tab-index="0" dlg:left="17" dlg:top="60" dlg:width="62" dlg:height="14" dlg:value="Button 2"/> </dlg:bulletinboard> </dlg:page> </dlg:bulletinboard> </dlg:multipage> </dlg:bulletinboard> </dlg:window> |