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 <config_options.h>
24 #include <vcl/button.hxx>
25 #include <vcl/dllapi.h>
26 #include <memory>
27 
28 class Timer;
29 class PopupMenu;
30 
32 {
33 private:
34  friend class VclBuilder;
35 
36  std::unique_ptr<Timer> mpMenuTimer;
39  OString msCurItemIdent;
40  sal_uInt16 mnCurItemId;
45 
46  DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, Timer*, void );
47 
48  MenuButton( const MenuButton & ) = delete;
49  MenuButton& operator=( const MenuButton & ) = delete;
50 
51 protected:
52  using Window::ImplInit;
53  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
54 
55 public:
56  explicit MenuButton( vcl::Window* pParent, WinBits nStyle = 0 );
57  virtual ~MenuButton() override;
58  virtual void dispose() override;
59 
60  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
61  virtual void KeyInput( const KeyEvent& rKEvt ) override;
62 
63  virtual void Activate() override;
64  virtual void Select();
65 
66  void ExecuteMenu();
67  bool InPopupMode() const;
68  void CancelMenu();
69 
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; }
77 
78  void SetPopupMenu(PopupMenu* pNewMenu);
79  PopupMenu* GetPopupMenu() const { return mpMenu; }
80 
81  void SetPopover(Window* pWindow);
82 
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 
90 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MenuToggleButton final : public MenuButton
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:41
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:1222
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
Link< MenuButton *, void > maSelectHdl
Definition: menubtn.hxx:44
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: button.cxx:106
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: button.cxx:590
sal_Int64 WinBits
Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar, etc.
Definition: builder.hxx:64
sal_uInt16 mnCurItemId
Definition: menubtn.hxx:40
PushButton & operator=(const PushButton &)=delete
VclPtr< PopupMenu > mpMenu
Definition: menubtn.hxx:37
OString const & GetCurItemIdent() const
Definition: menubtn.hxx:83
PopupMenu * GetPopupMenu() const
Definition: menubtn.hxx:79
std::unique_ptr< Timer > mpMenuTimer
Definition: menubtn.hxx:36
VclPtr< Window > mpFloatingWindow
Definition: menubtn.hxx:38
bool mbStartingMenu
Definition: menubtn.hxx:42
void SetDelayMenu(bool bDelay)
Definition: menubtn.hxx:76
void SetSelectHdl(const Link< MenuButton *, void > &rLink)
Definition: menubtn.hxx:86
Link< MenuButton *, void > maActivateHdl
Definition: menubtn.hxx:43
OString msCurItemIdent
Definition: menubtn.hxx:39
virtual void Activate()
Definition: window.cxx:1832
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:1138