From 25507f1dc5dada133dc915a2991c40843edbcf78 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 14 Feb 2020 09:12:54 +0000 Subject: weld NavElementBox_Impl Item Window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I72a7cc6d60cb4149838933c3c57982ebefea458d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88677 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- svx/source/tbxctrls/tbunosearchcontrollers.cxx | 10 ++- sw/UIConfig_swriter.mk | 1 + sw/inc/pch/precompiled_msword.hxx | 13 ++- sw/inc/pch/precompiled_sw.hxx | 11 +-- sw/inc/pch/precompiled_vbaswobj.hxx | 6 +- sw/source/uibase/ribbar/workctrl.cxx | 111 ++++++++++++++----------- sw/uiconfig/swriter/ui/combobox.ui | 52 ++++++++++++ vcl/source/window/toolbox2.cxx | 2 - 8 files changed, 135 insertions(+), 71 deletions(-) create mode 100644 sw/uiconfig/swriter/ui/combobox.ui diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index ec8f23b7f8f0..43c1d7ec456c 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -106,7 +106,9 @@ public: virtual void GetFocus() override { - m_xWidget->grab_focus(); + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); } private: @@ -396,9 +398,9 @@ void FindTextFieldControl::set_entry_message_type(weld::EntryMessageType eType) void FindTextFieldControl::GetFocus() { - if (!m_xWidget) - return; - m_xWidget->grab_focus(); + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); } namespace { diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index a1f97fcd7c00..d94a854e1efd 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -114,6 +114,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ sw/uiconfig/swriter/ui/columndialog \ sw/uiconfig/swriter/ui/columnpage \ sw/uiconfig/swriter/ui/columnwidth \ + sw/uiconfig/swriter/ui/combobox \ sw/uiconfig/swriter/ui/comboboxfragment \ sw/uiconfig/swriter/ui/conditionpage \ sw/uiconfig/swriter/ui/converttexttable \ diff --git a/sw/inc/pch/precompiled_msword.hxx b/sw/inc/pch/precompiled_msword.hxx index dfcc3948e15f..0eff00865266 100644 --- a/sw/inc/pch/precompiled_msword.hxx +++ b/sw/inc/pch/precompiled_msword.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2020-01-22 15:58:37 using: + Generated on 2020-02-14 09:24:02 using: ./bin/update_pch sw msword --cutoff=4 --exclude:system --include:module --include:local If after updating build fails, use the following command to locate conflicting headers: @@ -128,6 +128,7 @@ #include #include #include +#include #include #include #include @@ -181,12 +182,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -220,6 +221,7 @@ #include #include #include +#include #include #include #include @@ -227,6 +229,7 @@ #include #include #include +#include #include #include #include @@ -343,7 +346,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -485,6 +489,9 @@ #include #include #include +#include +#include +#include #endif // PCH_LEVEL >= 3 #if PCH_LEVEL >= 4 #include diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx index 9784c56086a0..ff6d99eaff68 100644 --- a/sw/inc/pch/precompiled_sw.hxx +++ b/sw/inc/pch/precompiled_sw.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2020-02-13 21:38:09 using: + Generated on 2020-02-14 09:24:22 using: ./bin/update_pch sw sw --cutoff=7 --exclude:system --exclude:module --include:local If after updating build fails, use the following command to locate conflicting headers: @@ -68,9 +68,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -93,9 +90,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -109,18 +104,14 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include -#include #include -#include #include #include #include diff --git a/sw/inc/pch/precompiled_vbaswobj.hxx b/sw/inc/pch/precompiled_vbaswobj.hxx index 3414f6daee68..b19ca8c76888 100644 --- a/sw/inc/pch/precompiled_vbaswobj.hxx +++ b/sw/inc/pch/precompiled_vbaswobj.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2020-02-01 10:59:00 using: + Generated on 2020-02-14 09:24:51 using: ./bin/update_pch sw vbaswobj --cutoff=4 --exclude:system --include:module --include:local If after updating build fails, use the following command to locate conflicting headers: @@ -193,7 +193,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -252,7 +254,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx index 74f1d2d12760..08df1397b935 100644 --- a/sw/source/uibase/ribbar/workctrl.cxx +++ b/sw/source/uibase/ribbar/workctrl.cxx @@ -36,8 +36,6 @@ #include #include #include -#include -#include #include #include #include @@ -605,25 +603,42 @@ class NavElementToolBoxControl : public svt::ToolboxController, VclPtr m_pBox; }; -class NavElementBox_Impl : public ListBox +class NavElementBox_Impl final : public InterimItemWindow { public: - NavElementBox_Impl( vcl::Window* pParent, - const uno::Reference< frame::XFrame >& _xFrame, - NavElementToolBoxControl& rCtrl ); + NavElementBox_Impl(vcl::Window* pParent, + const uno::Reference& _xFrame, + NavElementToolBoxControl& rCtrl); - void Update(); + virtual void dispose() override + { + m_xWidget.reset(); + InterimItemWindow::dispose(); + } - virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void GetFocus() override + { + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); + } + + virtual ~NavElementBox_Impl() override + { + disposeOnce(); + } -protected: - virtual void Select() override; + void Update(); private: + std::unique_ptr m_xWidget; NavElementToolBoxControl* m_pCtrl; bool m_bRelease; uno::Reference< frame::XFrame > m_xFrame; + DECL_LINK(SelectHdl, weld::ComboBox&, void); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + void ReleaseFocus_Impl(); }; @@ -632,19 +647,21 @@ private: NavElementBox_Impl::NavElementBox_Impl( vcl::Window* _pParent, const uno::Reference< frame::XFrame >& _xFrame, - NavElementToolBoxControl& _rCtrl ) : - - ListBox( _pParent, WinBits( WB_DROPDOWN ) ), - - m_pCtrl ( &_rCtrl ), - m_bRelease ( true ), - m_xFrame ( _xFrame ) + NavElementToolBoxControl& _rCtrl ) + : InterimItemWindow(_pParent, "modules/swriter/ui/combobox.ui", "ComboBox") + , m_xWidget(m_xBuilder->weld_combo_box("combobox")) + , m_pCtrl(&_rCtrl) + , m_bRelease(true) + , m_xFrame(_xFrame) { - SetSizePixel( Size( 150, 260 ) ); + m_xWidget->set_size_request(42, -1); // set to something small so the size set at the .ui takes precedence + + for (sal_uInt16 i = 0; i < NID_COUNT; ++i) + m_xWidget->append("", SwResId(aNavigationStrIds[i]), aNavigationImgIds[i]); + m_xWidget->connect_changed(LINK(this, NavElementBox_Impl, SelectHdl)); + m_xWidget->connect_key_press(LINK(this, NavElementBox_Impl, KeyInputHdl)); - sal_uInt16 i; - for ( i = 0; i < NID_COUNT; i++ ) - InsertEntry( SwResId( aNavigationStrIds[i] ), Image( StockImage::Yes, aNavigationImgIds[i] ) ); + SetSizePixel(m_xContainer->get_preferred_size()); } void NavElementBox_Impl::ReleaseFocus_Impl() @@ -659,15 +676,13 @@ void NavElementBox_Impl::ReleaseFocus_Impl() m_xFrame->getContainerWindow()->setFocus(); } -void NavElementBox_Impl::Select() +IMPL_LINK(NavElementBox_Impl, SelectHdl, weld::ComboBox&, rComboBox, void) { - ListBox::Select(); - - if ( !IsTravelSelect() ) + if (rComboBox.changed_by_direct_pick()) // only when picked from the list { SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); - sal_uInt16 nPos = GetSelectedEntryPos(); + sal_uInt16 nPos = rComboBox.get_active(); sal_uInt16 nMoveType = aNavigationInsertIds[nPos]; SwView::SetMoveType( nMoveType ); @@ -691,43 +706,39 @@ void NavElementBox_Impl::Update() { const char* id = aNavigationStrIds[i]; OUString sText = SwResId( id ); - SelectEntry( sText ); + m_xWidget->set_active_text(sText); break; } } } -bool NavElementBox_Impl::EventNotify( NotifyEvent& rNEvt ) +IMPL_LINK(NavElementBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool) { bool bHandled = false; - if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) - { - vcl::KeyCode aKeyCode = rNEvt.GetKeyEvent()->GetKeyCode(); - sal_uInt16 nCode = aKeyCode.GetCode(); + sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); - switch ( nCode ) + switch ( nCode ) + { + case KEY_TAB: { - case KEY_TAB: - { - static_cast(GetParent())->ChangeHighlightUpDn( aKeyCode.IsShift() ); - m_bRelease = false; - [[fallthrough]]; - } - case KEY_RETURN: - { - bHandled = true; - Select(); - break; - } - case KEY_ESCAPE: - ReleaseFocus_Impl(); - bHandled = true; - break; + m_bRelease = false; + SelectHdl(*m_xWidget); + break; + } + case KEY_RETURN: + { + bHandled = true; + SelectHdl(*m_xWidget); + break; } + case KEY_ESCAPE: + ReleaseFocus_Impl(); + bHandled = true; + break; } - return bHandled || ListBox::EventNotify( rNEvt ); + return bHandled || ChildKeyInput(rKEvt); } NavElementToolBoxControl::NavElementToolBoxControl( const uno::Reference< uno::XComponentContext >& rxContext ) diff --git a/sw/uiconfig/swriter/ui/combobox.ui b/sw/uiconfig/swriter/ui/combobox.ui new file mode 100644 index 000000000000..914a33571019 --- /dev/null +++ b/sw/uiconfig/swriter/ui/combobox.ui @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + 150 + True + False + True + 6 + + + True + False + True + True + liststore4 + 0 + 1 + + + + 0 + + + + + + 2 + + + + + False + True + 0 + + + + diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 1136e35442ff..68cf9a383085 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -881,12 +881,10 @@ void ToolBox::SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits ) void ToolBox::SetItemWindowNonInteractive(sal_uInt16 nItemId, bool bNonInteractive) { - fprintf(stderr, "attempt\n"); ImplToolItems::size_type nPos = GetItemPos( nItemId ); if ( nPos < GetItemCount() ) { - fprintf(stderr, "success\n"); mpData->m_aItems[nPos].mbNonInteractiveWindow = bNonInteractive; } } -- cgit