diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-05-13 09:26:18 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-05-13 15:00:08 +0200 |
commit | 562d1ba1fff07183dbae24437977e204cbc6471d (patch) | |
tree | 17a459c01400343d3a88020acfc32f7238722bf6 /extensions/source | |
parent | bc059c08d86ccdeca4f340078b0de39053bc0888 (diff) |
weld bibliography EditBox control ItemWindow
Change-Id: I17859c10714afa387f47385d2abd8b8827770038
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94099
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'extensions/source')
-rw-r--r-- | extensions/source/bibliography/toolbar.cxx | 64 | ||||
-rw-r--r-- | extensions/source/bibliography/toolbar.hxx | 30 |
2 files changed, 63 insertions, 31 deletions
diff --git a/extensions/source/bibliography/toolbar.cxx b/extensions/source/bibliography/toolbar.cxx index ccdc2476e884..d7726cbf9580 100644 --- a/extensions/source/bibliography/toolbar.cxx +++ b/extensions/source/bibliography/toolbar.cxx @@ -194,12 +194,35 @@ ComboBoxControl::~ComboBoxControl() disposeOnce(); } +EditControl::EditControl(vcl::Window* pParent) + : InterimItemWindow(pParent, "modules/sbibliography/ui/editbox.ui", "EditBox") + , m_xFtQuery(m_xBuilder->weld_label("label")) + , m_xEdQuery(m_xBuilder->weld_entry("entry")) +{ + m_xFtQuery->set_toolbar_background(); + m_xEdQuery->set_toolbar_background(); + m_xEdQuery->set_size_request(100, -1); + SetSizePixel(get_preferred_size()); +} + +void EditControl::dispose() +{ + m_xEdQuery.reset(); + m_xFtQuery.reset(); + InterimItemWindow::dispose(); +} + +EditControl::~EditControl() +{ + disposeOnce(); +} + BibToolBar::BibToolBar(vcl::Window* pParent, Link<void*,void> aLink) : ToolBox(pParent, "toolbar", "modules/sbibliography/ui/toolbar.ui") , xSource(VclPtr<ComboBoxControl>::Create(this)) , pLbSource(xSource->get_widget()) - , aFtQuery(VclPtr<FixedText>::Create(this,WB_VCENTER)) - , aEdQuery(VclPtr<Edit>::Create(this)) + , xQuery(VclPtr<EditControl>::Create(this)) + , pEdQuery(xQuery->get_widget()) , pPopupMenu(VclPtr<PopupMenu>::Create()) , nMenuId(0) , nSelMenuItem(0) @@ -223,26 +246,18 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link<void*,void> aLink) SetDropdownClickHdl( LINK( this, BibToolBar, MenuHdl)); - aEdQuery->SetSizePixel(pLbSource->get_preferred_size()); - aEdQuery->Show(); + xQuery->Show(); nTBC_SOURCE = GetItemId(".uno:Bib/source"); - nTBC_FT_QUERY = GetItemId("TBC_FT_QUERY"); - nTBC_ED_QUERY = GetItemId(".uno:Bib/query"); + nTBC_QUERY = GetItemId(".uno:Bib/query"); nTBC_BT_AUTOFILTER = GetItemId(".uno:Bib/autoFilter"); nTBC_BT_COL_ASSIGN = GetItemId("TBC_BT_COL_ASSIGN"); nTBC_BT_CHANGESOURCE = GetItemId(".uno:Bib/sdbsource"); nTBC_BT_FILTERCRIT = GetItemId(".uno:Bib/standardFilter"); nTBC_BT_REMOVEFILTER = GetItemId(".uno:Bib/removeFilter"); - OUString aStr=GetItemText(nTBC_FT_QUERY); - aFtQuery->SetText(aStr); - aFtQuery->SetSizePixel(aFtQuery->get_preferred_size()); - aFtQuery->SetBackground(Wallpaper( COL_TRANSPARENT )); - SetItemWindow(nTBC_SOURCE, xSource.get()); - SetItemWindow(nTBC_FT_QUERY , aFtQuery.get()); - SetItemWindow(nTBC_ED_QUERY , aEdQuery.get()); + SetItemWindow(nTBC_QUERY , xQuery.get()); ApplyImageList(); @@ -259,8 +274,9 @@ void BibToolBar::dispose() SvtMiscOptions().RemoveListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) ); Application::RemoveEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) ); ::bib::RemoveFromTaskPaneList( this ); - aFtQuery.disposeAndClear(); - aEdQuery.disposeAndClear(); + pEdQuery = nullptr; + xQuery.disposeAndClear(); + pLbSource = nullptr; xSource.disposeAndClear(); ToolBox::dispose(); } @@ -283,7 +299,7 @@ void BibToolBar::InitListener() for(ToolBox::ImplToolItems::size_type nPos=0;nPos<nCount;nPos++) { sal_uInt16 nId=GetItemId(nPos); - if(!nId || nId == nTBC_FT_QUERY) + if (!nId) continue; util::URL aURL; @@ -298,7 +314,7 @@ void BibToolBar::InitListener() { xListener=new BibTBListBoxListener(this,aURL.Complete,nId); } - else if (nId == nTBC_ED_QUERY) + else if (nId == nTBC_QUERY) { xListener=new BibTBEditListener(this,aURL.Complete,nId); } @@ -332,7 +348,7 @@ void BibToolBar::Select() Sequence<PropertyValue> aPropVal(2); PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray()); pPropertyVal[0].Name="QueryText"; - OUString aSelection = aEdQuery->GetText(); + OUString aSelection = pEdQuery->get_text(); pPropertyVal[0].Value <<= aSelection; pPropertyVal[1].Name="QueryField"; @@ -440,22 +456,20 @@ void BibToolBar::SelectSourceEntry(const OUString& aStr) void BibToolBar::EnableQuery(bool bFlag) { - aFtQuery->Enable(bFlag); - aEdQuery->Enable(bFlag); + xQuery->set_sensitive(bFlag); } void BibToolBar::SetQueryString(const OUString& aStr) { - aEdQuery->SetText(aStr); + pEdQuery->set_text(aStr); } - bool BibToolBar::PreNotify( NotifyEvent& rNEvt ) { bool bResult = true; MouseNotifyEvent nSwitch=rNEvt.GetType(); - if(aEdQuery->HasFocus() && nSwitch==MouseNotifyEvent::KEYINPUT) + if (pEdQuery && pEdQuery->has_focus() && nSwitch == MouseNotifyEvent::KEYINPUT) { const vcl::KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode(); sal_uInt16 nKey = aKeyCode.GetCode(); @@ -464,7 +478,7 @@ bool BibToolBar::PreNotify( NotifyEvent& rNEvt ) Sequence<PropertyValue> aPropVal(2); PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray()); pPropertyVal[0].Name = "QueryText"; - OUString aSelection = aEdQuery->GetText(); + OUString aSelection = pEdQuery->get_text(); pPropertyVal[0].Value <<= aSelection; pPropertyVal[1].Name="QueryField"; pPropertyVal[1].Value <<= aQueryField; @@ -515,7 +529,7 @@ IMPL_LINK_NOARG( BibToolBar, MenuHdl, ToolBox*, void) Sequence<PropertyValue> aPropVal(2); PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray()); pPropertyVal[0].Name = "QueryText"; - OUString aSelection = aEdQuery->GetText(); + OUString aSelection = pEdQuery->get_text(); pPropertyVal[0].Value <<= aSelection; pPropertyVal[1].Name="QueryField"; pPropertyVal[1].Value <<= aQueryField; diff --git a/extensions/source/bibliography/toolbar.hxx b/extensions/source/bibliography/toolbar.hxx index 34a4db9a867b..135b7dcb1f15 100644 --- a/extensions/source/bibliography/toolbar.hxx +++ b/extensions/source/bibliography/toolbar.hxx @@ -25,8 +25,6 @@ #include <svtools/InterimItemWindow.hxx> #include <vcl/toolbox.hxx> -#include <vcl/edit.hxx> -#include <vcl/fixed.hxx> #include <vcl/timer.hxx> #include <cppuhelper/implbase.hxx> #include <vector> @@ -118,6 +116,27 @@ private: std::unique_ptr<weld::ComboBox> m_xLBSource; }; +class EditControl final : public InterimItemWindow +{ +public: + EditControl(vcl::Window* pParent); + virtual ~EditControl() override; + virtual void dispose() override; + + weld::Entry* get_widget() { return m_xEdQuery.get(); } + + void set_sensitive(bool bSensitive) + { + m_xFtQuery->set_sensitive(bSensitive); + m_xEdQuery->set_sensitive(bSensitive); + Enable(bSensitive); + } + +private: + std::unique_ptr<weld::Label> m_xFtQuery; + std::unique_ptr<weld::Entry> m_xEdQuery; +}; + class BibToolBar: public ToolBox { private: @@ -127,8 +146,8 @@ class BibToolBar: public ToolBox Idle aIdle; VclPtr<ComboBoxControl> xSource; weld::ComboBox* pLbSource; - VclPtr<FixedText> aFtQuery; - VclPtr<Edit> aEdQuery; + VclPtr<EditControl> xQuery; + weld::Entry* pEdQuery; ScopedVclPtr<PopupMenu> pPopupMenu; sal_uInt16 nMenuId; sal_uInt16 nSelMenuItem; @@ -138,8 +157,7 @@ class BibToolBar: public ToolBox sal_Int16 nOutStyle; sal_uInt16 nTBC_SOURCE; - sal_uInt16 nTBC_FT_QUERY; - sal_uInt16 nTBC_ED_QUERY; + sal_uInt16 nTBC_QUERY; sal_uInt16 nTBC_BT_AUTOFILTER; sal_uInt16 nTBC_BT_COL_ASSIGN; sal_uInt16 nTBC_BT_CHANGESOURCE; |