LibreOffice Module vcl (master)  1
menufloatingwindow.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_MENUFLOATINGWINDOW_HXX
21 #define INCLUDED_VCL_SOURCE_WINDOW_MENUFLOATINGWINDOW_HXX
22 
23 #include "menuwindow.hxx"
24 
25 #include <vcl/floatwin.hxx>
26 #include <vcl/menu.hxx>
27 
28 #define EXTRASPACEY 2
29 #define GUTTERBORDER 8
30 
34 {
35  friend void Menu::ImplFillLayoutData() const;
36  friend void Menu::dispose();
37 
38 private:
45  sal_uInt16 nHighlightedItem; // highlighted/selected Item
46  sal_uInt16 nMBDownPos;
47  sal_uInt16 nScrollerHeight;
48  sal_uInt16 nFirstEntry;
49  sal_uInt16 nPosInParent;
50 
51  bool bInExecute : 1;
52  bool bScrollMenu : 1;
53  bool bScrollUp : 1;
54  bool bScrollDown : 1;
55  bool bIgnoreFirstMove : 1;
56  bool bKeyInput : 1;
57 
58  DECL_LINK( PopupEnd, FloatingWindow*, void );
59  DECL_LINK( HighlightChanged, Timer*, void );
60  DECL_LINK( SubmenuClose, Timer *, void );
61  DECL_LINK( AutoScroll, Timer *, void );
62  DECL_LINK( ShowHideListener, VclWindowEvent&, void );
63 
64  virtual void StateChanged( StateChangedType nType ) override;
65  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
66 
67  void InitMenuClipRegion(vcl::RenderContext& rRenderContext);
68 
69  void Start();
70  void End();
71 
72 protected:
74  void ImplDrawScroller(vcl::RenderContext& rRenderContext, bool bUp);
75  using Window::ImplScroll;
76  void ImplScroll( const Point& rMousePos );
77  void ImplScroll( bool bUp );
78  void ImplCursorUpDown( bool bUp, bool bHomeEnd = false );
79  void ImplHighlightItem( const MouseEvent& rMEvt, bool bMBDown );
80  long ImplGetStartY() const;
81  tools::Rectangle ImplGetItemRect( sal_uInt16 nPos );
82  void RenderHighlightItem( vcl::RenderContext& rRenderContext, sal_uInt16 nPos );
83  long GetInitialItemY( long *pOptStartY = nullptr ) const;
84  void InvalidateItem( sal_uInt16 nPos );
85 
86 public:
87  MenuFloatingWindow(Menu* pMenu, vcl::Window* pParent, WinBits nStyle);
88  virtual ~MenuFloatingWindow() override;
89 
90  virtual void dispose() override;
91  void doShutdown();
92 
93  virtual void MouseMove(const MouseEvent& rMEvt) override;
94  virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
95  virtual void MouseButtonUp(const MouseEvent& rMEvt) override;
96  virtual void KeyInput(const KeyEvent& rKEvent) override;
97  virtual void Command(const CommandEvent& rCEvt) override;
98  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
99  virtual void RequestHelp( const HelpEvent& rHEvt ) override;
100  virtual void Resize() override;
101 
102  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
103 
104  void SetFocusId( const VclPtr<vcl::Window>& xId ) { xSaveFocusId = xId; }
105  const VclPtr<vcl::Window>& GetFocusId() const { return xSaveFocusId; }
106 
107  void EnableScrollMenu( bool b );
108  bool IsScrollMenu() const { return bScrollMenu; }
109  sal_uInt16 GetScrollerHeight() const { return nScrollerHeight; }
110 
111  void Execute();
112  void StopExecute();
113  void EndExecute();
114  void EndExecute( sal_uInt16 nSelectId );
115 
116  PopupMenu* GetActivePopup() const { return pActivePopup; }
117  void KillActivePopup( PopupMenu* pThisOnly = nullptr );
118 
119  void ChangeHighlightItem(sal_uInt16 n, bool bStartPopupTimer);
120  sal_uInt16 GetHighlightedItem() const { return nHighlightedItem; }
121 
122  void SetPosInParent( sal_uInt16 nPos ) { nPosInParent = nPos; }
123 
124  bool MenuInHierarchyHasFocus() const;
125 
126  virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
127 };
128 
129 #endif // INCLUDED_VCL_SOURCE_WINDOW_MENUFLOATINGWINDOW_HXX
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void StateChanged(StateChangedType nType) override
VclPtr< vcl::Window > xSaveFocusId
void RenderHighlightItem(vcl::RenderContext &rRenderContext, sal_uInt16 nPos)
void ImplHighlightItem(const MouseEvent &rMEvt, bool bMBDown)
void InvalidateItem(sal_uInt16 nPos)
Emit an Invalidate just for this item's area.
tools::Rectangle ImplGetItemRect(sal_uInt16 nPos)
void ChangeHighlightItem(sal_uInt16 n, bool bStartPopupTimer)
VclPtr< PopupMenu > pActivePopup
DECL_LINK(PopupEnd, FloatingWindow *, void)
PopupMenu * GetActivePopup() const
virtual void Resize() override
MenuFloatingWindow(Menu *pMenu, vcl::Window *pParent, WinBits nStyle)
StateChangedType
Definition: window.hxx:311
bool MenuInHierarchyHasFocus() const
sal_Int64 WinBits
long GetInitialItemY(long *pOptStartY=nullptr) const
Calculate the initial vertical pixel offset of the first item.
Class that implements the actual window of the floating menu.
void KillActivePopup(PopupMenu *pThisOnly=nullptr)
sal_uInt16 GetHighlightedItem() const
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
const VclPtr< vcl::Window > & GetFocusId() const
void InitMenuClipRegion(vcl::RenderContext &rRenderContext)
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
sal_uInt16 GetScrollerHeight() const
void ImplScroll(const Point &rMousePos)
void ImplDrawScroller(vcl::RenderContext &rRenderContext, bool bUp)
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
vcl::Region ImplCalcClipRegion() const
Common ancestor for MenuFloatingWindow and MenuBarWindow.
Definition: menuwindow.hxx:49
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
virtual void RequestHelp(const HelpEvent &rHEvt) override
virtual ~MenuFloatingWindow() override
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
void SetPosInParent(sal_uInt16 nPos)
void ImplCursorUpDown(bool bUp, bool bHomeEnd=false)
Definition: menu.hxx:121
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
void SetFocusId(const VclPtr< vcl::Window > &xId)
SAL_DLLPRIVATE void ImplFillLayoutData() const
Definition: menu.cxx:2214
virtual void Command(const CommandEvent &rCEvt) override
Definition: timer.hxx:26
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
virtual void KeyInput(const KeyEvent &rKEvent) override
long ImplGetStartY() const
Get a negative pixel offset for an offset menu.
virtual void dispose() override
Definition: menu.cxx:180
virtual void MouseMove(const MouseEvent &rMEvt) override