Line data Source code
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 :
26 : class Timer;
27 : class PopupMenu;
28 : class VclBuilder;
29 : class VclSimpleEvent;
30 :
31 : #define MENUBUTTON_MENUMODE_TIMED ((sal_uInt16)0x0001)
32 :
33 : class VCL_DLLPUBLIC MenuButton : public PushButton
34 : {
35 : private:
36 : friend class VclBuilder;
37 :
38 : Rectangle maFocusRect;
39 : Timer* mpMenuTimer;
40 : PopupMenu* mpOwnMenu;
41 : PopupMenu* mpMenu;
42 : sal_uInt16 mnCurItemId;
43 : sal_uInt16 mnMenuMode;
44 : Link<> maActivateHdl;
45 : Link<MenuButton *, void> maSelectHdl;
46 :
47 : SAL_DLLPRIVATE void ImplInitMenuButtonData();
48 : DECL_DLLPRIVATE_LINK_TYPED( ImplMenuTimeoutHdl, Timer*, void );
49 :
50 : MenuButton( const MenuButton & ) SAL_DELETED_FUNCTION;
51 : MenuButton& operator=( const MenuButton & ) SAL_DELETED_FUNCTION;
52 :
53 : protected:
54 : using Window::ImplInit;
55 : SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
56 :
57 : public:
58 : explicit MenuButton( vcl::Window* pParent, WinBits nStyle = 0 );
59 : virtual ~MenuButton();
60 : virtual void dispose() SAL_OVERRIDE;
61 :
62 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
63 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
64 :
65 : virtual void Activate() SAL_OVERRIDE;
66 : virtual void Select();
67 :
68 : void ExecuteMenu();
69 :
70 : void SetMenuMode( sal_uInt16 nMode );
71 : sal_uInt16 GetMenuMode() const { return mnMenuMode; }
72 :
73 : void SetPopupMenu( PopupMenu* pNewMenu );
74 1 : PopupMenu* GetPopupMenu() const { return mpMenu; }
75 :
76 0 : sal_uInt16 GetCurItemId() const { return mnCurItemId; }
77 : OString GetCurItemIdent() const;
78 : void SetCurItemId( sal_uInt16 nItemId ) { mnCurItemId = nItemId; }
79 :
80 0 : void SetActivateHdl( const Link<>& rLink ) { maActivateHdl = rLink; }
81 : const Link<>& GetActivateHdl() const { return maActivateHdl; }
82 1 : void SetSelectHdl( const Link<MenuButton *, void>& rLink ) { maSelectHdl = rLink; }
83 : };
84 :
85 : #endif // INCLUDED_VCL_MENUBTN_HXX
86 :
87 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|