/src/libreoffice/sw/source/uibase/inc/PageBreakWin.hxx
Line | Count | Source |
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 | | #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_PAGEBREAKWIN_HXX |
10 | | #define INCLUDED_SW_SOURCE_UIBASE_INC_PAGEBREAKWIN_HXX |
11 | | |
12 | | #include "edtwin.hxx" |
13 | | #include "DashedLine.hxx" |
14 | | #include "FrameControl.hxx" |
15 | | #include <vcl/timer.hxx> |
16 | | #include <optional> |
17 | | |
18 | | namespace weld |
19 | | { |
20 | | class MenuButton; |
21 | | class Toggleable; |
22 | | } |
23 | | |
24 | | class SwPageBreakWin; |
25 | | |
26 | | /** Class for the page break control window. |
27 | | |
28 | | This control shows a line indicating a manual page break and a |
29 | | button providing a few actions on that page break. |
30 | | */ |
31 | | class SwBreakDashedLine final : public SwDashedLine, public ISwFrameControl |
32 | | { |
33 | | private: |
34 | | VclPtr<SwPageBreakWin> m_pWin; |
35 | | VclPtr<SwEditWin> m_pEditWin; |
36 | | std::optional<Point> m_xMousePt; |
37 | | ::tools::Rectangle m_aBtnRect; |
38 | | const SwFrame* m_pFrame; |
39 | | |
40 | | SwPageBreakWin& GetOrCreateWin(); |
41 | | |
42 | | public: |
43 | | SwBreakDashedLine(SwEditWin* pEditWin, const SwFrame *pFrame, const OUString& rText = u""_ustr); |
44 | | |
45 | 0 | virtual ~SwBreakDashedLine() override { disposeOnce(); } |
46 | 0 | virtual void dispose() override { m_pWin.disposeAndClear(); m_pEditWin.reset(); SwDashedLine::dispose(); } |
47 | | |
48 | | virtual void MouseMove(const MouseEvent& rMEvt) override; |
49 | | |
50 | 0 | virtual const SwFrame* GetFrame() override { return m_pFrame; } |
51 | 0 | virtual SwEditWin* GetEditWin() override { return m_pEditWin; } |
52 | | virtual void ShowAll(bool bShow) override; |
53 | | virtual bool Contains(const Point &rDocPt) const override; |
54 | | virtual void SetReadonly(bool bReadonly) override; |
55 | | |
56 | | void execute(std::u16string_view rIdent); |
57 | | |
58 | | virtual FactoryFunction GetUITestFactory() const override; |
59 | | |
60 | | void UpdatePosition(const std::optional<Point>& xEvtPt = std::optional<Point>()); |
61 | | void DestroyWin(); |
62 | | }; |
63 | | |
64 | | class SwPageBreakWin final : public InterimItemWindow |
65 | | { |
66 | | std::unique_ptr<weld::MenuButton> m_xMenuButton; |
67 | | VclPtr<SwBreakDashedLine> m_pLine; |
68 | | VclPtr<SwEditWin> m_pEditWin; |
69 | | ScopedVclPtr<VirtualDevice> m_xVirDev; |
70 | | const SwFrame* m_pFrame; |
71 | | bool m_bIsAppearing; |
72 | | int m_nFadeRate; |
73 | | int m_nDelayAppearing; ///< Before we show the control, let it transparent for a few timer ticks to avoid appearing with every mouse over. |
74 | | Timer m_aFadeTimer; |
75 | | bool m_bDestroyed; |
76 | | |
77 | | public: |
78 | | SwPageBreakWin(SwBreakDashedLine* pLine, SwEditWin* pEditWin, const SwFrame *pFrame); |
79 | | virtual ~SwPageBreakWin() override; |
80 | | virtual void dispose() override; |
81 | | |
82 | | void Fade( bool bFadeIn ); |
83 | | |
84 | | void SetRectanglePixel(const ::tools::Rectangle& rRect); |
85 | | |
86 | | private: |
87 | | DECL_LINK( FadeHandler, Timer *, void ); |
88 | | /// Hide the button when the menu is toggled closed, e.g by clicking outside |
89 | | DECL_LINK(ToggleHdl, weld::Toggleable&, void); |
90 | | DECL_LINK(SelectHdl, const OUString&, void); |
91 | | void PaintButton(); |
92 | | }; |
93 | | |
94 | | #endif |
95 | | |
96 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |