summaryrefslogtreecommitdiff
path: root/svx/source/sidebar/text
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-01-13 12:55:23 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-01-13 18:29:14 +0100
commitbd738ed736cc5e1f4ed8e81c3691538d401bbf65 (patch)
treee043f481390e9c67dc7a4670e7b46b6fb2d4f6f7 /svx/source/sidebar/text
parentc9ba69cdfaaf19695fc8e40ba7af1d06490a123f (diff)
weld TextCharacterSpacingControl
Change-Id: Id0789c8c590a120efa8585d45fe7f5cdb0077cbb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86694 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source/sidebar/text')
-rw-r--r--svx/source/sidebar/text/TextCharacterSpacingControl.cxx98
-rw-r--r--svx/source/sidebar/text/TextCharacterSpacingControl.hxx34
-rw-r--r--svx/source/sidebar/text/TextCharacterSpacingPopup.cxx14
3 files changed, 73 insertions, 73 deletions
diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
index 3de287aff0f9..e19044e2eb25 100644
--- a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
+++ b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
@@ -42,41 +42,40 @@
namespace svx {
-TextCharacterSpacingControl::TextCharacterSpacingControl(TextCharacterSpacingPopup* pControl, vcl::Window* pParent)
- : ToolbarPopup(pControl->getFrameInterface(), pParent, "TextCharacterSpacingControl", "svx/ui/textcharacterspacingcontrol.ui")
+TextCharacterSpacingControl::TextCharacterSpacingControl(TextCharacterSpacingPopup* pControl, weld::Widget* pParent)
+ : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/textcharacterspacingcontrol.ui", "TextCharacterSpacingControl")
, mnId(SID_ATTR_CHAR_KERNING)
, mnCustomKern(0)
, mnLastCus(SPACING_NOCUSTOM)
+ , mxEditKerning(m_xBuilder->weld_metric_spin_button("kerning", FieldUnit::POINT))
+ , mxTight(m_xBuilder->weld_button("tight"))
+ , mxVeryTight(m_xBuilder->weld_button("very_tight"))
+ , mxNormal(m_xBuilder->weld_button("normal"))
+ , mxLoose(m_xBuilder->weld_button("loose"))
+ , mxVeryLoose(m_xBuilder->weld_button("very_loose"))
+ , mxLastCustom(m_xBuilder->weld_button("last_custom"))
+ , mxControl(pControl)
{
- get(maEditKerning, "kerning");
-
- get(maNormal, "normal");
- get(maVeryTight, "very_tight");
- get(maTight, "tight");
- get(maVeryLoose, "very_loose");
- get(maLoose, "loose");
- get(maLastCustom, "last_custom");
-
- maEditKerning->SetModifyHdl(LINK(this, TextCharacterSpacingControl, KerningModifyHdl));
- maEditKerning->SetHelpId(HID_SPACING_MB_KERN);
-
- Link<Button*,void> aLink = LINK(this, TextCharacterSpacingControl, PredefinedValuesHdl);
- maNormal->SetClickHdl(aLink);
- maVeryTight->SetClickHdl(aLink);
- maTight->SetClickHdl(aLink);
- maVeryLoose->SetClickHdl(aLink);
- maLoose->SetClickHdl(aLink);
- maLastCustom->SetClickHdl(aLink);
+ mxEditKerning->connect_value_changed(LINK(this, TextCharacterSpacingControl, KerningModifyHdl));
+ mxEditKerning->set_help_id(HID_SPACING_MB_KERN);
+
+ Link<weld::Button&,void> aLink = LINK(this, TextCharacterSpacingControl, PredefinedValuesHdl);
+ mxNormal->connect_clicked(aLink);
+ mxVeryTight->connect_clicked(aLink);
+ mxTight->connect_clicked(aLink);
+ mxVeryLoose->connect_clicked(aLink);
+ mxLoose->connect_clicked(aLink);
+ mxLastCustom->connect_clicked(aLink);
Initialize();
}
-TextCharacterSpacingControl::~TextCharacterSpacingControl()
+void TextCharacterSpacingControl::GrabFocus()
{
- disposeOnce();
+ mxVeryTight->grab_focus();
}
-void TextCharacterSpacingControl::dispose()
+TextCharacterSpacingControl::~TextCharacterSpacingControl()
{
if (mnLastCus == SPACING_CLOSE_BY_CUS_EDIT)
{
@@ -85,17 +84,6 @@ void TextCharacterSpacingControl::dispose()
{ { "Spacing", css::uno::makeAny(OUString::number(mnCustomKern)) } };
aWinOpt.SetUserData(aSeq);
}
-
- maEditKerning.clear();
-
- maNormal.clear();
- maVeryTight.clear();
- maTight.clear();
- maVeryLoose.clear();
- maLoose.clear();
- maLastCustom.clear();
-
- ToolbarPopup::dispose();
}
void TextCharacterSpacingControl::Initialize()
@@ -130,19 +118,19 @@ void TextCharacterSpacingControl::Initialize()
{
MapUnit eUnit = GetCoreMetric();
MapUnit eOrgUnit = eUnit;
- long nBig = maEditKerning->Normalize(nKerning);
- nKerning = LogicToLogic(nBig, eOrgUnit, MapUnit::MapPoint);
- maEditKerning->SetValue(nKerning);
+ long nBig = mxEditKerning->normalize(nKerning);
+ nKerning = OutputDevice::LogicToLogic(nBig, eOrgUnit, MapUnit::MapPoint);
+ mxEditKerning->set_value(nKerning, FieldUnit::NONE);
}
else if(SfxItemState::DISABLED == eState)
{
- maEditKerning->SetText(OUString());
- maEditKerning->Disable();
+ mxEditKerning->set_text(OUString());
+ mxEditKerning->set_sensitive(false);
}
else
{
- maEditKerning->SetText(OUString());
- maEditKerning->Disable();
+ mxEditKerning->set_text(OUString());
+ mxEditKerning->set_sensitive(false);
}
}
@@ -153,52 +141,52 @@ void TextCharacterSpacingControl::ExecuteCharacterSpacing(long nValue, bool bClo
long nSign = (nValue < 0) ? -1 : 1;
nValue = nValue * nSign;
- long nVal = LogicToLogic(nValue, MapUnit::MapPoint, eUnit);
- short nKern = (nValue == 0) ? 0 : static_cast<short>(maEditKerning->Denormalize(nVal));
+ long nVal = OutputDevice::LogicToLogic(nValue, MapUnit::MapPoint, eUnit);
+ short nKern = (nValue == 0) ? 0 : static_cast<short>(mxEditKerning->denormalize(nVal));
SvxKerningItem aKernItem(nSign * nKern, SID_ATTR_CHAR_KERNING);
SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
SfxCallMode::RECORD, { &aKernItem });
- if(bClose)
- EndPopupMode();
+ if (bClose)
+ mxControl->EndPopupMode();
}
-IMPL_LINK(TextCharacterSpacingControl, PredefinedValuesHdl, Button*, pControl, void)
+IMPL_LINK(TextCharacterSpacingControl, PredefinedValuesHdl, weld::Button&, rControl, void)
{
mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
- if(pControl == maNormal)
+ if (&rControl == mxNormal.get())
{
ExecuteCharacterSpacing(SPACING_NORMAL);
}
- else if(pControl == maVeryTight)
+ else if (&rControl == mxVeryTight.get())
{
ExecuteCharacterSpacing(SPACING_VERY_TIGHT);
}
- else if(pControl == maTight)
+ else if (&rControl == mxTight.get())
{
ExecuteCharacterSpacing(SPACING_TIGHT);
}
- else if(pControl == maVeryLoose)
+ else if (&rControl == mxVeryLoose.get())
{
ExecuteCharacterSpacing(SPACING_VERY_LOOSE);
}
- else if(pControl == maLoose)
+ else if (&rControl == mxLoose.get())
{
ExecuteCharacterSpacing(SPACING_LOOSE);
}
- else if(pControl == maLastCustom)
+ else if (&rControl == mxLastCustom.get())
{
ExecuteCharacterSpacing(mnCustomKern);
}
}
-IMPL_LINK_NOARG(TextCharacterSpacingControl, KerningModifyHdl, Edit&, void)
+IMPL_LINK_NOARG(TextCharacterSpacingControl, KerningModifyHdl, weld::MetricSpinButton&, void)
{
mnLastCus = SPACING_CLOSE_BY_CUS_EDIT;
- mnCustomKern = static_cast<long>(maEditKerning->GetValue());
+ mnCustomKern = mxEditKerning->get_value(FieldUnit::NONE);
ExecuteCharacterSpacing(mnCustomKern, false);
}
diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.hxx b/svx/source/sidebar/text/TextCharacterSpacingControl.hxx
index d4f79cdbbbe7..c1ea339b1ae3 100644
--- a/svx/source/sidebar/text/TextCharacterSpacingControl.hxx
+++ b/svx/source/sidebar/text/TextCharacterSpacingControl.hxx
@@ -20,8 +20,6 @@
#define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTCHARACTERSPACINGCONTROL_HXX
#include <sfx2/bindings.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/field.hxx>
#include <svtools/toolbarmenu.hxx>
namespace svx {
@@ -33,35 +31,39 @@ namespace svx {
class TextCharacterSpacingPopup;
-class TextCharacterSpacingControl final : public svtools::ToolbarPopup
+class TextCharacterSpacingControl final : public WeldToolbarPopup
{
public:
- explicit TextCharacterSpacingControl(TextCharacterSpacingPopup* pControl, vcl::Window* pParent);
- virtual ~TextCharacterSpacingControl() override;
- virtual void dispose() override;
+ explicit TextCharacterSpacingControl(TextCharacterSpacingPopup* pControl, weld::Widget* pParent);
-private:
- VclPtr<MetricField> maEditKerning;
+ virtual void GrabFocus() override;
- VclPtr<PushButton> maNormal;
- VclPtr<PushButton> maVeryTight;
- VclPtr<PushButton> maTight;
- VclPtr<PushButton> maVeryLoose;
- VclPtr<PushButton> maLoose;
- VclPtr<PushButton> maLastCustom;
+ virtual ~TextCharacterSpacingControl() override;
+private:
sal_uInt16 mnId;
long mnCustomKern;
short mnLastCus;
+ std::unique_ptr<weld::MetricSpinButton> mxEditKerning;
+ std::unique_ptr<weld::Button> mxTight;
+ std::unique_ptr<weld::Button> mxVeryTight;
+ std::unique_ptr<weld::Button> mxNormal;
+ std::unique_ptr<weld::Button> mxLoose;
+ std::unique_ptr<weld::Button> mxVeryLoose;
+ std::unique_ptr<weld::Button> mxLastCustom;
+
+ rtl::Reference<TextCharacterSpacingPopup> mxControl;
+
void Initialize();
void ExecuteCharacterSpacing(long nValue, bool bClose = true);
- DECL_LINK(PredefinedValuesHdl, Button*, void);
- DECL_LINK(KerningModifyHdl, Edit&, void);
+ DECL_LINK(PredefinedValuesHdl, weld::Button&, void);
+ DECL_LINK(KerningModifyHdl, weld::MetricSpinButton&, void);
MapUnit GetCoreMetric() const;
};
+
}
#endif
diff --git a/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx b/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx
index ea7104344f75..259fa83fe494 100644
--- a/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx
+++ b/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx
@@ -43,9 +43,19 @@ TextCharacterSpacingPopup::~TextCharacterSpacingPopup()
{
}
-VclPtr<vcl::Window> TextCharacterSpacingPopup::createPopupWindow(vcl::Window* pParent)
+std::unique_ptr<WeldToolbarPopup> TextCharacterSpacingPopup::weldPopupWindow()
{
- return VclPtr<TextCharacterSpacingControl>::Create(this, pParent);
+ return std::make_unique<TextCharacterSpacingControl>(this, m_pToolbar);
+}
+
+VclPtr<vcl::Window> TextCharacterSpacingPopup::createPopupWindow( vcl::Window* pParent )
+{
+ mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
+ std::make_unique<TextCharacterSpacingControl>(this, pParent->GetFrameWeld()));
+
+ mxInterimPopover->Show();
+
+ return mxInterimPopover;
}
OUString TextCharacterSpacingPopup::getImplementationName()