1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
43 explicit DecoToolBox(vcl::Window
* pParent
);
45 void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
47 void SetImages( long nMaxHeight
, bool bForce
= false );
50 const Size
& getMinSize() const { return maMinSize
;}
56 /** Class that implements the actual window of the menu bar.
58 class MenuBarWindow
: public vcl::Window
, public MenuWindow
66 Link
<MenuBar::MenuBarButtonCallbackArg
&,bool> m_aSelectLink
;
67 Link
<MenuBar::MenuBarButtonCallbackArg
&,bool> m_aHighlightLink
;
71 VclPtr
<PopupMenu
> m_pActivePopup
;
72 VclPtr
<PopupMenu
> mpParentPopup
;
73 sal_uInt16 m_nHighlightedItem
;
74 sal_uInt16 m_nRolloveredItem
;
75 VclPtr
<vcl::Window
> m_xSaveFocusId
;
77 bool m_bIgnoreFirstMove
;
81 VclPtr
<DecoToolBox
> m_aCloseBtn
;
82 VclPtr
<PushButton
> m_aFloatBtn
;
83 VclPtr
<PushButton
> m_aHideBtn
;
85 std::map
< sal_uInt16
, AddButtonEntry
> m_aAddButtons
;
87 void HighlightItem(vcl::RenderContext
& rRenderContext
, sal_uInt16 nPos
);
88 void ChangeHighlightItem(sal_uInt16 n
, bool bSelectPopupEntry
, bool bAllowRestoreFocus
= true, bool bDefaultToDocument
= true);
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
);
95 void ImplInitStyleSettings();
97 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
99 DECL_LINK( CloseHdl
, ToolBox
*, void );
100 DECL_LINK( ToolboxEventHdl
, VclWindowEvent
&, void );
101 DECL_LINK( ShowHideListener
, VclWindowEvent
&, void );
103 void StateChanged( StateChangedType nType
) override
;
104 void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
105 void LoseFocus() override
;
106 void GetFocus() override
;
109 explicit MenuBarWindow( vcl::Window
* pParent
);
110 virtual ~MenuBarWindow() override
;
111 virtual void dispose() override
;
113 void ShowButtons(bool bClose
, bool bFloat
, bool bHide
);
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
;
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
;
130 void SetAutoPopup(bool bAuto
) { mbAutoPopup
= bAuto
; }
131 void LayoutChanged();
132 Size
const & MinCloseButtonSize();
134 /// Add an arbitrary button to the menubar that will appear next to the close button.
135 sal_uInt16
AddMenuBarButton(const Image
&, const Link
<MenuBar::MenuBarButtonCallbackArg
&,bool>&, const OUString
&);
136 void SetMenuBarButtonHighlightHdl(sal_uInt16 nId
, const Link
<MenuBar::MenuBarButtonCallbackArg
&,bool>&);
137 tools::Rectangle
GetMenuBarButtonRectPixel(sal_uInt16 nId
);
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;
147 #endif // INCLUDED_VCL_SOURCE_WINDOW_MENUBARWINDOW_HXX
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */