summaryrefslogtreecommitdiff
path: root/svx/source/stbctrls
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-09-29 17:11:21 -0400
committerKohei Yoshida <kyoshida@novell.com>2010-09-29 17:11:21 -0400
commitf1a80a9f2de1751b5e350a870b31d6d96ace6185 (patch)
tree4820bd319276a22c574fa39df57b80f5a1df6309 /svx/source/stbctrls
parentadc9cd843559897a8c65d9d9da2a5e810223981b (diff)
Ported statusbar-fancy-modified-status-svx.diff from ooo-build.
Diffstat (limited to 'svx/source/stbctrls')
-rw-r--r--svx/source/stbctrls/makefile.mk1
-rw-r--r--svx/source/stbctrls/modctrl.cxx103
-rw-r--r--svx/source/stbctrls/stbctrls.src26
3 files changed, 107 insertions, 23 deletions
diff --git a/svx/source/stbctrls/makefile.mk b/svx/source/stbctrls/makefile.mk
index 4e125adcd9d8..0cd85945637f 100644
--- a/svx/source/stbctrls/makefile.mk
+++ b/svx/source/stbctrls/makefile.mk
@@ -55,6 +55,7 @@ SLOFILES= \
$(SLO)$/zoomsliderctrl.obj
EXCEPTIONSFILES= \
+ $(SLO)$/modctrl.obj \
$(SLO)$/zoomsliderctrl.obj
HXX1TARGET=stbctrls
diff --git a/svx/source/stbctrls/modctrl.cxx b/svx/source/stbctrls/modctrl.cxx
index fbb212e131f0..5347d612246c 100644
--- a/svx/source/stbctrls/modctrl.cxx
+++ b/svx/source/stbctrls/modctrl.cxx
@@ -30,29 +30,47 @@
// include ---------------------------------------------------------------
-#ifndef _STATUS_HXX //autogen
+#include "modctrl.hxx"
+
#include <vcl/status.hxx>
-#endif
+#include <vcl/image.hxx>
#include <svl/eitem.hxx>
#include <sfx2/app.hxx>
-#define _SVX_MODCTRL_CXX
-
#include <svx/dialogs.hrc>
-
-#include "modctrl.hxx"
#include <svx/dialmgr.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::PropertyValue;
+using ::rtl::OUString;
+
SFX_IMPL_STATUSBAR_CONTROL(SvxModifyControl, SfxBoolItem);
// class SvxModifyControl ------------------------------------------------
+struct SvxModifyControl::ImplData
+{
+ Image maModifiedButton;
+ Image maNonModifiedButton;
+
+ bool mbModified;
+
+ ImplData() :
+ maModifiedButton( SVX_RES(RID_SVXBMP_DOC_MODIFIED_YES) ),
+ maNonModifiedButton( SVX_RES(RID_SVXBMP_DOC_MODIFIED_NO) ),
+ mbModified(false)
+ {
+ }
+};
+
SvxModifyControl::SvxModifyControl( USHORT _nSlotId,
USHORT _nId,
StatusBar& rStb ) :
SfxStatusBarControl( _nSlotId, _nId, rStb ),
- bState( TRUE )
+ mpImpl(new ImplData)
{
}
@@ -62,32 +80,71 @@ void SvxModifyControl::StateChanged( USHORT, SfxItemState eState,
const SfxPoolItem* pState )
{
if ( SFX_ITEM_AVAILABLE != eState )
- GetStatusBar().SetItemText( GetId(), String() );
- else
- {
- DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
- SfxBoolItem* pItem = (SfxBoolItem*)pState;
- bState = pItem->GetValue();
- DrawItemText_Impl();
- }
+ return;
+
+ DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
+ SfxBoolItem* pItem = (SfxBoolItem*)pState;
+ mpImpl->mbModified = pItem->GetValue();
+
+ if ( GetStatusBar().AreItemsVisible() )
+ GetStatusBar().SetItemData( GetId(), 0 ); // force repaint
+
+ int nResId = mpImpl->mbModified ? RID_SVXSTR_DOC_MODIFIED_YES : RID_SVXSTR_DOC_MODIFIED_NO;
+ GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(nResId));
}
// -----------------------------------------------------------------------
-void SvxModifyControl::Paint( const UserDrawEvent& )
+namespace {
+
+/**
+ * Given a bounding rectangle and an image, determine the top-left position
+ * of the image so that the image would look centered both horizontally and
+ * vertically.
+ *
+ * @param rBoundingRect bounding rectangle
+ * @param rImg image
+ *
+ * @return Point top-left corner of the centered image position
+ */
+Point centerImage(const Rectangle& rBoundingRect, const Image& rImg)
{
- DrawItemText_Impl();
+ Size aImgSize = rImg.GetSizePixel();
+ Size aRectSize = rBoundingRect.GetSize();
+ long nXOffset = (aRectSize.getWidth() - aImgSize.getWidth())/2;
+ long nYOffset = (aRectSize.getHeight() - aImgSize.getHeight())/2;
+ Point aPt = rBoundingRect.TopLeft();
+ aPt += Point(nXOffset, nYOffset);
+ return aPt;
}
-// -----------------------------------------------------------------------
+}
+void SvxModifyControl::Paint( const UserDrawEvent& rUsrEvt )
+{
+ const Rectangle aControlRect = getControlRect();
+ 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);
+ }
+}
-void SvxModifyControl::DrawItemText_Impl()
+void SvxModifyControl::DoubleClick()
{
- String sMode;
+ if (!mpImpl->mbModified)
+ // document not modified. nothing to do here.
+ return;
- if ( bState )
- sMode = '*';
- GetStatusBar().SetItemText( GetId(), sMode );
+ Sequence<PropertyValue> aArgs;
+ execute(OUString::createFromAscii(".uno:Save"), aArgs);
}
ULONG SvxModifyControl::GetDefItemWidth(const StatusBar& rStb)
diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src
index c6f466955254..d63384a76f16 100644
--- a/svx/source/stbctrls/stbctrls.src
+++ b/svx/source/stbctrls/stbctrls.src
@@ -89,6 +89,16 @@ String RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG
Text [ en-US ] = "Digital Signature: The document signature and the certificate are OK, but not all parts of the document are signed.";
};
+String RID_SVXSTR_DOC_MODIFIED_YES
+{
+ Text [ en-US ] = "The document has been modified. Double-click to save the document.";
+};
+
+String RID_SVXSTR_DOC_MODIFIED_NO
+{
+ Text [ en-US ] = "The document has not been modified since the last save.";
+};
+
// PopupMenu -------------------------------------------------------------
Menu RID_SVXMNU_ZOOM
{
@@ -325,3 +335,19 @@ Image RID_SVXBMP_SLIDERINCREASE_HC
MaskColor = STD_MASKCOLOR;
};
+Image RID_SVXBMP_DOC_MODIFIED_YES
+{
+ ImageBitmap = Bitmap
+ {
+ File = "doc_modified_yes_14.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_DOC_MODIFIED_NO
+{
+ ImageBitmap = Bitmap
+ {
+ File = "doc_modified_no_14.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};