diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-07-23 10:26:09 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-07-23 20:45:17 +0200 |
commit | b6311393b5a01eee500b1ebe440bce60939aaead (patch) | |
tree | 2da743b5fb32645a8b579825410ba456b4316215 /svtools | |
parent | 6afd1e3c06e476a01c25032d3d95ed7e624b58e0 (diff) |
weld AbsolutePos
Change-Id: I273d01bb5d8bf1a1d2dc9066b0c9f099bf115e32
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99311
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/source/brwbox/brwbox1.cxx | 6 | ||||
-rw-r--r-- | svtools/source/brwbox/brwbox2.cxx | 4 | ||||
-rw-r--r-- | svtools/source/brwbox/recorditemwindow.cxx | 99 |
4 files changed, 105 insertions, 5 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 63bb7e13205d..456a7ae568a0 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -74,6 +74,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/brwbox/ebbcontrols \ svtools/source/brwbox/editbrowsebox \ svtools/source/brwbox/editbrowsebox2 \ + svtools/source/brwbox/recorditemwindow \ svtools/source/config/accessibilityoptions \ svtools/source/config/apearcfg \ svtools/source/config/colorcfg \ diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx index 17392a79db0e..5bac96fc1945 100644 --- a/svtools/source/brwbox/brwbox1.cxx +++ b/svtools/source/brwbox/brwbox1.cxx @@ -19,6 +19,7 @@ #include <svtools/brwbox.hxx> #include <svtools/brwhead.hxx> +#include <svtools/recorditemwindow.hxx> #include <o3tl/numeric.hxx> #include <o3tl/safeint.hxx> #include "datwin.hxx" @@ -26,7 +27,6 @@ #include <tools/fract.hxx> #include <sal/log.hxx> #include <vcl/scrbar.hxx> -#include <vcl/status.hxx> #include <algorithm> #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp> @@ -110,7 +110,7 @@ BrowseBox::BrowseBox( vcl::Window* pParent, WinBits nBits, BrowserMode nMode ) ,DragSourceHelper( this ) ,DropTargetHelper( this ) ,aHScroll( VclPtr<ScrollBar>::Create(this, WB_HSCROLL) ) - ,aStatusBar( VclPtr<StatusBar>::Create(this) ) + ,aStatusBarHeight(VclPtr<RecordItemWindow>::Create(this, false)) { ConstructImpl( nMode ); } @@ -137,7 +137,7 @@ void BrowseBox::dispose() pDataWin.disposeAndClear(); pVScroll.disposeAndClear(); aHScroll.disposeAndClear(); - aStatusBar.disposeAndClear(); + aStatusBarHeight.disposeAndClear(); // free columns-space mvCols.clear(); diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx index 1046363849b9..5abdf5e34099 100644 --- a/svtools/source/brwbox/brwbox2.cxx +++ b/svtools/source/brwbox/brwbox2.cxx @@ -22,13 +22,13 @@ #include <osl/diagnose.h> #include <tools/debug.hxx> #include <svtools/brwbox.hxx> +#include <svtools/recorditemwindow.hxx> #include "datwin.hxx" #include <svtools/colorcfg.hxx> #include <vcl/commandevent.hxx> #include <vcl/ptrstyle.hxx> #include <vcl/scrbar.hxx> #include <vcl/settings.hxx> -#include <vcl/status.hxx> #include <tools/multisel.hxx> #include <tools/fract.hxx> @@ -1037,7 +1037,7 @@ long BrowseBox::GetBarHeight() const // (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(aStatusBar->GetSizePixel().Height(), GetSettings().GetStyleSettings().GetScrollBarSize()); + 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 new file mode 100644 index 000000000000..a993044cb6de --- /dev/null +++ b/svtools/source/brwbox/recorditemwindow.cxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <svtools/recorditemwindow.hxx> +#include <vcl/event.hxx> + +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")) +{ + 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 + + SetSizePixel(aPrefSize); +} + +void RecordItemWindow::dispose() +{ + m_xWidget.reset(); + InterimItemWindow::dispose(); +} + +RecordItemWindow::~RecordItemWindow() { disposeOnce(); } + +void RecordItemWindow::FirePosition(bool _bForce) +{ + if (!_bForce && !m_xWidget->get_value_changed_from_saved()) + return; + + sal_Int64 nRecord = m_xWidget->get_text().toInt64(); + if (nRecord < 1) + nRecord = 1; + + PositionFired(nRecord); + + m_xWidget->save_value(); +} + +IMPL_LINK_NOARG(RecordItemWindow, FocusOutHdl, weld::Widget&, void) { FirePosition(false); } + +bool RecordItemWindow::DoKeyInput(const KeyEvent& rKEvt) +{ + vcl::KeyCode aCode = rKEvt.GetKeyCode(); + bool bUp = (aCode.GetCode() == KEY_UP); + bool bDown = (aCode.GetCode() == KEY_DOWN); + + if (!aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() && (bUp || bDown)) + { + sal_Int64 nRecord = m_xWidget->get_text().toInt64(); + if (bUp) + ++nRecord; + else + --nRecord; + if (nRecord < 1) + nRecord = 1; + m_xWidget->set_text(OUString::number(nRecord)); + return true; + } + + return ChildKeyInput(rKEvt); +} + +void RecordItemWindow::PositionFired(sal_Int64 /*nRecord*/) {} + +IMPL_LINK(RecordItemWindow, KeyInputHdl, const KeyEvent&, rKEvt, bool) { return DoKeyInput(rKEvt); } + +IMPL_LINK_NOARG(RecordItemWindow, ActivatedHdl, weld::Entry&, bool) +{ + if (!m_xWidget->get_text().isEmpty()) + FirePosition(true); + return true; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |