diff options
author | Dmitry Ashkadov <dmitry.ashkadov@gmail.com> | 2011-09-21 15:58:43 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-21 16:03:22 +0100 |
commit | bcbabc4b3a1c394cfab2602be14e2575a5b1ef42 (patch) | |
tree | 75e982b3f475484e7d66bdb493510c078e000d02 /svx | |
parent | 1b2965833c97da449f5d38c9e683c14507a97462 (diff) |
fdo#39430: Implement improved Saving Information Icon in the Status Bar
Diffstat (limited to 'svx')
-rwxr-xr-x | svx/inc/svx/dialogs.hrc | 9 | ||||
-rw-r--r-- | svx/inc/svx/modctrl.hxx | 10 | ||||
-rw-r--r-- | svx/source/stbctrls/modctrl.cxx | 88 | ||||
-rw-r--r-- | svx/source/stbctrls/stbctrls.src | 8 |
4 files changed, 89 insertions, 26 deletions
diff --git a/svx/inc/svx/dialogs.hrc b/svx/inc/svx/dialogs.hrc index b10c4b3bb195..d8e79ea9b743 100755 --- a/svx/inc/svx/dialogs.hrc +++ b/svx/inc/svx/dialogs.hrc @@ -1156,9 +1156,10 @@ #define SVX_OOO_BUILD_START (RID_SVX_START + 1200) -#define RID_SVXBMP_DOC_MODIFIED_YES (SVX_OOO_BUILD_START + 1) -#define RID_SVXBMP_DOC_MODIFIED_NO (SVX_OOO_BUILD_START + 2) -#define RID_SVXSTR_DOC_MODIFIED_YES (SVX_OOO_BUILD_START + 3) -#define RID_SVXSTR_DOC_MODIFIED_NO (SVX_OOO_BUILD_START + 4) +#define RID_SVXBMP_DOC_MODIFIED_YES (SVX_OOO_BUILD_START + 1) +#define RID_SVXBMP_DOC_MODIFIED_NO (SVX_OOO_BUILD_START + 2) +#define RID_SVXBMP_DOC_MODIFIED_FEEDBACK (SVX_OOO_BUILD_START + 3) +#define RID_SVXSTR_DOC_MODIFIED_YES (SVX_OOO_BUILD_START + 4) +#define RID_SVXSTR_DOC_MODIFIED_NO (SVX_OOO_BUILD_START + 5) #endif diff --git a/svx/inc/svx/modctrl.hxx b/svx/inc/svx/modctrl.hxx index 34abea0f274a..b3c52936275a 100644 --- a/svx/inc/svx/modctrl.hxx +++ b/svx/inc/svx/modctrl.hxx @@ -30,11 +30,15 @@ // include --------------------------------------------------------------- +#include <tools/link.hxx> #include <sfx2/stbitem.hxx> #include "svx/svxdllapi.h" #include <boost/shared_ptr.hpp> +// Forward declarations +class Timer; + // class SvxModifyControl ------------------------------------------------ class SVX_DLLPUBLIC SvxModifyControl : public SfxStatusBarControl @@ -49,6 +53,12 @@ public: SvxModifyControl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb ); +private: // Links + DECL_LINK( OnTimer, Timer * ); + +private: // Functions + void _repaint(); + private: struct ImplData; ::boost::shared_ptr<ImplData> mpImpl; diff --git a/svx/source/stbctrls/modctrl.cxx b/svx/source/stbctrls/modctrl.cxx index 1e94cd99ae06..4d56d807d128 100644 --- a/svx/source/stbctrls/modctrl.cxx +++ b/svx/source/stbctrls/modctrl.cxx @@ -33,6 +33,7 @@ #include <vcl/status.hxx> #include <vcl/image.hxx> +#include <vcl/timer.hxx> #include <svl/eitem.hxx> #include <sfx2/app.hxx> @@ -48,20 +49,37 @@ using ::rtl::OUString; SFX_IMPL_STATUSBAR_CONTROL(SvxModifyControl, SfxBoolItem); + +namespace +{ +const unsigned _FEEDBACK_TIMEOUT = 3000; +} + + // class SvxModifyControl ------------------------------------------------ struct SvxModifyControl::ImplData { - Image maModifiedButton; - Image maNonModifiedButton; + enum ModificationState + { + MODIFICATION_STATE_NO = 0, + MODIFICATION_STATE_YES, + MODIFICATION_STATE_FEEDBACK, + MODIFICATION_STATE_SIZE + }; + + Timer maTimer; + Image maImages[MODIFICATION_STATE_SIZE]; - bool mbModified; + ModificationState mnModState; - ImplData() : - maModifiedButton( SVX_RES(RID_SVXBMP_DOC_MODIFIED_YES) ), - maNonModifiedButton( SVX_RES(RID_SVXBMP_DOC_MODIFIED_NO) ), - mbModified(false) + ImplData(): + mnModState(MODIFICATION_STATE_NO) { + maImages[MODIFICATION_STATE_NO] = Image(SVX_RES(RID_SVXBMP_DOC_MODIFIED_NO)); + maImages[MODIFICATION_STATE_YES] = Image(SVX_RES(RID_SVXBMP_DOC_MODIFIED_YES)); + maImages[MODIFICATION_STATE_FEEDBACK] = Image(SVX_RES(RID_SVXBMP_DOC_MODIFIED_FEEDBACK)); + maTimer.SetTimeout(_FEEDBACK_TIMEOUT); } }; @@ -72,6 +90,7 @@ SvxModifyControl::SvxModifyControl( sal_uInt16 _nSlotId, SfxStatusBarControl( _nSlotId, _nId, rStb ), mpImpl(new ImplData) { + mpImpl->maTimer.SetTimeoutHdl( LINK(this, SvxModifyControl, OnTimer) ); } // ----------------------------------------------------------------------- @@ -84,13 +103,43 @@ void SvxModifyControl::StateChanged( sal_uInt16, SfxItemState eState, DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" ); SfxBoolItem* pItem = (SfxBoolItem*)pState; - mpImpl->mbModified = pItem->GetValue(); + mpImpl->maTimer.Stop(); - if ( GetStatusBar().AreItemsVisible() ) - GetStatusBar().SetItemData( GetId(), 0 ); // force repaint + bool modified = pItem->GetValue(); + bool start = ( !modified && mpImpl->mnModState == ImplData::MODIFICATION_STATE_YES); // should timer be started and feedback image displayed ? - int nResId = mpImpl->mbModified ? RID_SVXSTR_DOC_MODIFIED_YES : RID_SVXSTR_DOC_MODIFIED_NO; + mpImpl->mnModState = (start ? ImplData::MODIFICATION_STATE_FEEDBACK : (modified ? ImplData::MODIFICATION_STATE_YES : ImplData::MODIFICATION_STATE_NO)); + + _repaint(); + + int nResId = modified ? RID_SVXSTR_DOC_MODIFIED_YES : RID_SVXSTR_DOC_MODIFIED_NO; GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(nResId)); + + if ( start ) + mpImpl->maTimer.Start(); +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( SvxModifyControl, OnTimer, Timer *, pTimer ) +{ + if (pTimer == 0) + return 0; + + pTimer->Stop(); + mpImpl->mnModState = ImplData::MODIFICATION_STATE_NO; + + _repaint(); + + return 0; +} + +// ----------------------------------------------------------------------- + +void SvxModifyControl::_repaint() +{ + if ( GetStatusBar().AreItemsVisible() ) + GetStatusBar().SetItemData( GetId(), 0 ); // force repaint } // ----------------------------------------------------------------------- @@ -119,26 +168,21 @@ Point centerImage(const Rectangle& rBoundingRect, const Image& rImg) } } + + void SvxModifyControl::Paint( const UserDrawEvent& rUsrEvt ) { OutputDevice* pDev = rUsrEvt.GetDevice(); Rectangle aRect = rUsrEvt.GetRect(); - if (mpImpl->mbModified) - { - Point aPt = centerImage(aRect, mpImpl->maModifiedButton); - pDev->DrawImage(aPt, mpImpl->maModifiedButton); - } - else - { - Point aPt = centerImage(aRect, mpImpl->maNonModifiedButton); - pDev->DrawImage(aPt, mpImpl->maNonModifiedButton); - } + ImplData::ModificationState state = mpImpl->mnModState; + Point aPt = centerImage(aRect, mpImpl->maImages[state]); + pDev->DrawImage(aPt, mpImpl->maImages[state]); } void SvxModifyControl::DoubleClick() { - if (!mpImpl->mbModified) + if (mpImpl->mnModState != ImplData::MODIFICATION_STATE_YES) // document not modified. nothing to do here. return; diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src index 4e50e1f7e4a7..9acfa83c03e2 100644 --- a/svx/source/stbctrls/stbctrls.src +++ b/svx/source/stbctrls/stbctrls.src @@ -301,3 +301,11 @@ Image RID_SVXBMP_DOC_MODIFIED_NO }; MaskColor = STD_MASKCOLOR; }; +Image RID_SVXBMP_DOC_MODIFIED_FEEDBACK +{ + ImageBitmap = Bitmap + { + File = "doc_modified_feedback.png" ; + }; + MaskColor = STD_MASKCOLOR; +}; |