From d2f1cd004310b9ea6654d17fddc11cb08e884c90 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 26 Jun 2020 20:57:29 +0100 Subject: weld EditControl for browsebox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8f21c12f7ee10e1b9ba883a8ff01bb5252429f09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97353 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- svtools/UIConfig_svt.mk | 1 + svtools/source/brwbox/ebbcontrols.cxx | 77 ++++++++++++++++++--------------- svtools/source/brwbox/editbrowsebox.cxx | 19 +++----- svtools/uiconfig/ui/thineditcontrol.ui | 27 ++++++++++++ 4 files changed, 75 insertions(+), 49 deletions(-) create mode 100644 svtools/uiconfig/ui/thineditcontrol.ui (limited to 'svtools') diff --git a/svtools/UIConfig_svt.mk b/svtools/UIConfig_svt.mk index 4c2a7cfd0703..23a9e7df778c 100644 --- a/svtools/UIConfig_svt.mk +++ b/svtools/UIConfig_svt.mk @@ -29,6 +29,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svt,\ svtools/uiconfig/ui/querydeletedialog \ svtools/uiconfig/ui/restartdialog \ svtools/uiconfig/ui/spinfieldcontrol \ + svtools/uiconfig/ui/thineditcontrol \ )) # vim: set noet sw=4 ts=4: diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx index df5eb4d4b2d8..c2534dc9efd4 100644 --- a/svtools/source/brwbox/ebbcontrols.cxx +++ b/svtools/source/brwbox/ebbcontrols.cxx @@ -93,12 +93,12 @@ namespace svt } } - bool ComboBoxCellController::IsModified() const + bool ComboBoxCellController::IsValueChangedFromSaved() const { return GetComboBox().get_value_changed_from_saved(); } - void ComboBoxCellController::ClearModified() + void ComboBoxCellController::SaveValue() { GetComboBox().save_value(); } @@ -149,12 +149,12 @@ namespace svt } } - bool ListBoxCellController::IsModified() const + bool ListBoxCellController::IsValueChangedFromSaved() const { return GetListBox().get_value_changed_from_saved(); } - void ListBoxCellController::ClearModified() + void ListBoxCellController::SaveValue() { GetListBox().save_value(); } @@ -285,19 +285,16 @@ namespace svt return static_cast(GetWindow()).GetBox(); } - - bool CheckBoxCellController::IsModified() const + bool CheckBoxCellController::IsValueChangedFromSaved() const { return GetCheckBox().IsValueChangedFromSaved(); } - - void CheckBoxCellController::ClearModified() + void CheckBoxCellController::SaveValue() { GetCheckBox().SaveValue(); } - IMPL_LINK_NOARG(CheckBoxCellController, ModifyHdl, LinkParamNone*, void) { callModifyHdl(); @@ -328,8 +325,6 @@ namespace svt } //= EditCellController - - EditCellController::EditCellController( Edit* _pEdit ) :CellController( _pEdit ) ,m_pEditImplementation( new EditImplementation( *_pEdit ) ) @@ -338,7 +333,6 @@ namespace svt m_pEditImplementation->SetModifyHdl( LINK(this, EditCellController, ModifyHdl) ); } - EditCellController::EditCellController( IEditImplementation* _pImplementation ) :CellController( &_pImplementation->GetControl() ) ,m_pEditImplementation( _pImplementation ) @@ -347,25 +341,48 @@ namespace svt m_pEditImplementation->SetModifyHdl( LINK(this, EditCellController, ModifyHdl) ); } + IMPL_LINK_NOARG(EntryImplementation, ModifyHdl, weld::Entry&, void) + { + m_aModifyHdl.Call(nullptr); + } - EditCellController::~EditCellController( ) + EditControl::EditControl(vcl::Window* pParent) + : InterimItemWindow(pParent, "svt/ui/thineditcontrol.ui", "EditControl") // *thin*editcontrol has no frame/border + , m_xWidget(m_xBuilder->weld_entry("entry")) { - if ( m_bOwnImplementation ) - DELETEZ( m_pEditImplementation ); + m_xWidget->set_width_chars(1); // so a smaller than default width can be used + m_xWidget->connect_key_press(LINK(this, EditControl, KeyInputHdl)); } + IMPL_LINK(EditControl, KeyInputHdl, const KeyEvent&, rKEvt, bool) + { + return ChildKeyInput(rKEvt); + } - void EditCellController::SetModified() + void EditControl::dispose() { - m_pEditImplementation->SetModified(); + m_xWidget.reset(); + InterimItemWindow::dispose(); } + EditCellController::EditCellController(EditControl* pEdit) + : CellController(pEdit) + , m_pEditImplementation(new EntryImplementation(*pEdit)) + , m_bOwnImplementation(true) + { + m_pEditImplementation->SetModifyHdl( LINK(this, EditCellController, ModifyHdl) ); + } - void EditCellController::ClearModified() + EditCellController::~EditCellController( ) { - m_pEditImplementation->ClearModified(); + if ( m_bOwnImplementation ) + DELETEZ( m_pEditImplementation ); } + void EditCellController::SaveValue() + { + m_pEditImplementation->SaveValue(); + } bool EditCellController::MoveAllowed(const KeyEvent& rEvt) const { @@ -390,13 +407,11 @@ namespace svt return bResult; } - - bool EditCellController::IsModified() const + bool EditCellController::IsValueChangedFromSaved() const { - return m_pEditImplementation->IsModified(); + return m_pEditImplementation->IsValueChangedFromSaved(); } - IMPL_LINK_NOARG(EditCellController, ModifyHdl, LinkParamNone*, void) { callModifyHdl(); @@ -421,18 +436,11 @@ namespace svt return static_cast(GetWindow()); } - void SpinCellController::SetModified() - { - GetSpinWindow().SetModifyFlag(); - } - - - void SpinCellController::ClearModified() + void SpinCellController::SaveValue() { - GetSpinWindow().ClearModifyFlag(); + GetSpinWindow().SaveValue(); } - bool SpinCellController::MoveAllowed(const KeyEvent& rEvt) const { bool bResult; @@ -456,10 +464,9 @@ namespace svt return bResult; } - - bool SpinCellController::IsModified() const + bool SpinCellController::IsValueChangedFromSaved() const { - return GetSpinWindow().IsModified(); + return GetSpinWindow().IsValueChangedFromSaved(); } IMPL_LINK_NOARG(SpinCellController, ModifyHdl, Edit&, void) diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx index 9b56e56c0afa..1db43ea8c40f 100644 --- a/svtools/source/brwbox/editbrowsebox.cxx +++ b/svtools/source/brwbox/editbrowsebox.cxx @@ -434,7 +434,7 @@ namespace svt if (rEvt.GetColumnId() == HandleColumnId) { // it was the handle column. save the current cell content if necessary // (clicking on the handle column results in selecting the current row) - if (IsEditing() && aController->IsModified()) + if (IsEditing() && aController->IsValueChangedFromSaved()) SaveModified(); } @@ -578,7 +578,7 @@ namespace svt case KEY_RETURN: // save the cell content (if necessary) - if (IsEditing() && aController->IsModified() && !SaveModified()) + if (IsEditing() && aController->IsValueChangedFromSaved() && !SaveModified()) { // maybe we're not visible ... EnableAndShow(); @@ -639,7 +639,7 @@ namespace svt if (nId == BROWSER_SELECT || BROWSER_SELECTCOLUMN == nId ) { // save the cell content (if necessary) - if (IsEditing() && aController->IsModified() && !SaveModified()) + if (IsEditing() && aController->IsValueChangedFromSaved() && !SaveModified()) { // maybe we're not visible ... EnableAndShow(); @@ -813,7 +813,7 @@ namespace svt return true; // save the cell content - if (IsEditing() && aController->IsModified() && !const_cast(this)->SaveModified()) + if (IsEditing() && aController->IsValueChangedFromSaved() && !const_cast(this)->SaveModified()) { // maybe we're not visible ... EnableAndShow(); @@ -958,7 +958,7 @@ namespace svt InitController(aController, nEditRow, nEditCol); - aController->ClearModified(); + aController->SaveValue(); aController->SetModifyHdl(LINK(this,EditBrowseBox,ModifyHdl)); EnableAndShow(); @@ -1278,7 +1278,6 @@ namespace svt } } - void CellController::resume( ) { DBG_ASSERT( bSuspended == !GetWindow().IsVisible(), "CellController::resume: inconsistence!" ); @@ -1290,24 +1289,16 @@ namespace svt } } - void CellController::CommitModifications() { // nothing to do in this base class } - bool CellController::WantMouseEvent() const { return false; } - - void CellController::SetModified() - { - } - - bool CellController::MoveAllowed(const KeyEvent&) const { return true; diff --git a/svtools/uiconfig/ui/thineditcontrol.ui b/svtools/uiconfig/ui/thineditcontrol.ui new file mode 100644 index 000000000000..a30e8db01435 --- /dev/null +++ b/svtools/uiconfig/ui/thineditcontrol.ui @@ -0,0 +1,27 @@ + + + + + + True + False + True + 6 + + + True + True + True + True + False + True + 1 + + + False + True + 0 + + + + -- cgit