vcl: no raw pointers
[LibreOffice.git] / include / svtools / toolbarmenu.hxx
blobf65687130e1557b577a463d7b3714a05481e0b88
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <svtools/svtdllapi.h>
24 #include <memory>
26 #include <rtl/ref.hxx>
27 #include <vcl/dockwin.hxx>
28 #include <vcl/weld.hxx>
30 namespace com :: sun :: star :: frame { class XFrame; }
31 namespace com :: sun :: star :: frame { struct FeatureStateEvent; }
32 namespace svt { class FrameStatusListener; }
34 class SVT_DLLPUBLIC WeldToolbarPopup
36 private:
37 DECL_DLLPRIVATE_LINK(FocusHdl, weld::Widget&, void);
39 protected:
40 std::unique_ptr<weld::Builder> m_xBuilder;
41 std::unique_ptr<weld::Container> m_xTopLevel;
42 std::unique_ptr<weld::Container> m_xContainer;
43 css::uno::Reference<css::frame::XFrame> m_xFrame;
44 rtl::Reference<svt::FrameStatusListener> m_xStatusListener;
46 public:
47 WeldToolbarPopup(css::uno::Reference<css::frame::XFrame> xFrame,
48 weld::Widget* pParent, const OUString& rUIFile, const OUString& rId);
49 virtual ~WeldToolbarPopup();
50 weld::Container* getTopLevel() { return m_xTopLevel.get(); }
51 weld::Container* getContainer() { return m_xContainer.get(); }
52 void AddStatusListener(const OUString& rCommandURL);
54 // Forwarded from XStatusListener (subclasses must override this one to get the status updates):
55 /// @throws css::uno::RuntimeException
56 virtual void statusChanged(const css::frame::FeatureStateEvent& Event);
57 virtual void GrabFocus() = 0;
60 // we want to create WeldToolbarPopup on-demand when a toolbar dropdown is
61 // clicked, but the widget to be shown must exist before the dropdown
62 // is activated, so ToolbarPopupContainer is that widget and the
63 // contents of the on-demand created WeldToolbarPopup is placed
64 // within the ToolbarPopupContainer
65 class SVT_DLLPUBLIC ToolbarPopupContainer final
67 private:
68 DECL_DLLPRIVATE_LINK(FocusHdl, weld::Widget&, void);
70 std::unique_ptr<weld::Builder> m_xBuilder;
71 std::unique_ptr<weld::Container> m_xTopLevel;
72 std::unique_ptr<weld::Container> m_xContainer;
73 std::unique_ptr<WeldToolbarPopup> m_xPopup;
74 public:
75 ToolbarPopupContainer(weld::Widget* pParent);
76 ~ToolbarPopupContainer();
77 weld::Container* getTopLevel() { return m_xTopLevel.get(); }
79 void setPopover(std::unique_ptr<WeldToolbarPopup> xPopup);
80 WeldToolbarPopup* getPopover() const { return m_xPopup.get(); }
81 void unsetPopover();
84 class SVT_DLLPUBLIC InterimToolbarPopup final : public DropdownDockingWindow
86 private:
87 css::uno::Reference<css::frame::XFrame> m_xFrame;
88 std::unique_ptr<weld::Builder> m_xBuilder;
89 std::unique_ptr<weld::Container> m_xContainer;
90 std::unique_ptr<WeldToolbarPopup> m_xPopup;
91 public:
92 InterimToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParent,
93 std::unique_ptr<WeldToolbarPopup> xPopup, bool bTearable = false);
94 virtual void dispose() override;
95 virtual ~InterimToolbarPopup() override;
97 virtual void GetFocus() override;
99 void EndPopupMode();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */