Kaydet (Commit) f1a80a9f authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Ported statusbar-fancy-modified-status-svx.diff from ooo-build.

üst adc9cd84
......@@ -32,6 +32,8 @@
#include <sfx2/stbitem.hxx>
#include "svx/svxdllapi.h"
#include <boost/shared_ptr.hpp>
// class SvxModifyControl ------------------------------------------------
class SVX_DLLPUBLIC SvxModifyControl : public SfxStatusBarControl
......@@ -39,7 +41,8 @@ class SVX_DLLPUBLIC SvxModifyControl : public SfxStatusBarControl
public:
virtual void StateChanged( USHORT nSID, SfxItemState eState,
const SfxPoolItem* pState );
virtual void Paint( const UserDrawEvent& rEvt );
virtual void Paint( const UserDrawEvent& rUsrEvt );
virtual void DoubleClick();
SFX_DECL_STATUSBAR_CONTROL();
......@@ -48,11 +51,8 @@ public:
static ULONG GetDefItemWidth(const StatusBar& rStb);
private:
BOOL bState;
#ifdef _SVX_MODCTRL_CXX
SVX_DLLPRIVATE void DrawItemText_Impl();
#endif
struct ImplData;
::boost::shared_ptr<ImplData> mpImpl;
};
......
......@@ -1060,5 +1060,9 @@
#define SVX_OOO_BUILD_START (RID_SVX_START + 1200)
#define SID_SC_TP_FORMULA (SVX_OOO_BUILD_START + 1)
#define RID_SVXBMP_DOC_MODIFIED_YES (SVX_OOO_BUILD_START + 2)
#define RID_SVXBMP_DOC_MODIFIED_NO (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
......@@ -55,6 +55,7 @@ SLOFILES= \
$(SLO)$/zoomsliderctrl.obj
EXCEPTIONSFILES= \
$(SLO)$/modctrl.obj \
$(SLO)$/zoomsliderctrl.obj
HXX1TARGET=stbctrls
......
......@@ -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)
......
......@@ -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;
};
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