diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-05-21 16:43:40 +0100 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2020-06-03 12:28:38 +0200 |
commit | d455add0c642d4426bf1593f9fe5203eca8f8c7c (patch) | |
tree | dfba5514ce0113face822adb0de44af31c4120f7 | |
parent | 27643882a5c1aaeea96e25aa5cbc061574eb84d2 (diff) |
move InterimItemWindow to vcl
Change-Id: If0a4a14708810c44d087b51961f2ecb3fda4df23
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94649
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | extensions/source/bibliography/toolbar.hxx | 1 | ||||
-rw-r--r-- | framework/source/uielement/edittoolbarcontroller.cxx | 1 | ||||
-rw-r--r-- | include/svx/labelitemwindow.hxx | 30 | ||||
-rw-r--r-- | include/vcl/InterimItemWindow.hxx | 38 | ||||
-rw-r--r-- | sd/source/ui/dlg/diactrl.cxx | 1 | ||||
-rw-r--r-- | sfx2/inc/pch/precompiled_sfx.hxx | 1 | ||||
-rw-r--r-- | svx/inc/pch/precompiled_svx.hxx | 3 | ||||
-rw-r--r-- | svx/source/inc/findtextfield.hxx | 69 | ||||
-rw-r--r-- | svx/source/tbxctrls/linemetricbox.hxx | 57 | ||||
-rw-r--r-- | vcl/Library_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/source/control/InterimItemWindow.cxx | 99 |
11 files changed, 299 insertions, 2 deletions
diff --git a/extensions/source/bibliography/toolbar.hxx b/extensions/source/bibliography/toolbar.hxx index 810445e85c7e..8ebec283431a 100644 --- a/extensions/source/bibliography/toolbar.hxx +++ b/extensions/source/bibliography/toolbar.hxx @@ -23,7 +23,6 @@ #include <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/XStatusListener.hpp> - #include <vcl/toolbox.hxx> #include <vcl/lstbox.hxx> #include <vcl/edit.hxx> diff --git a/framework/source/uielement/edittoolbarcontroller.cxx b/framework/source/uielement/edittoolbarcontroller.cxx index c095ef746010..78bbda07c00e 100644 --- a/framework/source/uielement/edittoolbarcontroller.cxx +++ b/framework/source/uielement/edittoolbarcontroller.cxx @@ -21,7 +21,6 @@ #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/beans/PropertyValue.hpp> - #include <svtools/toolboxcontroller.hxx> #include <vcl/svapp.hxx> #include <vcl/mnemonic.hxx> diff --git a/include/svx/labelitemwindow.hxx b/include/svx/labelitemwindow.hxx new file mode 100644 index 000000000000..5271482b11ad --- /dev/null +++ b/include/svx/labelitemwindow.hxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <vcl/InterimItemWindow.hxx> +#include <svx/svxdllapi.h> + +class SVXCORE_DLLPUBLIC LabelItemWindow final : public InterimItemWindow +{ +private: + std::unique_ptr<weld::Label> m_xLabel; + +public: + LabelItemWindow(vcl::Window* pParent, const OUString& rLabel); + void set_label(const OUString& rLabel); + OUString get_label() const; + + void SetOptimalSize(); + virtual void dispose() override; + virtual ~LabelItemWindow() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/InterimItemWindow.hxx b/include/vcl/InterimItemWindow.hxx new file mode 100644 index 000000000000..3ba842a3eca1 --- /dev/null +++ b/include/vcl/InterimItemWindow.hxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <vcl/weld.hxx> + +class VCL_DLLPUBLIC InterimItemWindow : public Control +{ +public: + virtual ~InterimItemWindow() override; + virtual void dispose() override; + + virtual void Resize() override; + virtual Size GetOptimalSize() const override; + virtual void GetFocus() override; + +protected: + InterimItemWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, const OString& rID); + + // pass keystrokes from our child window through this to handle focus changes correctly + // returns true if keystroke is consumed + bool ChildKeyInput(const KeyEvent& rKEvt); + + std::unique_ptr<weld::Builder> m_xBuilder; + VclPtr<vcl::Window> m_xVclContentArea; + std::unique_ptr<weld::Container> m_xContainer; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sd/source/ui/dlg/diactrl.cxx b/sd/source/ui/dlg/diactrl.cxx index d05f4f1f16a0..3a4841458de0 100644 --- a/sd/source/ui/dlg/diactrl.cxx +++ b/sd/source/ui/dlg/diactrl.cxx @@ -19,6 +19,7 @@ #include <svl/intitem.hxx> #include <vcl/toolbox.hxx> +#include <svl/intitem.hxx> #include <strings.hrc> diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx index b4e1587a5801..f06a39148a70 100644 --- a/sfx2/inc/pch/precompiled_sfx.hxx +++ b/sfx2/inc/pch/precompiled_sfx.hxx @@ -89,6 +89,7 @@ #include <sal/types.h> #include <vcl/EnumContext.hxx> #include <vcl/NotebookbarContextControl.hxx> +#include <vcl/InterimItemWindow.hxx> #include <vcl/Scanline.hxx> #include <vcl/alpha.hxx> #include <vcl/bitmapex.hxx> diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx index 0de6708d0827..4d0c183208b9 100644 --- a/svx/inc/pch/precompiled_svx.hxx +++ b/svx/inc/pch/precompiled_svx.hxx @@ -80,6 +80,7 @@ #include <sal/typesizes.h> #include <vcl/BitmapFilter.hxx> #include <vcl/EnumContext.hxx> +#include <vcl/InterimItemWindow.hxx> #include <vcl/Scanline.hxx> #include <vcl/alpha.hxx> #include <vcl/bitmapex.hxx> @@ -316,6 +317,7 @@ #include <sfx2/dispatch.hxx> #include <sfx2/dllapi.h> #include <sfx2/dockwin.hxx> +#include <sfx2/lokhelper.hxx> #include <sfx2/module.hxx> #include <sfx2/objsh.hxx> #include <sfx2/request.hxx> @@ -361,6 +363,7 @@ #include <svtools/valueset.hxx> #include <toolkit/helper/convert.hxx> #include <toolkit/helper/vclunohelper.hxx> +#include <tools/UnitConversion.hxx> #include <tools/color.hxx> #include <tools/date.hxx> #include <tools/datetime.hxx> diff --git a/svx/source/inc/findtextfield.hxx b/svx/source/inc/findtextfield.hxx new file mode 100644 index 000000000000..1ac5519a2dcd --- /dev/null +++ b/svx/source/inc/findtextfield.hxx @@ -0,0 +1,69 @@ +/* -*- 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 . + */ + +#pragma once + +#include <vcl/InterimItemWindow.hxx> + +namespace svt +{ +class AcceleratorExecute; +} + +class FindTextFieldControl final : public InterimItemWindow +{ +public: + FindTextFieldControl(vcl::Window* pParent, + css::uno::Reference<css::frame::XFrame> const& xFrame, + const css::uno::Reference<css::uno::XComponentContext>& xContext); + + virtual void dispose() override; + + virtual ~FindTextFieldControl() override; + + virtual void GetFocus() override; + + void Remember_Impl(const OUString& rStr); + void SetTextToSelected_Impl(); + + void connect_changed(const Link<weld::ComboBox&, void>& rLink); + + int get_count() const; + OUString get_text(int nIndex) const; + OUString get_active_text() const; + void append_text(const OUString& rText); + void set_entry_message_type(weld::EntryMessageType eType); + +private: + ImplSVEvent* m_nAsyncGetFocusId; + std::unique_ptr<weld::ComboBox> m_xWidget; + css::uno::Reference<css::frame::XFrame> m_xFrame; + css::uno::Reference<css::uno::XComponentContext> m_xContext; + std::unique_ptr<svt::AcceleratorExecute> m_pAcc; + Link<weld::ComboBox&, void> m_aChangeHdl; + + DECL_LINK(FocusInHdl, weld::Widget&, void); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ActivateHdl, weld::ComboBox&, bool); + DECL_LINK(OnAsyncGetFocus, void*, void); + + void ActivateFind(bool bShift); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/linemetricbox.hxx b/svx/source/tbxctrls/linemetricbox.hxx new file mode 100644 index 000000000000..e58566a10d00 --- /dev/null +++ b/svx/source/tbxctrls/linemetricbox.hxx @@ -0,0 +1,57 @@ +/* -*- 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 . + */ +#pragma once + +#include <vcl/InterimItemWindow.hxx> +#include <svx/svxdllapi.h> + +class XLineWidthItem; + +class SvxMetricField final : public InterimItemWindow +{ +private: + std::unique_ptr<weld::MetricSpinButton> m_xWidget; + int nCurValue; + MapUnit eDestPoolUnit; + FieldUnit eDlgUnit; + css::uno::Reference<css::frame::XFrame> mxFrame; + + DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(FocusInHdl, weld::Widget&, void); + + static void ReleaseFocus_Impl(); + + virtual void DataChanged(const DataChangedEvent& rDCEvt) override; + + virtual void GetFocus() override; + +public: + SvxMetricField(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rFrame); + virtual void dispose() override; + virtual ~SvxMetricField() override; + + void Update(const XLineWidthItem* pItem); + void SetDestCoreUnit(MapUnit eUnit); + void RefreshDlgUnit(); + + void set_sensitive(bool bSensitive); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 73c74636c482..1a6fdce0d48b 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -191,6 +191,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/control/fixedhyper \ vcl/source/control/hyperlabel \ vcl/source/control/fmtfield \ + vcl/source/control/InterimItemWindow \ vcl/source/control/imgctrl \ vcl/source/control/imivctl1 \ vcl/source/control/imivctl2 \ diff --git a/vcl/source/control/InterimItemWindow.cxx b/vcl/source/control/InterimItemWindow.cxx new file mode 100644 index 000000000000..f9f54d757fd5 --- /dev/null +++ b/vcl/source/control/InterimItemWindow.cxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#include <vcl/InterimItemWindow.hxx> +#include <vcl/layout.hxx> + +InterimItemWindow::InterimItemWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, + const OString& rID) + : Control(pParent, WB_TABSTOP | WB_DIALOGCONTROL) +{ + m_xVclContentArea = VclPtr<VclVBox>::Create(this); + m_xVclContentArea->Show(); + m_xBuilder.reset(Application::CreateInterimBuilder(m_xVclContentArea, rUIXMLDescription)); + m_xContainer = m_xBuilder->weld_container(rID); + + SetBackground(); + SetPaintTransparent(true); +} + +InterimItemWindow::~InterimItemWindow() { disposeOnce(); } + +void InterimItemWindow::dispose() +{ + m_xContainer.reset(); + m_xBuilder.reset(); + m_xVclContentArea.disposeAndClear(); + + Control::dispose(); +} + +void InterimItemWindow::Resize() +{ + vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); + assert(pChild); + VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel()); + Control::Resize(); +} + +Size InterimItemWindow::GetOptimalSize() const +{ + return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild)); +} + +void InterimItemWindow::GetFocus() +{ + /* let toolbox know this item window has focus so it updates its mnHighItemId to point + to this toolitem in case tab means to move to another toolitem within + the toolbox + */ + vcl::Window* pToolBox = GetParent(); + NotifyEvent aNEvt(MouseNotifyEvent::GETFOCUS, this); + pToolBox->EventNotify(aNEvt); +} + +bool InterimItemWindow::ChildKeyInput(const KeyEvent& rKEvt) +{ + sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); + if (nCode != KEY_TAB) + return false; + + /* if the native widget has focus, then no vcl window has focus. + + We want to grab focus to this vcl widget so that pressing tab will traverse + to the next vcl widget. + + But just using GrabFocus will, because no vcl widget has focus, trigger + bringing the toplevel to front with the expectation that a suitable widget + will be picked for focus when that happen, which is no use to us here. + + SetFakeFocus avoids the problem, allowing GrabFocus to do the expected thing + then sending the Tab to our parent will do the right traversal + */ + SetFakeFocus(true); + GrabFocus(); + + /* now give focus to our toolbox parent */ + vcl::Window* pToolBox = GetParent(); + pToolBox->GrabFocus(); + + /* let toolbox know this item window has focus so it updates its mnHighItemId to point + to this toolitem in case tab means to move to another toolitem within + the toolbox + */ + NotifyEvent aNEvt(MouseNotifyEvent::GETFOCUS, this); + pToolBox->EventNotify(aNEvt); + + /* send parent the tab */ + pToolBox->KeyInput(rKEvt); + + return true; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |