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 
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 class Button;
32 
38 class DecoToolBox : public ToolBox
39 {
42 
43 public:
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 
59 class MenuBarWindow : public vcl::Window, public MenuWindow
60 {
61  friend class MenuBar;
62  friend class Menu;
63 
64 private:
66  {
69  };
70 
74  sal_uInt16 m_nHighlightedItem;
75  sal_uInt16 m_nRolloveredItem;
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 );
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  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();
132 
134  sal_uInt16 AddMenuBarButton(const Image&, const Link<MenuBar::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: */
void calcMinSize()
tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId)
tools::Long lastSize
VclPtr< DecoToolBox > m_aCloseBtn
void PopupClosed(Menu const *pMenu)
long Long
void SetHeight(tools::Long nHeight)
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
void ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus=true, bool bDefaultToDocument=true)
void ShowButtons(bool bClose, bool bFloat, bool bHide)
void SetAutoPopup(bool bAuto)
VclPtr< Menu > m_pMenu
void KillActivePopup()
bool CanGetFocus() const
sal_uInt16 m_nRolloveredItem
StateChangedType
Definition: window.hxx:289
Toolbox that holds the close button (right hand side of the menubar).
void SetImages(tools::Long nMaxHeight, bool bForce=false)
Link< MenuBar::MenuBarButtonCallbackArg &, bool > m_aSelectLink
void GetFocus() override
VclPtr< PopupMenu > mpParentPopup
Class that implements the actual window of the menu bar.
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
DECL_LINK(CloseHdl, ToolBox *, void)
void SetMenu(MenuBar *pMenu)
void HighlightItem(vcl::RenderContext &rRenderContext, sal_uInt16 nPos)
void DataChanged(const DataChangedEvent &rDCEvt) override
void LoseFocus() override
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId)
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
virtual void RequestHelp(const HelpEvent &rHEvt) override
std::map< sal_uInt16, AddButtonEntry > m_aAddButtons
Common ancestor for MenuFloatingWindow and MenuBarWindow.
Definition: menuwindow.hxx:48
sal_uInt16 GetHighlightedItem() const
void DataChanged(const DataChangedEvent &rDCEvt) override
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
void ImplInitStyleSettings()
VclPtr< PopupMenu > m_pActivePopup
void ImplCreatePopup(bool bPreSelectFirst)
MenuBarWindow(vcl::Window *pParent)
void RemoveMenuBarButton(sal_uInt16 nId)
Definition: menu.hxx:123
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
VclPtr< PushButton > m_aFloatBtn
sal_uInt16 ImplFindEntry(const Point &rMousePos) const
void StateChanged(StateChangedType nType) override
tools::Rectangle ImplGetItemRect(sal_uInt16 nPos)
sal_uInt16 AddMenuBarButton(const Image &, const Link< MenuBar::MenuBarButtonCallbackArg &, bool > &, const OUString &)
Add an arbitrary button to the menubar that will appear next to the close button. ...
VclPtr< vcl::Window > m_xSaveFocusId
const Size & getMinSize() const
Definition: image.hxx:39
virtual void KeyInput(const KeyEvent &rKEvent) override
virtual void Resize() override
DecoToolBox(vcl::Window *pParent)
void SetMenuBarButtonHighlightHdl(sal_uInt16 nId, const Link< MenuBar::MenuBarButtonCallbackArg &, bool > &)
virtual void MouseMove(const MouseEvent &rMEvt) override
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
VclPtr< PushButton > m_aHideBtn
virtual ~MenuBarWindow() override
Link< MenuBar::MenuBarButtonCallbackArg &, bool > m_aHighlightLink
sal_uInt16 m_nHighlightedItem
Size const & MinCloseButtonSize()
bool HandleKeyEvent(const KeyEvent &rKEvent, bool bFromMenu=true)