update credits
[LibreOffice.git] / include / vcl / menubtn.hxx
blob85dc0150b53925ead89a3fcdeb77d105a551407c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _SV_MENUBTN_HXX
21 #define _SV_MENUBTN_HXX
23 #include <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/button.hxx>
27 class Timer;
28 class PopupMenu;
29 class VclBuilder;
30 class VclSimpleEvent;
32 // --------------------
33 // - MenuButton-Types -
34 // --------------------
36 #define MENUBUTTON_MENUMODE_TIMED ((sal_uInt16)0x0001)
38 // --------------
39 // - MenuButton -
40 // --------------
42 class VCL_DLLPUBLIC MenuButton : public PushButton
44 private:
45 friend class VclBuilder;
47 Rectangle maFocusRect;
48 Timer* mpMenuTimer;
49 PopupMenu* mpOwnMenu;
50 PopupMenu* mpMenu;
51 sal_uInt16 mnCurItemId;
52 sal_uInt16 mnMenuMode;
53 Link maActivateHdl;
54 Link maSelectHdl;
56 SAL_DLLPRIVATE void ImplInitMenuButtonData();
57 SAL_DLLPRIVATE void ImplExecuteMenu();
58 DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, void* );
60 // Copy assignment is forbidden and not implemented.
61 SAL_DLLPRIVATE MenuButton( const MenuButton & );
62 SAL_DLLPRIVATE MenuButton& operator=( const MenuButton & );
64 protected:
65 using Window::ImplInit;
66 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
67 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
69 public:
70 explicit MenuButton( Window* pParent, WinBits nStyle = 0 );
71 explicit MenuButton( Window* pParent, const ResId& );
72 virtual ~MenuButton();
74 virtual void MouseButtonDown( const MouseEvent& rMEvt );
75 virtual void KeyInput( const KeyEvent& rKEvt );
77 virtual void Activate();
78 virtual void Select();
80 void SetMenuMode( sal_uInt16 nMode );
81 sal_uInt16 GetMenuMode() const { return mnMenuMode; }
83 void SetPopupMenu( PopupMenu* pNewMenu );
84 PopupMenu* GetPopupMenu() const { return mpMenu; }
86 sal_uInt16 GetCurItemId() const { return mnCurItemId; }
87 OString GetCurItemIdent() const;
88 void SetCurItemId( sal_uInt16 nItemId ) { mnCurItemId = nItemId; }
90 void SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; }
91 const Link& GetActivateHdl() const { return maActivateHdl; }
92 void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
93 const Link& GetSelectHdl() const { return maSelectHdl; }
96 #endif // _SV_MENUBTN_HXX
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */