diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-30 11:55:31 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-30 16:01:20 +0200 |
commit | 23cf9370edf41c591ebb5acad372b5ce2395f68e (patch) | |
tree | 423c32cfaa29cce485ba0d9e1b181484a4d91a94 /sd/source/ui/dlg/dlgsnap.cxx | |
parent | 5fb3b6b925db2989ce61bb954d7156f2a3b84b4c (diff) |
weld SdSnapLineDlg
Change-Id: I3a8117719525fa204f29cc10a944376116050d61
Reviewed-on: https://gerrit.libreoffice.org/53658
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd/source/ui/dlg/dlgsnap.cxx')
-rw-r--r-- | sd/source/ui/dlg/dlgsnap.cxx | 165 |
1 files changed, 71 insertions, 94 deletions
diff --git a/sd/source/ui/dlg/dlgsnap.cxx b/sd/source/ui/dlg/dlgsnap.cxx index 58a893078aa1..40de52f786e0 100644 --- a/sd/source/ui/dlg/dlgsnap.cxx +++ b/sd/source/ui/dlg/dlgsnap.cxx @@ -30,32 +30,28 @@ /** * dialog to adjust grid (scarcely ESO!) */ -SdSnapLineDlg::SdSnapLineDlg( - vcl::Window* pWindow, - const SfxItemSet& rInAttrs, - ::sd::View const * pView) - : ModalDialog(pWindow, "SnapObjectDialog", "modules/sdraw/ui/dlgsnap.ui") +SdSnapLineDlg::SdSnapLineDlg(weld::Window* pWindow, const SfxItemSet& rInAttrs, ::sd::View const * pView) + : GenericDialogController(pWindow, "modules/sdraw/ui/dlgsnap.ui", "SnapObjectDialog") , eUIUnit(pView->GetDoc().GetUIUnit()) , aUIScale(pView->GetDoc().GetUIScale()) + , m_xFtX(m_xBuilder->weld_label("xlabel")) + , m_xMtrFldX(m_xBuilder->weld_metric_spin_button("x", FUNIT_CM)) + , m_xFtY(m_xBuilder->weld_label("ylabel")) + , m_xMtrFldY(m_xBuilder->weld_metric_spin_button("y", FUNIT_CM)) + , m_xRadioGroup(m_xBuilder->weld_widget("radiogroup")) + , m_xRbPoint(m_xBuilder->weld_radio_button("point")) + , m_xRbVert(m_xBuilder->weld_radio_button("vert")) + , m_xRbHorz(m_xBuilder->weld_radio_button("horz")) + , m_xBtnDelete(m_xBuilder->weld_button("delete")) { - get(m_pFtX, "xlabel"); - get(m_pMtrFldX, "x"); - get(m_pFtY, "ylabel"); - get(m_pMtrFldY, "y"); - get(m_pRadioGroup, "radiogroup"); - get(m_pRbPoint, "point"); - get(m_pRbVert, "vert"); - get(m_pRbHorz, "horz"); - get(m_pBtnDelete, "delete"); + m_xRbHorz->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl)); + m_xRbVert->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl)); + m_xRbPoint->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl)); - m_pRbHorz->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl)); - m_pRbVert->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl)); - m_pRbPoint->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl)); + m_xBtnDelete->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl)); - m_pBtnDelete->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl)); - - SetFieldUnit( *m_pMtrFldX, eUIUnit, true ); - SetFieldUnit( *m_pMtrFldY, eUIUnit, true ); + SetFieldUnit(*m_xMtrFldX, eUIUnit, true); + SetFieldUnit(*m_xMtrFldY, eUIUnit, true); // get WorkArea ::tools::Rectangle aWorkArea = pView->GetWorkArea(); @@ -74,70 +70,51 @@ SdSnapLineDlg::SdSnapLineDlg( // determine max and min values depending on // WorkArea, PoolUnit and FieldUnit: - SetMetricValue( *m_pMtrFldX, aLeftTop.X(), ePoolUnit ); - - long nValue = static_cast<long>(m_pMtrFldX->GetValue()); - nValue = long( nValue / aUIScale); - m_pMtrFldX->SetMin( nValue ); - m_pMtrFldX->SetFirst( nValue ); - - SetMetricValue( *m_pMtrFldX, aRightBottom.X(), ePoolUnit ); - nValue = static_cast<long>(m_pMtrFldX->GetValue()); - nValue = long( nValue / aUIScale); - m_pMtrFldX->SetMax( nValue ); - m_pMtrFldX->SetLast( nValue ); - - SetMetricValue( *m_pMtrFldY, aLeftTop.Y(), ePoolUnit ); - nValue = static_cast<long>(m_pMtrFldY->GetValue()); - nValue = long( nValue / aUIScale); - m_pMtrFldY->SetMin( nValue ); - m_pMtrFldY->SetFirst( nValue ); - - SetMetricValue( *m_pMtrFldY, aRightBottom.Y(), ePoolUnit ); - nValue = static_cast<long>(m_pMtrFldY->GetValue()); - nValue = long( nValue / aUIScale); - m_pMtrFldY->SetMax( nValue ); - m_pMtrFldY->SetLast( nValue ); + SetMetricValue(*m_xMtrFldX, aLeftTop.X(), ePoolUnit ); + + int nValue = m_xMtrFldX->get_value(FUNIT_NONE); + nValue = sal_Int32(nValue / aUIScale); + m_xMtrFldX->set_min(nValue, FUNIT_NONE); + + SetMetricValue(*m_xMtrFldX, aRightBottom.X(), ePoolUnit); + nValue = m_xMtrFldX->get_value(FUNIT_NONE); + nValue = sal_Int32(nValue / aUIScale); + m_xMtrFldX->set_max(nValue, FUNIT_NONE); + + SetMetricValue(*m_xMtrFldY, aLeftTop.Y(), ePoolUnit); + nValue = m_xMtrFldY->get_value(FUNIT_NONE); + nValue = sal_Int32(nValue / aUIScale); + m_xMtrFldY->set_min(nValue, FUNIT_NONE); + + SetMetricValue(*m_xMtrFldY, aRightBottom.Y(), ePoolUnit); + nValue = m_xMtrFldY->get_value(FUNIT_NONE); + nValue = sal_Int32(nValue / aUIScale); + m_xMtrFldY->set_max(nValue, FUNIT_NONE); // set values nXValue = static_cast<const SfxInt32Item&>( rInAttrs.Get(ATTR_SNAPLINE_X)).GetValue(); nYValue = static_cast<const SfxInt32Item&>( rInAttrs.Get(ATTR_SNAPLINE_Y)).GetValue(); - nXValue = long(nXValue / aUIScale); - nYValue = long(nYValue / aUIScale); - SetMetricValue( *m_pMtrFldX, nXValue, MapUnit::Map100thMM); - SetMetricValue( *m_pMtrFldY, nYValue, MapUnit::Map100thMM); + nXValue = sal_Int32(nXValue / aUIScale); + nYValue = sal_Int32(nYValue / aUIScale); + SetMetricValue(*m_xMtrFldX, nXValue, MapUnit::Map100thMM); + SetMetricValue(*m_xMtrFldY, nYValue, MapUnit::Map100thMM); - m_pRbPoint->Check(); + m_xRbPoint->set_active(true); } SdSnapLineDlg::~SdSnapLineDlg() { - disposeOnce(); -} - -void SdSnapLineDlg::dispose() -{ - m_pFtX.clear(); - m_pMtrFldX.clear(); - m_pFtY.clear(); - m_pMtrFldY.clear(); - m_pRadioGroup.clear(); - m_pRbPoint.clear(); - m_pRbVert.clear(); - m_pRbHorz.clear(); - m_pBtnDelete.clear(); - ModalDialog::dispose(); } /** * fills provided item sets with dialog box attributes */ -IMPL_LINK( SdSnapLineDlg, ClickHdl, Button *, pBtn, void ) +IMPL_LINK( SdSnapLineDlg, ClickHdl, weld::Button&, rBtn, void ) { - if ( pBtn == m_pRbPoint ) SetInputFields(true, true); - else if ( pBtn == m_pRbHorz ) SetInputFields(false, true); - else if ( pBtn == m_pRbVert ) SetInputFields(true, false); - else if ( pBtn == m_pBtnDelete ) EndDialog(RET_SNAP_DELETE); + if (&rBtn == m_xRbPoint.get()) SetInputFields(true, true); + else if (&rBtn == m_xRbHorz.get()) SetInputFields(false, true); + else if (&rBtn == m_xRbVert.get()) SetInputFields(true, false); + else if (&rBtn == m_xBtnDelete.get()) m_xDialog->response(RET_SNAP_DELETE); } /** @@ -147,12 +124,12 @@ void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs) { SnapKind eKind; - if ( m_pRbHorz->IsChecked() ) eKind = SK_HORIZONTAL; - else if ( m_pRbVert->IsChecked() ) eKind = SK_VERTICAL; - else eKind = SK_POINT; + if (m_xRbHorz->get_active()) eKind = SK_HORIZONTAL; + else if (m_xRbVert->get_active()) eKind = SK_VERTICAL; + else eKind = SK_POINT; - nXValue = long( GetCoreValue( *m_pMtrFldX, MapUnit::Map100thMM) * aUIScale); - nYValue = long( GetCoreValue( *m_pMtrFldY, MapUnit::Map100thMM) * aUIScale); + nXValue = sal_Int32(GetCoreValue(*m_xMtrFldX, MapUnit::Map100thMM) * aUIScale); + nYValue = sal_Int32(GetCoreValue(*m_xMtrFldY, MapUnit::Map100thMM) * aUIScale); rOutAttrs.Put(SfxAllEnumItem(ATTR_SNAPLINE_KIND, static_cast<sal_uInt16>(eKind))); rOutAttrs.Put(SfxInt32Item(ATTR_SNAPLINE_X, nXValue)); @@ -161,7 +138,7 @@ void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs) void SdSnapLineDlg::HideRadioGroup() { - m_pRadioGroup->Hide(); + m_xRadioGroup->hide(); } /** @@ -171,31 +148,31 @@ void SdSnapLineDlg::SetInputFields(bool bEnableX, bool bEnableY) { if ( bEnableX ) { - if ( !m_pMtrFldX->IsEnabled() ) - m_pMtrFldX->SetValue(nXValue); - m_pMtrFldX->Enable(); - m_pFtX->Enable(); + if (!m_xMtrFldX->get_sensitive()) + m_xMtrFldX->set_value(nXValue, FUNIT_NONE); + m_xMtrFldX->set_sensitive(true); + m_xFtX->set_sensitive(true); } - else if ( m_pMtrFldX->IsEnabled() ) + else if (m_xMtrFldX->get_sensitive()) { - nXValue = static_cast<long>(m_pMtrFldX->GetValue()); - m_pMtrFldX->SetText(OUString()); - m_pMtrFldX->Disable(); - m_pFtX->Disable(); + nXValue = m_xMtrFldX->get_value(FUNIT_NONE); + m_xMtrFldX->set_text(OUString()); + m_xMtrFldX->set_sensitive(false); + m_xFtX->set_sensitive(false); } if ( bEnableY ) { - if ( !m_pMtrFldY->IsEnabled() ) - m_pMtrFldY->SetValue(nYValue); - m_pMtrFldY->Enable(); - m_pFtY->Enable(); + if (!m_xMtrFldY->get_sensitive()) + m_xMtrFldY->set_value(nYValue, FUNIT_NONE); + m_xMtrFldY->set_sensitive(true); + m_xFtY->set_sensitive(true); } - else if ( m_pMtrFldY->IsEnabled() ) + else if (m_xMtrFldY->get_sensitive()) { - nYValue = static_cast<long>(m_pMtrFldY->GetValue()); - m_pMtrFldY->SetText(OUString()); - m_pMtrFldY->Disable(); - m_pFtY->Disable(); + nYValue = m_xMtrFldY->get_value(FUNIT_NONE); + m_xMtrFldY->set_text(OUString()); + m_xMtrFldY->set_sensitive(false); + m_xFtY->set_sensitive(false); } } |