diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2012-09-26 21:20:27 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2012-09-26 21:22:41 +0200 |
commit | 0cd97e8c33c49a6c44d26ba309493dbfec00eb8d (patch) | |
tree | f6fa8a08f4564058eaac2238fff075c5769df9b9 | |
parent | 70412d0f3f7979d3d069be8121d49dbb96775cce (diff) |
Change the image rotation widget to better looking DialControl
Change-Id: Ie11827a924a5b22d86bad24aa7f14a66b870e90c
-rw-r--r-- | cui/source/inc/transfrm.hxx | 10 | ||||
-rw-r--r-- | cui/source/tabpages/transfrm.cxx | 61 | ||||
-rw-r--r-- | cui/source/tabpages/transfrm.hrc | 2 | ||||
-rw-r--r-- | cui/source/tabpages/transfrm.src | 21 | ||||
-rw-r--r-- | svx/inc/svx/dialcontrol.hxx | 6 | ||||
-rw-r--r-- | svx/source/dialog/dialcontrol.cxx | 12 |
6 files changed, 42 insertions, 70 deletions
diff --git a/cui/source/inc/transfrm.hxx b/cui/source/inc/transfrm.hxx index 0081d58acba6..35196b1905a7 100644 --- a/cui/source/inc/transfrm.hxx +++ b/cui/source/inc/transfrm.hxx @@ -29,6 +29,7 @@ #define _SVX_TRANSFRM_HXX #include <svx/dlgctrl.hxx> +#include <svx/dialcontrol.hxx> #include <vcl/fixed.hxx> @@ -205,9 +206,9 @@ private: FixedLine aFlAngle; FixedText aFtAngle; - MetricField aMtrAngle; + NumericField maNfAngle; FixedText aFtAnglePresets; - SvxRectCtl aCtlAngle; + svx::DialControl aCtlAngle; const SfxItemSet& rOutAttrs; const SdrView* pView; @@ -218,10 +219,7 @@ private: SfxMapUnit ePoolUnit; FieldUnit eDlgUnit; - //------------------------------------ -#if _SOLAR__PRIVATE - DECL_LINK( ModifiedHdl, void * ); -#endif + public: SvxAngleTabPage( Window* pParent, const SfxItemSet& rInAttrs ); diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx index 57daf104f89e..54d32d81e558 100644 --- a/cui/source/tabpages/transfrm.cxx +++ b/cui/source/tabpages/transfrm.cxx @@ -228,10 +228,9 @@ SvxAngleTabPage::SvxAngleTabPage( Window* pParent, const SfxItemSet& rInAttrs ) aFlAngle ( this, CUI_RES( FL_ANGLE ) ), aFtAngle ( this, CUI_RES( FT_ANGLE ) ), - aMtrAngle ( this, CUI_RES( MTR_FLD_ANGLE ) ), + maNfAngle ( this, CUI_RES( NF_ANGLE ) ), aFtAnglePresets ( this, CUI_RES(FT_ANGLEPRESETS) ), - aCtlAngle ( this, CUI_RES( CTL_ANGLE ), - RP_RB, 200, 80, CS_ANGLE ), + aCtlAngle ( this, CUI_RES( CTL_ANGLE ) ), rOutAttrs ( rInAttrs ) { FreeResource(); @@ -241,12 +240,11 @@ SvxAngleTabPage::SvxAngleTabPage( Window* pParent, const SfxItemSet& rInAttrs ) DBG_ASSERT( pPool, "no pool (!)" ); ePoolUnit = pPool->GetMetric(SID_ATTR_TRANSFORM_POS_X); - aMtrAngle.SetModifyHdl(LINK( this, SvxAngleTabPage, ModifiedHdl)); - aCtlRect.SetAccessibleRelationLabeledBy(&aFtPosPresets); aCtlRect.SetAccessibleRelationMemberOf(&aFlPosition); aCtlAngle.SetAccessibleRelationLabeledBy(&aFtAnglePresets); aCtlAngle.SetAccessibleRelationMemberOf(&aFlAngle); + aCtlAngle.SetLinkedField( &maNfAngle ); } // ----------------------------------------------------------------------- @@ -303,29 +301,27 @@ void SvxAngleTabPage::Construct() aCtlRect.Disable(); aFlAngle.Disable(); aFtAngle.Disable(); - aMtrAngle.Disable(); + maNfAngle.Disable(); aFtAnglePresets.Disable(); aCtlAngle.Disable(); } } -// ----------------------------------------------------------------------- - sal_Bool SvxAngleTabPage::FillItemSet(SfxItemSet& rSet) { sal_Bool bModified = sal_False; - if(aMtrAngle.IsValueModified() || aMtrPosX.IsValueModified() || aMtrPosY.IsValueModified()) + if(aCtlAngle.IsValueModified() || aMtrPosX.IsValueModified() || aMtrPosY.IsValueModified()) { const double fUIScale(double(pView->GetModel()->GetUIScale())); const double fTmpX((GetCoreValue(aMtrPosX, ePoolUnit) + maAnchor.getX()) * fUIScale); const double fTmpY((GetCoreValue(aMtrPosY, ePoolUnit) + maAnchor.getY()) * fUIScale); - rSet.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ANGLE), static_cast<sal_Int32>(aMtrAngle.GetValue()))); + rSet.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ANGLE), aCtlAngle.GetRotation())); rSet.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_X), basegfx::fround(fTmpX))); rSet.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_Y), basegfx::fround(fTmpY))); - bModified |= sal_True; + bModified = sal_True; } return bModified; @@ -362,15 +358,13 @@ void SvxAngleTabPage::Reset(const SfxItemSet& rAttrs) pItem = GetItem( rAttrs, SID_ATTR_TRANSFORM_ANGLE ); if(pItem) { - aMtrAngle.SetValue(((const SfxInt32Item*)pItem)->GetValue()); + aCtlAngle.SetRotation(((const SfxInt32Item*)pItem)->GetValue()); } else { - aMtrAngle.SetText( String() ); + aCtlAngle.SetRotation(0); } - - aMtrAngle.SaveValue(); - ModifiedHdl(this); + aCtlAngle.SaveValue(); } // ----------------------------------------------------------------------- @@ -469,41 +463,6 @@ void SvxAngleTabPage::PointChanged(Window* pWindow, RECT_POINT eRP) } } } - else if(pWindow == &aCtlAngle) - { - switch( eRP ) - { - case RP_LT: aMtrAngle.SetUserValue( 13500, FUNIT_NONE ); break; - case RP_MT: aMtrAngle.SetUserValue( 9000, FUNIT_NONE ); break; - case RP_RT: aMtrAngle.SetUserValue( 4500, FUNIT_NONE ); break; - case RP_LM: aMtrAngle.SetUserValue( 18000, FUNIT_NONE ); break; - case RP_RM: aMtrAngle.SetUserValue( 0, FUNIT_NONE ); break; - case RP_LB: aMtrAngle.SetUserValue( 22500, FUNIT_NONE ); break; - case RP_MB: aMtrAngle.SetUserValue( 27000, FUNIT_NONE ); break; - case RP_RB: aMtrAngle.SetUserValue( 31500, FUNIT_NONE ); break; - case RP_MM: break; - } - } -} - -//------------------------------------------------------------------------ - -IMPL_LINK_NOARG(SvxAngleTabPage, ModifiedHdl) -{ - switch(aMtrAngle.GetValue()) - { - case 13500: aCtlAngle.SetActualRP( RP_LT ); break; - case 9000: aCtlAngle.SetActualRP( RP_MT ); break; - case 4500: aCtlAngle.SetActualRP( RP_RT ); break; - case 18000: aCtlAngle.SetActualRP( RP_LM ); break; - case 0: aCtlAngle.SetActualRP( RP_RM ); break; - case 22500: aCtlAngle.SetActualRP( RP_LB ); break; - case 27000: aCtlAngle.SetActualRP( RP_MB ); break; - case 31500: aCtlAngle.SetActualRP( RP_RB ); break; - default: aCtlAngle.SetActualRP( RP_MM ); break; - } - - return( 0L ); } /************************************************************************* diff --git a/cui/source/tabpages/transfrm.hrc b/cui/source/tabpages/transfrm.hrc index a735e41e74b4..99d141a93b43 100644 --- a/cui/source/tabpages/transfrm.hrc +++ b/cui/source/tabpages/transfrm.hrc @@ -61,5 +61,5 @@ #define TSB_SIZEPROTECT 46 #define FL_PROTECT 47 #define FL_DIVIDER 48 - +#define NF_ANGLE 49 // diff --git a/cui/source/tabpages/transfrm.src b/cui/source/tabpages/transfrm.src index 562f691ce70c..e87e52f8e9d7 100644 --- a/cui/source/tabpages/transfrm.src +++ b/cui/source/tabpages/transfrm.src @@ -378,35 +378,32 @@ TabPage RID_SVXPAGE_ANGLE Size = MAP_APPFONT ( 40 , 10 ) ; Text [ en-US ] = "~Angle" ; }; - MetricField MTR_FLD_ANGLE + NumericField NF_ANGLE { HelpID = "cui:MetricField:RID_SVXPAGE_ANGLE:MTR_FLD_ANGLE"; Border = TRUE ; Pos = MAP_APPFONT ( 56 , 82 + 22 ) ; - Size = MAP_APPFONT ( 54 , 12 ) ; + Size = MAP_APPFONT ( 30 , 12 ) ; + Border = TRUE ; TabStop = TRUE ; Repeat = TRUE ; Spin = TRUE ; - Minimum = -500000 ; - Maximum = 500000 ; - StrictFormat = TRUE ; - DecimalDigits = 2 ; - Unit = FUNIT_CUSTOM ; - CustomUnitText [ en-US ] = " degrees" ; - SpinSize = 500 ; + Minimum = 0 ; + Maximum = 359 ; + SpinSize = 5 ; }; FixedText FT_ANGLEPRESETS { Pos = MAP_APPFONT ( 178 , 82 + 11 ) ; - Size = MAP_APPFONT ( 70 , 8 ) ; + Size = MAP_APPFONT ( 64 , 8 ) ; Text [ en-US ] = "Default settings"; }; Control CTL_ANGLE { HelpId = HID_TPROTATION_CTRL2 ; - Border = TRUE ; + Border = FALSE ; Pos = MAP_APPFONT ( 178 , 82 + 22 ) ; - Size = MAP_APPFONT ( 70 , 48 ) ; + Size = MAP_APPFONT ( 48 , 48 ) ; TabStop = TRUE ; QuickHelpText [ en-US ] = "Rotation Angle"; }; diff --git a/svx/inc/svx/dialcontrol.hxx b/svx/inc/svx/dialcontrol.hxx index 4b5c15df84a1..fde436781cf3 100644 --- a/svx/inc/svx/dialcontrol.hxx +++ b/svx/inc/svx/dialcontrol.hxx @@ -86,6 +86,12 @@ public: /** Links the passed numeric edit field to the control (bi-directional). */ void SetLinkedField( NumericField* pField ); + /** Save value for later comparison */ + void SaveValue(); + + /** Compare value with the saved value */ + bool IsValueModified(); + private: void Init( const Size& rWinSize, const Font& rWinFont ); void Init( const Size& rWinSize ); diff --git a/svx/source/dialog/dialcontrol.cxx b/svx/source/dialog/dialcontrol.cxx index e715a1cf0599..ce44493b2e3a 100644 --- a/svx/source/dialog/dialcontrol.cxx +++ b/svx/source/dialog/dialcontrol.cxx @@ -249,6 +249,7 @@ struct DialControl_Impl Size maWinSize; Font maWinFont; sal_Int32 mnAngle; + sal_Int32 mnInitialAngle; sal_Int32 mnOldAngle; long mnCenterX; long mnCenterY; @@ -266,6 +267,7 @@ DialControl_Impl::DialControl_Impl( Window& rParent ) : maBmpBuffered( rParent ), mpLinkField( 0 ), mnAngle( 0 ), + mnInitialAngle( 0 ), mnCenterX( 0 ), mnCenterY( 0 ), mbNoRot( false ) @@ -417,6 +419,16 @@ void DialControl::SetLinkedField( NumericField* pField ) ImplSetFieldLink( LINK( this, DialControl, LinkedFieldModifyHdl ) ); } +void DialControl::SaveValue() +{ + mpImpl->mnInitialAngle = mpImpl->mnAngle; +} + +bool DialControl::IsValueModified() +{ + return mpImpl->mnInitialAngle != mpImpl->mnAngle; +} + // private -------------------------------------------------------------------- void DialControl::Init( const Size& rWinSize, const Font& rWinFont ) |