/src/libreoffice/include/svtools/toolbarmenu.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <svtools/svtdllapi.h> |
23 | | |
24 | | #include <memory> |
25 | | |
26 | | #include <rtl/ref.hxx> |
27 | | #include <vcl/dockwin.hxx> |
28 | | |
29 | | namespace com::sun::star::frame { class XFrame; } |
30 | | namespace com::sun::star::frame { struct FeatureStateEvent; } |
31 | | namespace svt { class FrameStatusListener; } |
32 | | namespace weld { class Builder; } |
33 | | namespace weld { class Container; } |
34 | | namespace weld { class Widget; } |
35 | | |
36 | | class SVT_DLLPUBLIC WeldToolbarPopup |
37 | | { |
38 | | private: |
39 | | DECL_DLLPRIVATE_LINK(FocusHdl, weld::Widget&, void); |
40 | | |
41 | | protected: |
42 | | std::unique_ptr<weld::Builder> m_xBuilder; |
43 | | std::unique_ptr<weld::Container> m_xTopLevel; |
44 | | std::unique_ptr<weld::Container> m_xContainer; |
45 | | css::uno::Reference<css::frame::XFrame> m_xFrame; |
46 | | rtl::Reference<svt::FrameStatusListener> m_xStatusListener; |
47 | | |
48 | | public: |
49 | | WeldToolbarPopup(css::uno::Reference<css::frame::XFrame> xFrame, |
50 | | weld::Widget* pParent, const OUString& rUIFile, const OUString& rId); |
51 | | virtual ~WeldToolbarPopup(); |
52 | 0 | weld::Container* getTopLevel() { return m_xTopLevel.get(); } |
53 | 0 | weld::Container* getContainer() { return m_xContainer.get(); } |
54 | | void AddStatusListener(const OUString& rCommandURL); |
55 | | |
56 | | // Forwarded from XStatusListener (subclasses must override this one to get the status updates): |
57 | | /// @throws css::uno::RuntimeException |
58 | | virtual void statusChanged(const css::frame::FeatureStateEvent& Event); |
59 | | virtual void GrabFocus() = 0; |
60 | | }; |
61 | | |
62 | | // we want to create WeldToolbarPopup on-demand when a toolbar dropdown is |
63 | | // clicked, but the widget to be shown must exist before the dropdown |
64 | | // is activated, so ToolbarPopupContainer is that widget and the |
65 | | // contents of the on-demand created WeldToolbarPopup is placed |
66 | | // within the ToolbarPopupContainer |
67 | | class SVT_DLLPUBLIC ToolbarPopupContainer final |
68 | | { |
69 | | private: |
70 | | DECL_DLLPRIVATE_LINK(FocusHdl, weld::Widget&, void); |
71 | | |
72 | | std::unique_ptr<weld::Builder> m_xBuilder; |
73 | | std::unique_ptr<weld::Container> m_xTopLevel; |
74 | | std::unique_ptr<weld::Container> m_xContainer; |
75 | | std::unique_ptr<WeldToolbarPopup> m_xPopup; |
76 | | public: |
77 | | ToolbarPopupContainer(weld::Widget* pParent); |
78 | | ~ToolbarPopupContainer(); |
79 | 0 | weld::Container* getTopLevel() { return m_xTopLevel.get(); } |
80 | | |
81 | | void setPopover(std::unique_ptr<WeldToolbarPopup> xPopup); |
82 | 0 | WeldToolbarPopup* getPopover() const { return m_xPopup.get(); } |
83 | | void unsetPopover(); |
84 | | }; |
85 | | |
86 | | class SVT_DLLPUBLIC InterimToolbarPopup final : public DropdownDockingWindow |
87 | | { |
88 | | private: |
89 | | css::uno::Reference<css::frame::XFrame> m_xFrame; |
90 | | std::unique_ptr<weld::Builder> m_xBuilder; |
91 | | std::unique_ptr<weld::Container> m_xContainer; |
92 | | std::unique_ptr<WeldToolbarPopup> m_xPopup; |
93 | | public: |
94 | | InterimToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParent, |
95 | | std::unique_ptr<WeldToolbarPopup> xPopup, bool bTearable = false); |
96 | | virtual void dispose() override; |
97 | | virtual ~InterimToolbarPopup() override; |
98 | | |
99 | | virtual void GetFocus() override; |
100 | | |
101 | | void EndPopupMode(); |
102 | | }; |
103 | | |
104 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |