summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2019-10-16 16:03:41 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-11-01 00:22:26 +0100
commitc720ad95d0c375d217db2816877a6d25d825163a (patch)
treec51b953dc0c0ac818ba13eb77ccc97d8b2218178 /framework
parent414cfd7a298cf378863cde992b2d7c69629fa791 (diff)
ToggleButton: add ability to set tooltip text for pop-up menu items
Change-Id: Iacd5c97438782ffddc8a9196688e1d58abce9abe Reviewed-on: https://gerrit.libreoffice.org/80906 Reviewed-by: Serge Krot (CIB) <Serge.Krot@cib.de> Tested-by: Serge Krot (CIB) <Serge.Krot@cib.de> (cherry picked from commit 8f79936d5278fd5172f5864f99befaa878de5f5d) Reviewed-on: https://gerrit.libreoffice.org/81642 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'framework')
-rwxr-xr-x[-rw-r--r--]framework/inc/uielement/togglebuttontoolbarcontroller.hxx9
-rw-r--r--framework/source/uielement/togglebuttontoolbarcontroller.cxx44
2 files changed, 40 insertions, 13 deletions
diff --git a/framework/inc/uielement/togglebuttontoolbarcontroller.hxx b/framework/inc/uielement/togglebuttontoolbarcontroller.hxx
index 1550e554d59f..ae532858d25b 100644..100755
--- a/framework/inc/uielement/togglebuttontoolbarcontroller.hxx
+++ b/framework/inc/uielement/togglebuttontoolbarcontroller.hxx
@@ -36,6 +36,13 @@ class ToggleButtonToolbarController : public ComplexToolbarController
{
public:
+ class DropdownMenuItem
+ {
+ public:
+ OUString mLabel;
+ OUString mTipHelpText;
+ };
+
enum class Style
{
DropDownButton,
@@ -64,7 +71,7 @@ class ToggleButtonToolbarController : public ComplexToolbarController
DECL_LINK( MenuSelectHdl, Menu *, bool);
OUString m_aCurrentSelection;
- std::vector< OUString > m_aDropdownMenuList;
+ std::vector< DropdownMenuItem > m_aDropdownMenuList;
};
}
diff --git a/framework/source/uielement/togglebuttontoolbarcontroller.cxx b/framework/source/uielement/togglebuttontoolbarcontroller.cxx
index 92818083c1f7..f884bb23e8cc 100644
--- a/framework/source/uielement/togglebuttontoolbarcontroller.cxx
+++ b/framework/source/uielement/togglebuttontoolbarcontroller.cxx
@@ -97,12 +97,15 @@ uno::Reference< awt::XWindow > SAL_CALL ToggleButtonToolbarController::createPop
const sal_uInt32 nCount = m_aDropdownMenuList.size();
for ( sal_uInt32 i = 0; i < nCount; i++ )
{
- OUString aLabel( m_aDropdownMenuList[i] );
- aPopup->InsertItem( sal_uInt16( i+1 ), aLabel );
- if ( aLabel == m_aCurrentSelection )
+ const OUString & rLabel = m_aDropdownMenuList[i].mLabel;
+ aPopup->InsertItem( sal_uInt16( i+1 ), rLabel );
+ if ( rLabel == m_aCurrentSelection )
aPopup->CheckItem( sal_uInt16( i+1 ) );
else
aPopup->CheckItem( sal_uInt16( i+1 ), false );
+
+ if ( !m_aDropdownMenuList[i].mTipHelpText.isEmpty() )
+ aPopup->SetTipHelpText( sal_uInt16( i+1 ), m_aDropdownMenuList[i].mTipHelpText );
}
m_pToolbar->SetItemDown( m_nID, true );
@@ -125,10 +128,14 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
{
Sequence< OUString > aList;
m_aDropdownMenuList.clear();
+ m_aCurrentSelection.clear();
rControlCommand.Arguments[i].Value >>= aList;
for ( sal_Int32 j = 0; j < aList.getLength(); j++ )
- m_aDropdownMenuList.push_back( aList[j] );
+ {
+ m_aDropdownMenuList.push_back( DropdownMenuItem() );
+ m_aDropdownMenuList.back().mLabel = aList[j];
+ }
// send notification
uno::Sequence< beans::NamedValue > aInfo { { "List", css::uno::makeAny(aList) } };
@@ -153,7 +160,7 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
( sal::static_int_cast< sal_uInt32 >(nPos)
< m_aDropdownMenuList.size() ) )
{
- m_aCurrentSelection = m_aDropdownMenuList[nPos];
+ m_aCurrentSelection = m_aDropdownMenuList[nPos].mLabel;
// send notification
uno::Sequence< beans::NamedValue > aInfo { { "ItemChecked", css::uno::makeAny(nPos) } };
@@ -168,15 +175,26 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
else if ( rControlCommand.Command == "AddEntry" )
{
OUString aText;
+ OUString aTipHelpText;
+
for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
{
if ( rControlCommand.Arguments[i].Name == "Text" )
{
- if ( rControlCommand.Arguments[i].Value >>= aText )
- m_aDropdownMenuList.push_back( aText );
- break;
+ rControlCommand.Arguments[i].Value >>= aText;
+ }
+ else if ( rControlCommand.Arguments[i].Name == "TipHelpText" )
+ {
+ rControlCommand.Arguments[i].Value >>= aTipHelpText;
}
}
+
+ if (!aText.isEmpty())
+ {
+ m_aDropdownMenuList.push_back( DropdownMenuItem() );
+ m_aDropdownMenuList.back().mLabel = aText;
+ m_aDropdownMenuList.back().mTipHelpText = aTipHelpText;
+ }
}
else if ( rControlCommand.Command == "InsertEntry" )
{
@@ -198,9 +216,11 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
rControlCommand.Arguments[i].Value >>= aText;
}
- std::vector< OUString >::iterator aIter = m_aDropdownMenuList.begin();
+ std::vector< DropdownMenuItem >::iterator aIter = m_aDropdownMenuList.begin();
aIter += nPos;
- m_aDropdownMenuList.insert( aIter, aText );
+ aIter = m_aDropdownMenuList.insert(aIter, DropdownMenuItem());
+ if (aIter != m_aDropdownMenuList.end())
+ aIter->mLabel = aText;
}
else if ( rControlCommand.Command == "RemoveEntryPos" )
{
@@ -232,7 +252,7 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
sal_Int32 nSize = sal_Int32( m_aDropdownMenuList.size() );
for ( sal_Int32 j = 0; j < nSize; j++ )
{
- if ( m_aDropdownMenuList[j] == aText )
+ if ( m_aDropdownMenuList[j].mLabel == aText )
{
m_aDropdownMenuList.erase(m_aDropdownMenuList.begin() + j);
break;
@@ -256,7 +276,7 @@ IMPL_LINK( ToggleButtonToolbarController, MenuSelectHdl, Menu *, pMenu, bool )
sal_uInt16 nItemId = pMenu->GetCurItemId();
if ( nItemId > 0 && nItemId <= m_aDropdownMenuList.size() )
{
- m_aCurrentSelection = m_aDropdownMenuList[nItemId-1];
+ m_aCurrentSelection = m_aDropdownMenuList[nItemId-1].mLabel;
execute( 0 );
}