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#pragma once
21
22#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23#error "don't use this in new code"
24#endif
25
26#include <config_options.h>
28#include <vcl/dllapi.h>
29#include <memory>
30
31class Timer;
32class PopupMenu;
33
35{
36private:
37 friend class VclBuilder;
38
39 std::unique_ptr<Timer> mpMenuTimer;
43 sal_uInt16 mnCurItemId;
48
49 DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, Timer*, void );
50
51 MenuButton( const MenuButton & ) = delete;
52 MenuButton& operator=( const MenuButton & ) = delete;
53
54protected:
55 using Window::ImplInit;
56 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
57
58public:
59 explicit MenuButton( vcl::Window* pParent, WinBits nStyle = 0 );
60 virtual ~MenuButton() override;
61 virtual void dispose() override;
62
63 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
64 virtual void KeyInput( const KeyEvent& rKEvt ) override;
65
66 virtual void Activate() override;
67 void Select();
68
69 void ExecuteMenu();
70 bool InPopupMode() const;
71 void CancelMenu();
72
73 //if false then the whole button launches the menu
74 //if true, then the button has a separator
75 //where the right portion launches the menu immediately
76 //where the left portion activates the underlying Button handlers
77 //before launching the menu in an idle, allowing it to be cancelled
78 //before being shown
79 void SetDelayMenu(bool bDelay) { mbDelayMenu = bDelay; }
80
81 void SetPopupMenu(PopupMenu* pNewMenu);
82 PopupMenu* GetPopupMenu() const { return mpMenu; }
83
84 void SetPopover(Window* pWindow);
85 Window* GetPopover() { return mpFloatingWindow.get(); }
86
87 OUString const& GetCurItemIdent() const { return msCurItemIdent; }
88
89 void SetActivateHdl( const Link<MenuButton *, void>& rLink ) { maActivateHdl = rLink; }
90 void SetSelectHdl( const Link<MenuButton *, void>& rLink ) { maSelectHdl = rLink; }
91
92 virtual FactoryFunction GetUITestFactory() const override;
93
94 void SetCurItemId();
95
96 virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
97};
98
99/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: button.cxx:112
virtual FactoryFunction GetUITestFactory() const override
Definition: button.cxx:576
MenuButton(const MenuButton &)=delete
sal_uInt16 mnCurItemId
Definition: menubtn.hxx:43
MenuButton & operator=(const MenuButton &)=delete
OUString const & GetCurItemIdent() const
Definition: menubtn.hxx:87
Window * GetPopover()
Definition: menubtn.hxx:85
OUString msCurItemIdent
Definition: menubtn.hxx:42
VclPtr< Window > mpFloatingWindow
Definition: menubtn.hxx:41
void SetDelayMenu(bool bDelay)
Definition: menubtn.hxx:79
bool mbDelayMenu
Definition: menubtn.hxx:44
VclPtr< PopupMenu > mpMenu
Definition: menubtn.hxx:40
PopupMenu * GetPopupMenu() const
Definition: menubtn.hxx:82
void SetActivateHdl(const Link< MenuButton *, void > &rLink)
Definition: menubtn.hxx:89
std::unique_ptr< Timer > mpMenuTimer
Definition: menubtn.hxx:39
DECL_DLLPRIVATE_LINK(ImplMenuTimeoutHdl, Timer *, void)
bool mbStartingMenu
Definition: menubtn.hxx:45
Link< MenuButton *, void > maActivateHdl
Definition: menubtn.hxx:46
Link< MenuButton *, void > maSelectHdl
Definition: menubtn.hxx:47
void SetSelectHdl(const Link< MenuButton *, void > &rLink)
Definition: menubtn.hxx:90
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: button.cxx:678
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: button.cxx:1269
void DumpAsPropertyTree(tools::JsonWriter &) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
Definition: button.cxx:641
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:1352
Definition: timer.hxx:27
Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar,...
Definition: builder.hxx:69
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
virtual void Activate()
Definition: window.cxx:1837
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
sal_Int64 WinBits
Definition: wintypes.hxx:109