xref: /AOO41X/main/vcl/inc/vcl/menubtn.hxx (revision 47148b3bc50811ceb41802e4cc50a5db21535900)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_MENUBTN_HXX
25 #define _SV_MENUBTN_HXX
26 
27 #include <vcl/sv.h>
28 #include <vcl/dllapi.h>
29 #include <vcl/button.hxx>
30 
31 class Timer;
32 class PopupMenu;
33 
34 // --------------------
35 // - MenuButton-Types -
36 // --------------------
37 
38 #define MENUBUTTON_MENUMODE_TIMED       ((sal_uInt16)0x0001)
39 
40 // --------------
41 // - MenuButton -
42 // --------------
43 
44 class VCL_DLLPUBLIC MenuButton : public PushButton
45 {
46 private:
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;
55 
56     SAL_DLLPRIVATE void    ImplInitMenuButtonData();
57     SAL_DLLPRIVATE void    ImplExecuteMenu();
58     DECL_DLLPRIVATE_LINK(  ImplMenuTimeoutHdl, Timer* );
59 
60     // Copy assignment is forbidden and not implemented.
61     SAL_DLLPRIVATE         MenuButton( const MenuButton & );
62     SAL_DLLPRIVATE         MenuButton& operator=( const MenuButton & );
63 
64 protected:
65     using Window::ImplInit;
66     SAL_DLLPRIVATE void    ImplInit( Window* pParent, WinBits nStyle );
67     SAL_DLLPRIVATE void    ImplLoadRes( const ResId& rResId );
68 
69 public:
70     explicit        MenuButton( Window* pParent, WinBits nStyle = 0 );
71     explicit        MenuButton( Window* pParent, const ResId& );
72     virtual         ~MenuButton();
73 
74     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
75     virtual void    KeyInput( const KeyEvent& rKEvt );
76 
77     virtual void    Activate();
78     virtual void    Select();
79 
80     void            SetMenuMode( sal_uInt16 nMode );
GetMenuMode() const81     sal_uInt16          GetMenuMode() const { return mnMenuMode; }
82 
83     void            SetPopupMenu( PopupMenu* pNewMenu );
GetPopupMenu() const84     PopupMenu*      GetPopupMenu() const { return mpMenu; }
85 
GetCurItemId() const86     sal_uInt16          GetCurItemId() const { return mnCurItemId; }
87 
SetActivateHdl(const Link & rLink)88     void            SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; }
GetActivateHdl() const89     const Link&     GetActivateHdl() const              { return maActivateHdl; }
SetSelectHdl(const Link & rLink)90     void            SetSelectHdl( const Link& rLink )   { maSelectHdl = rLink; }
GetSelectHdl() const91     const Link&     GetSelectHdl() const                { return maSelectHdl; }
92 };
93 
94 #endif  // _SV_MENUBTN_HXX
95 
96