Peter Eberlein wrote:
Hi,
Carsten showed an example of inserting a toolbar with StarBasic.
If it is extended with a graphic, the UI has the possibilities to show
icon, text or icon and text.
How to handle this with api?
Hi Peter,
Every toolbar consist of two different parts:
1. Content (describes which buttons are part of a toolbar)
2. State (describes the visual state, e.g. visibility, position, size,
style, docked/non-docked, title)
1. Can the change via the settings you get via the user interface
element or the ui configuration manager.
2. Can be accessed via the window state configuration. You have to
create the service "com.sun.star.ui.WindowStateConfiguration" and
retrieve the window states for a specific module (via getByName(
ModuleIdentifier ). There you can access the window state information
for every window based ui element using the private-URL (f.e.
"private:toolbar/standardbar" ).
HINT:
You can only the change the style (text, icons, text+icons) for the
whole toolbar, not for every button separately!
Inspecting the settings of the toolbar, I found a property "Style" as a
PropertyValue, but this doesn't influence on the layout.
The "style" property has a different meaning. It defines button specific
attributes (e.g. radio/checkmark,dropdown,dropdownonly). You can find
more information in the IDL documentation, see com.sun.star.ui.ItemStyle.
Any hints?
See the following Basic example which creates a new custom toolbar and
sets the style to "icons+text".
REM ***** BASIC *****
Sub Main
REM *** Creates a new custom toolbar persistently for the Basic IDE
REM *** The name of our new custom toolbar. A custom toolbar name MUST
REM *** start with "custom_"!
sToolbar = "private:resource/toolbar/custom_toolbar1"
sBasicIDEModuleIdentifier = "com.sun.star.script.BasicIDE"
REM *** Retrieve the module configuration manager from central module
configuration manager supplier
oModuleCfgMgrSupplier =
createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
oWindowState =
createUnoService("com.sun.star.ui.WindowStateConfiguration")
REM *** Retrieve the module configuration manager with the module
identifier
REM *** See com.sun.star.frame.ModuleManager for more information
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager(
"com.sun.star.script.BasicIDE" )
REM *** Retrieve the window state configuration for the Basic IDE
oBasicWindowState = oWindowState.getByName( sBasicIDEModuleIdentifier )
REM *** Create a settings container which will define the structure of
our new
REM *** custom toolbar.
oToolbarSettings = oModuleCfgMgr.createSettings()
REM *** Set a title for our new custom toolbar
oToolbarSettings.UIName = "My little custom toolbar"
REM *** Set visual settings of our new toolbar ***
Dim aWindowStateData(1) as new com.sun.star.beans.PropertyValue
REM *** Set new style for toolbar:
REM See org.openoffice.Office.UI.WindowState.xcs for all possible
properties
REM *** Style: 0 = symbol buttons, 1 = text buttons, 2 = symbols+text
buttons
aWindowStateData(0).Name = "Style"
aWindowStateData(0).Value = 2
if oBasicWindowState.hasByName( sToolbar ) then
oBasicWindowState.replaceByName( sToolbar, aWindowStateData )
else
oBasicWindowState.insertByName( sToolbar, aWindowStateData )
endif
REM *** Create a button for our new custom toolbar
sString = "My Macro's"
oToolbarItem = CreateToolbarItem( "macro:///Standard.Module1.Test()",
"Standard.Module1.Test" )
oToolbarSettings.insertByIndex( nCount, oToolbarItem )
REM *** Set the settings for our new custom toolbar. (replace/insert)
if ( oModuleCfgMgr.hasSettings( sToolbar )) then
oModuleCfgMgr.replaceSettings( sToolbar, oToolbarSettings )
else
oModuleCfgMgr.insertSettings( sToolbar, oToolbarSettings )
endif
End Sub
Function CreateToolbarItem( Command as String, Label as String ) as Variant
Dim aToolbarItem(3) as new com.sun.star.beans.PropertyValue
aToolbarItem(0).Name = "CommandURL"
aToolbarItem(0).Value = Command
aToolbarItem(1).Name = "Label"
aToolbarItem(1).Value = Label
aToolbarItem(2).Name = "Type"
aToolbarItem(2).Value = 0
aToolbarItem(3).Name = "Visible"
aToolbarItem(3).Value = true
CreateToolbarItem = aToolbarItem()
End Function
Sub Test
MsgBox "Test"
End Sub
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]