summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2014-09-21 19:50:09 +0200
committerAndras Timar <andras.timar@collabora.com>2015-02-03 14:35:47 +0100
commit352ece87fc5f85ad95f35cc4f33eec29d2dfa59b (patch)
tree870c43059b21252cea4fd5bbafe0fc3464f4389b /svx
parent5f10e5f2ab5f940ab39f0a24a504ff943ddaba63 (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. Reviewed-on: https://gerrit.libreoffice.org/11581 Reviewed-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com> Tested-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com> (cherry picked from commit b4de0bd548399593ad2627afde443a569e7b8ea1) Conflicts: svx/source/tbxctrls/tbcontrl.cxx Change-Id: I3b5c153a0674d06541d403bb0f34ec73418bb778
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx79
-rw-r--r--svx/source/tbxctrls/tbcontrl.src17
2 files changed, 95 insertions, 1 deletions
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 638c1797d05c..746b49a96d8e 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 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" ;