/src/libreoffice/vcl/source/window/menubarwindow.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include "menuwindow.hxx" |
23 | | |
24 | | #include <vcl/toolkit/button.hxx> |
25 | | #include <vcl/menu.hxx> |
26 | | #include <vcl/toolbox.hxx> |
27 | | #include <vcl/window.hxx> |
28 | | |
29 | | #include <map> |
30 | | |
31 | | /** Toolbox that holds the close button (right hand side of the menubar). |
32 | | |
33 | | This is also used by the online update check; when an update is available, it |
34 | | inserts here the button that leads to the download of the update. |
35 | | */ |
36 | | class DecoToolBox : public ToolBox |
37 | | { |
38 | | tools::Long lastSize; |
39 | | Size maMinSize; |
40 | | |
41 | | public: |
42 | | explicit DecoToolBox(vcl::Window* pParent); |
43 | | |
44 | | void DataChanged( const DataChangedEvent& rDCEvt ) override; |
45 | | |
46 | | void SetImages( tools::Long nMaxHeight, bool bForce = false ); |
47 | | |
48 | | void calcMinSize(); |
49 | 0 | const Size& getMinSize() const { return maMinSize;} |
50 | | |
51 | | Image maImage; |
52 | | }; |
53 | | |
54 | | |
55 | | /** Class that implements the actual window of the menu bar. |
56 | | */ |
57 | | class MenuBarWindow : public vcl::Window, public MenuWindow |
58 | | { |
59 | | friend class MenuBar; |
60 | | friend class Menu; |
61 | | |
62 | | private: |
63 | | struct AddButtonEntry |
64 | | { |
65 | | Link<MenuBarButtonCallbackArg&,bool> m_aSelectLink; |
66 | | Link<MenuBarButtonCallbackArg&,bool> m_aHighlightLink; |
67 | | }; |
68 | | |
69 | | VclPtr<MenuBar> m_pMenu; |
70 | | VclPtr<PopupMenu> m_pActivePopup; |
71 | | VclPtr<PopupMenu> mpParentPopup; |
72 | | sal_uInt16 m_nHighlightedItem; |
73 | | sal_uInt16 m_nRolloveredItem; |
74 | | VclPtr<vcl::Window> m_xSaveFocusId; |
75 | | bool mbAutoPopup; |
76 | | bool m_bIgnoreFirstMove; |
77 | | bool mbHideAccel; |
78 | | bool mbMenuKey; |
79 | | |
80 | | VclPtr<DecoToolBox> m_aCloseBtn; |
81 | | VclPtr<PushButton> m_aFloatBtn; |
82 | | VclPtr<PushButton> m_aHideBtn; |
83 | | |
84 | | std::map< sal_uInt16, AddButtonEntry > m_aAddButtons; |
85 | | |
86 | | void HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos); |
87 | | void ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus = true, bool bDefaultToDocument = true); |
88 | | |
89 | | sal_uInt16 ImplFindEntry( const Point& rMousePos ) const; |
90 | | void ImplCreatePopup( bool bPreSelectFirst ); |
91 | | bool HandleKeyEvent(const KeyEvent& rKEvent, bool bFromMenu = true); |
92 | | tools::Rectangle ImplGetItemRect( sal_uInt16 nPos ) const; |
93 | | |
94 | | void ImplInitStyleSettings(); |
95 | | |
96 | | virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; |
97 | | |
98 | | DECL_LINK( CloseHdl, ToolBox*, void ); |
99 | | DECL_LINK( ToolboxEventHdl, VclWindowEvent&, void ); |
100 | | DECL_LINK( ShowHideListener, VclWindowEvent&, void ); |
101 | | |
102 | | void StateChanged( StateChangedType nType ) override; |
103 | | void DataChanged( const DataChangedEvent& rDCEvt ) override; |
104 | | void LoseFocus() override; |
105 | | void GetFocus() override; |
106 | | |
107 | | public: |
108 | | explicit MenuBarWindow( vcl::Window* pParent ); |
109 | | virtual ~MenuBarWindow() override; |
110 | | virtual void dispose() override; |
111 | | |
112 | | void ShowButtons(bool bClose, bool bFloat, bool bHide); |
113 | | |
114 | | virtual void MouseMove( const MouseEvent& rMEvt ) override; |
115 | | virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; |
116 | | virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; |
117 | | virtual void KeyInput( const KeyEvent& rKEvent ) override; |
118 | | virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; |
119 | | virtual void Resize() override; |
120 | | virtual void RequestHelp( const HelpEvent& rHEvt ) override; |
121 | | |
122 | | void SetMenu(MenuBar* pMenu); |
123 | | void SetHeight(tools::Long nHeight); |
124 | | void KillActivePopup(); |
125 | | void PopupClosed(Menu const * pMenu); |
126 | 0 | sal_uInt16 GetHighlightedItem() const { return m_nHighlightedItem; } |
127 | | virtual rtl::Reference<comphelper::OAccessible> CreateAccessible() override; |
128 | | |
129 | 0 | void SetAutoPopup(bool bAuto) { mbAutoPopup = bAuto; } |
130 | | void LayoutChanged(); |
131 | | Size const & MinCloseButtonSize() const; |
132 | | |
133 | | /// Add an arbitrary button to the menubar that will appear next to the close button. |
134 | | sal_uInt16 AddMenuBarButton(const Image&, const Link<MenuBarButtonCallbackArg&,bool>&, const OUString&); |
135 | | void SetMenuBarButtonHighlightHdl(sal_uInt16 nId, const Link<MenuBarButtonCallbackArg&,bool>&); |
136 | | tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId); |
137 | | void RemoveMenuBarButton(sal_uInt16 nId); |
138 | | bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId); |
139 | 0 | void SetMBWHideAccel(bool val) { mbHideAccel = val; } |
140 | 0 | bool GetMBWHideAccel() const { return mbHideAccel; } |
141 | 0 | void SetMBWMenuKey(bool val) { mbMenuKey = val; } |
142 | 0 | bool GetMBWMenuKey() const { return mbMenuKey; } |
143 | | bool CanGetFocus() const; |
144 | | }; |
145 | | |
146 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |