Bump version to 21.06.18.1
[LibreOffice.git] / include / vcl / menubtn.hxx
blobccbd23a041f818f8c138e81232c34963c1aac63d
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 #ifndef INCLUDED_VCL_MENUBTN_HXX
21 #define INCLUDED_VCL_MENUBTN_HXX
23 #include <config_options.h>
24 #include <vcl/button.hxx>
25 #include <vcl/dllapi.h>
26 #include <memory>
28 class Timer;
29 class PopupMenu;
31 class VCL_DLLPUBLIC MenuButton : public PushButton
33 private:
34 friend class VclBuilder;
36 std::unique_ptr<Timer> mpMenuTimer;
37 VclPtr<PopupMenu> mpMenu;
38 VclPtr<Window> mpFloatingWindow;
39 OString msCurItemIdent;
40 sal_uInt16 mnCurItemId;
41 bool mbDelayMenu;
42 bool mbStartingMenu;
43 Link<MenuButton*,void> maActivateHdl;
44 Link<MenuButton*,void> maSelectHdl;
46 DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, Timer*, void );
48 MenuButton( const MenuButton & ) = delete;
49 MenuButton& operator=( const MenuButton & ) = delete;
51 protected:
52 using Window::ImplInit;
53 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
55 public:
56 explicit MenuButton( vcl::Window* pParent, WinBits nStyle = 0 );
57 virtual ~MenuButton() override;
58 virtual void dispose() override;
60 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
61 virtual void KeyInput( const KeyEvent& rKEvt ) override;
63 virtual void Activate() override;
64 virtual void Select();
66 void ExecuteMenu();
67 bool InPopupMode() const;
68 void CancelMenu();
70 //if false then the whole button launches the menu
71 //if true, then the button has a separator
72 //where the right portion launches the menu immediately
73 //where the left portion activates the underlying Button handlers
74 //before launching the menu in an idle, allowing it to be cancelled
75 //before being shown
76 void SetDelayMenu(bool bDelay) { mbDelayMenu = bDelay; }
78 void SetPopupMenu(PopupMenu* pNewMenu);
79 PopupMenu* GetPopupMenu() const { return mpMenu; }
81 void SetPopover(Window* pWindow);
82 Window* GetPopover() { return mpFloatingWindow.get(); }
84 OString const & GetCurItemIdent() const { return msCurItemIdent; }
86 void SetActivateHdl( const Link<MenuButton *, void>& rLink ) { maActivateHdl = rLink; }
87 void SetSelectHdl( const Link<MenuButton *, void>& rLink ) { maSelectHdl = rLink; }
89 virtual FactoryFunction GetUITestFactory() const override;
91 void SetCurItemId();
95 #endif // INCLUDED_VCL_MENUBTN_HXX
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */