diff options
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/grfpage.hxx | 91 | ||||
-rw-r--r-- | cui/source/tabpages/grfpage.cxx | 523 | ||||
-rw-r--r-- | cui/uiconfig/ui/croppage.ui | 134 |
3 files changed, 360 insertions, 388 deletions
diff --git a/cui/source/inc/grfpage.hxx b/cui/source/inc/grfpage.hxx index 887a93789eb6..e1b15e2c1520 100644 --- a/cui/source/inc/grfpage.hxx +++ b/cui/source/inc/grfpage.hxx @@ -20,31 +20,30 @@ #ifndef INCLUDED_CUI_SOURCE_INC_GRFPAGE_HXX #define INCLUDED_CUI_SOURCE_INC_GRFPAGE_HXX -#include <vcl/fixed.hxx> -#include <vcl/button.hxx> -#include <vcl/field.hxx> +#include <vcl/customweld.hxx> #include <vcl/graph.hxx> #include <sfx2/tabdlg.hxx> -class SvxCropExample : public vcl::Window +class SvxCropExample : public weld::CustomWidgetController { - Size aFrameSize; - Point aTopLeft, aBottomRight; - Graphic aGrf; + MapMode m_aMapMode; + Size m_aFrameSize; + Point m_aTopLeft, m_aBottomRight; + Graphic m_aGrf; public: - SvxCropExample( vcl::Window* pPar, WinBits nStyle ); + SvxCropExample(); virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override; virtual void Resize() override; - virtual Size GetOptimalSize() const override; + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; - void SetTop( long nVal ) { aTopLeft.setX(nVal); } - void SetBottom( long nVal ) { aBottomRight.setX(nVal); } - void SetLeft( long nVal ) { aTopLeft.setY(nVal); } - void SetRight( long nVal) { aBottomRight.setY(nVal); } + void SetTop( long nVal ) { m_aTopLeft.setX(nVal); } + void SetBottom( long nVal ) { m_aBottomRight.setX(nVal); } + void SetLeft( long nVal ) { m_aTopLeft.setY(nVal); } + void SetRight( long nVal) { m_aBottomRight.setY(nVal); } void SetFrameSize( const Size& rSz ); - void SetGraphic( const Graphic& rGrf ) { aGrf = rGrf; } + void SetGraphic( const Graphic& rGrf ) { m_aGrf = rGrf; } }; class SvxGrfCropPage : public SfxTabPage @@ -54,53 +53,48 @@ class SvxGrfCropPage : public SfxTabPage using TabPage::ActivatePage; using TabPage::DeactivatePage; - VclPtr<VclContainer> m_pCropFrame; - VclPtr<RadioButton> m_pZoomConstRB; - VclPtr<RadioButton> m_pSizeConstRB; - VclPtr<MetricField> m_pLeftMF; - VclPtr<MetricField> m_pRightMF; - VclPtr<MetricField> m_pTopMF; - VclPtr<MetricField> m_pBottomMF; - - VclPtr<VclContainer> m_pScaleFrame; - VclPtr<MetricField> m_pWidthZoomMF; - VclPtr<MetricField> m_pHeightZoomMF; - - VclPtr<VclContainer> m_pSizeFrame; - VclPtr<MetricField> m_pWidthMF; - VclPtr<MetricField> m_pHeightMF; - - VclPtr<VclContainer> m_pOrigSizeGrid; - VclPtr<FixedText> m_pOrigSizeFT; - VclPtr<PushButton> m_pOrigSizePB; - - // Example - VclPtr<SvxCropExample> m_pExampleWN; - - - Timer aTimer; OUString aGraphicName; Size aOrigSize; Size aOrigPixelSize; Size aPageSize; - VclPtr<MetricField> pLastCropField; long nOldWidth; long nOldHeight; bool bReset; bool bSetOrigSize; + SvxCropExample m_aExampleWN; - SvxGrfCropPage( vcl::Window *pParent, const SfxItemSet &rSet ); + std::unique_ptr<weld::Widget> m_xCropFrame; + std::unique_ptr<weld::RadioButton> m_xZoomConstRB; + std::unique_ptr<weld::RadioButton> m_xSizeConstRB; + std::unique_ptr<weld::MetricSpinButton> m_xLeftMF; + std::unique_ptr<weld::MetricSpinButton> m_xRightMF; + std::unique_ptr<weld::MetricSpinButton> m_xTopMF; + std::unique_ptr<weld::MetricSpinButton> m_xBottomMF; + + std::unique_ptr<weld::Widget> m_xScaleFrame; + std::unique_ptr<weld::MetricSpinButton> m_xWidthZoomMF; + std::unique_ptr<weld::MetricSpinButton> m_xHeightZoomMF; + + std::unique_ptr<weld::Widget> m_xSizeFrame; + std::unique_ptr<weld::MetricSpinButton> m_xWidthMF; + std::unique_ptr<weld::MetricSpinButton> m_xHeightMF; + + std::unique_ptr<weld::Widget> m_xOrigSizeGrid; + std::unique_ptr<weld::Label> m_xOrigSizeFT; + std::unique_ptr<weld::Button> m_xOrigSizePB; + + // Example + std::unique_ptr<weld::CustomWeld> m_xExampleWN; + + SvxGrfCropPage(TabPageParent pParent, const SfxItemSet &rSet); virtual ~SvxGrfCropPage() override; virtual void dispose() override; - DECL_LINK( ZoomHdl, Edit&, void ); - DECL_LINK( SizeHdl, Edit&, void ); - DECL_LINK( CropHdl, SpinField&, void ); - DECL_LINK( CropLoseFocusHdl, Control&, void ); - DECL_LINK( CropModifyHdl, Edit&, void ); - DECL_LINK( OrigSizeHdl, Button*, void ); - DECL_LINK( Timeout, Timer *, void ); + DECL_LINK(ZoomHdl, weld::MetricSpinButton&, void); + DECL_LINK(SizeHdl, weld::MetricSpinButton&, void); + DECL_LINK(CropModifyHdl, weld::MetricSpinButton&, void); + DECL_LINK(OrigSizeHdl, weld::Button&, void); void CalcZoom(); void CalcMinMaxBorder(); @@ -116,7 +110,6 @@ public: virtual DeactivateRC DeactivatePage( SfxItemSet *pSet ) override; }; - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx index 121329e3ef87..a94e1b4569b7 100644 --- a/cui/source/tabpages/grfpage.cxx +++ b/cui/source/tabpages/grfpage.cxx @@ -40,87 +40,66 @@ #define TWIP_TO_INCH 1440 -static inline long lcl_GetValue( MetricField const & rMetric, FieldUnit eUnit ) +static inline int lcl_GetValue(const weld::MetricSpinButton& rMetric, FieldUnit eUnit) { - return static_cast<long>(rMetric.Denormalize( rMetric.GetValue( eUnit ))); + return rMetric.denormalize(rMetric.get_value(eUnit)); } /*-------------------------------------------------------------------- description: crop graphic --------------------------------------------------------------------*/ -SvxGrfCropPage::SvxGrfCropPage ( vcl::Window *pParent, const SfxItemSet &rSet ) - : SfxTabPage(pParent, "CropPage", "cui/ui/croppage.ui", &rSet) - , pLastCropField(nullptr) +SvxGrfCropPage::SvxGrfCropPage(TabPageParent pParent, const SfxItemSet &rSet) + : SfxTabPage(pParent, "cui/ui/croppage.ui", "CropPage", &rSet) , nOldWidth(0) , nOldHeight(0) , bReset(false) , bSetOrigSize(false) + , m_xCropFrame(m_xBuilder->weld_widget("cropframe")) + , m_xZoomConstRB(m_xBuilder->weld_radio_button("keepscale")) + , m_xSizeConstRB(m_xBuilder->weld_radio_button("keepsize")) + , m_xLeftMF(m_xBuilder->weld_metric_spin_button("left", FUNIT_CM)) + , m_xRightMF(m_xBuilder->weld_metric_spin_button("right", FUNIT_CM)) + , m_xTopMF(m_xBuilder->weld_metric_spin_button("top", FUNIT_CM)) + , m_xBottomMF(m_xBuilder->weld_metric_spin_button("bottom", FUNIT_CM)) + , m_xScaleFrame(m_xBuilder->weld_widget("scaleframe")) + , m_xWidthZoomMF(m_xBuilder->weld_metric_spin_button("widthzoom", FUNIT_PERCENT)) + , m_xHeightZoomMF(m_xBuilder->weld_metric_spin_button("heightzoom", FUNIT_PERCENT)) + , m_xSizeFrame(m_xBuilder->weld_widget("sizeframe")) + , m_xWidthMF(m_xBuilder->weld_metric_spin_button("width", FUNIT_CM)) + , m_xHeightMF(m_xBuilder->weld_metric_spin_button("height", FUNIT_CM)) + , m_xOrigSizeGrid(m_xBuilder->weld_widget("origsizegrid")) + , m_xOrigSizeFT(m_xBuilder->weld_label("origsizeft")) + , m_xOrigSizePB(m_xBuilder->weld_button("origsize")) + , m_xExampleWN(new weld::CustomWeld(*m_xBuilder, "preview", m_aExampleWN)) { - get(m_pCropFrame, "cropframe"); - get(m_pScaleFrame, "scaleframe"); - get(m_pSizeFrame, "sizeframe"); - get(m_pOrigSizeGrid, "origsizegrid"); - get(m_pZoomConstRB, "keepscale"); - get(m_pSizeConstRB, "keepsize"); - get(m_pOrigSizeFT, "origsizeft"); - get(m_pOrigSizePB, "origsize"); - get(m_pLeftMF, "left"); - get(m_pRightMF, "right"); - get(m_pTopMF, "top"); - get(m_pBottomMF, "bottom"); - get(m_pWidthZoomMF, "widthzoom"); - get(m_pHeightZoomMF, "heightzoom"); - get(m_pWidthMF, "width"); - get(m_pHeightMF, "height"); - get(m_pExampleWN, "preview"); - SetExchangeSupport(); // set the correct metric const FieldUnit eMetric = GetModuleFieldUnit( rSet ); - SetFieldUnit( *m_pWidthMF, eMetric ); - SetFieldUnit( *m_pHeightMF, eMetric ); - SetFieldUnit( *m_pLeftMF, eMetric ); - SetFieldUnit( *m_pRightMF, eMetric ); - SetFieldUnit( *m_pTopMF , eMetric ); - SetFieldUnit( *m_pBottomMF, eMetric ); + SetFieldUnit( *m_xWidthMF, eMetric ); + SetFieldUnit( *m_xHeightMF, eMetric ); + SetFieldUnit( *m_xLeftMF, eMetric ); + SetFieldUnit( *m_xRightMF, eMetric ); + SetFieldUnit( *m_xTopMF , eMetric ); + SetFieldUnit( *m_xBottomMF, eMetric ); - Link<Edit&,void> aLk = LINK(this, SvxGrfCropPage, SizeHdl); - m_pWidthMF->SetModifyHdl( aLk ); - m_pHeightMF->SetModifyHdl( aLk ); + Link<weld::MetricSpinButton&,void> aLk = LINK(this, SvxGrfCropPage, SizeHdl); + m_xWidthMF->connect_value_changed( aLk ); + m_xHeightMF->connect_value_changed( aLk ); aLk = LINK(this, SvxGrfCropPage, ZoomHdl); - m_pWidthZoomMF->SetModifyHdl( aLk ); - m_pHeightZoomMF->SetModifyHdl( aLk ); - - Link<SpinField&,void> aLk3 = LINK(this, SvxGrfCropPage, CropHdl); - m_pLeftMF->SetDownHdl( aLk3 ); - m_pRightMF->SetDownHdl( aLk3 ); - m_pTopMF->SetDownHdl( aLk3 ); - m_pBottomMF->SetDownHdl( aLk3 ); - m_pLeftMF->SetUpHdl( aLk3 ); - m_pRightMF->SetUpHdl( aLk3 ); - m_pTopMF->SetUpHdl( aLk3 ); - m_pBottomMF->SetUpHdl( aLk3 ); + m_xWidthZoomMF->connect_value_changed( aLk ); + m_xHeightZoomMF->connect_value_changed( aLk ); aLk = LINK(this, SvxGrfCropPage, CropModifyHdl); - m_pLeftMF->SetModifyHdl( aLk ); - m_pRightMF->SetModifyHdl( aLk ); - m_pTopMF->SetModifyHdl( aLk ); - m_pBottomMF->SetModifyHdl( aLk ); - - Link<Control&,void> aLk2 = LINK(this, SvxGrfCropPage, CropLoseFocusHdl); - m_pLeftMF->SetLoseFocusHdl( aLk2 ); - m_pRightMF->SetLoseFocusHdl( aLk2 ); - m_pTopMF->SetLoseFocusHdl( aLk2 ); - m_pBottomMF->SetLoseFocusHdl( aLk2 ); + m_xLeftMF->connect_value_changed( aLk ); + m_xRightMF->connect_value_changed( aLk ); + m_xTopMF->connect_value_changed( aLk ); + m_xBottomMF->connect_value_changed( aLk ); - m_pOrigSizePB->SetClickHdl( LINK(this, SvxGrfCropPage, OrigSizeHdl) ); - - aTimer.SetInvokeHandler(LINK(this, SvxGrfCropPage, Timeout)); - aTimer.SetTimeout( 1500 ); + m_xOrigSizePB->connect_clicked(LINK(this, SvxGrfCropPage, OrigSizeHdl)); } SvxGrfCropPage::~SvxGrfCropPage() @@ -130,31 +109,13 @@ SvxGrfCropPage::~SvxGrfCropPage() void SvxGrfCropPage::dispose() { - aTimer.Stop(); - m_pCropFrame.clear(); - m_pZoomConstRB.clear(); - m_pSizeConstRB.clear(); - m_pLeftMF.clear(); - m_pRightMF.clear(); - m_pTopMF.clear(); - m_pBottomMF.clear(); - m_pScaleFrame.clear(); - m_pWidthZoomMF.clear(); - m_pHeightZoomMF.clear(); - m_pSizeFrame.clear(); - m_pWidthMF.clear(); - m_pHeightMF.clear(); - m_pOrigSizeGrid.clear(); - m_pOrigSizeFT.clear(); - m_pOrigSizePB.clear(); - m_pExampleWN.clear(); - pLastCropField.clear(); + m_xExampleWN.reset(); SfxTabPage::dispose(); } VclPtr<SfxTabPage> SvxGrfCropPage::Create(TabPageParent pParent, const SfxItemSet *rSet) { - return VclPtr<SvxGrfCropPage>::Create( pParent.pParent, *rSet ); + return VclPtr<SvxGrfCropPage>::Create(pParent, *rSet); } void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) @@ -166,10 +127,10 @@ void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) SID_ATTR_GRAF_KEEP_ZOOM ), true, &pItem )) { if( static_cast<const SfxBoolItem*>(pItem)->GetValue() ) - m_pZoomConstRB->Check(); + m_xZoomConstRB->set_active(true); else - m_pSizeConstRB->Check(); - m_pZoomConstRB->SaveValue(); + m_xSizeConstRB->set_active(true); + m_xZoomConstRB->save_state(); } sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_CROP ); @@ -179,24 +140,29 @@ void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) const SvxGrfCrop* pCrop = static_cast<const SvxGrfCrop*>(pItem); - m_pExampleWN->SetLeft( pCrop->GetLeft()); - m_pExampleWN->SetRight( pCrop->GetRight()); - m_pExampleWN->SetTop( pCrop->GetTop()); - m_pExampleWN->SetBottom( pCrop->GetBottom()); + m_aExampleWN.SetLeft(pCrop->GetLeft()); + m_aExampleWN.SetRight(pCrop->GetRight()); + m_aExampleWN.SetTop(pCrop->GetTop()); + m_aExampleWN.SetBottom(pCrop->GetBottom()); - m_pLeftMF->SetValue( m_pLeftMF->Normalize( pCrop->GetLeft()), eUnit ); - m_pRightMF->SetValue( m_pRightMF->Normalize( pCrop->GetRight()), eUnit ); - m_pTopMF->SetValue( m_pTopMF->Normalize( pCrop->GetTop()), eUnit ); - m_pBottomMF->SetValue( m_pBottomMF->Normalize( pCrop->GetBottom()), eUnit ); + m_xLeftMF->set_value( m_xLeftMF->normalize( pCrop->GetLeft()), eUnit ); + m_xRightMF->set_value( m_xRightMF->normalize( pCrop->GetRight()), eUnit ); + m_xTopMF->set_value( m_xTopMF->normalize( pCrop->GetTop()), eUnit ); + m_xBottomMF->set_value( m_xBottomMF->normalize( pCrop->GetBottom()), eUnit ); } else { - m_pLeftMF->SetValue( 0 ); - m_pRightMF->SetValue( 0 ); - m_pTopMF->SetValue( 0 ); - m_pBottomMF->SetValue( 0 ); + m_xLeftMF->set_value(0, FUNIT_NONE); + m_xRightMF->set_value(0, FUNIT_NONE); + m_xTopMF->set_value(0, FUNIT_NONE); + m_xBottomMF->set_value(0, FUNIT_NONE); } + m_xLeftMF->save_value(); + m_xRightMF->save_value(); + m_xTopMF->save_value(); + m_xBottomMF->save_value(); + nW = rPool.GetWhich( SID_ATTR_PAGE_SIZE ); if ( SfxItemState::SET == rSet->GetItemState( nW, false, &pItem ) ) { @@ -205,13 +171,11 @@ void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) aPageSize = static_cast<const SvxSizeItem*>(pItem)->GetSize(); - sal_Int64 nTmp = m_pHeightMF->Normalize(aPageSize.Height()); - m_pHeightMF->SetMax( nTmp, eUnit ); - nTmp = m_pWidthMF->Normalize(aPageSize.Width()); - m_pWidthMF->SetMax( nTmp, eUnit ); - nTmp = m_pWidthMF->Normalize( 23 ); - m_pHeightMF->SetMin( nTmp, eUnit ); - m_pWidthMF->SetMin( nTmp, eUnit ); + auto nMin = m_xWidthMF->normalize( 23 ); + auto nMax = m_xHeightMF->normalize(aPageSize.Height()); + m_xHeightMF->set_range(nMin, nMax, eUnit); + nMax = m_xWidthMF->normalize(aPageSize.Width()); + m_xWidthMF->set_range(nMin, nMax, eUnit); } else { @@ -242,8 +206,8 @@ void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) if( aOrigSize.Width() && aOrigSize.Height() ) { CalcMinMaxBorder(); - m_pExampleWN->SetGraphic( *pGrf ); - m_pExampleWN->SetFrameSize( aOrigSize ); + m_aExampleWN.SetGraphic( *pGrf ); + m_aExampleWN.SetFrameSize( aOrigSize ); bFound = true; if( !static_cast<const SvxBrushItem*>(pItem)->GetGraphicLink().isEmpty() ) @@ -262,8 +226,8 @@ bool SvxGrfCropPage::FillItemSet(SfxItemSet *rSet) { const SfxItemPool& rPool = *rSet->GetPool(); bool bModified = false; - if( m_pWidthMF->IsValueChangedFromSaved() || - m_pHeightMF->IsValueChangedFromSaved() ) + if( m_xWidthMF->get_value_changed_from_saved() || + m_xHeightMF->get_value_changed_from_saved() ) { sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_FRMSIZE ); FieldUnit eUnit = MapToFieldUnit( rSet->GetPool()->GetMetric( nW )); @@ -280,13 +244,13 @@ bool SvxGrfCropPage::FillItemSet(SfxItemSet *rSet) aSz = static_cast<const SvxSizeItem&>(GetItemSet().Get( nW )); Size aTmpSz( aSz.GetSize() ); - if( m_pWidthMF->IsValueChangedFromSaved() ) - aTmpSz.setWidth( lcl_GetValue( *m_pWidthMF, eUnit ) ); - if( m_pHeightMF->IsValueChangedFromSaved() ) - aTmpSz.setHeight( lcl_GetValue( *m_pHeightMF, eUnit ) ); + if( m_xWidthMF->get_value_changed_from_saved() ) + aTmpSz.setWidth( lcl_GetValue( *m_xWidthMF, eUnit ) ); + if( m_xHeightMF->get_value_changed_from_saved() ) + aTmpSz.setHeight( lcl_GetValue( *m_xHeightMF, eUnit ) ); aSz.SetSize( aTmpSz ); - m_pWidthMF->SaveValue(); - m_pHeightMF->SaveValue(); + m_xWidthMF->save_value(); + m_xHeightMF->save_value(); bModified |= nullptr != rSet->Put( aSz ); @@ -296,24 +260,24 @@ bool SvxGrfCropPage::FillItemSet(SfxItemSet *rSet) SID_ATTR_GRAF_FRMSIZE_PERCENT ), Size( 0, 0 )) ); } } - if( m_pLeftMF->IsModified() || m_pRightMF->IsModified() || - m_pTopMF->IsModified() || m_pBottomMF->IsModified() ) + if( m_xLeftMF->get_value_changed_from_saved() || m_xRightMF->get_value_changed_from_saved() || + m_xTopMF->get_value_changed_from_saved() || m_xBottomMF->get_value_changed_from_saved() ) { sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_CROP ); FieldUnit eUnit = MapToFieldUnit( rSet->GetPool()->GetMetric( nW )); std::unique_ptr<SvxGrfCrop> pNew(static_cast<SvxGrfCrop*>(rSet->Get( nW ).Clone())); - pNew->SetLeft( lcl_GetValue( *m_pLeftMF, eUnit ) ); - pNew->SetRight( lcl_GetValue( *m_pRightMF, eUnit ) ); - pNew->SetTop( lcl_GetValue( *m_pTopMF, eUnit ) ); - pNew->SetBottom( lcl_GetValue( *m_pBottomMF, eUnit ) ); + pNew->SetLeft( lcl_GetValue( *m_xLeftMF, eUnit ) ); + pNew->SetRight( lcl_GetValue( *m_xRightMF, eUnit ) ); + pNew->SetTop( lcl_GetValue( *m_xTopMF, eUnit ) ); + pNew->SetBottom( lcl_GetValue( *m_xBottomMF, eUnit ) ); bModified |= nullptr != rSet->Put( *pNew ); } - if( m_pZoomConstRB->IsValueChangedFromSaved() ) + if( m_xZoomConstRB->get_state_changed_from_saved() ) { bModified |= nullptr != rSet->Put( SfxBoolItem( rPool.GetWhich( - SID_ATTR_GRAF_KEEP_ZOOM), m_pZoomConstRB->IsChecked() ) ); + SID_ATTR_GRAF_KEEP_ZOOM), m_xZoomConstRB->get_active() ) ); } return bModified; @@ -337,34 +301,16 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet) nOldWidth = aSize.Width(); nOldHeight = aSize.Height(); - sal_Int64 nWidth = m_pWidthMF->Normalize(nOldWidth); - sal_Int64 nHeight = m_pHeightMF->Normalize(nOldHeight); + auto nWidth = m_xWidthMF->normalize(nOldWidth); + auto nHeight = m_xHeightMF->normalize(nOldHeight); - if (nWidth != m_pWidthMF->GetValue(FUNIT_TWIP)) - { - if(!bReset) - { - // value was changed by wrap-tabpage and has to - // be set with modify-flag - m_pWidthMF->SetUserValue(nWidth, FUNIT_TWIP); - } - else - m_pWidthMF->SetValue(nWidth, FUNIT_TWIP); - } - m_pWidthMF->SaveValue(); + if (nWidth != m_xWidthMF->get_value(FUNIT_TWIP)) + m_xWidthMF->set_value(nWidth, FUNIT_TWIP); + m_xWidthMF->save_value(); - if (nHeight != m_pHeightMF->GetValue(FUNIT_TWIP)) - { - if (!bReset) - { - // value was changed by wrap-tabpage and has to - // be set with modify-flag - m_pHeightMF->SetUserValue(nHeight, FUNIT_TWIP); - } - else - m_pHeightMF->SetValue(nHeight, FUNIT_TWIP); - } - m_pHeightMF->SaveValue(); + if (nHeight != m_xHeightMF->get_value(FUNIT_TWIP)) + m_xHeightMF->set_value(nHeight, FUNIT_TWIP); + m_xHeightMF->save_value(); if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, false, &pItem ) ) { @@ -382,12 +328,12 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet) const Graphic* pGrf = rBrush.GetGraphic(referer); if( pGrf ) { - m_pExampleWN->SetGraphic( *pGrf ); + m_aExampleWN.SetGraphic( *pGrf ); aOrigSize = GetGrfOrigSize( *pGrf ); if (pGrf->GetType() == GraphicType::Bitmap && aOrigSize.Width() > 1 && aOrigSize.Height() > 1) { aOrigPixelSize = pGrf->GetSizePixel(); } - m_pExampleWN->SetFrameSize(aOrigSize); + m_aExampleWN.SetFrameSize(aOrigSize); GraphicHasChanged( aOrigSize.Width() && aOrigSize.Height() ); CalcMinMaxBorder(); } @@ -409,27 +355,27 @@ DeactivateRC SvxGrfCropPage::DeactivatePage(SfxItemSet *_pSet) description: scale changed, adjust size --------------------------------------------------------------------*/ -IMPL_LINK( SvxGrfCropPage, ZoomHdl, Edit&, rField, void ) +IMPL_LINK( SvxGrfCropPage, ZoomHdl, weld::MetricSpinButton&, rField, void ) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( SID_ATTR_GRAF_CROP ) ) ); - if( &rField == m_pWidthZoomMF ) + if (&rField == m_xWidthZoomMF.get()) { - long nLRBorders = lcl_GetValue(*m_pLeftMF, eUnit) - +lcl_GetValue(*m_pRightMF, eUnit); - m_pWidthMF->SetValue( m_pWidthMF->Normalize( - ((aOrigSize.Width() - nLRBorders) * static_cast<MetricField&>(rField).GetValue())/100), + long nLRBorders = lcl_GetValue(*m_xLeftMF, eUnit) + +lcl_GetValue(*m_xRightMF, eUnit); + m_xWidthMF->set_value( m_xWidthMF->normalize( + ((aOrigSize.Width() - nLRBorders) * rField.get_value(FUNIT_NONE))/100), eUnit); } else { - long nULBorders = lcl_GetValue(*m_pTopMF, eUnit) - +lcl_GetValue(*m_pBottomMF, eUnit); - m_pHeightMF->SetValue( m_pHeightMF->Normalize( - ((aOrigSize.Height() - nULBorders ) * static_cast<MetricField&>(rField).GetValue())/100) , + long nULBorders = lcl_GetValue(*m_xTopMF, eUnit) + +lcl_GetValue(*m_xBottomMF, eUnit); + m_xHeightMF->set_value( m_xHeightMF->normalize( + ((aOrigSize.Height() - nULBorders ) * rField.get_value(FUNIT_NONE))/100) , eUnit ); } } @@ -438,35 +384,35 @@ IMPL_LINK( SvxGrfCropPage, ZoomHdl, Edit&, rField, void ) description: change size, adjust scale --------------------------------------------------------------------*/ -IMPL_LINK( SvxGrfCropPage, SizeHdl, Edit&, rField, void ) +IMPL_LINK( SvxGrfCropPage, SizeHdl, weld::MetricSpinButton&, rField, void ) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( SID_ATTR_GRAF_CROP ) ) ); - Size aSize( lcl_GetValue(*m_pWidthMF, eUnit), - lcl_GetValue(*m_pHeightMF, eUnit) ); + Size aSize( lcl_GetValue(*m_xWidthMF, eUnit), + lcl_GetValue(*m_xHeightMF, eUnit) ); - if(&rField == m_pWidthMF) + if(&rField == m_xWidthMF.get()) { long nWidth = aOrigSize.Width() - - ( lcl_GetValue(*m_pLeftMF, eUnit) + - lcl_GetValue(*m_pRightMF, eUnit) ); + ( lcl_GetValue(*m_xLeftMF, eUnit) + + lcl_GetValue(*m_xRightMF, eUnit) ); if(!nWidth) nWidth++; sal_uInt16 nZoom = static_cast<sal_uInt16>( aSize.Width() * 100 / nWidth); - m_pWidthZoomMF->SetValue(nZoom); + m_xWidthZoomMF->set_value(nZoom, FUNIT_NONE); } else { long nHeight = aOrigSize.Height() - - ( lcl_GetValue(*m_pTopMF, eUnit) + - lcl_GetValue(*m_pBottomMF, eUnit)); + ( lcl_GetValue(*m_xTopMF, eUnit) + + lcl_GetValue(*m_xBottomMF, eUnit)); if(!nHeight) nHeight++; sal_uInt16 nZoom = static_cast<sal_uInt16>( aSize.Height() * 100 / nHeight); - m_pHeightZoomMF->SetValue(nZoom); + m_xHeightZoomMF->set_value(nZoom, FUNIT_NONE); } } @@ -474,82 +420,82 @@ IMPL_LINK( SvxGrfCropPage, SizeHdl, Edit&, rField, void ) description: evaluate border --------------------------------------------------------------------*/ -IMPL_LINK( SvxGrfCropPage, CropHdl, SpinField&, rField, void ) +IMPL_LINK( SvxGrfCropPage, CropModifyHdl, weld::MetricSpinButton&, rField, void ) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( SID_ATTR_GRAF_CROP ) ) ); - bool bZoom = m_pZoomConstRB->IsChecked(); - if( &rField == m_pLeftMF || &rField == m_pRightMF ) + bool bZoom = m_xZoomConstRB->get_active(); + if (&rField == m_xLeftMF.get() || &rField == m_xRightMF.get()) { - long nLeft = lcl_GetValue( *m_pLeftMF, eUnit ); - long nRight = lcl_GetValue( *m_pRightMF, eUnit ); - long nWidthZoom = static_cast<long>(m_pWidthZoomMF->GetValue()); + long nLeft = lcl_GetValue( *m_xLeftMF, eUnit ); + long nRight = lcl_GetValue( *m_xRightMF, eUnit ); + long nWidthZoom = static_cast<long>(m_xWidthZoomMF->get_value(FUNIT_NONE)); if (bZoom && nWidthZoom != 0 && ( ( ( aOrigSize.Width() - (nLeft + nRight )) * nWidthZoom ) / 100 >= aPageSize.Width() ) ) { - if(&rField == m_pLeftMF) + if (&rField == m_xLeftMF.get()) { nLeft = aOrigSize.Width() - ( aPageSize.Width() * 100 / nWidthZoom + nRight ); - m_pLeftMF->SetValue( m_pLeftMF->Normalize( nLeft ), eUnit ); + m_xLeftMF->set_value( m_xLeftMF->normalize( nLeft ), eUnit ); } else { nRight = aOrigSize.Width() - ( aPageSize.Width() * 100 / nWidthZoom + nLeft ); - m_pRightMF->SetValue( m_pRightMF->Normalize( nRight ), eUnit ); + m_xRightMF->set_value( m_xRightMF->normalize( nRight ), eUnit ); } } if (AllSettings::GetLayoutRTL()) { - m_pExampleWN->SetLeft(nRight); - m_pExampleWN->SetRight(nLeft); + m_aExampleWN.SetLeft(nRight); + m_aExampleWN.SetRight(nLeft); } else { - m_pExampleWN->SetLeft(nLeft); - m_pExampleWN->SetRight(nRight); + m_aExampleWN.SetLeft(nLeft); + m_aExampleWN.SetRight(nRight); } if(bZoom) { // scale stays, recompute width - ZoomHdl(*m_pWidthZoomMF); + ZoomHdl(*m_xWidthZoomMF); } } else { - long nTop = lcl_GetValue( *m_pTopMF, eUnit ); - long nBottom = lcl_GetValue( *m_pBottomMF, eUnit ); - long nHeightZoom = static_cast<long>(m_pHeightZoomMF->GetValue()); + long nTop = lcl_GetValue( *m_xTopMF, eUnit ); + long nBottom = lcl_GetValue( *m_xBottomMF, eUnit ); + long nHeightZoom = static_cast<long>(m_xHeightZoomMF->get_value(FUNIT_NONE)); if(bZoom && ( ( ( aOrigSize.Height() - (nTop + nBottom )) * nHeightZoom) / 100 >= aPageSize.Height())) { assert(nHeightZoom && "div-by-zero"); - if(&rField == m_pTopMF) + if(&rField == m_xTopMF.get()) { nTop = aOrigSize.Height() - ( aPageSize.Height() * 100 / nHeightZoom + nBottom); - m_pTopMF->SetValue( m_pWidthMF->Normalize( nTop ), eUnit ); + m_xTopMF->set_value( m_xWidthMF->normalize( nTop ), eUnit ); } else { nBottom = aOrigSize.Height() - ( aPageSize.Height() * 100 / nHeightZoom + nTop); - m_pBottomMF->SetValue( m_pWidthMF->Normalize( nBottom ), eUnit ); + m_xBottomMF->set_value( m_xWidthMF->normalize( nBottom ), eUnit ); } } - m_pExampleWN->SetTop( nTop ); - m_pExampleWN->SetBottom( nBottom ); + m_aExampleWN.SetTop( nTop ); + m_aExampleWN.SetBottom( nBottom ); if(bZoom) { // scale stays, recompute height - ZoomHdl(*m_pHeightZoomMF); + ZoomHdl(*m_xHeightZoomMF); } } - m_pExampleWN->Invalidate(); + m_aExampleWN.Invalidate(); // size and border changed -> recompute scale if(!bZoom) CalcZoom(); @@ -559,7 +505,7 @@ IMPL_LINK( SvxGrfCropPage, CropHdl, SpinField&, rField, void ) description: set original size --------------------------------------------------------------------*/ -IMPL_LINK_NOARG(SvxGrfCropPage, OrigSizeHdl, Button*, void) +IMPL_LINK_NOARG(SvxGrfCropPage, OrigSizeHdl, weld::Button&, void) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); @@ -567,15 +513,15 @@ IMPL_LINK_NOARG(SvxGrfCropPage, OrigSizeHdl, Button*, void) SID_ATTR_GRAF_CROP ) ) ); long nWidth = aOrigSize.Width() - - lcl_GetValue( *m_pLeftMF, eUnit ) - - lcl_GetValue( *m_pRightMF, eUnit ); - m_pWidthMF->SetValue( m_pWidthMF->Normalize( nWidth ), eUnit ); + lcl_GetValue( *m_xLeftMF, eUnit ) - + lcl_GetValue( *m_xRightMF, eUnit ); + m_xWidthMF->set_value( m_xWidthMF->normalize( nWidth ), eUnit ); long nHeight = aOrigSize.Height() - - lcl_GetValue( *m_pTopMF, eUnit ) - - lcl_GetValue( *m_pBottomMF, eUnit ); - m_pHeightMF->SetValue( m_pHeightMF->Normalize( nHeight ), eUnit ); - m_pWidthZoomMF->SetValue(100); - m_pHeightZoomMF->SetValue(100); + lcl_GetValue( *m_xTopMF, eUnit ) - + lcl_GetValue( *m_xBottomMF, eUnit ); + m_xHeightMF->set_value( m_xHeightMF->normalize( nHeight ), eUnit ); + m_xWidthZoomMF->set_value(100, FUNIT_NONE); + m_xHeightZoomMF->set_value(100, FUNIT_NONE); bSetOrigSize = true; } /*-------------------------------------------------------------------- @@ -589,22 +535,22 @@ void SvxGrfCropPage::CalcZoom() FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( SID_ATTR_GRAF_CROP ) ) ); - long nWidth = lcl_GetValue( *m_pWidthMF, eUnit ); - long nHeight = lcl_GetValue( *m_pHeightMF, eUnit ); - long nLRBorders = lcl_GetValue( *m_pLeftMF, eUnit ) + - lcl_GetValue( *m_pRightMF, eUnit ); - long nULBorders = lcl_GetValue( *m_pTopMF, eUnit ) + - lcl_GetValue( *m_pBottomMF, eUnit ); + long nWidth = lcl_GetValue( *m_xWidthMF, eUnit ); + long nHeight = lcl_GetValue( *m_xHeightMF, eUnit ); + long nLRBorders = lcl_GetValue( *m_xLeftMF, eUnit ) + + lcl_GetValue( *m_xRightMF, eUnit ); + long nULBorders = lcl_GetValue( *m_xTopMF, eUnit ) + + lcl_GetValue( *m_xBottomMF, eUnit ); sal_uInt16 nZoom = 0; long nDen; if( (nDen = aOrigSize.Width() - nLRBorders) > 0) nZoom = static_cast<sal_uInt16>((( nWidth * 1000 / nDen )+5)/10); - m_pWidthZoomMF->SetValue(nZoom); + m_xWidthZoomMF->set_value(nZoom, FUNIT_NONE); if( (nDen = aOrigSize.Height() - nULBorders) > 0) nZoom = static_cast<sal_uInt16>((( nHeight * 1000 / nDen )+5)/10); else nZoom = 0; - m_pHeightZoomMF->SetValue(nZoom); + m_xHeightZoomMF->set_value(nZoom, FUNIT_NONE); } /*-------------------------------------------------------------------- @@ -617,23 +563,23 @@ void SvxGrfCropPage::CalcMinMaxBorder() DBG_ASSERT( pPool, "Where is the pool?" ); FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( SID_ATTR_GRAF_CROP ) ) ); - long nR = lcl_GetValue(*m_pRightMF, eUnit ); + long nR = lcl_GetValue(*m_xRightMF, eUnit ); long nMinWidth = (aOrigSize.Width() * 10) /11; long nMin = nMinWidth - (nR >= 0 ? nR : 0); - m_pLeftMF->SetMax( m_pLeftMF->Normalize(nMin), eUnit ); + m_xLeftMF->set_max( m_xLeftMF->normalize(nMin), eUnit ); - long nL = lcl_GetValue(*m_pLeftMF, eUnit ); + long nL = lcl_GetValue(*m_xLeftMF, eUnit ); nMin = nMinWidth - (nL >= 0 ? nL : 0); - m_pRightMF->SetMax( m_pRightMF->Normalize(nMin), eUnit ); + m_xRightMF->set_max( m_xRightMF->normalize(nMin), eUnit ); - long nUp = lcl_GetValue( *m_pTopMF, eUnit ); + long nUp = lcl_GetValue( *m_xTopMF, eUnit ); long nMinHeight = (aOrigSize.Height() * 10) /11; nMin = nMinHeight - (nUp >= 0 ? nUp : 0); - m_pBottomMF->SetMax( m_pBottomMF->Normalize(nMin), eUnit ); + m_xBottomMF->set_max( m_xBottomMF->normalize(nMin), eUnit ); - long nLow = lcl_GetValue(*m_pBottomMF, eUnit ); + long nLow = lcl_GetValue(*m_xBottomMF, eUnit ); nMin = nMinHeight - (nLow >= 0 ? nLow : 0); - m_pTopMF->SetMax( m_pTopMF->Normalize(nMin), eUnit ); + m_xTopMF->set_max( m_xTopMF->normalize(nMin), eUnit ); } /*-------------------------------------------------------------------- description: set spinsize to 1/20 of the original size, @@ -649,46 +595,46 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( SID_ATTR_GRAF_CROP ) )); - sal_Int64 nSpin = m_pLeftMF->Normalize(aOrigSize.Width()) / 20; + sal_Int64 nSpin = m_xLeftMF->normalize(aOrigSize.Width()) / 20; nSpin = MetricField::ConvertValue( nSpin, aOrigSize.Width(), 0, - eUnit, m_pLeftMF->GetUnit()); + eUnit, m_xLeftMF->get_unit()); // if the margin is too big, it is set to 1/3 on both pages - long nR = lcl_GetValue( *m_pRightMF, eUnit ); - long nL = lcl_GetValue( *m_pLeftMF, eUnit ); + long nR = lcl_GetValue( *m_xRightMF, eUnit ); + long nL = lcl_GetValue( *m_xLeftMF, eUnit ); if((nL + nR) < - aOrigSize.Width()) { long nVal = aOrigSize.Width() / -3; - m_pRightMF->SetValue( m_pRightMF->Normalize( nVal ), eUnit ); - m_pLeftMF->SetValue( m_pLeftMF->Normalize( nVal ), eUnit ); - m_pExampleWN->SetLeft(nVal); - m_pExampleWN->SetRight(nVal); + m_xRightMF->set_value( m_xRightMF->normalize( nVal ), eUnit ); + m_xLeftMF->set_value( m_xLeftMF->normalize( nVal ), eUnit ); + m_aExampleWN.SetLeft(nVal); + m_aExampleWN.SetRight(nVal); } - long nUp = lcl_GetValue(*m_pTopMF, eUnit ); - long nLow = lcl_GetValue(*m_pBottomMF, eUnit ); + long nUp = lcl_GetValue(*m_xTopMF, eUnit ); + long nLow = lcl_GetValue(*m_xBottomMF, eUnit ); if((nUp + nLow) < - aOrigSize.Height()) { long nVal = aOrigSize.Height() / -3; - m_pTopMF->SetValue( m_pTopMF->Normalize( nVal ), eUnit ); - m_pBottomMF->SetValue( m_pBottomMF->Normalize( nVal ), eUnit ); - m_pExampleWN->SetTop(nVal); - m_pExampleWN->SetBottom(nVal); + m_xTopMF->set_value( m_xTopMF->normalize( nVal ), eUnit ); + m_xBottomMF->set_value( m_xBottomMF->normalize( nVal ), eUnit ); + m_aExampleWN.SetTop(nVal); + m_aExampleWN.SetBottom(nVal); } - m_pLeftMF->SetSpinSize(nSpin); - m_pRightMF->SetSpinSize(nSpin); - nSpin = m_pTopMF->Normalize(aOrigSize.Height()) / 20; + m_xLeftMF->set_increments(nSpin, nSpin * 10, FUNIT_NONE); + m_xRightMF->set_increments(nSpin, nSpin * 10, FUNIT_NONE); + nSpin = m_xTopMF->normalize(aOrigSize.Height()) / 20; nSpin = MetricField::ConvertValue( nSpin, aOrigSize.Width(), 0, - eUnit, m_pLeftMF->GetUnit() ); - m_pTopMF->SetSpinSize(nSpin); - m_pBottomMF->SetSpinSize(nSpin); + eUnit, m_xLeftMF->get_unit() ); + m_xTopMF->set_increments(nSpin, nSpin * 10, FUNIT_NONE); + m_xBottomMF->set_increments(nSpin, nSpin * 10, FUNIT_NONE); // display original size const FieldUnit eMetric = GetModuleFieldUnit( GetItemSet() ); ScopedVclPtrInstance< MetricField > aFld(this, WB_HIDE); SetFieldUnit( *aFld.get(), eMetric ); - aFld->SetDecimalDigits( m_pWidthMF->GetDecimalDigits() ); + aFld->SetDecimalDigits(m_xWidthMF->get_digits()); aFld->SetMax( LONG_MAX - 1 ); aFld->SetValue( aFld->Normalize( aOrigSize.Width() ), eUnit ); @@ -710,37 +656,14 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) } sTemp = sTemp.replaceAll("%1", sPPI); } - m_pOrigSizeFT->SetText( sTemp ); + m_xOrigSizeFT->set_label(sTemp); } - m_pCropFrame->Enable(bFound); - m_pScaleFrame->Enable(bFound); - m_pSizeFrame->Enable(bFound); - m_pOrigSizeGrid->Enable(bFound); - m_pZoomConstRB->Enable(bFound); -} - -IMPL_LINK_NOARG(SvxGrfCropPage, Timeout, Timer *, void) -{ - DBG_ASSERT(pLastCropField,"Timeout without field?"); - CropHdl(*pLastCropField); - pLastCropField = nullptr; -} - - -IMPL_LINK( SvxGrfCropPage, CropLoseFocusHdl, Control&, rControl, void ) -{ - MetricField* pField = static_cast<MetricField*>(&rControl); - aTimer.Stop(); - CropHdl(*pField); - pLastCropField = nullptr; -} - - -IMPL_LINK( SvxGrfCropPage, CropModifyHdl, Edit&, rField, void ) -{ - aTimer.Start(); - pLastCropField = static_cast<MetricField*>(&rField); + m_xCropFrame->set_sensitive(bFound); + m_xScaleFrame->set_sensitive(bFound); + m_xSizeFrame->set_sensitive(bFound); + m_xOrigSizeGrid->set_sensitive(bFound); + m_xZoomConstRB->set_sensitive(bFound); } Size SvxGrfCropPage::GetGrfOrigSize( const Graphic& rGrf ) const @@ -757,72 +680,74 @@ Size SvxGrfCropPage::GetGrfOrigSize( const Graphic& rGrf ) const /*****************************************************************/ -SvxCropExample::SvxCropExample( vcl::Window* pPar, WinBits nStyle ) - : Window( pPar, nStyle) - , aFrameSize( OutputDevice::LogicToLogic( - Size( CM_1_TO_TWIP / 2, CM_1_TO_TWIP / 2 ), - MapMode( MapUnit::MapTwip ), GetMapMode() )) - , aTopLeft(0,0) - , aBottomRight(0,0) +SvxCropExample::SvxCropExample() + : m_aTopLeft(0, 0) + , m_aBottomRight(0, 0) { - SetBorderStyle( WindowBorderStyle::MONO ); } -Size SvxCropExample::GetOptimalSize() const +void SvxCropExample::SetDrawingArea(weld::DrawingArea* pDrawingArea) { - return LogicToPixel(Size(78, 78), MapMode(MapUnit::MapAppFont)); + CustomWidgetController::SetDrawingArea(pDrawingArea); + OutputDevice& rDevice = pDrawingArea->get_ref_device(); + Size aSize(rDevice.LogicToPixel(Size(78, 78), MapMode(MapUnit::MapAppFont))); + pDrawingArea->set_size_request(aSize.Width(), aSize.Height()); + + m_aMapMode = rDevice.GetMapMode(); + m_aFrameSize = OutputDevice::LogicToLogic( + Size(CM_1_TO_TWIP / 2, CM_1_TO_TWIP / 2), + MapMode(MapUnit::MapTwip), m_aMapMode); } -VCL_BUILDER_FACTORY_CONSTRUCTOR(SvxCropExample, 0) - void SvxCropExample::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle&) { + rRenderContext.Push(PushFlags::MAPMODE | PushFlags::RASTEROP); + rRenderContext.SetMapMode(m_aMapMode); + Size aWinSize(rRenderContext.PixelToLogic(GetOutputSizePixel())); rRenderContext.SetLineColor(); rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetWindowColor()); - rRenderContext.SetRasterOp(RasterOp::OverPaint); rRenderContext.DrawRect(::tools::Rectangle(Point(), aWinSize)); rRenderContext.SetLineColor(COL_WHITE); - ::tools::Rectangle aRect(Point((aWinSize.Width() - aFrameSize.Width())/2, - (aWinSize.Height() - aFrameSize.Height())/2), - aFrameSize); - aGrf.Draw(&rRenderContext, aRect.TopLeft(), aRect.GetSize()); + ::tools::Rectangle aRect(Point((aWinSize.Width() - m_aFrameSize.Width())/2, + (aWinSize.Height() - m_aFrameSize.Height())/2), + m_aFrameSize); + m_aGrf.Draw(&rRenderContext, aRect.TopLeft(), aRect.GetSize()); rRenderContext.SetFillColor(COL_TRANSPARENT); rRenderContext.SetRasterOp(RasterOp::Invert); - aRect.AdjustLeft(aTopLeft.Y() ); - aRect.AdjustTop(aTopLeft.X() ); - aRect.AdjustRight( -(aBottomRight.Y()) ); - aRect.AdjustBottom( -(aBottomRight.X()) ); + aRect.AdjustLeft(m_aTopLeft.Y() ); + aRect.AdjustTop(m_aTopLeft.X() ); + aRect.AdjustRight(-m_aBottomRight.Y()); + aRect.AdjustBottom(-m_aBottomRight.X()); rRenderContext.DrawRect(aRect); + + rRenderContext.Pop(); } void SvxCropExample::Resize() { - SetFrameSize(aFrameSize); + SetFrameSize(m_aFrameSize); } void SvxCropExample::SetFrameSize( const Size& rSz ) { - aFrameSize = rSz; - if(!aFrameSize.Width()) - aFrameSize.setWidth( 1 ); - if(!aFrameSize.Height()) - aFrameSize.setHeight( 1 ); + m_aFrameSize = rSz; + if (!m_aFrameSize.Width()) + m_aFrameSize.setWidth( 1 ); + if (!m_aFrameSize.Height()) + m_aFrameSize.setHeight( 1 ); Size aWinSize( GetOutputSizePixel() ); - Fraction aXScale( aWinSize.Width() * 4, aFrameSize.Width() * 5 ); - Fraction aYScale( aWinSize.Height() * 4, aFrameSize.Height() * 5 ); + Fraction aXScale( aWinSize.Width() * 4, m_aFrameSize.Width() * 5 ); + Fraction aYScale( aWinSize.Height() * 4, m_aFrameSize.Height() * 5 ); if( aYScale < aXScale ) aXScale = aYScale; - MapMode aMapMode( GetMapMode() ); - - aMapMode.SetScaleX( aXScale ); - aMapMode.SetScaleY( aXScale ); + m_aMapMode.SetScaleX(aXScale); + m_aMapMode.SetScaleY(aXScale); - SetMapMode( aMapMode ); Invalidate(); } diff --git a/cui/uiconfig/ui/croppage.ui b/cui/uiconfig/ui/croppage.ui index 2c083f184568..c3b5ff00942e 100644 --- a/cui/uiconfig/ui/croppage.ui +++ b/cui/uiconfig/ui/croppage.ui @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="cui"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkAdjustment" id="adjustment1"> <property name="lower">-99.989999999999995</property> <property name="upper">99.989999999999995</property> @@ -22,6 +21,36 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> + <object class="GtkAdjustment" id="adjustment4"> + <property name="lower">0.050000000000000003</property> + <property name="upper">200</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment5"> + <property name="lower">1</property> + <property name="upper">9999</property> + <property name="step_increment">10</property> + <property name="page_increment">100</property> + </object> + <object class="GtkAdjustment" id="adjustment6"> + <property name="lower">-99.989999999999995</property> + <property name="upper">99.989999999999995</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment7"> + <property name="lower">-99.989999999999995</property> + <property name="upper">99.989999999999995</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment8"> + <property name="lower">-99.989999999999995</property> + <property name="upper">99.989999999999995</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> <object class="GtkGrid" id="CropPage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -93,10 +122,10 @@ <object class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="croppage|label2">_Left:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">left:0.00cm</property> + <property name="mnemonic_widget">left</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -104,9 +133,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="left:0.00cm"> + <object class="GtkSpinButton" id="left"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="adjustment">adjustment1</property> <property name="digits">2</property> </object> @@ -119,10 +149,10 @@ <object class="GtkLabel" id="label3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="croppage|label3">_Right:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">right:0.00cm</property> + <property name="mnemonic_widget">right</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -130,10 +160,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="right:0.00cm"> + <object class="GtkSpinButton" id="right"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">adjustment1</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustment7</property> <property name="digits">2</property> </object> <packing> @@ -157,10 +188,10 @@ <object class="GtkLabel" id="label4"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="croppage|label4">_Top:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">top:0.00cm</property> + <property name="mnemonic_widget">top</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -171,10 +202,10 @@ <object class="GtkLabel" id="label5"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="croppage|label5">_Bottom:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">bottom:0.00cm</property> + <property name="mnemonic_widget">bottom</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -182,10 +213,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="top:0.00cm"> + <object class="GtkSpinButton" id="top"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">adjustment1</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustment6</property> <property name="digits">2</property> </object> <packing> @@ -194,10 +226,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="bottom:0.00cm"> + <object class="GtkSpinButton" id="bottom"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">adjustment1</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustment8</property> <property name="digits">2</property> </object> <packing> @@ -253,10 +286,10 @@ <object class="GtkLabel" id="label6"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="croppage|label6">_Width:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">widthzoom:0%</property> + <property name="mnemonic_widget">widthzoom</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -264,9 +297,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="widthzoom:0%"> + <object class="GtkSpinButton" id="widthzoom"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="adjustment">adjustment2</property> </object> <packing> @@ -278,10 +312,10 @@ <object class="GtkLabel" id="label7"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="croppage|label7">_Height:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">heightzoom:0%</property> + <property name="mnemonic_widget">heightzoom</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -289,10 +323,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="heightzoom:0%"> + <object class="GtkSpinButton" id="heightzoom"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">adjustment2</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustment5</property> </object> <packing> <property name="left_attach">1</property> @@ -341,10 +376,10 @@ <object class="GtkLabel" id="label8"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="croppage|label8">_Width:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">width:0.00cm</property> + <property name="mnemonic_widget">width</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -352,9 +387,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="width:0.00cm"> + <object class="GtkSpinButton" id="width"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="adjustment">adjustment3</property> <property name="digits">2</property> </object> @@ -367,10 +403,10 @@ <object class="GtkLabel" id="label9"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="croppage|label9">_Height:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">height:0.00cm</property> + <property name="mnemonic_widget">height</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -378,10 +414,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="height:0.00cm"> + <object class="GtkSpinButton" id="height"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">adjustment3</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustment4</property> <property name="digits">2</property> </object> <packing> @@ -415,11 +452,28 @@ <property name="can_focus">False</property> <property name="hexpand">True</property> <child> - <object class="cuilo-SvxCropExample" id="preview:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">center</property> <property name="hexpand">True</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkDrawingArea" id="preview"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">center</property> + <property name="hexpand">True</property> + </object> + </child> + </object> + </child> </object> <packing> <property name="left_attach">0</property> @@ -488,14 +542,14 @@ </object> <object class="GtkSizeGroup" id="sizegroup2"> <widgets> - <widget name="left:0.00cm"/> - <widget name="right:0.00cm"/> - <widget name="top:0.00cm"/> - <widget name="bottom:0.00cm"/> - <widget name="widthzoom:0%"/> - <widget name="heightzoom:0%"/> - <widget name="width:0.00cm"/> - <widget name="height:0.00cm"/> + <widget name="left"/> + <widget name="right"/> + <widget name="top"/> + <widget name="bottom"/> + <widget name="widthzoom"/> + <widget name="heightzoom"/> + <widget name="width"/> + <widget name="height"/> </widgets> </object> </interface> |