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 #ifndef INCLUDED_SVX_WELDEDITVIEW_HXX
12 #define INCLUDED_SVX_WELDEDITVIEW_HXX
13 
14 #include <sal/config.h>
15 #include <svx/svxdllapi.h>
16 #include <editeng/editeng.hxx>
17 #include <editeng/editview.hxx>
18 #include <vcl/customweld.hxx>
19 #include <vcl/outdev.hxx>
20 
21 class WeldEditAccessible;
22 
23 class SVX_DLLPUBLIC WeldEditView : public weld::CustomWidgetController, public EditViewCallbacks
24 {
25 public:
26     WeldEditView();
27     virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
28 
SetText(const OUString & rStr)29     void SetText(const OUString& rStr) { m_xEditEngine->SetText(rStr); }
30 
GetText() const31     OUString GetText() const { return m_xEditEngine->GetText(); }
32 
SetModifyHdl(const Link<LinkParamNone *,void> & rLink)33     void SetModifyHdl(const Link<LinkParamNone*, void>& rLink)
34     {
35         m_xEditEngine->SetModifyHdl(rLink);
36     }
37 
GetEditEngine()38     EditEngine& GetEditEngine() { return *m_xEditEngine; }
39 
40     virtual ~WeldEditView() override;
41 
42 protected:
43     std::unique_ptr<EditEngine> m_xEditEngine;
44     std::unique_ptr<EditView> m_xEditView;
45     rtl::Reference<WeldEditAccessible> m_xAccessible;
46 
47     virtual void makeEditEngine();
48 
49     virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
50     virtual bool MouseMove(const MouseEvent& rMEvt) override;
51     virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
52     virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
53     virtual bool KeyInput(const KeyEvent& rKEvt) override;
54     virtual bool Command(const CommandEvent& rCEvt) override;
55     virtual void GetFocus() override;
56     virtual void LoseFocus() override;
57     virtual void Resize() override;
58 
59     virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
60 
EditViewInvalidate(const tools::Rectangle & rRect) const61     virtual void EditViewInvalidate(const tools::Rectangle& rRect) const override
62     {
63         weld::DrawingArea* pDrawingArea = GetDrawingArea();
64         pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(),
65                                       rRect.GetHeight());
66     }
67 
EditViewSelectionChange() const68     virtual void EditViewSelectionChange() const override
69     {
70         weld::DrawingArea* pDrawingArea = GetDrawingArea();
71         pDrawingArea->queue_draw();
72     }
73 
EditViewOutputDevice() const74     virtual OutputDevice& EditViewOutputDevice() const override
75     {
76         return GetDrawingArea()->get_ref_device();
77     }
78 };
79 
80 #endif // INCLUDED_SVX_WELDEDITVIEW_HXX
81 
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
83