LibreOffice Module svx (master)  1
graphctl.hxx
Go to the documentation of this file.
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/customweld.hxx>
24 #include <svx/svxdllapi.h>
25 
26 #include <svx/svdview.hxx>
27 #include <svx/svdobj.hxx>
28 
29 class GraphCtrl;
30 
31 class GraphCtrlUserCall final : public SdrObjUserCall
32 {
34 
35 public:
36 
38  : rWin(rGraphWin)
39  {}
40 
41  virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const tools::Rectangle& rOldBoundRect) override;
42 };
43 
45 
47 {
48  friend class GraphCtrlView;
49  friend class GraphCtrlUserCall;
50 
60  std::unique_ptr<GraphCtrlUserCall> pUserCall;
62  sal_uInt16 nPolyEdit;
63  bool bEditMode;
64  bool mbSdrMode;
67 
68  DECL_LINK( UpdateHdl, Timer*, void );
69 
71 
72 protected:
73 
74  std::unique_ptr<SdrModel> pModel;
75  std::unique_ptr<SdrView> pView;
76 
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;
83 
84  virtual void InitSdrModel();
85 
86  virtual void SdrObjCreated( const SdrObject& rObj );
87  virtual void SdrObjChanged( const SdrObject& rObj );
88  virtual void MarkListHasChanged();
89 
90  void GraphicToVD();
91 
92  SdrObjUserCall* GetSdrUserCall() { return pUserCall.get(); }
93 
94 public:
95 
96  GraphCtrl(weld::Dialog* pDialog);
97  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
98  virtual ~GraphCtrl() override;
99 
100  void SetGraphic( const Graphic& rGraphic, bool bNewModel = true );
101  const Graphic& GetGraphic() const { return aGraphic; }
102  const Size& GetGraphicSize() const { return aGraphSize; }
103 
104  const Point& GetMousePos() const { return aMousePos; }
105 
106  void SetEditMode( const bool bEditMode );
107 
108  void SetPolyEditMode( const sal_uInt16 nPolyEdit );
109  sal_uInt16 GetPolyEditMode() const { return nPolyEdit; }
110 
111  void SetObjKind( const SdrObjKind eObjKind );
112 
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(); }
117 
118  void SetMousePosLink( const Link<GraphCtrl*,void>& rLink ) { aMousePosLink = rLink; }
119 
120  void SetGraphSizeLink( const Link<GraphCtrl*,void>& rLink ) { aGraphSizeLink = rLink; }
121 
122  void SetUpdateLink( const Link<GraphCtrl*,void>& rLink ) { aUpdateLink = rLink; }
123  void QueueIdleUpdate();
124 
125  void SetSdrMode(bool b);
126 
127  Point GetPositionInDialog() const;
128  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
129 };
130 
131 class GraphCtrlView : public SdrView
132 {
134 
135 protected:
136 
137  virtual void MarkListHasChanged() override
138  {
140  rGraphCtrl.MarkListHasChanged();
141  }
142 
143 public:
144  GraphCtrlView(SdrModel& rSdrModel, GraphCtrl* pWindow)
145  : SdrView(rSdrModel, &pWindow->GetDrawingArea()->get_ref_device())
146  , rGraphCtrl(*pWindow)
147  {
148  }
149 
150  virtual ~GraphCtrlView() override;
151 
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
155  virtual void InvalidateOneWin(OutputDevice& rWin) override;
156  virtual void InvalidateOneWin(OutputDevice& rWin, const tools::Rectangle& rRect) override;
157 };
158 
159 #endif // INCLUDED_SVX_GRAPHCTL_HXX
160 
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< GraphCtrlUserCall > pUserCall
Definition: graphctl.hxx:60
const Graphic & GetGraphic() const
Definition: graphctl.hxx:101
sal_uInt16 nPolyEdit
Definition: graphctl.hxx:62
std::unique_ptr< SdrModel > pModel
Definition: graphctl.hxx:74
Link< GraphCtrl *, void > aUpdateLink
Definition: graphctl.hxx:56
virtual rtl::Reference< sdr::overlay::OverlayManager > CreateOverlayManager(OutputDevice &rDevice) const override
Definition: graphctl.cxx:776
SdrUserCallType
Definition: svdobj.hxx:166
virtual bool MouseButtonUp(const MouseEvent &)
virtual void MarkListHasChanged() override
Definition: graphctl.hxx:137
sal_uInt16 GetPolyEditMode() const
Definition: graphctl.hxx:109
virtual void MarkListHasChanged()
Definition: graphctl.cxx:273
Graphic aGraphic
Definition: graphctl.hxx:51
virtual bool MouseMove(const MouseEvent &)
void SetUpdateLink(const Link< GraphCtrl *, void > &rLink)
Definition: graphctl.hxx:122
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
SdrObjUserCall * GetSdrUserCall()
Definition: graphctl.hxx:92
virtual void MarkListHasChanged() override
Definition: svdedxv.cxx:2468
virtual void Changed(const SdrObject &rObj, SdrUserCallType eType, const tools::Rectangle &rOldBoundRect) override
Definition: graphctl.cxx:32
rtl::Reference< SvxGraphCtrlAccessibleContext > mpAccContext
Definition: graphctl.hxx:70
virtual void InvalidateOneWin(OutputDevice &rWin) override
If the View should not call Invalidate() on the windows, override the following 2 methods and do some...
Definition: graphctl.cxx:788
const Size & GetGraphicSize() const
Definition: graphctl.hxx:102
bool mbInIdleUpdate
Definition: graphctl.hxx:65
void SetMousePosLink(const Link< GraphCtrl *, void > &rLink)
Definition: graphctl.hxx:118
ScopedVclPtrInstance< VirtualDevice > xVD
Definition: graphctl.hxx:52
DocumentType eType
weld::Dialog * mpDialog
Definition: graphctl.hxx:66
MapMode aMap100
Definition: graphctl.hxx:57
SdrView * GetSdrView() const
Definition: graphctl.hxx:114
GraphCtrlUserCall(GraphCtrl &rGraphWin)
Definition: graphctl.hxx:37
Link< GraphCtrl *, void > aMousePosLink
Definition: graphctl.hxx:54
SdrModel * GetSdrModel() const
Definition: graphctl.hxx:113
virtual bool KeyInput(const KeyEvent &)
Abstract DrawObject.
Definition: svdobj.hxx:312
bool bEditMode
Definition: graphctl.hxx:63
void SetGraphSizeLink(const Link< GraphCtrl *, void > &rLink)
Definition: graphctl.hxx:120
DECL_LINK(DragBeginHdl, weld::DrawingArea &, bool)
SdrObjKind
Definition: svdobj.hxx:116
virtual ~GraphCtrlView() override
Definition: graphctl.cxx:810
virtual bool MouseButtonDown(const MouseEvent &)
SdrObjKind eObjKind
Definition: graphctl.hxx:61
GraphCtrlView(SdrModel &rSdrModel, GraphCtrl *pWindow)
Definition: graphctl.hxx:144
std::unique_ptr< SdrView > pView
Definition: graphctl.hxx:75
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
Idle aUpdateIdle
Definition: graphctl.hxx:53
Point aMousePos
Definition: graphctl.hxx:59
bool mbSdrMode
Definition: graphctl.hxx:64
Link< GraphCtrl *, void > aGraphSizeLink
Definition: graphctl.hxx:55
GraphCtrl & rGraphCtrl
Definition: graphctl.hxx:133
GraphCtrl & rWin
Definition: graphctl.hxx:33
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)=0
bool IsChanged() const
Definition: graphctl.hxx:116
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
Size aGraphSize
Definition: graphctl.hxx:58
const Point & GetMousePos() const
Definition: graphctl.hxx:104