/src/libreoffice/include/svx/graphctl.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 | | * 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 | | #ifndef INCLUDED_SVX_GRAPHCTL_HXX |
20 | | #define INCLUDED_SVX_GRAPHCTL_HXX |
21 | | |
22 | | #include <vcl/graph.hxx> |
23 | | #include <vcl/weld/Dialog.hxx> |
24 | | #include <vcl/weld/customweld.hxx> |
25 | | #include <svx/svxdllapi.h> |
26 | | |
27 | | #include <svx/svdview.hxx> |
28 | | #include <svx/svdobj.hxx> |
29 | | |
30 | | class GraphCtrl; |
31 | | |
32 | | class GraphCtrlUserCall final : public SdrObjUserCall |
33 | | { |
34 | | GraphCtrl& m_rWin; |
35 | | |
36 | | public: |
37 | | |
38 | | GraphCtrlUserCall(GraphCtrl& rGraphWin) |
39 | 0 | : m_rWin(rGraphWin) |
40 | 0 | {} |
41 | | |
42 | | virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const tools::Rectangle& rOldBoundRect) override; |
43 | | }; |
44 | | |
45 | | class SvxGraphCtrlAccessibleContext; |
46 | | |
47 | | class SAL_DLLPUBLIC_RTTI GraphCtrl : public weld::CustomWidgetController |
48 | | { |
49 | | friend class GraphCtrlView; |
50 | | friend class GraphCtrlUserCall; |
51 | | |
52 | | Graphic maGraphic; |
53 | | ScopedVclPtrInstance<VirtualDevice> mxVD; |
54 | | Idle maUpdateIdle; |
55 | | Link<GraphCtrl*,void> maMousePosLink; |
56 | | Link<GraphCtrl*,void> maGraphSizeLink; |
57 | | Link<GraphCtrl*,void> maUpdateLink; |
58 | | MapMode maMap100; |
59 | | Size maGraphSize; |
60 | | Point maMousePos; |
61 | | std::unique_ptr<GraphCtrlUserCall> mpUserCall; |
62 | | SdrObjKind meObjKind; |
63 | | sal_uInt16 mnPolyEdit; |
64 | | bool mbEditMode; |
65 | | bool mbSdrMode; |
66 | | bool mbInIdleUpdate; |
67 | | weld::Dialog* mpDialog; |
68 | | |
69 | | DECL_LINK( UpdateHdl, Timer*, void ); |
70 | | |
71 | | rtl::Reference<SvxGraphCtrlAccessibleContext> mpAccContext; |
72 | | |
73 | | protected: |
74 | | |
75 | | std::unique_ptr<SdrModel> mpModel; |
76 | | std::unique_ptr<SdrView> mpView; |
77 | | |
78 | | virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; |
79 | | virtual void Resize() override; |
80 | | virtual bool KeyInput(const KeyEvent& rKEvt) override; |
81 | | virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; |
82 | | virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; |
83 | | virtual bool MouseMove(const MouseEvent& rMEvt) override; |
84 | | |
85 | | virtual void InitSdrModel(); |
86 | | |
87 | | virtual void SdrObjCreated( const SdrObject& rObj ); |
88 | | virtual void SdrObjChanged( const SdrObject& rObj ); |
89 | | virtual void MarkListHasChanged(); |
90 | | |
91 | | void GraphicToVD(); |
92 | | |
93 | 0 | SdrObjUserCall* GetSdrUserCall() { return mpUserCall.get(); } |
94 | | |
95 | | public: |
96 | | |
97 | | SVX_DLLPUBLIC GraphCtrl(weld::Dialog* pDialog); |
98 | | virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; |
99 | | SVX_DLLPUBLIC virtual ~GraphCtrl() override; |
100 | | |
101 | | SVX_DLLPUBLIC void SetGraphic( const Graphic& rGraphic, bool bNewModel = true ); |
102 | 0 | const Graphic& GetGraphic() const { return maGraphic; } |
103 | 0 | const Size& GetGraphicSize() const { return maGraphSize; } |
104 | | |
105 | 0 | const Point& GetMousePos() const { return maMousePos; } |
106 | | |
107 | | void SetEditMode( const bool bEditMode ); |
108 | | |
109 | | void SetPolyEditMode( const sal_uInt16 nPolyEdit ); |
110 | 0 | sal_uInt16 GetPolyEditMode() const { return mnPolyEdit; } |
111 | | |
112 | | void SetObjKind( const SdrObjKind eObjKind ); |
113 | | |
114 | 0 | SdrModel* GetSdrModel() const { return mpModel.get(); } |
115 | 0 | SdrView* GetSdrView() const { return mpView.get(); } |
116 | | SdrObject* GetSelectedSdrObject() const; |
117 | 0 | bool IsChanged() const { return mbSdrMode && mpModel->IsChanged(); } |
118 | | |
119 | 0 | void SetMousePosLink( const Link<GraphCtrl*,void>& rLink ) { maMousePosLink = rLink; } |
120 | | |
121 | 0 | void SetGraphSizeLink( const Link<GraphCtrl*,void>& rLink ) { maGraphSizeLink = rLink; } |
122 | | |
123 | 0 | void SetUpdateLink( const Link<GraphCtrl*,void>& rLink ) { maUpdateLink = rLink; } |
124 | | void QueueIdleUpdate(); |
125 | | |
126 | | void SetSdrMode(bool b); |
127 | | |
128 | | Point GetPositionInDialog() const; |
129 | | virtual rtl::Reference<comphelper::OAccessible> CreateAccessible() override; |
130 | | }; |
131 | | |
132 | | class GraphCtrlView final : public SdrView |
133 | | { |
134 | | GraphCtrl& m_rGraphCtrl; |
135 | | |
136 | | virtual void MarkListHasChanged() override |
137 | 0 | { |
138 | 0 | SdrView::MarkListHasChanged(); |
139 | 0 | m_rGraphCtrl.MarkListHasChanged(); |
140 | 0 | } |
141 | | |
142 | | public: |
143 | | GraphCtrlView(SdrModel& rSdrModel, GraphCtrl* pWindow) |
144 | 0 | : SdrView(rSdrModel, &pWindow->GetDrawingArea()->get_ref_device()) |
145 | 0 | , m_rGraphCtrl(*pWindow) |
146 | 0 | { |
147 | 0 | } |
148 | | |
149 | | virtual ~GraphCtrlView() override; |
150 | | |
151 | | // override these so we can get the occasions SdrPaintView would call Window::Invalidate on its vcl::Window |
152 | | // if it had one, and route to WidgetController::Invalidate instead |
153 | | virtual rtl::Reference<sdr::overlay::OverlayManager> CreateOverlayManager(OutputDevice& rDevice) const override; |
154 | | virtual void InvalidateOneWin(OutputDevice& rWin) override; |
155 | | virtual void InvalidateOneWin(OutputDevice& rWin, const tools::Rectangle& rRect) override; |
156 | | }; |
157 | | |
158 | | #endif // INCLUDED_SVX_GRAPHCTL_HXX |
159 | | |
160 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |