LibreOffice Module vcl (master) 1
menubarwindow.hxx
Go to the documentation of this file.
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
25#include <vcl/menu.hxx>
26#include <vcl/toolbox.hxx>
27#include <vcl/window.hxx>
28
29#include <map>
30
31class Button;
32
38class DecoToolBox : public ToolBox
39{
42
43public:
44 explicit DecoToolBox(vcl::Window* pParent);
45
46 void DataChanged( const DataChangedEvent& rDCEvt ) override;
47
48 void SetImages( tools::Long nMaxHeight, bool bForce = false );
49
50 void calcMinSize();
51 const Size& getMinSize() const { return maMinSize;}
52
54};
55
56
59class MenuBarWindow : public vcl::Window, public MenuWindow
60{
61 friend class MenuBar;
62 friend class Menu;
63
64private:
66 {
69 };
70
79
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
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
107public:
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 sal_uInt16 GetHighlightedItem() const { return m_nHighlightedItem; }
127 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
128
129 void SetAutoPopup(bool bAuto) { mbAutoPopup = bAuto; }
130 void LayoutChanged();
131 Size const & MinCloseButtonSize() const;
132
134 sal_uInt16 AddMenuBarButton(const Image&, const Link<MenuBarButtonCallbackArg&,bool>&, const OUString&);
137 void RemoveMenuBarButton(sal_uInt16 nId);
138 bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId);
139 bool CanGetFocus() const;
140};
141
142/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Toolbox that holds the close button (right hand side of the menubar).
void DataChanged(const DataChangedEvent &rDCEvt) override
tools::Long lastSize
const Size & getMinSize() const
void calcMinSize()
DecoToolBox(vcl::Window *pParent)
void SetImages(tools::Long nMaxHeight, bool bForce=false)
Definition: image.hxx:40
Class that implements the actual window of the menu bar.
void HighlightItem(vcl::RenderContext &rRenderContext, sal_uInt16 nPos)
VclPtr< vcl::Window > m_xSaveFocusId
VclPtr< PopupMenu > mpParentPopup
void ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus=true, bool bDefaultToDocument=true)
void RemoveMenuBarButton(sal_uInt16 nId)
void PopupClosed(Menu const *pMenu)
DECL_LINK(CloseHdl, ToolBox *, void)
sal_uInt16 GetHighlightedItem() const
void SetHeight(tools::Long nHeight)
bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId)
void ImplCreatePopup(bool bPreSelectFirst)
void GetFocus() override
sal_uInt16 AddMenuBarButton(const Image &, const Link< MenuBarButtonCallbackArg &, bool > &, const OUString &)
Add an arbitrary button to the menubar that will appear next to the close button.
sal_uInt16 m_nHighlightedItem
DECL_LINK(ShowHideListener, VclWindowEvent &, void)
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
void ShowButtons(bool bClose, bool bFloat, bool bHide)
void ImplInitStyleSettings()
VclPtr< PushButton > m_aFloatBtn
virtual ~MenuBarWindow() override
virtual void Resize() override
void SetMenuBarButtonHighlightHdl(sal_uInt16 nId, const Link< MenuBarButtonCallbackArg &, bool > &)
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId)
std::map< sal_uInt16, AddButtonEntry > m_aAddButtons
VclPtr< Menu > m_pMenu
MenuBarWindow(vcl::Window *pParent)
sal_uInt16 m_nRolloveredItem
DECL_LINK(ToolboxEventHdl, VclWindowEvent &, void)
VclPtr< PopupMenu > m_pActivePopup
virtual void RequestHelp(const HelpEvent &rHEvt) override
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
void SetMenu(MenuBar *pMenu)
void KillActivePopup()
void StateChanged(StateChangedType nType) override
VclPtr< DecoToolBox > m_aCloseBtn
void DataChanged(const DataChangedEvent &rDCEvt) override
tools::Rectangle ImplGetItemRect(sal_uInt16 nPos) const
sal_uInt16 ImplFindEntry(const Point &rMousePos) const
virtual void MouseMove(const MouseEvent &rMEvt) override
Size const & MinCloseButtonSize() const
void LoseFocus() override
bool CanGetFocus() const
VclPtr< PushButton > m_aHideBtn
virtual void KeyInput(const KeyEvent &rKEvent) override
bool HandleKeyEvent(const KeyEvent &rKEvent, bool bFromMenu=true)
void SetAutoPopup(bool bAuto)
Common ancestor for MenuFloatingWindow and MenuBarWindow.
Definition: menuwindow.hxx:49
Definition: menu.hxx:116
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
A toolbar: contains all those icons, typically below the menu bar.
Definition: toolbox.hxx:74
long Long
Link< MenuBarButtonCallbackArg &, bool > m_aSelectLink
Link< MenuBarButtonCallbackArg &, bool > m_aHighlightLink
StateChangedType
Definition: window.hxx:291