include/svx/dialogs.hrc | 3 + include/vcl/menubtn.hxx | 3 + svx/source/tbxctrls/tbcontrl.cxx | 75 ++++++++++++++++++++++++++++++++++++++- svx/source/tbxctrls/tbcontrl.src | 19 +++++++++ vcl/source/control/menubtn.cxx | 10 ++--- 5 files changed, 102 insertions(+), 8 deletions(-)
New commits: commit 5c596ffbd81b495800d59663cc99e3ce65d56356 Author: Samuel Mehrbrodt <s.mehrbr...@gmail.com> Date: Tue Sep 30 20:37:12 2014 +0200 fdo#62081 Improve split menu on style dropdown * Remove "Apply style" * Add "Update Style Based on Selection" * A11y: * Context menu key: Open submenu * Return key: Apply style Change-Id: Ib2960baa1412a05ea00b0e214d1af0a3d119e852 (cherry picked from commit d59e33500a250824e713afacef2ea295576caba6) diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc index b917f16..f04a0bf 100644 --- a/include/svx/dialogs.hrc +++ b/include/svx/dialogs.hrc @@ -185,7 +185,7 @@ // for Toolbox-Control style #define RID_SVXTBX_STYLE (RID_SVX_START + 120) #define RID_SVX_STYLE_MENU (RID_SVX_START + 121) -#define RID_SVX_APPLY_STYLE (RID_SVX_START + 122) +#define RID_SVX_UPDATE_STYLE (RID_SVX_START + 122) #define RID_SVX_MODIFY_STYLE (RID_SVX_START + 123) #define RID_SVXDLG_COMPRESSGRAPHICS (RID_SVX_START + 142) diff --git a/include/vcl/menubtn.hxx b/include/vcl/menubtn.hxx index f62c3cb..f917edf 100644 --- a/include/vcl/menubtn.hxx +++ b/include/vcl/menubtn.hxx @@ -45,7 +45,6 @@ private: Link maSelectHdl; SAL_DLLPRIVATE void ImplInitMenuButtonData(); - SAL_DLLPRIVATE void ImplExecuteMenu(); DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, void* ); // Copy assignment is forbidden and not implemented. @@ -68,6 +67,8 @@ public: virtual void Activate() SAL_OVERRIDE; virtual void Select(); + void ExecuteMenu(); + void SetMenuMode( sal_uInt16 nMode ); sal_uInt16 GetMenuMode() const { return mnMenuMode; } diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 746b49a..64de29b 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -385,24 +385,24 @@ void SvxStyleBox_Impl::ReleaseFocus() IMPL_LINK( SvxStyleBox_Impl, MenuSelectHdl, Menu*, pMenu) { + ReleaseFocus(); + OUString sEntry = OUString( (GetEntry(GetSelectEntryPos())) ); + Sequence< PropertyValue > aArgs( 2 ); + aArgs[0].Name = "Param"; + aArgs[0].Value = makeAny( sEntry ); + aArgs[1].Name = "Family"; + aArgs[1].Value = makeAny( sal_Int16( eStyleFamily )); + sal_uInt16 nMenuId = pMenu->GetCurItemId(); switch(nMenuId) { - case RID_SVX_APPLY_STYLE: + case RID_SVX_UPDATE_STYLE: { - nCurSel = GetSelectEntryPos(); - SetText(GetEntry(nCurSel)); - Select(); + SfxToolBoxControl::Dispatch( m_xDispatchProvider, + OUString( ".uno:StyleUpdateByExample" ), aArgs ); 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; @@ -535,22 +535,18 @@ bool SvxStyleBox_Impl::Notify( NotifyEvent& rNEvt ) switch ( nCode ) { - case KEY_RETURN: + case KEY_CONTEXTMENU: { if(IsInDropDown()) { sal_uInt16 nItem = GetSelectEntryPos() - 1; if(nItem < MAX_STYLES_ENTRIES) - m_pButtons[nItem]->KeyInput(*rNEvt.GetKeyEvent()); - nHandled = true; - } - else - { + m_pButtons[nItem]->ExecuteMenu(); nHandled = true; - Select(); } break; } + case KEY_RETURN: case KEY_TAB: { if ( KEY_TAB == nCode ) diff --git a/svx/source/tbxctrls/tbcontrl.src b/svx/source/tbxctrls/tbcontrl.src index 59728c6..df42dca 100644 --- a/svx/source/tbxctrls/tbcontrl.src +++ b/svx/source/tbxctrls/tbcontrl.src @@ -79,7 +79,7 @@ String RID_SVXSTR_LINECOLOR ComboBox RID_SVXTBX_STYLE { HelpId = HID_STYLE_LISTBOX ; - Size = MAP_APPFONT ( 50 , 86 ) ; + Size = MAP_APPFONT ( 60 , 86 ) ; DropDown = TRUE ; Sort = TRUE ; AutoHScroll = TRUE ; @@ -94,13 +94,13 @@ Menu RID_SVX_STYLE_MENU { MenuItem { - Identifier = RID_SVX_APPLY_STYLE ; - Text [ en-US ] = "Apply style" ; + Identifier = RID_SVX_UPDATE_STYLE ; + Text [ en-US ] = "Update Style Based on Selection" ; }; MenuItem { Identifier = RID_SVX_MODIFY_STYLE ; - Text [ en-US ] = "Modify style" ; + Text [ en-US ] = "Edit Style" ; }; }; }; diff --git a/vcl/source/control/menubtn.cxx b/vcl/source/control/menubtn.cxx index 7f263b6..b3cd7a2 100644 --- a/vcl/source/control/menubtn.cxx +++ b/vcl/source/control/menubtn.cxx @@ -46,7 +46,7 @@ void MenuButton::ImplInit( Window* pParent, WinBits nStyle ) EnableRTL( Application::GetSettings().GetLayoutRTL() ); } -void MenuButton::ImplExecuteMenu() +void MenuButton::ExecuteMenu() { Activate(); @@ -120,7 +120,7 @@ IMPL_LINK_NOARG(MenuButton, ImplMenuTimeoutHdl) { if ( !(GetStyle() & WB_NOPOINTERFOCUS) ) GrabFocus(); - ImplExecuteMenu(); + ExecuteMenu(); } return 0; @@ -154,7 +154,7 @@ void MenuButton::MouseButtonDown( const MouseEvent& rMEvt ) { if ( !(GetStyle() & WB_NOPOINTERFOCUS) ) GrabFocus(); - ImplExecuteMenu(); + ExecuteMenu(); } } } @@ -164,11 +164,11 @@ void MenuButton::KeyInput( const KeyEvent& rKEvt ) KeyCode aKeyCode = rKEvt.GetKeyCode(); sal_uInt16 nCode = aKeyCode.GetCode(); if ( (nCode == KEY_DOWN) && aKeyCode.IsMod2() ) - ImplExecuteMenu(); + ExecuteMenu(); else if ( !(mnMenuMode & MENUBUTTON_MENUMODE_TIMED) && !aKeyCode.GetModifier() && ((nCode == KEY_RETURN) || (nCode == KEY_SPACE)) ) - ImplExecuteMenu(); + ExecuteMenu(); else PushButton::KeyInput( rKEvt ); } commit 352ece87fc5f85ad95f35cc4f33eec29d2dfa59b Author: Szymon KÅos <eszka...@gmail.com> Date: Sun Sep 21 19:50:09 2014 +0200 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. Reviewed-on: https://gerrit.libreoffice.org/11581 Reviewed-by: Samuel Mehrbrodt <s.mehrbr...@gmail.com> Tested-by: Samuel Mehrbrodt <s.mehrbr...@gmail.com> (cherry picked from commit b4de0bd548399593ad2627afde443a569e7b8ea1) Conflicts: svx/source/tbxctrls/tbcontrl.cxx Change-Id: I3b5c153a0674d06541d403bb0f34ec73418bb778 diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc index 2756267..b917f16 100644 --- a/include/svx/dialogs.hrc +++ b/include/svx/dialogs.hrc @@ -184,6 +184,9 @@ // for Toolbox-Control style #define RID_SVXTBX_STYLE (RID_SVX_START + 120) +#define RID_SVX_STYLE_MENU (RID_SVX_START + 121) +#define RID_SVX_APPLY_STYLE (RID_SVX_START + 122) +#define RID_SVX_MODIFY_STYLE (RID_SVX_START + 123) #define RID_SVXDLG_COMPRESSGRAPHICS (RID_SVX_START + 142) diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 638c179..746b49a 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -25,6 +25,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> @@ -166,8 +167,12 @@ private: OUString aMoreKey; OUString sDefaultStyle; bool bInSpecialMode; + MenuButton* m_pButtons[MAX_STYLES_ENTRIES]; + PopupMenu m_aMenu; void ReleaseFocus(); + + DECL_LINK( MenuSelectHdl, Menu * ); }; @@ -348,7 +353,11 @@ SvxStyleBox_Impl::SvxStyleBox_Impl(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 ); @@ -357,6 +366,8 @@ SvxStyleBox_Impl::SvxStyleBox_Impl(Window* pParent, SvxStyleBox_Impl::~SvxStyleBox_Impl() { + for(int i = 0; i < MAX_STYLES_ENTRIES; i++) + delete m_pButtons[i]; } @@ -372,7 +383,33 @@ 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() { @@ -499,6 +536,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 ) @@ -556,6 +608,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 ); } @@ -667,6 +723,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 793eb76..59728c6 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" ;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits