diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2014-09-21 19:50:09 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <s.mehrbrodt@gmail.com> | 2014-09-24 18:26:34 +0000 |
commit | b4de0bd548399593ad2627afde443a569e7b8ea1 (patch) | |
tree | 550b503630a07221be10c22639d96b74d9f5c937 /svx | |
parent | 96d7ca35f9307cd6fcf61884d0e09fba070a42f8 (diff) |
fdo#62081: Add split menus to items in the style dropdown
I added buttons to the Style dropdown. Each button opens a menu.
So far I added "apply style" and "edit style" options.
Change-Id: I3b5c153a0674d06541d403bb0f34ec73418bb778
Reviewed-on: https://gerrit.libreoffice.org/11581
Reviewed-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com>
Tested-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 79 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.src | 17 |
2 files changed, 96 insertions, 0 deletions
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 63d28d9a3535..774749db83d7 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -24,6 +24,7 @@ #include <svl/itemset.hxx> #include <vcl/toolbox.hxx> #include <vcl/bmpacc.hxx> +#include <vcl/menubtn.hxx> #include <svtools/valueset.hxx> #include <svtools/ctrlbox.hxx> #include <svl/style.hxx> @@ -151,8 +152,12 @@ private: OUString aMoreKey; OUString sDefaultStyle; bool bInSpecialMode; + MenuButton* m_pButtons[MAX_STYLES_ENTRIES]; + PopupMenu m_aMenu; void ReleaseFocus(); + + DECL_LINK( MenuSelectHdl, Menu * ); }; class SvxFontNameBox_Impl : public FontNameBox @@ -312,7 +317,11 @@ SvxStyleBox_Impl::SvxStyleBox_Impl(vcl::Window* pParent, , aClearFormatKey( rClearFormatKey ) , aMoreKey( rMoreKey ) , bInSpecialMode( bInSpec ) + , m_aMenu ( SVX_RES( RID_SVX_STYLE_MENU ) ) { + m_aMenu.SetSelectHdl( LINK( this, SvxStyleBox_Impl, MenuSelectHdl ) ); + for(int i = 0; i < MAX_STYLES_ENTRIES; i++) + m_pButtons[i] = NULL; aLogicalSize = PixelToLogic( GetSizePixel(), MAP_APPFONT ); EnableAutocomplete( true ); EnableUserDraw( true ); @@ -321,6 +330,8 @@ SvxStyleBox_Impl::SvxStyleBox_Impl(vcl::Window* pParent, SvxStyleBox_Impl::~SvxStyleBox_Impl() { + for(int i = 0; i < MAX_STYLES_ENTRIES; i++) + delete m_pButtons[i]; } void SvxStyleBox_Impl::ReleaseFocus() @@ -334,6 +345,34 @@ void SvxStyleBox_Impl::ReleaseFocus() m_xFrame->getContainerWindow()->setFocus(); } +IMPL_LINK( SvxStyleBox_Impl, MenuSelectHdl, Menu*, pMenu) +{ + sal_uInt16 nMenuId = pMenu->GetCurItemId(); + switch(nMenuId) { + case RID_SVX_APPLY_STYLE: + { + nCurSel = GetSelectEntryPos(); + SetText(GetEntry(nCurSel)); + Select(); + break; + } + case RID_SVX_MODIFY_STYLE: + { + OUString sEntry = OUString( (GetEntry(GetSelectEntryPos())) ); + ReleaseFocus(); + Sequence< PropertyValue > aArgs( 2 ); + aArgs[0].Name = "Param"; + aArgs[0].Value = makeAny( sEntry ); + aArgs[1].Name = "Family"; + aArgs[1].Value = makeAny( sal_Int16( eStyleFamily )); + SfxToolBoxControl::Dispatch( m_xDispatchProvider, + OUString( ".uno:EditStyle" ), aArgs ); + break; + } + } + return 0; +} + void SvxStyleBox_Impl::Select() { // Tell base class about selection so that AT get informed about it. @@ -448,6 +487,21 @@ bool SvxStyleBox_Impl::Notify( NotifyEvent& rNEvt ) switch ( nCode ) { case KEY_RETURN: + { + if(IsInDropDown()) + { + sal_uInt16 nItem = GetSelectEntryPos() - 1; + if(nItem < MAX_STYLES_ENTRIES) + m_pButtons[nItem]->KeyInput(*rNEvt.GetKeyEvent()); + nHandled = true; + } + else + { + nHandled = true; + Select(); + } + break; + } case KEY_TAB: { if ( KEY_TAB == nCode ) @@ -505,6 +559,10 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt ) if ( nItem == 0 || nItem == GetEntryCount() - 1 ) { + Rectangle aRect(rUDEvt.GetRect()); + unsigned int nId = (aRect.getY() / aRect.GetSize().Height()); + if(m_pButtons[nId]) + m_pButtons[nId]->Hide(); // draw the non-style entries, ie. "Clear Formatting" or "More..." DrawEntry( rUDEvt, true, true ); } @@ -616,6 +674,27 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt ) pDevice->SetFillColor( aColor ); pDevice->DrawRect( rUDEvt.GetRect() ); } + + Rectangle aRect(rUDEvt.GetRect()); + unsigned int nId = (aRect.getY() / aRect.GetSize().Height()); + if(nId < MAX_STYLES_ENTRIES && m_pButtons[nId]) + m_pButtons[nId]->Hide(); + } + else + { + Rectangle aRect(rUDEvt.GetRect()); + unsigned int nId = (aRect.getY() / aRect.GetSize().Height()); + if(nId < MAX_STYLES_ENTRIES) + { + if(m_pButtons[nId] == NULL) + { + m_pButtons[nId] = new MenuButton((Window*)pDevice); + m_pButtons[nId]->SetSizePixel(Size(20, aRect.GetSize().Height())); + m_pButtons[nId]->SetPopupMenu(&m_aMenu); + } + m_pButtons[nId]->SetPosPixel(Point(aRect.GetWidth() - 20, aRect.getY())); + m_pButtons[nId]->Show(); + } } // IMG_TXT_DISTANCE in ilstbox.hxx is 6, then 1 is added as diff --git a/svx/source/tbxctrls/tbcontrl.src b/svx/source/tbxctrls/tbcontrl.src index 793eb76445d7..59728c6977e0 100644 --- a/svx/source/tbxctrls/tbcontrl.src +++ b/svx/source/tbxctrls/tbcontrl.src @@ -88,6 +88,23 @@ ComboBox RID_SVXTBX_STYLE Hide = TRUE ; }; +Menu RID_SVX_STYLE_MENU +{ + ItemList = + { + MenuItem + { + Identifier = RID_SVX_APPLY_STYLE ; + Text [ en-US ] = "Apply style" ; + }; + MenuItem + { + Identifier = RID_SVX_MODIFY_STYLE ; + Text [ en-US ] = "Modify style" ; + }; + }; +}; + String RID_SVXSTR_EXTRAS_CHARBACKGROUND { Text [ en-US ] = "Highlighting" ; |