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