summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-06-26 20:57:29 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-07-01 18:04:46 +0200
commitd2f1cd004310b9ea6654d17fddc11cb08e884c90 (patch)
tree2d2ad2d4afa5e2eb1c62a8e7ee1ac7bd0bf4f791 /svtools
parent96dc14a041ea803f0d194a47a8f3d62f6cfa37be (diff)
weld EditControl for browsebox
Change-Id: I8f21c12f7ee10e1b9ba883a8ff01bb5252429f09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97353 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/UIConfig_svt.mk1
-rw-r--r--svtools/source/brwbox/ebbcontrols.cxx77
-rw-r--r--svtools/source/brwbox/editbrowsebox.cxx19
-rw-r--r--svtools/uiconfig/ui/thineditcontrol.ui27
4 files changed, 75 insertions, 49 deletions
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<CheckBoxControl &>(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<SpinField &>(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<EditBrowseBox *>(this)->SaveModified())
+ if (IsEditing() && aController->IsValueChangedFromSaved() && !const_cast<EditBrowseBox *>(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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.2 -->
+<interface domain="svt">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkBox" id="EditControl">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="has_frame">False</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">1</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>