1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
32 class VCL_DLLPUBLIC MenuButton
: public PushButton
35 friend class VclBuilder
;
38 VclPtr
<PopupMenu
> mpMenu
;
39 VclPtr
<FloatingWindow
> mpFloatingWindow
;
40 sal_uInt16 mnCurItemId
;
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;
51 using Window::ImplInit
;
52 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
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();
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
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
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: */