LibreOffice Module vcl (master)  1
menubtn.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_VCL_MENUBTN_HXX
21 #define INCLUDED_VCL_MENUBTN_HXX
22 
23 #include <vcl/button.hxx>
24 #include <vcl/dllapi.h>
25 #include <memory>
26 
27 class Timer;
28 class PopupMenu;
29 
31 {
32 private:
33  friend class VclBuilder;
34 
35  std::unique_ptr<Timer> mpMenuTimer;
38  OString msCurItemIdent;
39  sal_uInt16 mnCurItemId;
44 
45  DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, Timer*, void );
46 
47  MenuButton( const MenuButton & ) = delete;
48  MenuButton& operator=( const MenuButton & ) = delete;
49 
50 protected:
51  using Window::ImplInit;
52  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
53 
54 public:
55  explicit MenuButton( vcl::Window* pParent, WinBits nStyle = 0 );
56  virtual ~MenuButton() override;
57  virtual void dispose() override;
58 
59  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
60  virtual void KeyInput( const KeyEvent& rKEvt ) override;
61 
62  virtual void Activate() override;
63  virtual void Select();
64 
65  void ExecuteMenu();
66  bool InPopupMode() const;
67  void CancelMenu();
68 
69  //if false then the whole button launches the menu
70  //if true, then the button has a separator
71  //where the right portion launches the menu immediately
72  //where the left portion activates the underlying Button handlers
73  //before launching the menu in an idle, allowing it to be cancelled
74  //before being shown
75  void SetDelayMenu(bool bDelay) { mbDelayMenu = bDelay; }
76 
77  void SetPopupMenu(PopupMenu* pNewMenu);
78  PopupMenu* GetPopupMenu() const { return mpMenu; }
79 
80  void SetPopover(Window* pWindow);
81 
82  sal_uInt16 GetCurItemId() const { return mnCurItemId; }
83  OString const & GetCurItemIdent() const { return msCurItemIdent; }
84 
85  void SetActivateHdl( const Link<MenuButton *, void>& rLink ) { maActivateHdl = rLink; }
86  void SetSelectHdl( const Link<MenuButton *, void>& rLink ) { maSelectHdl = rLink; }
87 };
88 
89 
91 {
92 public:
93  explicit MenuToggleButton( vcl::Window* pParent, WinBits nStyle );
94  virtual ~MenuToggleButton() override;
95 
96  void SetActive( bool bSel );
97 };
98 
99 #endif // INCLUDED_VCL_MENUBTN_HXX
100 
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool mbDelayMenu
Definition: menubtn.hxx:40
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:1201
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_uInt16 GetCurItemId() const
Definition: menubtn.hxx:82
Link< MenuButton *, void > maSelectHdl
Definition: menubtn.hxx:43
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: button.cxx:105
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: button.cxx:585
sal_Int64 WinBits
sal_uInt16 mnCurItemId
Definition: menubtn.hxx:39
PushButton & operator=(const PushButton &)=delete
VclPtr< PopupMenu > mpMenu
Definition: menubtn.hxx:36
OString const & GetCurItemIdent() const
Definition: menubtn.hxx:83
PopupMenu * GetPopupMenu() const
Definition: menubtn.hxx:78
std::unique_ptr< Timer > mpMenuTimer
Definition: menubtn.hxx:35
VclPtr< Window > mpFloatingWindow
Definition: menubtn.hxx:37
bool mbStartingMenu
Definition: menubtn.hxx:41
void SetDelayMenu(bool bDelay)
Definition: menubtn.hxx:75
void SetSelectHdl(const Link< MenuButton *, void > &rLink)
Definition: menubtn.hxx:86
Link< MenuButton *, void > maActivateHdl
Definition: menubtn.hxx:42
OString msCurItemIdent
Definition: menubtn.hxx:38
virtual void Activate()
Definition: window.cxx:1801
Definition: timer.hxx:26
void SetActivateHdl(const Link< MenuButton *, void > &rLink)
Definition: menubtn.hxx:85
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: button.cxx:1117