/src/libreoffice/include/svx/weldeditview.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 | | */ |
10 | | |
11 | | #pragma once |
12 | | |
13 | | #include <sal/config.h> |
14 | | #include <svx/svxdllapi.h> |
15 | | #include <editeng/editeng.hxx> |
16 | | #include <editeng/editview.hxx> |
17 | | #include <vcl/outdev.hxx> |
18 | | #include <vcl/timer.hxx> |
19 | | #include <vcl/virdev.hxx> |
20 | | #include <vcl/weld/customweld.hxx> |
21 | | |
22 | | class WeldEditAccessible; |
23 | | |
24 | | class SVX_DLLPUBLIC WeldEditView : public weld::CustomWidgetController, public EditViewCallbacks |
25 | | { |
26 | | public: |
27 | | WeldEditView(); |
28 | | virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; |
29 | | virtual int GetSurroundingText(OUString& rSurrounding) override; |
30 | | virtual bool DeleteSurroundingText(const Selection& rRange) override; |
31 | | |
32 | | void SetText(const OUString& rStr); |
33 | | |
34 | | OUString GetText() const; |
35 | | |
36 | | virtual FactoryFunction GetUITestFactory() const override; |
37 | | |
38 | | void SetModifyHdl(const Link<LinkParamNone*, void>& rLink); |
39 | | |
40 | | virtual EditView* GetEditView() const; |
41 | | virtual EditEngine* GetEditEngine() const; |
42 | | |
43 | | bool HasSelection() const; |
44 | | |
45 | | void Delete(); |
46 | | void Cut(); |
47 | | void Copy(); |
48 | | void Paste(); |
49 | | |
50 | | virtual ~WeldEditView() override; |
51 | | |
52 | | protected: |
53 | | bool m_bAcceptsTab; |
54 | | // m_xDropTarget must outlive m_xEditView |
55 | | css::uno::Reference<css::datatransfer::dnd::XDropTarget> m_xDropTarget; |
56 | | std::unique_ptr<EditEngine> m_xEditEngine; |
57 | | std::unique_ptr<EditView> m_xEditView; |
58 | | rtl::Reference<WeldEditAccessible> m_xAccessible; |
59 | | |
60 | | // Cursor blink support |
61 | | AutoTimer m_aCursorTimer; |
62 | | bool m_bCursorVisible; |
63 | | tools::Rectangle m_aCachedCursorPixRect; // pixel coords of cached cursor area |
64 | | ScopedVclPtrInstance<VirtualDevice> m_xCursorOnDev; |
65 | | ScopedVclPtrInstance<VirtualDevice> m_xCursorOffDev; |
66 | | DECL_DLLPRIVATE_LINK(BlinkTimerHdl, Timer*, void); |
67 | | |
68 | | virtual void makeEditEngine(); |
69 | | |
70 | | void InitAccessible(); |
71 | | |
72 | | static void PaintSelection(vcl::RenderContext& rRenderContext, tools::Rectangle const& rRect, |
73 | | std::vector<tools::Rectangle> const& rLogicRects, Color const color); |
74 | | void DoPaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); |
75 | | |
76 | | public: |
77 | | virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; |
78 | | virtual bool MouseMove(const MouseEvent& rMEvt) override; |
79 | | virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; |
80 | | virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; |
81 | | virtual bool KeyInput(const KeyEvent& rKEvt) override; |
82 | | virtual bool Command(const CommandEvent& rCEvt) override; |
83 | | virtual bool CanFocus() const; |
84 | | virtual void GetFocus() override; |
85 | | virtual void LoseFocus() override; |
86 | | virtual void Resize() override; |
87 | | |
88 | | virtual css::uno::Reference<css::datatransfer::clipboard::XClipboard> |
89 | | GetClipboard() const override; |
90 | | virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> GetDropTarget() override; |
91 | | |
92 | | // Whether Tab will result in entering a tab or not |
93 | 0 | bool GetAcceptsTab() const { return m_bAcceptsTab; } |
94 | | |
95 | 0 | void SetAcceptsTab(bool bAcceptsTab) { m_bAcceptsTab = bAcceptsTab; } |
96 | | |
97 | | protected: |
98 | | virtual rtl::Reference<comphelper::OAccessible> CreateAccessible() override; |
99 | | |
100 | 0 | virtual void EditViewInvalidate(const tools::Rectangle& rRect) override { Invalidate(rRect); } |
101 | | |
102 | | virtual void EditViewSelectionChange() override; |
103 | | |
104 | | virtual OutputDevice& EditViewOutputDevice() const override |
105 | 0 | { |
106 | 0 | return GetDrawingArea()->get_ref_device(); |
107 | 0 | } |
108 | | |
109 | | virtual Point EditViewPointerPosPixel() const override; |
110 | | |
111 | | virtual void EditViewInputContext(const InputContext& rInputContext) override |
112 | 0 | { |
113 | 0 | SetInputContext(rInputContext); |
114 | 0 | } |
115 | | |
116 | | virtual void EditViewCursorRect(const tools::Rectangle& rRect, int nExtTextInputWidth) override |
117 | 0 | { |
118 | 0 | OutputDevice& rRefDevice = EditViewOutputDevice(); |
119 | 0 | SetCursorRect(rRefDevice.LogicToPixel(rRect), |
120 | 0 | rRefDevice.LogicToPixel(Size(nExtTextInputWidth, 0)).Width()); |
121 | 0 | } |
122 | | |
123 | 0 | virtual weld::Widget* EditViewPopupParent() const override { return GetDrawingArea(); } |
124 | | }; |
125 | | |
126 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |