diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-07-25 12:52:30 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-07-27 20:13:41 +0200 |
commit | 32f0a170c941522d0b7c0594aa4627a84a0d1b38 (patch) | |
tree | 94f85b7cba784546bfc1feaabb81a53c195f76c0 /svtools | |
parent | fe019b702cfe2af24c35f40db340a82892feb69c (diff) |
weld NavigationBar
Change-Id: I5d31d603a9e5f91723a310900aeee875df1599c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99445
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/brwbox/brwbox1.cxx | 50 | ||||
-rw-r--r-- | svtools/source/brwbox/brwbox2.cxx | 11 | ||||
-rw-r--r-- | svtools/source/brwbox/recorditemwindow.cxx | 42 |
3 files changed, 77 insertions, 26 deletions
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx index eb185380af8a..943e888385e8 100644 --- a/svtools/source/brwbox/brwbox1.cxx +++ b/svtools/source/brwbox/brwbox1.cxx @@ -27,6 +27,7 @@ #include <tools/fract.hxx> #include <sal/log.hxx> #include <vcl/scrbar.hxx> +#include <vcl/svapp.hxx> #include <algorithm> #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp> @@ -105,12 +106,59 @@ void BrowseBox::ConstructImpl( BrowserMode nMode ) ( bHasFocus ? 0 : 1 ) + ( GetUpdateMode() ? 0 : 1 ); } +// we're just measuring the "real" NavigationBar +class MeasureStatusBar final : public InterimItemWindow +{ +private: + std::unique_ptr<weld::Label> m_xRecordText; + std::unique_ptr<weld::Entry> m_xAbsolute; + std::unique_ptr<weld::Label> m_xRecordOf; + std::unique_ptr<weld::Label> m_xRecordCount; +public: + MeasureStatusBar(vcl::Window *pParent) + : InterimItemWindow(pParent, "svx/ui/navigationbar.ui", "NavigationBar") + , m_xRecordText(m_xBuilder->weld_label("recordtext")) + , m_xAbsolute(m_xBuilder->weld_entry("entry-noframe")) + , m_xRecordOf(m_xBuilder->weld_label("recordof")) + , m_xRecordCount(m_xBuilder->weld_label("recordcount")) + { + vcl::Font aApplFont(Application::GetSettings().GetStyleSettings().GetToolFont()); + m_xAbsolute->set_font(aApplFont); + m_xRecordText->set_font(aApplFont); + m_xRecordOf->set_font(aApplFont); + m_xRecordCount->set_font(aApplFont); + + SetSizePixel(get_preferred_size()); + } + + virtual void dispose() override + { + m_xRecordCount.reset(); + m_xRecordOf.reset(); + m_xAbsolute.reset(); + m_xRecordText.reset(); + InterimItemWindow::dispose(); + } +}; + +long BrowseBox::GetBarHeight() const +{ + // tdf#115941 because some platforms have things like overlay scrollbars, take a max + // of a statusbar height and a scrollbar height as the control area height + + // (we can't ask the scrollbars for their size cause if we're zoomed they still have to be + // resized - which is done in UpdateScrollbars) + + return std::max(aStatusBarHeight->GetSizePixel().Height(), GetSettings().GetStyleSettings().GetScrollBarSize()); +} + BrowseBox::BrowseBox( vcl::Window* pParent, WinBits nBits, BrowserMode nMode ) :Control( pParent, nBits | WB_3DLOOK ) ,DragSourceHelper( this ) ,DropTargetHelper( this ) ,aHScroll( VclPtr<ScrollBar>::Create(this, WB_HSCROLL) ) - ,aStatusBarHeight(VclPtr<RecordItemWindow>::Create(this, false)) + // see NavigationBar ctor, here we just want to know its height + ,aStatusBarHeight(VclPtr<MeasureStatusBar>::Create(this)) { ConstructImpl( nMode ); } diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx index 5abdf5e34099..298a61a31c80 100644 --- a/svtools/source/brwbox/brwbox2.cxx +++ b/svtools/source/brwbox/brwbox2.cxx @@ -1029,17 +1029,6 @@ void BrowseBox::PaintData( vcl::Window const & rWin, vcl::RenderContext& rRender ImplPaintData(rRenderContext, rRect, false); } -long BrowseBox::GetBarHeight() const -{ - // tdf#115941 because some platforms have things like overlay scrollbars, take a max - // of a statusbar height and a scrollbar height as the control area height - - // (we can't ask the scrollbars for their size cause if we're zoomed they still have to be - // resized - which is done in UpdateScrollbars) - - return std::max(aStatusBarHeight->GetSizePixel().Height(), GetSettings().GetStyleSettings().GetScrollBarSize()); -} - void BrowseBox::UpdateScrollbars() { diff --git a/svtools/source/brwbox/recorditemwindow.cxx b/svtools/source/brwbox/recorditemwindow.cxx index a993044cb6de..6898f9febbd7 100644 --- a/svtools/source/brwbox/recorditemwindow.cxx +++ b/svtools/source/brwbox/recorditemwindow.cxx @@ -20,18 +20,24 @@ #include <svtools/recorditemwindow.hxx> #include <vcl/event.hxx> +RecordItemWindowBase::RecordItemWindowBase(std::unique_ptr<weld::Entry> xEntry) + : m_xWidget(std::move(xEntry)) +{ + m_xWidget->connect_key_press(LINK(this, RecordItemWindowBase, KeyInputHdl)); + m_xWidget->connect_activate(LINK(this, RecordItemWindowBase, ActivatedHdl)); + m_xWidget->connect_focus_out(LINK(this, RecordItemWindowBase, FocusOutHdl)); + + m_xWidget->show(); +} + +RecordItemWindowBase::~RecordItemWindowBase() {} + RecordItemWindow::RecordItemWindow(vcl::Window* pParent, bool bHasFrame) : InterimItemWindow(pParent, "svx/ui/absrecbox.ui", "AbsRecBox") - , m_xWidget(m_xBuilder->weld_entry(bHasFrame ? "entry-frame" : "entry-noframe")) + , RecordItemWindowBase(m_xBuilder->weld_entry(bHasFrame ? "entry-frame" : "entry-noframe")) { InitControlBase(m_xWidget.get()); - m_xWidget->connect_key_press(LINK(this, RecordItemWindow, KeyInputHdl)); - m_xWidget->connect_activate(LINK(this, RecordItemWindow, ActivatedHdl)); - m_xWidget->connect_focus_out(LINK(this, RecordItemWindow, FocusOutHdl)); - - m_xWidget->show(); - auto aPrefSize(m_xWidget->get_preferred_size()); m_xWidget->set_width_chars(1); // so a smaller than default width can be used later @@ -47,7 +53,7 @@ void RecordItemWindow::dispose() RecordItemWindow::~RecordItemWindow() { disposeOnce(); } -void RecordItemWindow::FirePosition(bool _bForce) +void RecordItemWindowBase::FirePosition(bool _bForce) { if (!_bForce && !m_xWidget->get_value_changed_from_saved()) return; @@ -61,9 +67,9 @@ void RecordItemWindow::FirePosition(bool _bForce) m_xWidget->save_value(); } -IMPL_LINK_NOARG(RecordItemWindow, FocusOutHdl, weld::Widget&, void) { FirePosition(false); } +IMPL_LINK_NOARG(RecordItemWindowBase, FocusOutHdl, weld::Widget&, void) { FirePosition(false); } -bool RecordItemWindow::DoKeyInput(const KeyEvent& rKEvt) +bool RecordItemWindowBase::DoKeyInput(const KeyEvent& rKEvt) { vcl::KeyCode aCode = rKEvt.GetKeyCode(); bool bUp = (aCode.GetCode() == KEY_UP); @@ -82,14 +88,22 @@ bool RecordItemWindow::DoKeyInput(const KeyEvent& rKEvt) return true; } - return ChildKeyInput(rKEvt); + return false; +} + +bool RecordItemWindow::DoKeyInput(const KeyEvent& rKEvt) +{ + return RecordItemWindowBase::DoKeyInput(rKEvt) || ChildKeyInput(rKEvt); } -void RecordItemWindow::PositionFired(sal_Int64 /*nRecord*/) {} +void RecordItemWindowBase::PositionFired(sal_Int64 /*nRecord*/) {} -IMPL_LINK(RecordItemWindow, KeyInputHdl, const KeyEvent&, rKEvt, bool) { return DoKeyInput(rKEvt); } +IMPL_LINK(RecordItemWindowBase, KeyInputHdl, const KeyEvent&, rKEvt, bool) +{ + return DoKeyInput(rKEvt); +} -IMPL_LINK_NOARG(RecordItemWindow, ActivatedHdl, weld::Entry&, bool) +IMPL_LINK_NOARG(RecordItemWindowBase, ActivatedHdl, weld::Entry&, bool) { if (!m_xWidget->get_text().isEmpty()) FirePosition(true); |