Kaydet (Commit) 73ada0a0 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld ScMetricInputDlg

Change-Id: I4693969c1ef740235e7c0d55619552dd4ace494c
Reviewed-on: https://gerrit.libreoffice.org/53675Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst b2869173
......@@ -243,7 +243,7 @@ class AbstractScMetricInputDlg : public VclAbstractDialog
protected:
virtual ~AbstractScMetricInputDlg() override = default;
public:
virtual long GetInputValue() const = 0;
virtual int GetInputValue() const = 0;
};
class AbstractScMoveTableDlg : public VclAbstractDialog
......@@ -455,7 +455,7 @@ public:
const std::vector<OUString> &rEntryList ) = 0;
virtual VclPtr<AbstractScLinkedAreaDlg> CreateScLinkedAreaDlg(weld::Window* pParent) = 0;
virtual VclPtr<AbstractScMetricInputDlg> CreateScMetricInputDlg ( vcl::Window* pParent,
virtual VclPtr<AbstractScMetricInputDlg> CreateScMetricInputDlg(weld::Window* pParent,
const OString& sDialogName,
long nCurrent,
long nDefault,
......
......@@ -111,7 +111,12 @@ short AbstractScInsertCellDlg_Impl::Execute()
IMPL_ABSTDLG_BASE(AbstractScInsertContentsDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScInsertTableDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScSelEntryDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScMetricInputDlg_Impl);
short AbstractScMetricInputDlg_Impl::Execute()
{
return m_xDlg->run();
}
IMPL_ABSTDLG_BASE(AbstractScMoveTableDlg_Impl);
short AbstractScNameCreateDlg_Impl::Execute()
......@@ -461,9 +466,9 @@ ScConditionalFormat* AbstractScCondFormatManagerDlg_Impl::GetCondFormatSelected(
return pDlg->GetCondFormatSelected();
}
long AbstractScMetricInputDlg_Impl::GetInputValue() const
int AbstractScMetricInputDlg_Impl::GetInputValue() const
{
return pDlg->GetInputValue();
return m_xDlg->GetInputValue();
}
sal_uInt16 AbstractScMoveTableDlg_Impl::GetSelectedDocument() const
......@@ -762,7 +767,7 @@ VclPtr<AbstractScLinkedAreaDlg> ScAbstractDialogFactory_Impl::CreateScLinkedArea
return VclPtr<AbstractScLinkedAreaDlg_Impl>::Create(new ScLinkedAreaDlg(pParent));
}
VclPtr<AbstractScMetricInputDlg> ScAbstractDialogFactory_Impl::CreateScMetricInputDlg ( vcl::Window* pParent,
VclPtr<AbstractScMetricInputDlg> ScAbstractDialogFactory_Impl::CreateScMetricInputDlg(weld::Window* pParent,
const OString& sDialogName,
long nCurrent,
long nDefault,
......@@ -771,9 +776,8 @@ VclPtr<AbstractScMetricInputDlg> ScAbstractDialogFactory_Impl::CreateScMetricInp
long nMaximum ,
long nMinimum )
{
VclPtr<ScMetricInputDlg> pDlg = VclPtr<ScMetricInputDlg>::Create(pParent, sDialogName, nCurrent ,nDefault, eFUnit,
nDecimals, nMaximum , nMinimum , 1, 100);
return VclPtr<AbstractScMetricInputDlg_Impl>::Create( pDlg );
return VclPtr<AbstractScMetricInputDlg_Impl>::Create(new ScMetricInputDlg(pParent, sDialogName, nCurrent ,nDefault, eFUnit,
nDecimals, nMaximum , nMinimum));
}
VclPtr<AbstractScMoveTableDlg> ScAbstractDialogFactory_Impl::CreateScMoveTableDlg(vcl::Window* pParent,
......
......@@ -284,8 +284,14 @@ public:
class AbstractScMetricInputDlg_Impl : public AbstractScMetricInputDlg
{
DECL_ABSTDLG_BASE( AbstractScMetricInputDlg_Impl, ScMetricInputDlg)
virtual long GetInputValue() const override;
std::unique_ptr<ScMetricInputDlg> m_xDlg;
public:
explicit AbstractScMetricInputDlg_Impl(ScMetricInputDlg* p)
: m_xDlg(p)
{
}
virtual short Execute() override;
virtual int GetInputValue() const override;
};
class AbstractScMoveTableDlg_Impl : public AbstractScMoveTableDlg
......@@ -491,7 +497,7 @@ public:
virtual VclPtr<AbstractScLinkedAreaDlg> CreateScLinkedAreaDlg(weld::Window* pParent) override;
virtual VclPtr<AbstractScMetricInputDlg> CreateScMetricInputDlg ( vcl::Window* pParent,
virtual VclPtr<AbstractScMetricInputDlg> CreateScMetricInputDlg(weld::Window* pParent,
const OString& sDialogName,
long nCurrent,
long nDefault,
......
......@@ -20,37 +20,31 @@
#ifndef INCLUDED_SC_SOURCE_UI_INC_MTRINDLG_HXX
#define INCLUDED_SC_SOURCE_UI_INC_MTRINDLG_HXX
#include <vcl/dialog.hxx>
#include <vcl/field.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
#include <vcl/weld.hxx>
class ScMetricInputDlg : public ModalDialog
class ScMetricInputDlg : public weld::GenericDialogController
{
public:
ScMetricInputDlg( vcl::Window* pParent,
ScMetricInputDlg( weld::Window* pParent,
const OString& sDialogName,
long nCurrent,
long nDefault,
FieldUnit eFUnit,
sal_uInt16 nDecimals,
long nMaximum,
long nMinimum,
long nFirst,
long nLast );
long nMinimum);
virtual ~ScMetricInputDlg() override;
virtual void dispose() override;
long GetInputValue() const;
int GetInputValue() const;
private:
VclPtr<MetricField> m_pEdValue;
VclPtr<CheckBox> m_pBtnDefVal;
long nDefaultValue;
long nCurrentValue;
std::unique_ptr<weld::MetricSpinButton> m_xEdValue;
std::unique_ptr<weld::CheckButton> m_xBtnDefVal;
int nDefaultValue;
int nCurrentValue;
DECL_LINK(SetDefValHdl, Button*, void);
DECL_LINK(ModifyHdl, Edit&, void);
DECL_LINK(SetDefValHdl, weld::Button&, void);
DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void);
};
#endif // INCLUDED_SC_SOURCE_UI_INC_MTRINDLG_HXX
......
......@@ -21,60 +21,51 @@
#include <mtrindlg.hxx>
ScMetricInputDlg::ScMetricInputDlg( vcl::Window* pParent,
ScMetricInputDlg::ScMetricInputDlg( weld::Window* pParent,
const OString& sDialogName,
long nCurrent,
long nDefault,
FieldUnit eFUnit,
sal_uInt16 nDecimals,
long nMaximum,
long nMinimum,
long nFirst,
long nLast )
long nMinimum)
: ModalDialog(pParent, OStringToOUString(sDialogName, RTL_TEXTENCODING_UTF8),
OStringToOUString("modules/scalc/ui/" +
sDialogName.toAsciiLowerCase() + ".ui", RTL_TEXTENCODING_UTF8))
: GenericDialogController(pParent, OStringToOUString("modules/scalc/ui/" +
sDialogName.toAsciiLowerCase() + ".ui", RTL_TEXTENCODING_UTF8), sDialogName)
, m_xEdValue(m_xBuilder->weld_metric_spin_button("value", FUNIT_CM))
, m_xBtnDefVal(m_xBuilder->weld_check_button("default"))
{
get(m_pEdValue, "value");
get(m_pBtnDefVal, "default");
m_pBtnDefVal->SetClickHdl ( LINK( this, ScMetricInputDlg, SetDefValHdl ) );
m_pEdValue->SetModifyHdl( LINK( this, ScMetricInputDlg, ModifyHdl ) );
m_pEdValue->SetUnit ( eFUnit );
m_pEdValue->SetDecimalDigits ( nDecimals );
m_pEdValue->SetMax ( m_pEdValue->Normalize( nMaximum ), FUNIT_TWIP );
m_pEdValue->SetMin ( m_pEdValue->Normalize( nMinimum ), FUNIT_TWIP );
m_pEdValue->SetLast ( m_pEdValue->Normalize( nLast ), FUNIT_TWIP );
m_pEdValue->SetFirst ( m_pEdValue->Normalize( nFirst ), FUNIT_TWIP );
m_pEdValue->SetSpinSize ( m_pEdValue->Normalize( 1 ) / 10 );
m_pEdValue->SetValue ( m_pEdValue->Normalize( nDefault ), FUNIT_TWIP );
nDefaultValue = sal::static_int_cast<long>( m_pEdValue->GetValue() );
m_pEdValue->SetValue ( m_pEdValue->Normalize( nCurrent ), FUNIT_TWIP );
nCurrentValue = sal::static_int_cast<long>( m_pEdValue->GetValue() );
m_pBtnDefVal->Check( nCurrentValue == nDefaultValue );
m_xBtnDefVal->connect_clicked(LINK(this, ScMetricInputDlg, SetDefValHdl));
m_xEdValue->connect_value_changed(LINK( this, ScMetricInputDlg, ModifyHdl));
m_xEdValue->set_unit(eFUnit);
m_xEdValue->set_digits(nDecimals);
m_xEdValue->set_range(m_xEdValue->normalize(nMinimum),
m_xEdValue->normalize(nMaximum), FUNIT_TWIP);
int nMin(0), nMax(0);
m_xEdValue->get_range(nMin, nMax, FUNIT_TWIP);
auto nIncrement = m_xEdValue->normalize(1);
m_xEdValue->set_increments(nIncrement / 10, nIncrement, FUNIT_NONE);
m_xEdValue->set_value(m_xEdValue->normalize(nDefault), FUNIT_TWIP);
nDefaultValue = m_xEdValue->get_value(FUNIT_NONE);
m_xEdValue->set_value(m_xEdValue->normalize(nCurrent), FUNIT_TWIP);
nCurrentValue = m_xEdValue->get_value(FUNIT_NONE);
m_xBtnDefVal->set_active(nCurrentValue == nDefaultValue);
}
ScMetricInputDlg::~ScMetricInputDlg()
{
disposeOnce();
}
void ScMetricInputDlg::dispose()
{
m_pEdValue.clear();
m_pBtnDefVal.clear();
ModalDialog::dispose();
}
long ScMetricInputDlg::GetInputValue() const
int ScMetricInputDlg::GetInputValue() const
{
/*
with decimal digits
double nVal = m_pEdValue->GetValue( eUnit );
sal_uInt16 nDecs = m_pEdValue->GetDecimalDigits();
double nVal = m_xEdValue->GetValue( eUnit );
sal_uInt16 nDecs = m_xEdValue->GetDecimalDigits();
double nFactor = 0.0;
// static long ImpPower10( sal_uInt16 nDecs )
......@@ -89,25 +80,25 @@ long ScMetricInputDlg::GetInputValue() const
*/
// first cut off the decimal digits - not that great...
return sal::static_int_cast<long>( m_pEdValue->Denormalize( m_pEdValue->GetValue( FUNIT_TWIP ) ) );
return m_xEdValue->denormalize(m_xEdValue->get_value(FUNIT_TWIP));
}
// Handler:
IMPL_LINK_NOARG(ScMetricInputDlg, SetDefValHdl, Button*, void)
IMPL_LINK_NOARG(ScMetricInputDlg, SetDefValHdl, weld::Button&, void)
{
if ( m_pBtnDefVal->IsChecked() )
if (m_xBtnDefVal->get_active())
{
nCurrentValue = sal::static_int_cast<long>( m_pEdValue->GetValue() );
m_pEdValue->SetValue( nDefaultValue );
nCurrentValue = m_xEdValue->get_value(FUNIT_NONE);
m_xEdValue->set_value(nDefaultValue, FUNIT_NONE);
}
else
m_pEdValue->SetValue( nCurrentValue );
m_xEdValue->set_value(nCurrentValue, FUNIT_NONE);
}
IMPL_LINK_NOARG(ScMetricInputDlg, ModifyHdl, Edit&, void)
IMPL_LINK_NOARG(ScMetricInputDlg, ModifyHdl, weld::MetricSpinButton&, void)
{
m_pBtnDefVal->Check( nDefaultValue == m_pEdValue->GetValue() );
m_xBtnDefVal->set_active(nDefaultValue == m_xEdValue->get_value(FUNIT_NONE));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -578,7 +578,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
assert(pFact); //ScAbstractFactory create fail!
ScopedVclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg(
pTabViewShell->GetDialogParent(), "RowHeightDialog",
pTabViewShell->GetFrameWeld(), "RowHeightDialog",
nCurHeight, ScGlobal::nStdRowHeight,
eMetric, 2, MAX_ROW_HEIGHT));
assert(pDlg); //Dialog create fail
......@@ -619,7 +619,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
assert(pFact); //ScAbstractFactory create fail!
ScopedVclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg(
pTabViewShell->GetDialogParent(), "OptimalRowHeightDialog",
pTabViewShell->GetFrameWeld(), "OptimalRowHeightDialog",
ScGlobal::nLastRowHeightExtra, 0, eMetric, 1, MAX_EXTRA_HEIGHT));
assert(pDlg); //Dialog create fail!
......@@ -684,7 +684,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
assert(pFact); //ScAbstractFactory create fail!
ScopedVclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg(
pTabViewShell->GetDialogParent(), "ColWidthDialog", nCurHeight,
pTabViewShell->GetFrameWeld(), "ColWidthDialog", nCurHeight,
STD_COL_WIDTH, eMetric, 2, MAX_COL_WIDTH));
assert(pDlg); //Dialog create fail!
......@@ -724,7 +724,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
assert(pFact); //ScAbstractFactory create fail!
ScopedVclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg(
pTabViewShell->GetDialogParent(), "OptimalColWidthDialog",
pTabViewShell->GetFrameWeld(), "OptimalColWidthDialog",
ScGlobal::nLastColWidthExtra, STD_EXTRA_WIDTH, eMetric, 1, MAX_EXTRA_WIDTH));
assert(pDlg); //Dialog create fail!
if ( pDlg->Execute() == RET_OK )
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="sc">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="ColWidthDialog">
......@@ -7,6 +7,9 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="colwidthdialog|ColWidthDialog">Column Width</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
......@@ -60,7 +63,6 @@
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
<property name="non_homogeneous">True</property>
</packing>
</child>
</object>
......@@ -84,10 +86,10 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="colwidthdialog|label1">Width</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">value:0.00cm</property>
<property name="mnemonic_widget">value</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -95,10 +97,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="value:0.00cm">
<object class="GtkSpinButton" id="value">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
<property name="digits">2</property>
</object>
<packing>
......@@ -138,5 +141,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="sc">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="OptimalColWidthDialog">
......@@ -7,6 +7,9 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="optimalcolwidthdialog|OptimalColWidthDialog">Optimal Column Width</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
......@@ -84,10 +87,10 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="optimalcolwidthdialog|label1">Add:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">value:0.00cm</property>
<property name="mnemonic_widget">value</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -95,10 +98,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="value:0.00cm">
<object class="GtkSpinButton" id="value">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
<property name="digits">2</property>
</object>
<packing>
......@@ -138,5 +142,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="sc">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="OptimalRowHeightDialog">
......@@ -7,6 +7,9 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="optimalrowheightdialog|OptimalRowHeightDialog">Optimal Row Height</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
......@@ -60,7 +63,6 @@
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
<property name="non_homogeneous">True</property>
</packing>
</child>
</object>
......@@ -84,10 +86,10 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="optimalrowheightdialog|label1">Add:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">value:0.00cm</property>
<property name="mnemonic_widget">value</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -95,10 +97,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="value:0.00cm">
<object class="GtkSpinButton" id="value">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
<property name="digits">2</property>
</object>
<packing>
......@@ -138,5 +141,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="sc">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="RowHeightDialog">
......@@ -7,6 +7,9 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="rowheightdialog|RowHeightDialog">Row Height</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
......@@ -60,7 +63,6 @@
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
<property name="non_homogeneous">True</property>
</packing>
</child>
</object>
......@@ -84,10 +86,10 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="rowheightdialog|label1">Height:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">value:0.00cm</property>
<property name="mnemonic_widget">value</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -95,10 +97,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="value:0.00cm">
<object class="GtkSpinButton" id="value">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
<property name="digits">2</property>
</object>
<packing>
......@@ -138,5 +141,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment