summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-07-01 17:00:44 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-07-02 20:22:05 +0200
commita751d9c414fc63f36ae4b54b8adbaba042b31f60 (patch)
tree14b16f3580b140e0e45da81bb93712ff321b6218 /vcl/source
parent4582ac7de8291a81c867492aad770206fbaca224 (diff)
weld FormattedControl
by using the newly split out Formatter to do the number formatting but input/output to/from a weld::Entry Change-Id: Ic9e619dc5d1ed2fae87e2d89a40dc51f3881468f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97660 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/app/weldutils.cxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx
index 20372a7b14b1..9cb6dfd53296 100644
--- a/vcl/source/app/weldutils.cxx
+++ b/vcl/source/app/weldutils.cxx
@@ -124,6 +124,44 @@ void RemoveParentKeepChildren(weld::TreeView& rTreeView, weld::TreeIter& rParent
}
rTreeView.remove(rParent);
}
+
+FormattedEntry::FormattedEntry(std::unique_ptr<weld::Entry> xEntry)
+ : m_xEntry(std::move(xEntry))
+ , m_eOptions(Application::GetSettings().GetStyleSettings().GetSelectionOptions())
+{
+ m_xEntry->connect_changed(LINK(this, FormattedEntry, ModifyHdl));
+ m_xEntry->connect_focus_out(LINK(this, FormattedEntry, FocusOutHdl));
+}
+
+Selection FormattedEntry::GetEntrySelection() const
+{
+ int nStartPos, nEndPos;
+ m_xEntry->get_selection_bounds(nStartPos, nEndPos);
+ return Selection(nStartPos, nEndPos);
+}
+
+OUString FormattedEntry::GetEntryText() const { return m_xEntry->get_text(); }
+
+void FormattedEntry::SetEntryText(const OUString& rText, const Selection& rSel)
+{
+ m_xEntry->set_text(rText);
+ auto nMin = rSel.Min();
+ auto nMax = rSel.Max();
+ m_xEntry->select_region(nMin < 0 ? 0 : nMin, nMax == SELECTION_MAX ? -1 : nMax);
+}
+
+void FormattedEntry::SetEntryTextColor(const Color* pColor)
+{
+ m_xEntry->set_font_color(pColor ? *pColor : COL_AUTO);
+}
+
+SelectionOptions FormattedEntry::GetEntrySelectionOptions() const { return m_eOptions; }
+
+void FormattedEntry::FieldModified() { m_aModifyHdl.Call(*m_xEntry); }
+
+IMPL_LINK_NOARG(FormattedEntry, ModifyHdl, weld::Entry&, void) { impl_Modify(); }
+
+IMPL_LINK_NOARG(FormattedEntry, FocusOutHdl, weld::Widget&, void) { EntryLostFocus(); }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */