Bump version to 6.4-15
[LibreOffice.git] / include / svx / graphctl.hxx
blob91b8babb261474ef8baf41cd24878d8503671231
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SVX_GRAPHCTL_HXX
20 #define INCLUDED_SVX_GRAPHCTL_HXX
22 #include <vcl/graph.hxx>
23 #include <vcl/customweld.hxx>
24 #include <svx/svxdllapi.h>
26 #include <svx/svdview.hxx>
27 #include <svx/svdobj.hxx>
29 class GraphCtrl;
31 class GraphCtrlUserCall final : public SdrObjUserCall
33 GraphCtrl& rWin;
35 public:
37 GraphCtrlUserCall(GraphCtrl& rGraphWin)
38 : rWin(rGraphWin)
41 virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const tools::Rectangle& rOldBoundRect) override;
44 class SvxGraphCtrlAccessibleContext;
46 class SVX_DLLPUBLIC GraphCtrl : public weld::CustomWidgetController
48 friend class GraphCtrlView;
49 friend class GraphCtrlUserCall;
51 Graphic aGraphic;
52 ScopedVclPtrInstance<VirtualDevice> xVD;
53 Idle aUpdateIdle;
54 Link<GraphCtrl*,void> aMousePosLink;
55 Link<GraphCtrl*,void> aGraphSizeLink;
56 Link<GraphCtrl*,void> aUpdateLink;
57 MapMode const aMap100;
58 Size aGraphSize;
59 Point aMousePos;
60 std::unique_ptr<GraphCtrlUserCall> pUserCall;
61 SdrObjKind eObjKind;
62 sal_uInt16 nPolyEdit;
63 bool bEditMode;
64 bool mbSdrMode;
65 bool mbInIdleUpdate;
66 weld::Dialog* mpDialog;
68 DECL_LINK( UpdateHdl, Timer*, void );
70 rtl::Reference<SvxGraphCtrlAccessibleContext> mpAccContext;
72 protected:
74 std::unique_ptr<SdrModel> pModel;
75 std::unique_ptr<SdrView> pView;
77 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
78 virtual void Resize() override;
79 virtual bool KeyInput(const KeyEvent& rKEvt) override;
80 virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
81 virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
82 virtual bool MouseMove(const MouseEvent& rMEvt) override;
84 virtual void InitSdrModel();
86 virtual void SdrObjCreated( const SdrObject& rObj );
87 virtual void SdrObjChanged( const SdrObject& rObj );
88 virtual void MarkListHasChanged();
90 void GraphicToVD();
92 SdrObjUserCall* GetSdrUserCall() { return pUserCall.get(); }
94 public:
96 GraphCtrl(weld::Dialog* pDialog);
97 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
98 virtual ~GraphCtrl() override;
100 void SetGraphic( const Graphic& rGraphic, bool bNewModel = true );
101 const Graphic& GetGraphic() const { return aGraphic; }
102 const Size& GetGraphicSize() const { return aGraphSize; }
104 const Point& GetMousePos() const { return aMousePos; }
106 void SetEditMode( const bool bEditMode );
108 void SetPolyEditMode( const sal_uInt16 nPolyEdit );
109 sal_uInt16 GetPolyEditMode() const { return nPolyEdit; }
111 void SetObjKind( const SdrObjKind eObjKind );
113 SdrModel* GetSdrModel() const { return pModel.get(); }
114 SdrView* GetSdrView() const { return pView.get(); }
115 SdrObject* GetSelectedSdrObject() const;
116 bool IsChanged() const { return mbSdrMode && pModel->IsChanged(); }
118 void SetMousePosLink( const Link<GraphCtrl*,void>& rLink ) { aMousePosLink = rLink; }
120 void SetGraphSizeLink( const Link<GraphCtrl*,void>& rLink ) { aGraphSizeLink = rLink; }
122 void SetUpdateLink( const Link<GraphCtrl*,void>& rLink ) { aUpdateLink = rLink; }
123 void QueueIdleUpdate();
125 void SetSdrMode(bool b);
127 Point GetPositionInDialog() const;
128 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
131 class GraphCtrlView : public SdrView
133 GraphCtrl& rGraphCtrl;
135 protected:
137 virtual void MarkListHasChanged() override
139 SdrView::MarkListHasChanged();
140 rGraphCtrl.MarkListHasChanged();
143 public:
144 GraphCtrlView(SdrModel& rSdrModel, GraphCtrl* pWindow)
145 : SdrView(rSdrModel, &pWindow->GetDrawingArea()->get_ref_device())
146 , rGraphCtrl(*pWindow)
150 virtual ~GraphCtrlView() override;
152 // override these so we can get the occasions SdrPaintView would call Window::Invalidate on its vcl::Window
153 // if it had one, and route to WidgetController::Invalidate instead
154 virtual rtl::Reference<sdr::overlay::OverlayManager> CreateOverlayManager(OutputDevice& rDevice) const override;
155 virtual void InvalidateOneWin(OutputDevice& rWin) override;
156 virtual void InvalidateOneWin(OutputDevice& rWin, const tools::Rectangle& rRect) override;
159 #endif // INCLUDED_SVX_GRAPHCTL_HXX
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */