build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / vcl / source / window / menubarwindow.hxx
blob86f0192785ec8b3099544dfe90d8eb629e7c50c6
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 #ifndef INCLUDED_VCL_SOURCE_WINDOW_MENUBARWINDOW_HXX
21 #define INCLUDED_VCL_SOURCE_WINDOW_MENUBARWINDOW_HXX
23 #include "menuwindow.hxx"
25 #include <vcl/button.hxx>
26 #include <vcl/menu.hxx>
27 #include <vcl/toolbox.hxx>
28 #include <vcl/window.hxx>
30 class Button;
32 /** Toolbox that holds the close button (right hand side of the menubar).
34 This is also used by the online update check; when an update is available, it
35 inserts here the button that leads to the download of the update.
37 class DecoToolBox : public ToolBox
39 long lastSize;
40 Size maMinSize;
42 public:
43 explicit DecoToolBox(vcl::Window* pParent);
45 void DataChanged( const DataChangedEvent& rDCEvt ) override;
47 void SetImages( long nMaxHeight, bool bForce = false );
49 void calcMinSize();
50 const Size& getMinSize() { return maMinSize;}
52 Image maImage;
56 /** Class that implements the actual window of the menu bar.
58 class MenuBarWindow : public vcl::Window, public MenuWindow
60 friend class MenuBar;
61 friend class Menu;
63 private:
64 struct AddButtonEntry
66 sal_uInt16 m_nId;
67 Link<MenuBar::MenuBarButtonCallbackArg&,bool> m_aSelectLink;
68 Link<MenuBar::MenuBarButtonCallbackArg&,bool> m_aHighlightLink;
70 AddButtonEntry() : m_nId( 0 ) {}
73 VclPtr<Menu> pMenu;
74 VclPtr<PopupMenu> pActivePopup;
75 sal_uInt16 nHighlightedItem;
76 sal_uInt16 nRolloveredItem;
77 VclPtr<vcl::Window> xSaveFocusId;
78 bool mbAutoPopup;
79 bool bIgnoreFirstMove;
80 bool mbHideAccel;
81 bool mbMenuKey;
83 VclPtr<DecoToolBox> aCloseBtn;
84 VclPtr<PushButton> aFloatBtn;
85 VclPtr<PushButton> aHideBtn;
87 std::map< sal_uInt16, AddButtonEntry > m_aAddButtons;
89 void HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos);
90 void ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus = true, bool bDefaultToDocument = true);
92 sal_uInt16 ImplFindEntry( const Point& rMousePos ) const;
93 void ImplCreatePopup( bool bPreSelectFirst );
94 bool HandleKeyEvent(const KeyEvent& rKEvent, bool bFromMenu = true);
95 Rectangle ImplGetItemRect( sal_uInt16 nPos );
97 void ImplInitStyleSettings();
99 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
101 DECL_LINK( CloseHdl, ToolBox*, void );
102 DECL_LINK( ToolboxEventHdl, VclWindowEvent&, void );
103 DECL_LINK( ShowHideListener, VclWindowEvent&, void );
105 void StateChanged( StateChangedType nType ) override;
106 void DataChanged( const DataChangedEvent& rDCEvt ) override;
107 void LoseFocus() override;
108 void GetFocus() override;
110 public:
111 explicit MenuBarWindow( vcl::Window* pParent );
112 virtual ~MenuBarWindow() override;
113 virtual void dispose() override;
115 void ShowButtons(bool bClose, bool bFloat, bool bHide);
117 virtual void MouseMove( const MouseEvent& rMEvt ) override;
118 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
119 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
120 virtual void KeyInput( const KeyEvent& rKEvent ) override;
121 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) override;
122 virtual void Resize() override;
123 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
125 void SetMenu(MenuBar* pMenu);
126 void SetHeight(long nHeight);
127 void KillActivePopup();
128 void PopupClosed(Menu* pMenu);
129 sal_uInt16 GetHighlightedItem() const { return nHighlightedItem; }
130 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
132 void SetAutoPopup(bool bAuto) { mbAutoPopup = bAuto; }
133 void LayoutChanged();
134 Size MinCloseButtonSize();
136 /// Add an arbitrary button to the menubar that will appear next to the close button.
137 sal_uInt16 AddMenuBarButton(const Image&, const Link<MenuBar::MenuBarButtonCallbackArg&,bool>&, const OUString&);
138 void SetMenuBarButtonHighlightHdl(sal_uInt16 nId, const Link<MenuBar::MenuBarButtonCallbackArg&,bool>&);
139 Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId);
140 void RemoveMenuBarButton(sal_uInt16 nId);
141 bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId);
142 void SetMBWHideAccel(bool val) { mbHideAccel = val; }
143 bool GetMBWHideAccel() const { return mbHideAccel; }
144 void SetMBWMenuKey(bool val) { mbMenuKey = val; }
145 bool GetMBWMenuKey() const { return mbMenuKey; }
146 bool CanGetFocus() const;
149 #endif // INCLUDED_VCL_SOURCE_WINDOW_MENUBARWINDOW_HXX
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */