Kaydet (Commit) b4de0bd5 authored tarafından Szymon Kłos's avatar Szymon Kłos Kaydeden (comit) Samuel Mehrbrodt

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/11581Reviewed-by: 's avatarSamuel Mehrbrodt <s.mehrbrodt@gmail.com>
Tested-by: 's avatarSamuel Mehrbrodt <s.mehrbrodt@gmail.com>
üst 96d7ca35
......@@ -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)
......
......@@ -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
......
......@@ -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" ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment