diff options
author | Jan Holesovsky <kendy@suse.cz> | 2012-05-25 10:02:26 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2012-05-25 10:07:34 +0200 |
commit | f76fde91c4103812d924b973cec83a7b316a1f05 (patch) | |
tree | 38a6115c690f3a65f174330aa69bd913160c810f /svx/source/stbctrls | |
parent | f4e9f095fc7306651246f648b9caf706652ca8a8 (diff) |
status bar: Get rid of STD/BLK/..., and introduce a menu for that instead.
Nobody know what these acronyms stay for; so instead use an icon, and a menu
that contains the full descrption. Tooltip now says what is active.
Change-Id: I21a67c5456c96081797c1cb88d2a980d161a1c0c
Diffstat (limited to 'svx/source/stbctrls')
-rw-r--r-- | svx/source/stbctrls/selctrl.cxx | 141 | ||||
-rw-r--r-- | svx/source/stbctrls/stbctrls.h | 5 | ||||
-rw-r--r-- | svx/source/stbctrls/stbctrls.src | 55 |
3 files changed, 129 insertions, 72 deletions
diff --git a/svx/source/stbctrls/selctrl.cxx b/svx/source/stbctrls/selctrl.cxx index cb4af8b4de8e..eb74fff9c040 100644 --- a/svx/source/stbctrls/selctrl.cxx +++ b/svx/source/stbctrls/selctrl.cxx @@ -26,31 +26,70 @@ * ************************************************************************/ - -// include --------------------------------------------------------------- #include <tools/shl.hxx> +#include <vcl/menu.hxx> #include <vcl/status.hxx> #include <svl/intitem.hxx> #include <sfx2/dispatch.hxx> #include <tools/urlobj.hxx> -#define _SVX_SELCTRL_CXX - -#include "svx/selctrl.hxx" +#include <svx/selctrl.hxx> #include <svx/dialmgr.hxx> - #include <svx/dialogs.hrc> +#include "stbctrls.h" + SFX_IMPL_STATUSBAR_CONTROL(SvxSelectionModeControl, SfxUInt16Item); +/// Popup menu to select the selection type +class SelectionTypePopup : public PopupMenu +{ +public: + SelectionTypePopup( sal_uInt16 nCurrent ); +}; + +/// Item id's cannot start from 0, so we need to convert +static sal_uInt16 id_to_state( sal_uInt16 nId ) +{ + switch ( nId ) + { + default: // fall through + case SELECTION_STANDARD: return 0; + case SELECTION_EXTENDED: return 1; + case SELECTION_ADDED: return 2; + case SELECTION_BLOCK: return 3; + } +} + +/// Item id's cannot start from 0, so we need to convert +static sal_uInt16 state_to_id( sal_uInt16 nState ) +{ + switch ( nState ) + { + default: // fall through + case 0: return SELECTION_STANDARD; + case 1: return SELECTION_EXTENDED; + case 2: return SELECTION_ADDED; + case 3: return SELECTION_BLOCK; + } +} + +SelectionTypePopup::SelectionTypePopup( sal_uInt16 nCurrent ) + : PopupMenu( ResId( RID_SVXMENU_SELECTION, DIALOG_MGR() ) ) +{ + CheckItem( state_to_id( nCurrent ), true ); +} + // class SvxSelectionModeControl ----------------------------------------- SvxSelectionModeControl::SvxSelectionModeControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& rStb ) : SfxStatusBarControl( _nSlotId, _nId, rStb ), - nState( 0 ) + mnState( 0 ), + maImage( SVX_RES( RID_SVXBMP_SELECTION ) ) { + GetStatusBar().SetItemText( GetId(), String() ); } // ----------------------------------------------------------------------- @@ -58,73 +97,63 @@ SvxSelectionModeControl::SvxSelectionModeControl( sal_uInt16 _nSlotId, void SvxSelectionModeControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState ) { - if ( SFX_ITEM_AVAILABLE != eState ) - GetStatusBar().SetItemText( GetId(), String() ); - else + if ( SFX_ITEM_AVAILABLE == eState ) { DBG_ASSERT( pState->ISA( SfxUInt16Item ), "invalid item type" ); SfxUInt16Item* pItem = (SfxUInt16Item*)pState; - nState = pItem->GetValue(); - DrawItemText_Impl(); + mnState = pItem->GetValue(); + + SelectionTypePopup aPop( mnState ); + GetStatusBar().SetQuickHelpText( GetId(), aPop.GetItemText( state_to_id( mnState ) ) ); } } // ----------------------------------------------------------------------- -void SvxSelectionModeControl::Click() +sal_Bool SvxSelectionModeControl::MouseButtonDown( const MouseEvent& rEvt ) { - if ( !GetStatusBar().GetItemText( GetId() ).Len() ) - return; - nState++; - if ( nState > 3 ) - nState = 0; - - ::com::sun::star::uno::Any a; - SfxUInt16Item aState( GetSlotId(), nState ); - INetURLObject aObj( m_aCommandURL ); - - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = aObj.GetURLPath(); - aState.QueryValue( a ); - aArgs[0].Value = a; - - execute( aArgs ); -} + CaptureMouse(); + SelectionTypePopup aPop( mnState ); + StatusBar& rStatusbar = GetStatusBar(); -// ----------------------------------------------------------------------- + if ( aPop.Execute( &rStatusbar, rEvt.GetPosPixel() ) ) + { + sal_uInt16 nNewState = id_to_state( aPop.GetCurItemId() ); + if ( nNewState != mnState ) + { + mnState = nNewState; + + ::com::sun::star::uno::Any a; + SfxUInt16Item aState( GetSlotId(), mnState ); + INetURLObject aObj( m_aCommandURL ); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 ); + aArgs[0].Name = aObj.GetURLPath(); + aState.QueryValue( a ); + aArgs[0].Value = a; + + execute( aArgs ); + } + } + ReleaseMouse(); -void SvxSelectionModeControl::Paint( const UserDrawEvent& ) -{ - DrawItemText_Impl(); + return sal_True; } // ----------------------------------------------------------------------- -void SvxSelectionModeControl::DrawItemText_Impl() +void SvxSelectionModeControl::Paint( const UserDrawEvent& rUsrEvt ) { - String sTxt; - sal_uInt16 _nId = 0; + const Rectangle aControlRect = getControlRect(); + OutputDevice* pDev = rUsrEvt.GetDevice(); + Rectangle aRect = rUsrEvt.GetRect(); - switch ( nState ) - { - case 0: - _nId = RID_SVXSTR_SELMODE_STD; - break; - case 1: - _nId = RID_SVXSTR_SELMODE_ER; - break; - case 2: - _nId = RID_SVXSTR_SELMODE_ERG; - break; - case 3: - _nId = RID_SVXSTR_SELMODE_BLK; - break; - default: OSL_FAIL( "invalid selection mode!" ); - } + Size aImgSize( maImage.GetSizePixel() ); + + Point aPos( aRect.Left() + ( aControlRect.GetWidth() - aImgSize.Width() ) / 2, + aRect.Top() + ( aControlRect.GetHeight() - aImgSize.Height() ) / 2 ); - if ( _nId ) - sTxt = SVX_RESSTR( _nId ); - GetStatusBar().SetItemText( GetId(), sTxt ); + pDev->DrawImage( aPos, maImage ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/stbctrls/stbctrls.h b/svx/source/stbctrls/stbctrls.h index 744082ebe523..28778740f528 100644 --- a/svx/source/stbctrls/stbctrls.h +++ b/svx/source/stbctrls/stbctrls.h @@ -52,6 +52,11 @@ #define XMLSEC_CALL 1 +#define SELECTION_STANDARD 1 +#define SELECTION_EXTENDED 2 +#define SELECTION_ADDED 3 +#define SELECTION_BLOCK 4 + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src index 0dc08437d143..e0f198a838ec 100644 --- a/svx/source/stbctrls/stbctrls.src +++ b/svx/source/stbctrls/stbctrls.src @@ -43,26 +43,49 @@ String RID_SVXSTR_OVERWRITE_TEXT Text [ x-comment ] = "To be shown in the status bar when in overwrite mode, please try to make it not longer than the word 'Overwrite'." ; Text [ en-US ] = "Overwrite" ; }; -String RID_SVXSTR_SELMODE_STD -{ - // 'Standard' shortened to a maximum of 3 characters - Text [ en-US ] = "STD" ; -}; -String RID_SVXSTR_SELMODE_ER -{ - // 'Extended' shortened to a maximum of 3 characters - Text [ en-US ] = "EXT" ; -}; -String RID_SVXSTR_SELMODE_ERG + +// Selection type menu +Menu RID_SVXMENU_SELECTION { - // 'Added' shortened to a maximum of 3 characters - Text [ en-US ] = "ADD" ; + ItemList = + { + MenuItem + { + Identifier = SELECTION_STANDARD ; + //HelpId = ; + RadioCheck = TRUE ; + Text [ en-US ] = "Standard selection" ; + }; + MenuItem + { + Identifier = SELECTION_EXTENDED ; + //HelpId = ; + RadioCheck = TRUE ; + Text [ en-US ] = "Extending selection" ; + }; + MenuItem + { + Identifier = SELECTION_ADDED ; + //HelpId = ; + RadioCheck = TRUE ; + Text [ en-US ] = "Adding selection" ; + }; + MenuItem + { + Identifier = SELECTION_BLOCK ; + //HelpId = ; + RadioCheck = TRUE ; + Text [ en-US ] = "Block selection" ; + }; + }; }; -String RID_SVXSTR_SELMODE_BLK +Image RID_SVXBMP_SELECTION { - // 'Block' shortened to max. 3 chararcters - Text [ en-US ] = "BLK" ; + ImageBitmap = Bitmap + { + File = "selection_10x22.png" ; + }; }; String RID_SVXSTR_XMLSEC_SIG_OK |