Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / vcl / toolkit / menubtn.hxx
blobd02d077e8d8a5fd93e9680dfa930247150a2423e
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 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
26 #include <config_options.h>
27 #include <vcl/toolkit/button.hxx>
28 #include <vcl/dllapi.h>
29 #include <memory>
31 class Timer;
32 class PopupMenu;
34 class VCL_DLLPUBLIC MenuButton : public PushButton
36 private:
37 friend class VclBuilder;
39 std::unique_ptr<Timer> mpMenuTimer;
40 VclPtr<PopupMenu> mpMenu;
41 VclPtr<Window> mpFloatingWindow;
42 OUString msCurItemIdent;
43 sal_uInt16 mnCurItemId;
44 bool mbDelayMenu;
45 bool mbStartingMenu;
46 Link<MenuButton*,void> maActivateHdl;
47 Link<MenuButton*,void> maSelectHdl;
49 DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, Timer*, void );
51 MenuButton( const MenuButton & ) = delete;
52 MenuButton& operator=( const MenuButton & ) = delete;
54 protected:
55 using Window::ImplInit;
56 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
58 public:
59 explicit MenuButton( vcl::Window* pParent, WinBits nStyle = 0 );
60 virtual ~MenuButton() override;
61 virtual void dispose() override;
63 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
64 virtual void KeyInput( const KeyEvent& rKEvt ) override;
66 virtual void Activate() override;
67 void Select();
69 void ExecuteMenu();
70 bool InPopupMode() const;
71 void CancelMenu();
73 //if false then the whole button launches the menu
74 //if true, then the button has a separator
75 //where the right portion launches the menu immediately
76 //where the left portion activates the underlying Button handlers
77 //before launching the menu in an idle, allowing it to be cancelled
78 //before being shown
79 void SetDelayMenu(bool bDelay) { mbDelayMenu = bDelay; }
81 void SetPopupMenu(PopupMenu* pNewMenu);
82 PopupMenu* GetPopupMenu() const { return mpMenu; }
84 void SetPopover(Window* pWindow);
85 Window* GetPopover() { return mpFloatingWindow.get(); }
87 OUString const& GetCurItemIdent() const { return msCurItemIdent; }
89 void SetActivateHdl( const Link<MenuButton *, void>& rLink ) { maActivateHdl = rLink; }
90 void SetSelectHdl( const Link<MenuButton *, void>& rLink ) { maSelectHdl = rLink; }
92 virtual FactoryFunction GetUITestFactory() const override;
94 void SetCurItemId();
96 virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */