Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / menubtn.hxx
blobda725103c1c72ed52ca0eaa0833a39b937665a74
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 <vcl/button.hxx>
24 #include <vcl/dllapi.h>
26 class FloatingWindow;
27 class Timer;
28 class PopupMenu;
29 class VclBuilder;
30 class VclSimpleEvent;
32 class VCL_DLLPUBLIC MenuButton : public PushButton
34 private:
35 friend class VclBuilder;
37 Timer* mpMenuTimer;
38 VclPtr<PopupMenu> mpMenu;
39 VclPtr<FloatingWindow> mpFloatingWindow;
40 sal_uInt16 mnCurItemId;
41 bool mbDelayMenu;
42 Link<MenuButton*,void> maActivateHdl;
43 Link<MenuButton*,void> maSelectHdl;
45 DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, Timer*, void );
47 MenuButton( const MenuButton & ) = delete;
48 MenuButton& operator=( const MenuButton & ) = delete;
50 protected:
51 using Window::ImplInit;
52 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
54 public:
55 explicit MenuButton( vcl::Window* pParent, WinBits nStyle = 0 );
56 virtual ~MenuButton() override;
57 virtual void dispose() override;
59 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
60 virtual void KeyInput( const KeyEvent& rKEvt ) override;
62 virtual void Activate() override;
63 virtual void Select();
65 void ExecuteMenu();
67 //if false then the whole button launches the menu
68 //if true, then the button has a separator
69 //where the right portion launches the menu immediately
70 //where the left portion activates the underlying Button handlers
71 //before launching the menu in an idle, allowing it to be cancelled
72 //before being shown
73 void SetDelayMenu(bool bDelay) { mbDelayMenu = bDelay; }
75 void SetPopupMenu(PopupMenu* pNewMenu);
76 PopupMenu* GetPopupMenu() const { return mpMenu; }
78 void SetPopover(FloatingWindow* pFloatingWindow);
80 sal_uInt16 GetCurItemId() const { return mnCurItemId; }
81 OString GetCurItemIdent() const;
83 void SetActivateHdl( const Link<MenuButton *, void>& rLink ) { maActivateHdl = rLink; }
84 void SetSelectHdl( const Link<MenuButton *, void>& rLink ) { maSelectHdl = rLink; }
88 class VCL_DLLPUBLIC MenuToggleButton : public MenuButton
90 public:
91 explicit MenuToggleButton( vcl::Window* pParent, WinBits nStyle );
92 virtual ~MenuToggleButton() override;
94 void SetActive( bool bSel );
97 #endif // INCLUDED_VCL_MENUBTN_HXX
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */