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 #ifndef INCLUDED_VCL_SOURCE_WINDOW_MENUBARWINDOW_HXX
21 #define INCLUDED_VCL_SOURCE_WINDOW_MENUBARWINDOW_HXX
22 
23 #include "menuwindow.hxx"
24 
25 #include <vcl/button.hxx>
26 #include <vcl/menu.hxx>
27 #include <vcl/toolbox.hxx>
28 #include <vcl/window.hxx>
29 
30 class Button;
31 
37 class DecoToolBox : public ToolBox
38 {
39  long lastSize;
41 
42 public:
43  explicit DecoToolBox(vcl::Window* pParent);
44 
45  void DataChanged( const DataChangedEvent& rDCEvt ) override;
46 
47  void SetImages( long nMaxHeight, bool bForce = false );
48 
49  void calcMinSize();
50  const Size& getMinSize() const { return maMinSize;}
51 
53 };
54 
55 
58 class MenuBarWindow : public vcl::Window, public MenuWindow
59 {
60  friend class MenuBar;
61  friend class Menu;
62 
63 private:
65  {
68  };
69 
73  sal_uInt16 m_nHighlightedItem;
74  sal_uInt16 m_nRolloveredItem;
79  bool mbMenuKey;
80 
84 
85  std::map< sal_uInt16, AddButtonEntry > m_aAddButtons;
86 
87  void HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos);
88  void ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus = true, bool bDefaultToDocument = true);
89 
90  sal_uInt16 ImplFindEntry( const Point& rMousePos ) const;
91  void ImplCreatePopup( bool bPreSelectFirst );
92  bool HandleKeyEvent(const KeyEvent& rKEvent, bool bFromMenu = true);
93  tools::Rectangle ImplGetItemRect( sal_uInt16 nPos );
94 
95  void ImplInitStyleSettings();
96 
97  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
98 
99  DECL_LINK( CloseHdl, ToolBox*, void );
100  DECL_LINK( ToolboxEventHdl, VclWindowEvent&, void );
101  DECL_LINK( ShowHideListener, VclWindowEvent&, void );
102 
103  void StateChanged( StateChangedType nType ) override;
104  void DataChanged( const DataChangedEvent& rDCEvt ) override;
105  void LoseFocus() override;
106  void GetFocus() override;
107 
108 public:
109  explicit MenuBarWindow( vcl::Window* pParent );
110  virtual ~MenuBarWindow() override;
111  virtual void dispose() override;
112 
113  void ShowButtons(bool bClose, bool bFloat, bool bHide);
114 
115  virtual void MouseMove( const MouseEvent& rMEvt ) override;
116  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
117  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
118  virtual void KeyInput( const KeyEvent& rKEvent ) override;
119  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
120  virtual void Resize() override;
121  virtual void RequestHelp( const HelpEvent& rHEvt ) override;
122 
123  void SetMenu(MenuBar* pMenu);
124  void SetHeight(long nHeight);
125  void KillActivePopup();
126  void PopupClosed(Menu const * pMenu);
127  sal_uInt16 GetHighlightedItem() const { return m_nHighlightedItem; }
128  virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
129 
130  void SetAutoPopup(bool bAuto) { mbAutoPopup = bAuto; }
131  void LayoutChanged();
132  Size const & MinCloseButtonSize();
133 
135  sal_uInt16 AddMenuBarButton(const Image&, const Link<MenuBar::MenuBarButtonCallbackArg&,bool>&, const OUString&);
138  void RemoveMenuBarButton(sal_uInt16 nId);
139  bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId);
140  void SetMBWHideAccel(bool val) { mbHideAccel = val; }
141  bool GetMBWHideAccel() const { return mbHideAccel; }
142  void SetMBWMenuKey(bool val) { mbMenuKey = val; }
143  bool GetMBWMenuKey() const { return mbMenuKey; }
144  bool CanGetFocus() const;
145 };
146 
147 #endif // INCLUDED_VCL_SOURCE_WINDOW_MENUBARWINDOW_HXX
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void calcMinSize()
tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId)
VclPtr< DecoToolBox > m_aCloseBtn
void PopupClosed(Menu const *pMenu)
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:309
bool GetMBWHideAccel() const
Toolbox that holds the close button (right hand side of the menubar).
void SetMBWMenuKey(bool val)
Link< MenuBar::MenuBarButtonCallbackArg &, bool > m_aSelectLink
void GetFocus() override
VclPtr< PopupMenu > mpParentPopup
Class that implements the actual window of the menu bar.
void SetMBWHideAccel(bool val)
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:304
virtual void RequestHelp(const HelpEvent &rHEvt) override
std::map< sal_uInt16, AddButtonEntry > m_aAddButtons
Common ancestor for MenuFloatingWindow and MenuBarWindow.
Definition: menuwindow.hxx:49
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:121
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:51
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
void SetHeight(long nHeight)
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
VclPtr< PushButton > m_aHideBtn
void SetImages(long nMaxHeight, bool bForce=false)
virtual ~MenuBarWindow() override
Link< MenuBar::MenuBarButtonCallbackArg &, bool > m_aHighlightLink
bool GetMBWMenuKey() const
sal_uInt16 m_nHighlightedItem
Size const & MinCloseButtonSize()
bool HandleKeyEvent(const KeyEvent &rKEvent, bool bFromMenu=true)