cui/source/inc/cuitabarea.hxx | 65 +++--- cui/source/tabpages/tptrans.cxx | 352 +++++++++++++++------------------ cui/uiconfig/ui/transparencytabpage.ui | 162 ++++++++++----- include/svx/dlgctrl.hxx | 51 ++++ include/vcl/customweld.hxx | 1 svx/source/dialog/dlgctrl.cxx | 149 +++++++++++++ 6 files changed, 511 insertions(+), 269 deletions(-)
New commits: commit df652aa70869f42ada2f4d8e7d1cacf55c6e6e96 Author: Caolán McNamara <caol...@redhat.com> Date: Tue Jun 12 11:22:15 2018 +0100 weld SvxTransparenceTabPage Change-Id: If8c8a6cf74664f9acd360d877c57e8dd9de2f2b5 Reviewed-on: https://gerrit.libreoffice.org/55683 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index da368bf460e0..7a72431bb9a5 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -146,42 +146,48 @@ class SvxTransparenceTabPage : public SvxTabPage PageType nPageType; sal_uInt16 nDlgType; + bool bBitmap; + + XFillAttrSetItem aXFillAttr; + SfxItemSet& rXFSet; + + XRectPreview m_aCtlBitmapPreview; + XRectPreview m_aCtlXRectPreview; + // main selection - VclPtr<RadioButton> m_pRbtTransOff; - VclPtr<RadioButton> m_pRbtTransLinear; - VclPtr<RadioButton> m_pRbtTransGradient; + std::unique_ptr<weld::RadioButton> m_xRbtTransOff; + std::unique_ptr<weld::RadioButton> m_xRbtTransLinear; + std::unique_ptr<weld::RadioButton> m_xRbtTransGradient; /// linear transparency - VclPtr<MetricField> m_pMtrTransparent; + std::unique_ptr<weld::MetricSpinButton> m_xMtrTransparent; // gradient transparency - VclPtr<VclGrid> m_pGridGradient; - VclPtr<ListBox> m_pLbTrgrGradientType; - VclPtr<FixedText> m_pFtTrgrCenterX; - VclPtr<MetricField> m_pMtrTrgrCenterX; - VclPtr<FixedText> m_pFtTrgrCenterY; - VclPtr<MetricField> m_pMtrTrgrCenterY; - VclPtr<FixedText> m_pFtTrgrAngle; - VclPtr<MetricField> m_pMtrTrgrAngle; - VclPtr<MetricField> m_pMtrTrgrBorder; - VclPtr<MetricField> m_pMtrTrgrStartValue; - VclPtr<MetricField> m_pMtrTrgrEndValue; + std::unique_ptr<weld::Widget> m_xGridGradient; + std::unique_ptr<weld::ComboBoxText> m_xLbTrgrGradientType; + std::unique_ptr<weld::Label> m_xFtTrgrCenterX; + std::unique_ptr<weld::MetricSpinButton> m_xMtrTrgrCenterX; + std::unique_ptr<weld::Label> m_xFtTrgrCenterY; + std::unique_ptr<weld::MetricSpinButton> m_xMtrTrgrCenterY; + std::unique_ptr<weld::Label> m_xFtTrgrAngle; + std::unique_ptr<weld::MetricSpinButton> m_xMtrTrgrAngle; + std::unique_ptr<weld::MetricSpinButton> m_xMtrTrgrBorder; + std::unique_ptr<weld::MetricSpinButton> m_xMtrTrgrStartValue; + std::unique_ptr<weld::MetricSpinButton> m_xMtrTrgrEndValue; + std::unique_ptr<weld::Widget> m_xCtlBitmapBorder; + std::unique_ptr<weld::Widget> m_xCtlXRectBorder; // preview - VclPtr<SvxXRectPreview> m_pCtlBitmapPreview; - VclPtr<SvxXRectPreview> m_pCtlXRectPreview; - bool bBitmap; - - XFillAttrSetItem aXFillAttr; - SfxItemSet& rXFSet; + std::unique_ptr<weld::CustomWeld> m_xCtlBitmapPreview; + std::unique_ptr<weld::CustomWeld> m_xCtlXRectPreview; - DECL_LINK(ClickTransOffHdl_Impl, Button*, void ); - DECL_LINK(ClickTransLinearHdl_Impl, Button*, void ); - DECL_LINK(ClickTransGradientHdl_Impl, Button*, void ); - DECL_LINK(ModifyTransparentHdl_Impl, Edit&, void); - DECL_LINK(ModifiedTrgrEditHdl_Impl, Edit&, void); - DECL_LINK(ModifiedTrgrListBoxHdl_Impl, ListBox&, void); - void ModifiedTrgrHdl_Impl(void const *); + DECL_LINK(ClickTransOffHdl_Impl, weld::ToggleButton&, void); + DECL_LINK(ClickTransLinearHdl_Impl, weld::ToggleButton&, void); + DECL_LINK(ClickTransGradientHdl_Impl, weld::ToggleButton&, void ); + DECL_LINK(ModifyTransparentHdl_Impl, weld::MetricSpinButton&, void); + DECL_LINK(ModifiedTrgrEditHdl_Impl, weld::MetricSpinButton&, void); + DECL_LINK(ModifiedTrgrListBoxHdl_Impl, weld::ComboBoxText&, void); + void ModifiedTrgrHdl_Impl(const weld::ComboBoxText*); void ActivateLinear(bool bActivate); void ActivateGradient(bool bActivate); @@ -191,9 +197,8 @@ class SvxTransparenceTabPage : public SvxTabPage void InvalidatePreview (bool bEnable = true ); public: - SvxTransparenceTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs); + SvxTransparenceTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs); virtual ~SvxTransparenceTabPage() override; - virtual void dispose() override; static VclPtr<SfxTabPage> Create(TabPageParent, const SfxItemSet*); static const sal_uInt16* GetRanges() { return pTransparenceRanges; } diff --git a/cui/source/tabpages/tptrans.cxx b/cui/source/tabpages/tptrans.cxx index 1f6fc20da7dd..f75416c0c94b 100644 --- a/cui/source/tabpages/tptrans.cxx +++ b/cui/source/tabpages/tptrans.cxx @@ -59,22 +59,22 @@ const sal_uInt16 SvxTransparenceTabPage::pTransparenceRanges[] = |* \************************************************************************/ -IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransOffHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransOffHdl_Impl, weld::ToggleButton&, void) { // disable all other controls ActivateLinear(false); ActivateGradient(false); // Preview - rXFSet.ClearItem (XATTR_FILLTRANSPARENCE); - rXFSet.ClearItem (XATTR_FILLFLOATTRANSPARENCE); - m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() ); - m_pCtlBitmapPreview->SetAttributes( aXFillAttr.GetItemSet() ); + rXFSet.ClearItem(XATTR_FILLTRANSPARENCE); + rXFSet.ClearItem(XATTR_FILLFLOATTRANSPARENCE); + m_aCtlXRectPreview.SetAttributes( aXFillAttr.GetItemSet() ); + m_aCtlBitmapPreview.SetAttributes( aXFillAttr.GetItemSet() ); - InvalidatePreview( false ); + InvalidatePreview(false); } -IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransLinearHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransLinearHdl_Impl, weld::ToggleButton&, void) { // enable linear, disable other ActivateLinear(true); @@ -82,10 +82,10 @@ IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransLinearHdl_Impl, Button*, void) // preview rXFSet.ClearItem (XATTR_FILLFLOATTRANSPARENCE); - ModifyTransparentHdl_Impl (*m_pMtrTransparent); + ModifyTransparentHdl_Impl(*m_xMtrTransparent); } -IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransGradientHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransGradientHdl_Impl, weld::ToggleButton&, void) { // enable gradient, disable other ActivateLinear(false); @@ -93,79 +93,56 @@ IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransGradientHdl_Impl, Button*, voi // preview rXFSet.ClearItem (XATTR_FILLTRANSPARENCE); - ModifiedTrgrHdl_Impl (nullptr); + ModifiedTrgrHdl_Impl(nullptr); } SvxTransparenceTabPage::~SvxTransparenceTabPage() { - disposeOnce(); -} - -void SvxTransparenceTabPage::dispose() -{ - m_pRbtTransOff.clear(); - m_pRbtTransLinear.clear(); - m_pRbtTransGradient.clear(); - m_pMtrTransparent.clear(); - m_pGridGradient.clear(); - m_pLbTrgrGradientType.clear(); - m_pFtTrgrCenterX.clear(); - m_pMtrTrgrCenterX.clear(); - m_pFtTrgrCenterY.clear(); - m_pMtrTrgrCenterY.clear(); - m_pFtTrgrAngle.clear(); - m_pMtrTrgrAngle.clear(); - m_pMtrTrgrBorder.clear(); - m_pMtrTrgrStartValue.clear(); - m_pMtrTrgrEndValue.clear(); - m_pCtlBitmapPreview.clear(); - m_pCtlXRectPreview.clear(); - SvxTabPage::dispose(); } void SvxTransparenceTabPage::ActivateLinear(bool bActivate) { - m_pMtrTransparent->Enable(bActivate); + m_xMtrTransparent->set_sensitive(bActivate); } -IMPL_LINK_NOARG(SvxTransparenceTabPage, ModifyTransparentHdl_Impl, Edit&, void) +IMPL_LINK_NOARG(SvxTransparenceTabPage, ModifyTransparentHdl_Impl, weld::MetricSpinButton&, void) { - sal_uInt16 nPos = static_cast<sal_uInt16>(m_pMtrTransparent->GetValue()); + sal_uInt16 nPos = m_xMtrTransparent->get_value(FUNIT_PERCENT); rXFSet.Put(XFillTransparenceItem(nPos)); // preview InvalidatePreview(); } -IMPL_LINK(SvxTransparenceTabPage, ModifiedTrgrListBoxHdl_Impl, ListBox&, rListBox, void) +IMPL_LINK(SvxTransparenceTabPage, ModifiedTrgrListBoxHdl_Impl, weld::ComboBoxText&, rListBox, void) { ModifiedTrgrHdl_Impl(&rListBox); } -IMPL_LINK(SvxTransparenceTabPage, ModifiedTrgrEditHdl_Impl, Edit&, rBox, void) +IMPL_LINK_NOARG(SvxTransparenceTabPage, ModifiedTrgrEditHdl_Impl, weld::MetricSpinButton&, void) { - ModifiedTrgrHdl_Impl(&rBox); + ModifiedTrgrHdl_Impl(nullptr); } -void SvxTransparenceTabPage::ModifiedTrgrHdl_Impl(void const * pControl) +void SvxTransparenceTabPage::ModifiedTrgrHdl_Impl(const weld::ComboBoxText* pControl) { - if(pControl == m_pLbTrgrGradientType || pControl == this) + if (pControl == m_xLbTrgrGradientType.get()) { - css::awt::GradientStyle eXGS = static_cast<css::awt::GradientStyle>(m_pLbTrgrGradientType->GetSelectedEntryPos()); + css::awt::GradientStyle eXGS = static_cast<css::awt::GradientStyle>(m_xLbTrgrGradientType->get_active()); SetControlState_Impl( eXGS ); } // preview - sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_pMtrTrgrStartValue->GetValue()) * 255) / 100); - sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_pMtrTrgrEndValue->GetValue()) * 255) / 100); + sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrStartValue->get_value(FUNIT_PERCENT)) * 255) / 100); + sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrEndValue->get_value(FUNIT_PERCENT)) * 255) / 100); XGradient aTmpGradient( Color(nStartCol, nStartCol, nStartCol), Color(nEndCol, nEndCol, nEndCol), - static_cast<css::awt::GradientStyle>(m_pLbTrgrGradientType->GetSelectedEntryPos()), - static_cast<sal_uInt16>(m_pMtrTrgrAngle->GetValue()) * 10, - static_cast<sal_uInt16>(m_pMtrTrgrCenterX->GetValue()), - static_cast<sal_uInt16>(m_pMtrTrgrCenterY->GetValue()), - static_cast<sal_uInt16>(m_pMtrTrgrBorder->GetValue()), + static_cast<css::awt::GradientStyle>(m_xLbTrgrGradientType->get_active()), + static_cast<sal_uInt16>(m_xMtrTrgrAngle->get_value(FUNIT_DEGREE)) * 10, + static_cast<sal_uInt16>(m_xMtrTrgrCenterX->get_value(FUNIT_PERCENT)), + static_cast<sal_uInt16>(m_xMtrTrgrCenterY->get_value(FUNIT_PERCENT)), + static_cast<sal_uInt16>(m_xMtrTrgrBorder->get_value(FUNIT_PERCENT)), 100, 100); XFillFloatTransparenceItem aItem( aTmpGradient); @@ -176,11 +153,11 @@ void SvxTransparenceTabPage::ModifiedTrgrHdl_Impl(void const * pControl) void SvxTransparenceTabPage::ActivateGradient(bool bActivate) { - m_pGridGradient->Enable(bActivate); + m_xGridGradient->set_sensitive(bActivate); - if(bActivate) + if (bActivate) { - css::awt::GradientStyle eXGS = static_cast<css::awt::GradientStyle>(m_pLbTrgrGradientType->GetSelectedEntryPos()); + css::awt::GradientStyle eXGS = static_cast<css::awt::GradientStyle>(m_xLbTrgrGradientType->get_active()); SetControlState_Impl( eXGS ); } } @@ -191,107 +168,102 @@ void SvxTransparenceTabPage::SetControlState_Impl(css::awt::GradientStyle eXGS) { case css::awt::GradientStyle_LINEAR: case css::awt::GradientStyle_AXIAL: - m_pFtTrgrCenterX->Disable(); - m_pMtrTrgrCenterX->Disable(); - m_pFtTrgrCenterY->Disable(); - m_pMtrTrgrCenterY->Disable(); - m_pFtTrgrAngle->Enable(); - m_pMtrTrgrAngle->Enable(); + m_xFtTrgrCenterX->set_sensitive(false); + m_xMtrTrgrCenterX->set_sensitive(false); + m_xFtTrgrCenterY->set_sensitive(false); + m_xMtrTrgrCenterY->set_sensitive(false); + m_xFtTrgrAngle->set_sensitive(true); + m_xMtrTrgrAngle->set_sensitive(true); break; case css::awt::GradientStyle_RADIAL: - m_pFtTrgrCenterX->Enable(); - m_pMtrTrgrCenterX->Enable(); - m_pFtTrgrCenterY->Enable(); - m_pMtrTrgrCenterY->Enable(); - m_pFtTrgrAngle->Disable(); - m_pMtrTrgrAngle->Disable(); + m_xFtTrgrCenterX->set_sensitive(true); + m_xMtrTrgrCenterX->set_sensitive(true); + m_xFtTrgrCenterY->set_sensitive(true); + m_xMtrTrgrCenterY->set_sensitive(true); + m_xFtTrgrAngle->set_sensitive(false); + m_xMtrTrgrAngle->set_sensitive(false); break; case css::awt::GradientStyle_ELLIPTICAL: - m_pFtTrgrCenterX->Enable(); - m_pMtrTrgrCenterX->Enable(); - m_pFtTrgrCenterY->Enable(); - m_pMtrTrgrCenterY->Enable(); - m_pFtTrgrAngle->Enable(); - m_pMtrTrgrAngle->Enable(); + m_xFtTrgrCenterX->set_sensitive(true); + m_xMtrTrgrCenterX->set_sensitive(true); + m_xFtTrgrCenterY->set_sensitive(true); + m_xMtrTrgrCenterY->set_sensitive(true); + m_xFtTrgrAngle->set_sensitive(true); + m_xMtrTrgrAngle->set_sensitive(true); break; case css::awt::GradientStyle_SQUARE: case css::awt::GradientStyle_RECT: - m_pFtTrgrCenterX->Enable(); - m_pMtrTrgrCenterX->Enable(); - m_pFtTrgrCenterY->Enable(); - m_pMtrTrgrCenterY->Enable(); - m_pFtTrgrAngle->Enable(); - m_pMtrTrgrAngle->Enable(); + m_xFtTrgrCenterX->set_sensitive(true); + m_xMtrTrgrCenterX->set_sensitive(true); + m_xFtTrgrCenterY->set_sensitive(true); + m_xMtrTrgrCenterY->set_sensitive(true); + m_xFtTrgrAngle->set_sensitive(true); + m_xMtrTrgrAngle->set_sensitive(true); break; default: break; } } -SvxTransparenceTabPage::SvxTransparenceTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs) -: SvxTabPage ( pParent, - "TransparencyTabPage", - "cui/ui/transparencytabpage.ui", - rInAttrs), - rOutAttrs ( rInAttrs ), - nPageType ( PageType::Area ), - nDlgType (0), - bBitmap ( false ), - aXFillAttr ( rInAttrs.GetPool() ), - rXFSet ( aXFillAttr.GetItemSet() ) +SvxTransparenceTabPage::SvxTransparenceTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs) + : SvxTabPage(pParent, "cui/ui/transparencytabpage.ui", "TransparencyTabPage", rInAttrs) + , rOutAttrs(rInAttrs) + , nPageType(PageType::Area) + , nDlgType(0) + , bBitmap(false) + , aXFillAttr(rInAttrs.GetPool()) + , rXFSet(aXFillAttr.GetItemSet()) + , m_xRbtTransOff(m_xBuilder->weld_radio_button("RBT_TRANS_OFF")) + , m_xRbtTransLinear(m_xBuilder->weld_radio_button("RBT_TRANS_LINEAR")) + , m_xRbtTransGradient(m_xBuilder->weld_radio_button("RBT_TRANS_GRADIENT")) + , m_xMtrTransparent(m_xBuilder->weld_metric_spin_button("MTR_TRANSPARENT", FUNIT_PERCENT)) + , m_xGridGradient(m_xBuilder->weld_widget("gridGradient")) + , m_xLbTrgrGradientType(m_xBuilder->weld_combo_box_text("LB_TRGR_GRADIENT_TYPES")) + , m_xFtTrgrCenterX(m_xBuilder->weld_label("FT_TRGR_CENTER_X")) + , m_xMtrTrgrCenterX(m_xBuilder->weld_metric_spin_button("MTR_TRGR_CENTER_X", FUNIT_PERCENT)) + , m_xFtTrgrCenterY(m_xBuilder->weld_label("FT_TRGR_CENTER_Y")) + , m_xMtrTrgrCenterY(m_xBuilder->weld_metric_spin_button("MTR_TRGR_CENTER_Y", FUNIT_PERCENT)) + , m_xFtTrgrAngle(m_xBuilder->weld_label("FT_TRGR_ANGLE")) + , m_xMtrTrgrAngle(m_xBuilder->weld_metric_spin_button("MTR_TRGR_ANGLE", FUNIT_DEGREE)) + , m_xMtrTrgrBorder(m_xBuilder->weld_metric_spin_button("MTR_TRGR_BORDER", FUNIT_PERCENT)) + , m_xMtrTrgrStartValue(m_xBuilder->weld_metric_spin_button("MTR_TRGR_START_VALUE", FUNIT_PERCENT)) + , m_xMtrTrgrEndValue(m_xBuilder->weld_metric_spin_button("MTR_TRGR_END_VALUE", FUNIT_PERCENT)) + , m_xCtlBitmapBorder(m_xBuilder->weld_widget("bitmap_border")) + , m_xCtlXRectBorder(m_xBuilder->weld_widget("trans_border")) + , m_xCtlBitmapPreview(new weld::CustomWeld(*m_xBuilder, "CTL_BITMAP_PREVIEW", m_aCtlBitmapPreview)) + , m_xCtlXRectPreview(new weld::CustomWeld(*m_xBuilder, "CTL_TRANS_PREVIEW", m_aCtlXRectPreview)) { - get(m_pRbtTransOff,"RBT_TRANS_OFF"); - get(m_pRbtTransLinear,"RBT_TRANS_LINEAR"); - get(m_pRbtTransGradient,"RBT_TRANS_GRADIENT"); - - get(m_pMtrTransparent,"MTR_TRANSPARENT"); - - get(m_pGridGradient,"gridGradient"); - get(m_pLbTrgrGradientType,"LB_TRGR_GRADIENT_TYPES"); - get(m_pFtTrgrCenterX,"FT_TRGR_CENTER_X"); - get(m_pMtrTrgrCenterX,"MTR_TRGR_CENTER_X"); - get(m_pFtTrgrCenterY,"FT_TRGR_CENTER_Y"); - get(m_pMtrTrgrCenterY,"MTR_TRGR_CENTER_Y"); - get(m_pFtTrgrAngle,"FT_TRGR_ANGLE"); - get(m_pMtrTrgrAngle,"MTR_TRGR_ANGLE"); - get(m_pMtrTrgrBorder,"MTR_TRGR_BORDER"); - get(m_pMtrTrgrStartValue,"MTR_TRGR_START_VALUE"); - get(m_pMtrTrgrEndValue,"MTR_TRGR_END_VALUE"); - - get(m_pCtlBitmapPreview,"CTL_BITMAP_PREVIEW"); - get(m_pCtlXRectPreview,"CTL_TRANS_PREVIEW"); - // main selection - m_pRbtTransOff->SetClickHdl(LINK(this, SvxTransparenceTabPage, ClickTransOffHdl_Impl)); - m_pRbtTransLinear->SetClickHdl(LINK(this, SvxTransparenceTabPage, ClickTransLinearHdl_Impl)); - m_pRbtTransGradient->SetClickHdl(LINK(this, SvxTransparenceTabPage, ClickTransGradientHdl_Impl)); + m_xRbtTransOff->connect_toggled(LINK(this, SvxTransparenceTabPage, ClickTransOffHdl_Impl)); + m_xRbtTransLinear->connect_toggled(LINK(this, SvxTransparenceTabPage, ClickTransLinearHdl_Impl)); + m_xRbtTransGradient->connect_toggled(LINK(this, SvxTransparenceTabPage, ClickTransGradientHdl_Impl)); // linear transparency - m_pMtrTransparent->SetValue( 50 ); - m_pMtrTransparent->SetModifyHdl(LINK(this, SvxTransparenceTabPage, ModifyTransparentHdl_Impl)); + m_xMtrTransparent->set_value(50, FUNIT_PERCENT); + m_xMtrTransparent->connect_value_changed(LINK(this, SvxTransparenceTabPage, ModifyTransparentHdl_Impl)); // gradient transparency - m_pMtrTrgrEndValue->SetValue( 100 ); - m_pMtrTrgrStartValue->SetValue( 0 ); - Link<Edit&,void> aLink = LINK( this, SvxTransparenceTabPage, ModifiedTrgrEditHdl_Impl); - m_pLbTrgrGradientType->SetSelectHdl( LINK( this, SvxTransparenceTabPage, ModifiedTrgrListBoxHdl_Impl) ); - m_pMtrTrgrCenterX->SetModifyHdl( aLink ); - m_pMtrTrgrCenterY->SetModifyHdl( aLink ); - m_pMtrTrgrAngle->SetModifyHdl( aLink ); - m_pMtrTrgrBorder->SetModifyHdl( aLink ); - m_pMtrTrgrStartValue->SetModifyHdl( aLink ); - m_pMtrTrgrEndValue->SetModifyHdl( aLink ); + m_xMtrTrgrEndValue->set_value(100, FUNIT_PERCENT); + m_xMtrTrgrStartValue->set_value(0, FUNIT_PERCENT); + Link<weld::MetricSpinButton&,void> aLink = LINK( this, SvxTransparenceTabPage, ModifiedTrgrEditHdl_Impl); + m_xLbTrgrGradientType->connect_changed(LINK(this, SvxTransparenceTabPage, ModifiedTrgrListBoxHdl_Impl)); + m_xMtrTrgrCenterX->connect_value_changed( aLink ); + m_xMtrTrgrCenterY->connect_value_changed( aLink ); + m_xMtrTrgrAngle->connect_value_changed( aLink ); + m_xMtrTrgrBorder->connect_value_changed( aLink ); + m_xMtrTrgrStartValue->connect_value_changed( aLink ); + m_xMtrTrgrEndValue->connect_value_changed( aLink ); // this page needs ExchangeSupport SetExchangeSupport(); } -VclPtr<SfxTabPage> SvxTransparenceTabPage::Create(TabPageParent pWindow, const SfxItemSet* rAttrs) +VclPtr<SfxTabPage> SvxTransparenceTabPage::Create(TabPageParent pParent, const SfxItemSet* rAttrs) { - return VclPtr<SvxTransparenceTabPage>::Create(pWindow.pParent, *rAttrs); + return VclPtr<SvxTransparenceTabPage>::Create(pParent, *rAttrs); } bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) @@ -310,11 +282,11 @@ bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) bool bSwitchOffLinear(false); bool bSwitchOffGradient(false); - if(m_pMtrTransparent->IsEnabled()) + if (m_xMtrTransparent->get_sensitive()) { // linear transparence - sal_uInt16 nPos = static_cast<sal_uInt16>(m_pMtrTransparent->GetValue()); - if(m_pMtrTransparent->IsValueChangedFromSaved() || !bLinearActive) + sal_uInt16 nPos = m_xMtrTransparent->get_value(FUNIT_PERCENT); + if (m_xMtrTransparent->get_value_changed_from_saved() || !bLinearActive) { XFillTransparenceItem aItem(nPos); SdrPercentItem aShadowItem(makeSdrShadowTransparenceItem(nPos)); @@ -328,28 +300,28 @@ bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) } } } - else if(m_pLbTrgrGradientType->IsEnabled()) + else if (m_xLbTrgrGradientType->get_active()) { // transparence gradient, fill ItemSet from values - if(!bGradActive - || m_pLbTrgrGradientType->IsValueChangedFromSaved() - || m_pMtrTrgrAngle->IsValueChangedFromSaved() - || m_pMtrTrgrCenterX->IsValueChangedFromSaved() - || m_pMtrTrgrCenterY->IsValueChangedFromSaved() - || m_pMtrTrgrBorder->IsValueChangedFromSaved() - || m_pMtrTrgrStartValue->IsValueChangedFromSaved() - || m_pMtrTrgrEndValue->IsValueChangedFromSaved() ) + if (!bGradActive + || m_xLbTrgrGradientType->get_value_changed_from_saved() + || m_xMtrTrgrAngle->get_value_changed_from_saved() + || m_xMtrTrgrCenterX->get_value_changed_from_saved() + || m_xMtrTrgrCenterY->get_value_changed_from_saved() + || m_xMtrTrgrBorder->get_value_changed_from_saved() + || m_xMtrTrgrStartValue->get_value_changed_from_saved() + || m_xMtrTrgrEndValue->get_value_changed_from_saved()) { - sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_pMtrTrgrStartValue->GetValue()) * 255) / 100); - sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_pMtrTrgrEndValue->GetValue()) * 255) / 100); + sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrStartValue->get_value(FUNIT_PERCENT)) * 255) / 100); + sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrEndValue->get_value(FUNIT_PERCENT)) * 255) / 100); XGradient aTmpGradient( Color(nStartCol, nStartCol, nStartCol), Color(nEndCol, nEndCol, nEndCol), - static_cast<css::awt::GradientStyle>(m_pLbTrgrGradientType->GetSelectedEntryPos()), - static_cast<sal_uInt16>(m_pMtrTrgrAngle->GetValue()) * 10, - static_cast<sal_uInt16>(m_pMtrTrgrCenterX->GetValue()), - static_cast<sal_uInt16>(m_pMtrTrgrCenterY->GetValue()), - static_cast<sal_uInt16>(m_pMtrTrgrBorder->GetValue()), + static_cast<css::awt::GradientStyle>(m_xLbTrgrGradientType->get_active()), + static_cast<sal_uInt16>(m_xMtrTrgrAngle->get_value(FUNIT_DEGREE)) * 10, + static_cast<sal_uInt16>(m_xMtrTrgrCenterX->get_value(FUNIT_PERCENT)), + static_cast<sal_uInt16>(m_xMtrTrgrCenterY->get_value(FUNIT_PERCENT)), + static_cast<sal_uInt16>(m_xMtrTrgrBorder->get_value(FUNIT_PERCENT)), 100, 100); XFillFloatTransparenceItem aItem(aTmpGradient); @@ -412,37 +384,37 @@ void SvxTransparenceTabPage::Reset(const SfxItemSet* rAttrs) // transparence gradient const XGradient& rGradient = static_cast<const XFillFloatTransparenceItem*>(pGradientItem)->GetGradientValue(); css::awt::GradientStyle eXGS(rGradient.GetGradientStyle()); - m_pLbTrgrGradientType->SelectEntryPos(sal::static_int_cast< sal_Int32 >(eXGS)); - m_pMtrTrgrAngle->SetValue(rGradient.GetAngle() / 10); - m_pMtrTrgrBorder->SetValue(rGradient.GetBorder()); - m_pMtrTrgrCenterX->SetValue(rGradient.GetXOffset()); - m_pMtrTrgrCenterY->SetValue(rGradient.GetYOffset()); - m_pMtrTrgrStartValue->SetValue(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(rGradient.GetStartColor().GetRed()) + 1) * 100) / 255)); - m_pMtrTrgrEndValue->SetValue(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(rGradient.GetEndColor().GetRed()) + 1) * 100) / 255)); + m_xLbTrgrGradientType->set_active(sal::static_int_cast< sal_Int32 >(eXGS)); + m_xMtrTrgrAngle->set_value(rGradient.GetAngle() / 10, FUNIT_DEGREE); + m_xMtrTrgrBorder->set_value(rGradient.GetBorder(), FUNIT_PERCENT); + m_xMtrTrgrCenterX->set_value(rGradient.GetXOffset(), FUNIT_PERCENT); + m_xMtrTrgrCenterY->set_value(rGradient.GetYOffset(), FUNIT_PERCENT); + m_xMtrTrgrStartValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(rGradient.GetStartColor().GetRed()) + 1) * 100) / 255), FUNIT_PERCENT); + m_xMtrTrgrEndValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(rGradient.GetEndColor().GetRed()) + 1) * 100) / 255), FUNIT_PERCENT); // linear transparence sal_uInt16 nTransp = static_cast<const XFillTransparenceItem*>(pLinearItem)->GetValue(); - m_pMtrTransparent->SetValue(bLinearActive ? nTransp : 50); - ModifyTransparentHdl_Impl(*m_pMtrTransparent); + m_xMtrTransparent->set_value(bLinearActive ? nTransp : 50, FUNIT_PERCENT); + ModifyTransparentHdl_Impl(*m_xMtrTransparent); // select the correct radio button if(bGradActive) { // transparence gradient, set controls appropriate to item - m_pRbtTransGradient->Check(); - ClickTransGradientHdl_Impl(nullptr); + m_xRbtTransGradient->set_active(true); + ClickTransGradientHdl_Impl(*m_xRbtTransGradient); } else if(bLinearActive) { // linear transparence - m_pRbtTransLinear->Check(); - ClickTransLinearHdl_Impl(nullptr); + m_xRbtTransLinear->set_active(true); + ClickTransLinearHdl_Impl(*m_xRbtTransLinear); } else { // no transparence - m_pRbtTransOff->Check(); - ClickTransOffHdl_Impl(nullptr); + m_xRbtTransOff->set_active(true); + ClickTransOffHdl_Impl(*m_xRbtTransOff); ModifiedTrgrHdl_Impl(nullptr); } @@ -454,14 +426,14 @@ void SvxTransparenceTabPage::Reset(const SfxItemSet* rAttrs) void SvxTransparenceTabPage::ChangesApplied() { - m_pMtrTransparent->SaveValue(); - m_pLbTrgrGradientType->SaveValue(); - m_pMtrTrgrCenterX->SaveValue(); - m_pMtrTrgrCenterY->SaveValue(); - m_pMtrTrgrAngle->SaveValue(); - m_pMtrTrgrBorder->SaveValue(); - m_pMtrTrgrStartValue->SaveValue(); - m_pMtrTrgrEndValue->SaveValue(); + m_xMtrTransparent->save_value(); + m_xLbTrgrGradientType->save_value(); + m_xMtrTrgrCenterX->save_value(); + m_xMtrTrgrCenterY->save_value(); + m_xMtrTrgrAngle->save_value(); + m_xMtrTrgrBorder->save_value(); + m_xMtrTrgrStartValue->save_value(); + m_xMtrTrgrEndValue->save_value(); } void SvxTransparenceTabPage::ActivatePage(const SfxItemSet& rSet) @@ -493,18 +465,20 @@ void SvxTransparenceTabPage::PointChanged(weld::DrawingArea*, RectPoint) // Preview-Methods -bool SvxTransparenceTabPage::InitPreview ( const SfxItemSet& rSet ) +bool SvxTransparenceTabPage::InitPreview(const SfxItemSet& rSet) { // set transparencetype for preview - if ( m_pRbtTransOff->IsChecked() ) + if (m_xRbtTransOff->get_active()) { - ClickTransOffHdl_Impl(nullptr); - } else if ( m_pRbtTransLinear->IsChecked() ) + ClickTransOffHdl_Impl(*m_xRbtTransOff); + } + else if (m_xRbtTransLinear->get_active()) { - ClickTransLinearHdl_Impl(nullptr); - } else if ( m_pRbtTransGradient->IsChecked() ) + ClickTransLinearHdl_Impl(*m_xRbtTransLinear); + } + else if (m_xRbtTransGradient->get_active()) { - ClickTransGradientHdl_Impl(nullptr); + ClickTransGradientHdl_Impl(*m_xRbtTransGradient); } // Get fillstyle for preview @@ -515,24 +489,24 @@ bool SvxTransparenceTabPage::InitPreview ( const SfxItemSet& rSet ) rXFSet.Put ( rSet.Get(XATTR_FILLBACKGROUND) ); rXFSet.Put ( rSet.Get(XATTR_FILLBITMAP) ); - m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() ); - m_pCtlBitmapPreview->SetAttributes( aXFillAttr.GetItemSet() ); + m_aCtlXRectPreview.SetAttributes( aXFillAttr.GetItemSet() ); + m_aCtlBitmapPreview.SetAttributes( aXFillAttr.GetItemSet() ); bBitmap = rSet.Get(XATTR_FILLSTYLE).GetValue() == drawing::FillStyle_BITMAP; // show the right preview window if ( bBitmap ) { - m_pCtlBitmapPreview->Show(); - m_pCtlXRectPreview->Hide(); + m_xCtlBitmapBorder->show(); + m_xCtlXRectBorder->hide(); } else { - m_pCtlBitmapPreview->Hide(); - m_pCtlXRectPreview->Show(); + m_xCtlBitmapBorder->hide(); + m_xCtlXRectBorder->show(); } - return !m_pRbtTransOff->IsChecked(); + return !m_xRbtTransOff->get_active(); } void SvxTransparenceTabPage::InvalidatePreview (bool bEnable) @@ -541,23 +515,23 @@ void SvxTransparenceTabPage::InvalidatePreview (bool bEnable) { if ( bEnable ) { - m_pCtlBitmapPreview->Enable(); - m_pCtlBitmapPreview->SetAttributes( aXFillAttr.GetItemSet() ); + m_xCtlBitmapPreview->set_sensitive(true); + m_aCtlBitmapPreview.SetAttributes( aXFillAttr.GetItemSet() ); } else - m_pCtlBitmapPreview->Disable(); - m_pCtlBitmapPreview->Invalidate(); + m_xCtlBitmapPreview->set_sensitive(false); + m_xCtlBitmapPreview->queue_draw(); } else { if ( bEnable ) { - m_pCtlXRectPreview->Enable(); - m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() ); + m_xCtlXRectPreview->set_sensitive(true); + m_aCtlXRectPreview.SetAttributes( aXFillAttr.GetItemSet() ); } else - m_pCtlXRectPreview->Disable(); - m_pCtlXRectPreview->Invalidate(); + m_xCtlXRectPreview->set_sensitive(false); + m_xCtlXRectPreview->queue_draw(); } } diff --git a/cui/uiconfig/ui/transparencytabpage.ui b/cui/uiconfig/ui/transparencytabpage.ui index 4ae85c2b1701..efb31b319517 100644 --- a/cui/uiconfig/ui/transparencytabpage.ui +++ b/cui/uiconfig/ui/transparencytabpage.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="adjustmentDegrees"> <property name="upper">359</property> <property name="step_increment">1</property> @@ -13,6 +12,31 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> + <object class="GtkAdjustment" id="adjustmentPercent1"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentPercent2"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentPercent3"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentPercent4"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentPercent5"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> <object class="GtkListStore" id="liststoreTYPE"> <columns> <!-- column-name gchararray1 --> @@ -91,7 +115,6 @@ <property name="image_position">bottom</property> <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">RBT_TRANS_LINEAR</property> </object> <packing> <property name="left_attach">0</property> @@ -107,11 +130,10 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="image_position">right</property> - <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">RBT_TRANS_GRADIENT</property> + <property name="group">RBT_TRANS_OFF</property> <accessibility> - <relation type="label-for" target="MTR_TRANSPARENT:0%"/> + <relation type="label-for" target="MTR_TRANSPARENT"/> </accessibility> </object> <packing> @@ -127,7 +149,6 @@ <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="xalign">0</property> - <property name="active">True</property> <property name="draw_indicator">True</property> <property name="group">RBT_TRANS_OFF</property> </object> @@ -137,9 +158,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="MTR_TRANSPARENT:0%"> + <object class="GtkSpinButton" id="MTR_TRANSPARENT"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="activates_default">True</property> <property name="adjustment">adjustmentPercent</property> <accessibility> <relation type="labelled-by" target="RBT_TRANS_LINEAR"/> @@ -170,10 +192,11 @@ <property name="row_spacing">6</property> <property name="column_spacing">12</property> <child> - <object class="GtkSpinButton" id="MTR_TRGR_END_VALUE:0%"> + <object class="GtkSpinButton" id="MTR_TRGR_END_VALUE"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="adjustment">adjustmentPercent</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustmentPercent5</property> </object> <packing> <property name="left_attach">1</property> @@ -181,10 +204,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="MTR_TRGR_START_VALUE:0%"> + <object class="GtkSpinButton" id="MTR_TRGR_START_VALUE"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="adjustment">adjustmentPercent</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustmentPercent4</property> </object> <packing> <property name="left_attach">1</property> @@ -192,10 +216,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="MTR_TRGR_BORDER:0%"> + <object class="GtkSpinButton" id="MTR_TRGR_BORDER"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="adjustment">adjustmentPercent</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustmentPercent3</property> </object> <packing> <property name="left_attach">1</property> @@ -203,9 +228,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="MTR_TRGR_ANGLE:0degree"> + <object class="GtkSpinButton" id="MTR_TRGR_ANGLE"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="activates_default">True</property> <property name="adjustment">adjustmentDegrees</property> </object> <packing> @@ -214,10 +240,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="MTR_TRGR_CENTER_Y:0%"> + <object class="GtkSpinButton" id="MTR_TRGR_CENTER_Y"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="adjustment">adjustmentPercent</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustmentPercent2</property> </object> <packing> <property name="left_attach">1</property> @@ -225,10 +252,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="MTR_TRGR_CENTER_X:0%"> + <object class="GtkSpinButton" id="MTR_TRGR_CENTER_X"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="adjustment">adjustmentPercent</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustmentPercent1</property> </object> <packing> <property name="left_attach">1</property> @@ -255,10 +283,10 @@ <object class="GtkLabel" id="FT_TRGR_TYPE"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="transparencytabpage|FT_TRGR_TYPE">Ty_pe:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">LB_TRGR_GRADIENT_TYPES</property> + <property name="xalign">1</property> </object> </child> </object> @@ -276,10 +304,10 @@ <object class="GtkLabel" id="FT_TRGR_CENTER_X"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="transparencytabpage|FT_TRGR_CENTER_X">Center _X:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">MTR_TRGR_CENTER_X:0%</property> + <property name="mnemonic_widget">MTR_TRGR_CENTER_X</property> + <property name="xalign">1</property> </object> </child> </object> @@ -297,10 +325,10 @@ <object class="GtkLabel" id="FT_TRGR_CENTER_Y"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="transparencytabpage|FT_TRGR_CENTER_Y">Center _Y:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">MTR_TRGR_CENTER_Y:0%</property> + <property name="mnemonic_widget">MTR_TRGR_CENTER_Y</property> + <property name="xalign">1</property> </object> </child> </object> @@ -318,10 +346,10 @@ <object class="GtkLabel" id="FT_TRGR_ANGLE"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="transparencytabpage|FT_TRGR_ANGLE">_Angle:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">MTR_TRGR_ANGLE:0degree</property> + <property name="mnemonic_widget">MTR_TRGR_ANGLE</property> + <property name="xalign">1</property> </object> </child> </object> @@ -339,10 +367,10 @@ <object class="GtkLabel" id="FT_TRGR_BORDER"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="transparencytabpage|FT_TRGR_BORDER">_Border:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">MTR_TRGR_BORDER:0%</property> + <property name="mnemonic_widget">MTR_TRGR_BORDER</property> + <property name="xalign">1</property> </object> </child> </object> @@ -360,10 +388,10 @@ <object class="GtkLabel" id="FT_TRGR_START_VALUE"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="transparencytabpage|FT_TRGR_START_VALUE">_Start value:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">MTR_TRGR_START_VALUE:0%</property> + <property name="mnemonic_widget">MTR_TRGR_START_VALUE</property> + <property name="xalign">1</property> </object> </child> </object> @@ -381,10 +409,10 @@ <object class="GtkLabel" id="FT_TRGR_END_VALUE"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="transparencytabpage|FT_TRGR_END_VALUE">_End value:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">MTR_TRGR_END_VALUE:0%</property> + <property name="mnemonic_widget">MTR_TRGR_END_VALUE</property> + <property name="xalign">1</property> </object> </child> </object> @@ -418,14 +446,31 @@ <property name="spacing">6</property> <property name="homogeneous">True</property> <child> - <object class="svxlo-SvxXRectPreview" id="CTL_BITMAP_PREVIEW"> + <object class="GtkScrolledWindow" id="bitmap_border"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="CTL_BITMAP_PREVIEW-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes" context="transparencytabpage|CTL_BITMAP_PREVIEW-atkobject">Example</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="CTL_BITMAP_PREVIEW"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="CTL_BITMAP_PREVIEW-atkobject"> + <property name="AtkObject::accessible-name" translatable="yes" context="transparencytabpage|CTL_BITMAP_PREVIEW-atkobject">Example</property> + </object> + </child> + </object> + </child> </object> </child> </object> @@ -436,14 +481,31 @@ </packing> </child> <child> - <object class="svxlo-SvxXRectPreview" id="CTL_TRANS_PREVIEW"> + <object class="GtkScrolledWindow" id="trans_border"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="CTL_TRANS_PREVIEW-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes" context="transparencytabpage|CTL_TRANS_PREVIEW-atkobject">Example</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="CTL_TRANS_PREVIEW"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="CTL_TRANS_PREVIEW-atkobject"> + <property name="AtkObject::accessible-name" translatable="yes" context="transparencytabpage|CTL_TRANS_PREVIEW-atkobject">Example</property> + </object> + </child> + </object> + </child> </object> </child> </object> @@ -483,8 +545,8 @@ <object class="GtkLabel" id="FL_PROP"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="transparencytabpage|FL_PROP">Area Transparency Mode</property> + <property name="xalign">0</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -495,13 +557,13 @@ <property name="mode">both</property> <property name="ignore_hidden">True</property> <widgets> - <widget name="MTR_TRANSPARENT:0%"/> - <widget name="MTR_TRGR_END_VALUE:0%"/> - <widget name="MTR_TRGR_START_VALUE:0%"/> - <widget name="MTR_TRGR_BORDER:0%"/> - <widget name="MTR_TRGR_ANGLE:0degree"/> - <widget name="MTR_TRGR_CENTER_Y:0%"/> - <widget name="MTR_TRGR_CENTER_X:0%"/> + <widget name="MTR_TRANSPARENT"/> + <widget name="MTR_TRGR_END_VALUE"/> + <widget name="MTR_TRGR_START_VALUE"/> + <widget name="MTR_TRGR_BORDER"/> + <widget name="MTR_TRGR_ANGLE"/> + <widget name="MTR_TRGR_CENTER_Y"/> + <widget name="MTR_TRGR_CENTER_X"/> <widget name="LB_TRGR_GRADIENT_TYPES"/> </widgets> </object> diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx index 9001543a0013..eb587a299378 100644 --- a/include/svx/dlgctrl.hxx +++ b/include/svx/dlgctrl.hxx @@ -383,6 +383,41 @@ public: } }; +class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI PreviewBase : public weld::CustomWidgetController +{ +private: + std::unique_ptr<SdrModel> mpModel; + VclPtr<VirtualDevice> mpBufferDevice; + +protected: + void InitSettings(); + + // prepare buffered paint + void LocalPrePaint(vcl::RenderContext const & rRenderContext); + + // end and output buffered paint + void LocalPostPaint(vcl::RenderContext& rRenderContext); + +public: + PreviewBase(); + virtual void SetDrawingArea(weld::DrawingArea*) override; + virtual ~PreviewBase() override; + + // change support + virtual void StyleUpdated() override; + + // dada read access + SdrModel& getModel() const + { + return *mpModel; + } + OutputDevice& getBufferDevice() const + { + return *mpBufferDevice; + } +}; + + /************************************************************************* |* |* SvxLinePreview @@ -438,6 +473,22 @@ public: virtual void Resize() override; }; +class SAL_WARN_UNUSED SVX_DLLPUBLIC XRectPreview : public PreviewBase +{ +private: + SdrObject* mpRectangleObject; + +public: + XRectPreview(); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual ~XRectPreview() override; + + void SetAttributes(const SfxItemSet& rItemSet); + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Resize() override; +}; + /************************************************************************* |* |* SvxXShadowPreview diff --git a/include/vcl/customweld.hxx b/include/vcl/customweld.hxx index 2d6089871ef3..622b20c256c5 100644 --- a/include/vcl/customweld.hxx +++ b/include/vcl/customweld.hxx @@ -104,6 +104,7 @@ public: m_xDrawingArea->set_size_request(nWidth, nHeight); } void show() { m_xDrawingArea->show(); } + void hide() { m_xDrawingArea->hide(); } void set_margin_top(int nMargin) { m_xDrawingArea->set_margin_top(nMargin); } void set_margin_bottom(int nMargin) { m_xDrawingArea->set_margin_bottom(nMargin); } void set_sensitive(bool bSensitive) { m_xDrawingArea->set_sensitive(bSensitive); } diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index 5330c2ad6841..171faef58906 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -2173,4 +2173,153 @@ void SvxXShadowPreview::Paint(vcl::RenderContext& rRenderContext, const tools::R LocalPostPaint(rRenderContext); } +void PreviewBase::InitSettings() +{ + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + svtools::ColorConfig aColorConfig; + Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); + getBufferDevice().SetTextColor(aTextColor); + + getBufferDevice().SetBackground(rStyleSettings.GetWindowColor()); + + getBufferDevice().SetDrawMode(rStyleSettings.GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR); + + Invalidate(); +} + +PreviewBase::PreviewBase() + : mpModel(new SdrModel()) +{ + // init model + mpModel->GetItemPool().FreezeIdRanges(); +} + +void PreviewBase::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + CustomWidgetController::SetDrawingArea(pDrawingArea); + mpBufferDevice = VclPtr<VirtualDevice>::Create(pDrawingArea->get_ref_device()); + mpBufferDevice->SetMapMode(MapMode(MapUnit::Map100thMM)); +} + +PreviewBase::~PreviewBase() +{ + mpModel.reset(); + mpBufferDevice.disposeAndClear(); +} + +void PreviewBase::LocalPrePaint(vcl::RenderContext const & rRenderContext) +{ + // init BufferDevice + if (mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel()) + { + mpBufferDevice->SetDrawMode(rRenderContext.GetDrawMode()); + mpBufferDevice->SetSettings(rRenderContext.GetSettings()); + mpBufferDevice->SetAntialiasing(rRenderContext.GetAntialiasing()); + mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel()); + mpBufferDevice->SetMapMode(rRenderContext.GetMapMode()); + } + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + if (rStyleSettings.GetPreviewUsesCheckeredBackground()) + { + const Point aNull(0, 0); + static const sal_uInt32 nLen(8); + static const Color aW(COL_WHITE); + static const Color aG(0xef, 0xef, 0xef); + const bool bWasEnabled(mpBufferDevice->IsMapModeEnabled()); + + mpBufferDevice->EnableMapMode(false); + mpBufferDevice->DrawCheckered(aNull, mpBufferDevice->GetOutputSizePixel(), nLen, aW, aG); + mpBufferDevice->EnableMapMode(bWasEnabled); + } + else + { + mpBufferDevice->Erase(); + } +} + +void PreviewBase::LocalPostPaint(vcl::RenderContext& rRenderContext) +{ + // copy to front (in pixel mode) + const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled()); + const bool bWasEnabledDst(rRenderContext.IsMapModeEnabled()); + const Point aEmptyPoint; + + mpBufferDevice->EnableMapMode(false); + rRenderContext.EnableMapMode(false); + + rRenderContext.DrawOutDev(aEmptyPoint, GetOutputSizePixel(), + aEmptyPoint, GetOutputSizePixel(), + *mpBufferDevice); + + mpBufferDevice->EnableMapMode(bWasEnabledSrc); + rRenderContext.EnableMapMode(bWasEnabledDst); +} + +void PreviewBase::StyleUpdated() +{ + InitSettings(); +} + +XRectPreview::XRectPreview() + : mpRectangleObject(nullptr) +{ +} + +void XRectPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + PreviewBase::SetDrawingArea(pDrawingArea); + InitSettings(); + + // create RectangleObject + const tools::Rectangle aObjectSize(Point(), GetOutputSizePixel()); + mpRectangleObject = new SdrRectObj( + getModel(), + aObjectSize); +} + +void XRectPreview::Resize() +{ + const tools::Rectangle aObjectSize(Point(), GetOutputSizePixel()); + SdrObject *pOrigObject = mpRectangleObject; + if (pOrigObject) + { + mpRectangleObject = new SdrRectObj( + getModel(), + aObjectSize); + SetAttributes(pOrigObject->GetMergedItemSet()); + SdrObject::Free(pOrigObject); + } + PreviewBase::Resize(); +} + +XRectPreview::~XRectPreview() +{ + SdrObject::Free(mpRectangleObject); +} + +void XRectPreview::SetAttributes(const SfxItemSet& rItemSet) +{ + mpRectangleObject->SetMergedItemSet(rItemSet, true); + mpRectangleObject->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE)); +} + +void XRectPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) +{ + LocalPrePaint(rRenderContext); + + sdr::contact::SdrObjectVector aObjectVector; + + aObjectVector.push_back(mpRectangleObject); + + sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, nullptr); + sdr::contact::DisplayInfo aDisplayInfo; + + aPainter.ProcessDisplay(aDisplayInfo); + + LocalPostPaint(rRenderContext); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits