/src/libreoffice/vcl/source/window/menufloatingwindow.hxx
Line | Count | Source (jump to first uncovered line) |
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/floatwin.hxx> |
25 | | #include <vcl/menu.hxx> |
26 | | |
27 | 0 | #define GUTTERBORDER 8 |
28 | | |
29 | | /** Class that implements the actual window of the floating menu. |
30 | | */ |
31 | | class MenuFloatingWindow : public FloatingWindow, public MenuWindow |
32 | | { |
33 | | friend void Menu::ImplFillLayoutData() const; |
34 | | friend void Menu::dispose(); |
35 | | |
36 | | private: |
37 | | VclPtr<PopupMenu> pMenu; |
38 | | VclPtr<PopupMenu> pActivePopup; |
39 | | Timer aHighlightChangedTimer; |
40 | | Timer aSubmenuCloseTimer; |
41 | | Timer aScrollTimer; |
42 | | VclPtr<vcl::Window> xSaveFocusId; |
43 | | sal_uInt16 nHighlightedItem; // highlighted/selected Item |
44 | | sal_uInt16 nMBDownPos; |
45 | | sal_uInt16 nScrollerHeight; |
46 | | sal_uInt16 nFirstEntry; |
47 | | sal_uInt16 nPosInParent; |
48 | | |
49 | | bool bInExecute : 1; |
50 | | bool bScrollMenu : 1; |
51 | | bool bScrollUp : 1; |
52 | | bool bScrollDown : 1; |
53 | | bool bIgnoreFirstMove : 1; |
54 | | bool bKeyInput : 1; |
55 | | |
56 | | DECL_LINK( PopupEnd, FloatingWindow*, void ); |
57 | | DECL_LINK( HighlightChanged, Timer*, void ); |
58 | | DECL_LINK( SubmenuClose, Timer *, void ); |
59 | | DECL_LINK( AutoScroll, Timer *, void ); |
60 | | DECL_LINK( ShowHideListener, VclWindowEvent&, void ); |
61 | | |
62 | | virtual void StateChanged( StateChangedType nType ) override; |
63 | | virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; |
64 | | |
65 | | void InitMenuClipRegion(vcl::RenderContext& rRenderContext); |
66 | | |
67 | | void Start(); |
68 | | void End(); |
69 | | |
70 | | protected: |
71 | | vcl::Region ImplCalcClipRegion() const; |
72 | | void ImplDrawScroller(vcl::RenderContext& rRenderContext, bool bUp); |
73 | | using Window::ImplScroll; |
74 | | void ImplScroll( const Point& rMousePos ); |
75 | | void ImplScroll( bool bUp ); |
76 | | void ImplCursorUpDown( bool bUp, bool bHomeEnd = false ); |
77 | | void ImplHighlightItem( const MouseEvent& rMEvt, bool bMBDown ); |
78 | | tools::Long ImplGetStartY() const; |
79 | | tools::Rectangle ImplGetItemRect( sal_uInt16 nPos ) const; |
80 | | void RenderHighlightItem( vcl::RenderContext& rRenderContext, sal_uInt16 nPos ); |
81 | | tools::Long GetInitialItemY( tools::Long *pOptStartY = nullptr ) const; |
82 | | void InvalidateItem( sal_uInt16 nPos ); |
83 | | |
84 | | public: |
85 | | MenuFloatingWindow(PopupMenu* pMenu, vcl::Window* pParent, WinBits nStyle); |
86 | | virtual ~MenuFloatingWindow() override; |
87 | | |
88 | | virtual void dispose() override; |
89 | | void doShutdown(); |
90 | | |
91 | | virtual void MouseMove(const MouseEvent& rMEvt) override; |
92 | | virtual void MouseButtonDown(const MouseEvent& rMEvt) override; |
93 | | virtual void MouseButtonUp(const MouseEvent& rMEvt) override; |
94 | | virtual void KeyInput(const KeyEvent& rKEvent) override; |
95 | | virtual void Command(const CommandEvent& rCEvt) override; |
96 | | virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; |
97 | | virtual void RequestHelp( const HelpEvent& rHEvt ) override; |
98 | | virtual void Resize() override; |
99 | | |
100 | | virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; |
101 | | |
102 | 0 | void SetFocusId( const VclPtr<vcl::Window>& xId ) { xSaveFocusId = xId; } |
103 | 0 | const VclPtr<vcl::Window>& GetFocusId() const { return xSaveFocusId; } |
104 | | |
105 | | void EnableScrollMenu( bool b ); |
106 | 0 | bool IsScrollMenu() const { return bScrollMenu; } |
107 | 0 | sal_uInt16 GetScrollerHeight() const { return nScrollerHeight; } |
108 | | |
109 | | void Execute(); |
110 | | void StopExecute(); |
111 | | void EndExecute(); |
112 | | void EndExecute( sal_uInt16 nSelectId ); |
113 | | |
114 | 0 | PopupMenu* GetActivePopup() const { return pActivePopup; } |
115 | | void KillActivePopup(); |
116 | | |
117 | | void ChangeHighlightItem(sal_uInt16 n, bool bStartPopupTimer); |
118 | 0 | sal_uInt16 GetHighlightedItem() const { return nHighlightedItem; } |
119 | | |
120 | 0 | void SetPosInParent( sal_uInt16 nPos ) { nPosInParent = nPos; } |
121 | | |
122 | | bool MenuInHierarchyHasFocus() const; |
123 | | |
124 | | virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override; |
125 | | }; |
126 | | |
127 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |