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