[Libreoffice-commits] core.git: include/svx svx/source

Szymon KÅ‚os eszkadev at gmail.com
Wed Sep 24 11:27:02 PDT 2014


 include/svx/dialogs.hrc          |    3 +
 svx/source/tbxctrls/tbcontrl.cxx |   79 +++++++++++++++++++++++++++++++++++++++
 svx/source/tbxctrls/tbcontrl.src |   17 ++++++++
 3 files changed, 99 insertions(+)

New commits:
commit b4de0bd548399593ad2627afde443a569e7b8ea1
Author: Szymon KÅ‚os <eszkadev at 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.
    
    Change-Id: I3b5c153a0674d06541d403bb0f34ec73418bb778
    Reviewed-on: https://gerrit.libreoffice.org/11581
    Reviewed-by: Samuel Mehrbrodt <s.mehrbrodt at gmail.com>
    Tested-by: Samuel Mehrbrodt <s.mehrbrodt at gmail.com>

diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc
index 8e24185..65e8087 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 63d28d9..774749d 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 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" ;


More information about the Libreoffice-commits mailing list