diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-09 20:46:52 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-10 15:20:40 +0100 |
commit | 48a307b69713a244e747b3a4d444d6793d59b8d9 (patch) | |
tree | ea67c623b2e4dc156be2bd8a558e367ab8ad354b /svx | |
parent | abfdfe6ac1bfc917d1693874f9dec80167e0806f (diff) |
weld SvxFmAbsRecWin item window
Change-Id: I6a11d8ba226b28447e2ab04925090491d6953132
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88348
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/source/form/tbxform.cxx | 66 | ||||
-rw-r--r-- | svx/source/inc/tbxform.hxx | 22 | ||||
-rw-r--r-- | svx/source/sidebar/paragraph/ParaSpacingWindow.cxx | 20 | ||||
-rw-r--r-- | svx/source/tbxctrls/grafctrl.cxx | 8 | ||||
-rw-r--r-- | svx/source/tbxctrls/itemwin.cxx | 4 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunocontroller.cxx | 4 | ||||
-rw-r--r-- | svx/uiconfig/ui/absrecbox.ui | 24 |
8 files changed, 105 insertions, 44 deletions
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index 48f8b24c3e09..e7d478800185 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -10,6 +10,7 @@ $(eval $(call gb_UIConfig_UIConfig,svx)) $(eval $(call gb_UIConfig_add_uifiles,svx,\ + svx/uiconfig/ui/absrecbox \ svx/uiconfig/ui/acceptrejectchangesdialog \ svx/uiconfig/ui/accessibilitycheckdialog \ svx/uiconfig/ui/accessibilitycheckentry \ diff --git a/svx/source/form/tbxform.cxx b/svx/source/form/tbxform.cxx index 94e00643b897..1bd90475e1cb 100644 --- a/svx/source/form/tbxform.cxx +++ b/svx/source/form/tbxform.cxx @@ -39,30 +39,44 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; -SvxFmAbsRecWin::SvxFmAbsRecWin( vcl::Window* _pParent, SfxToolBoxControl* _pController ) - :NumericField( _pParent, WB_BORDER ) - ,m_pController(_pController) +SvxFmAbsRecWin::SvxFmAbsRecWin(vcl::Window* pParent, SfxToolBoxControl* pController) + : InterimItemWindow(pParent, "svx/ui/absrecbox.ui", "AbsRecBox") + , m_xWidget(m_xBuilder->weld_entry("entry")) + , m_pController(pController) { - SetMin(1); - SetFirst(1); - SetSpinSize(1); - SetSizePixel( Size(70,19) ); + m_xWidget->connect_key_press(LINK(this, SvxFmAbsRecWin, KeyInputHdl)); + m_xWidget->connect_activate(LINK(this, SvxFmAbsRecWin, ActivatedHdl)); + m_xWidget->connect_focus_out(LINK(this, SvxFmAbsRecWin, FocusOutHdl)); - SetDecimalDigits(0); - SetStrictFormat(true); + SetSizePixel(m_xWidget->get_preferred_size()); } +void SvxFmAbsRecWin::dispose() +{ + m_xWidget.reset(); + InterimItemWindow::dispose(); +} + +void SvxFmAbsRecWin::GetFocus() +{ + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); +} + +SvxFmAbsRecWin::~SvxFmAbsRecWin() +{ + disposeOnce(); +} void SvxFmAbsRecWin::FirePosition( bool _bForce ) { - if ( !_bForce && !IsValueChangedFromSaved() ) + if (!_bForce && !m_xWidget->get_value_changed_from_saved()) return; - sal_Int64 nRecord = GetValue(); - if (nRecord < GetMin() || nRecord > GetMax()) - { - return; - } + sal_Int64 nRecord = m_xWidget->get_text().toInt64(); + if (nRecord < 1) + nRecord = 1; SfxInt32Item aPositionParam( FN_PARAM_1, static_cast<sal_Int32>(nRecord) ); @@ -75,25 +89,26 @@ void SvxFmAbsRecWin::FirePosition( bool _bForce ) aArgs ); m_pController->updateStatus(); - SaveValue(); + m_xWidget->save_value(); } - -void SvxFmAbsRecWin::LoseFocus() +IMPL_LINK_NOARG(SvxFmAbsRecWin, FocusOutHdl, weld::Widget&, void) { FirePosition( false ); } +IMPL_LINK(SvxFmAbsRecWin, KeyInputHdl, const KeyEvent&, rKEvt, bool) +{ + return ChildKeyInput(rKEvt); +} -void SvxFmAbsRecWin::KeyInput( const KeyEvent& rKeyEvent ) +IMPL_LINK_NOARG(SvxFmAbsRecWin, ActivatedHdl, weld::Entry&, bool) { - if( rKeyEvent.GetKeyCode() == KEY_RETURN && !GetText().isEmpty() ) + if (!m_xWidget->get_text().isEmpty()) FirePosition( true ); - else - NumericField::KeyInput( rKeyEvent ); + return true; } - SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlAbsRec, SfxInt32Item ); SvxFmTbxCtlAbsRec::SvxFmTbxCtlAbsRec( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) @@ -106,7 +121,6 @@ SvxFmTbxCtlAbsRec::~SvxFmTbxCtlAbsRec() { } - void SvxFmTbxCtlAbsRec::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) { sal_uInt16 nId = GetId(); @@ -119,12 +133,12 @@ void SvxFmTbxCtlAbsRec::StateChanged( sal_uInt16 nSID, SfxItemState eState, cons { const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >( pState ); DBG_ASSERT( pItem, "SvxFmTbxCtlAbsRec::StateChanged: invalid item!" ); - pWin->SetValue( pItem ? pItem->GetValue() : -1 ); + pWin->set_text(OUString::number(pItem ? pItem->GetValue() : -1)); } bool bEnable = SfxItemState::DISABLED != eState && pState; if (!bEnable) - pWin->SetText(OUString()); + pWin->set_text(OUString()); // enabling/disabling of the window diff --git a/svx/source/inc/tbxform.hxx b/svx/source/inc/tbxform.hxx index f436a91b2275..0d80e6e72480 100644 --- a/svx/source/inc/tbxform.hxx +++ b/svx/source/inc/tbxform.hxx @@ -20,25 +20,31 @@ #define INCLUDED_SVX_SOURCE_INC_TBXFORM_HXX #include <sfx2/tbxctrl.hxx> -#include <vcl/field.hxx> +#include <sfx2/InterimItemWindow.hxx> -class SvxFmAbsRecWin final : public NumericField +class SvxFmAbsRecWin final : public InterimItemWindow { public: SvxFmAbsRecWin( vcl::Window* _pParent, SfxToolBoxControl* _pController ); + virtual void dispose() override; + virtual ~SvxFmAbsRecWin() override; - virtual void KeyInput( const KeyEvent& rKeyEvt ) override; - virtual void LoseFocus() override; + void set_text(const OUString& rText) { m_xWidget->set_text(rText); } + + virtual void GetFocus() override; private: + std::unique_ptr<weld::Entry> m_xWidget; + + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ActivatedHdl, weld::Entry&, bool); + DECL_LINK(FocusOutHdl, weld::Widget&, void); // for invalidating our content when losing the focus + void FirePosition( bool _bForce ); SfxToolBoxControl* m_pController; - // for invalidating our content when losing the focus }; - -class FixedText; class SvxFmTbxCtlAbsRec : public SfxToolBoxControl { public: @@ -53,7 +59,6 @@ public: const SfxPoolItem* pState ) override; }; - class SvxFmTbxCtlRecText : public SfxToolBoxControl { public: @@ -65,7 +70,6 @@ public: virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window* pParent ) override; }; - class SvxFmTbxCtlRecFromText : public SfxToolBoxControl { public: diff --git a/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx b/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx index 05fdfe721fec..e29cb7e177da 100644 --- a/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx +++ b/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx @@ -118,7 +118,9 @@ ParaAboveSpacingWindow::ParaAboveSpacingWindow(vcl::Window* pParent) void ParaAboveSpacingWindow::GetFocus() { - m_xAboveSpacing->grab_focus(); + if (m_xAboveSpacing) + m_xAboveSpacing->grab_focus(); + ParaULSpacingWindow::GetFocus(); } // ParaBelowSpacingWindow @@ -134,7 +136,9 @@ ParaBelowSpacingWindow::ParaBelowSpacingWindow(vcl::Window* pParent) void ParaBelowSpacingWindow::GetFocus() { - m_xBelowSpacing->grab_focus(); + if (m_xBelowSpacing) + m_xBelowSpacing->grab_focus(); + ParaULSpacingWindow::GetFocus(); } // ParaLRSpacingWindow @@ -319,7 +323,9 @@ ParaLeftSpacingWindow::ParaLeftSpacingWindow(vcl::Window* pParent) void ParaLeftSpacingWindow::GetFocus() { - m_xBeforeSpacing->grab_focus(); + if (m_xBeforeSpacing) + m_xBeforeSpacing->grab_focus(); + ParaLRSpacingWindow::GetFocus(); } // ParaRightSpacingWindow @@ -336,7 +342,9 @@ ParaRightSpacingWindow::ParaRightSpacingWindow(vcl::Window* pParent) void ParaRightSpacingWindow::GetFocus() { - m_xAfterSpacing->grab_focus(); + if (m_xAfterSpacing) + m_xAfterSpacing->grab_focus(); + ParaLRSpacingWindow::GetFocus(); } // ParaFirstLineSpacingWindow @@ -353,7 +361,9 @@ ParaFirstLineSpacingWindow::ParaFirstLineSpacingWindow(vcl::Window* pParent) void ParaFirstLineSpacingWindow::GetFocus() { - m_xFLSpacing->grab_focus(); + if (m_xFLSpacing) + m_xFLSpacing->grab_focus(); + ParaLRSpacingWindow::GetFocus(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx index 0fcf01de5d32..bc9246689547 100644 --- a/svx/source/tbxctrls/grafctrl.cxx +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -264,7 +264,9 @@ void ImplGrafControl::dispose() void ImplGrafControl::GetFocus() { - mxField->grab_focus(); + if (mxField) + mxField->grab_focus(); + InterimItemWindow::GetFocus(); } namespace { @@ -289,7 +291,9 @@ public: virtual void GetFocus() override { - m_xWidget->grab_focus(); + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); } void set_sensitive(bool bSensitive) diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx index 4be04c13f882..52f28c91cb4d 100644 --- a/svx/source/tbxctrls/itemwin.cxx +++ b/svx/source/tbxctrls/itemwin.cxx @@ -180,7 +180,9 @@ void SvxMetricField::DataChanged( const DataChangedEvent& rDCEvt ) void SvxMetricField::GetFocus() { - m_xWidget->grab_focus(); + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); } SvxFillTypeBox::SvxFillTypeBox( vcl::Window* pParent ) : diff --git a/svx/source/tbxctrls/tbunocontroller.cxx b/svx/source/tbxctrls/tbunocontroller.cxx index 81c4b8e7bd73..f03a9b36848d 100644 --- a/svx/source/tbxctrls/tbunocontroller.cxx +++ b/svx/source/tbxctrls/tbunocontroller.cxx @@ -157,7 +157,9 @@ SvxFontSizeBox_Impl::~SvxFontSizeBox_Impl() void SvxFontSizeBox_Impl::GetFocus() { - m_xWidget->grab_focus(); + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); } void SvxFontSizeBox_Impl::ReleaseFocus_Impl() diff --git a/svx/uiconfig/ui/absrecbox.ui b/svx/uiconfig/ui/absrecbox.ui new file mode 100644 index 000000000000..f61f75509ecc --- /dev/null +++ b/svx/uiconfig/ui/absrecbox.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface domain="svx"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkBox" id="AbsRecBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="spacing">4</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="width_chars">4</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface> |