Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_MENUBTN_HXX
30 : : #define _SV_MENUBTN_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <vcl/dllapi.h>
34 : : #include <vcl/button.hxx>
35 : :
36 : : class Timer;
37 : : class PopupMenu;
38 : :
39 : : // --------------------
40 : : // - MenuButton-Types -
41 : : // --------------------
42 : :
43 : : #define MENUBUTTON_MENUMODE_TIMED ((sal_uInt16)0x0001)
44 : :
45 : : // --------------
46 : : // - MenuButton -
47 : : // --------------
48 : :
49 : : class VCL_DLLPUBLIC MenuButton : public PushButton
50 : : {
51 : : private:
52 : : Rectangle maFocusRect;
53 : : Timer* mpMenuTimer;
54 : : PopupMenu* mpOwnMenu;
55 : : PopupMenu* mpMenu;
56 : : sal_uInt16 mnCurItemId;
57 : : sal_uInt16 mnMenuMode;
58 : : Link maActivateHdl;
59 : : Link maSelectHdl;
60 : :
61 : : SAL_DLLPRIVATE void ImplInitMenuButtonData();
62 : : SAL_DLLPRIVATE void ImplExecuteMenu();
63 : : DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, void* );
64 : :
65 : : // Copy assignment is forbidden and not implemented.
66 : : SAL_DLLPRIVATE MenuButton( const MenuButton & );
67 : : SAL_DLLPRIVATE MenuButton& operator=( const MenuButton & );
68 : :
69 : : protected:
70 : : using Window::ImplInit;
71 : : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
72 : : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
73 : :
74 : : public:
75 : : MenuButton( Window* pParent, WinBits nStyle = 0 );
76 : : MenuButton( Window* pParent, const ResId& rResId );
77 : : ~MenuButton();
78 : :
79 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
80 : : virtual void KeyInput( const KeyEvent& rKEvt );
81 : :
82 : : virtual void Activate();
83 : : virtual void Select();
84 : :
85 : : void SetMenuMode( sal_uInt16 nMode );
86 : : sal_uInt16 GetMenuMode() const { return mnMenuMode; }
87 : :
88 : : void SetPopupMenu( PopupMenu* pNewMenu );
89 : 0 : PopupMenu* GetPopupMenu() const { return mpMenu; }
90 : :
91 : 0 : sal_uInt16 GetCurItemId() const { return mnCurItemId; }
92 : : void SetCurItemId( sal_uInt16 nItemId ) { mnCurItemId = nItemId; }
93 : :
94 : 2 : void SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; }
95 : : const Link& GetActivateHdl() const { return maActivateHdl; }
96 : 2 : void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
97 : : const Link& GetSelectHdl() const { return maSelectHdl; }
98 : : };
99 : :
100 : : #endif // _SV_MENUBTN_HXX
101 : :
102 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|