Line data Source code
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/ctrl.hxx>
23 : #include <vcl/graph.hxx>
24 : #include <svx/svxdllapi.h>
25 :
26 : #include <svx/svdview.hxx>
27 : #include <svx/svdobj.hxx>
28 :
29 : class GraphCtrlUserCall;
30 : class SvxGraphCtrlAccessibleContext;
31 :
32 : #define WB_SDRMODE ((WinBits)0x0080)
33 : #define WB_ANIMATION ((WinBits)0x0100)
34 :
35 : class SVX_DLLPUBLIC GraphCtrl : public Control
36 : {
37 : friend class GraphCtrlView;
38 : friend class GraphCtrlUserCall;
39 :
40 : Graphic aGraphic;
41 : Idle aUpdateIdle;
42 : Link<> aMousePosLink;
43 : Link<> aGraphSizeLink;
44 : Link<> aMarkObjLink;
45 : Link<> aUpdateLink;
46 : MapMode aMap100;
47 : Size aGraphSize;
48 : Point aMousePos;
49 : GraphCtrlUserCall* pUserCall;
50 : WinBits nWinStyle;
51 : SdrObjKind eObjKind;
52 : sal_uInt16 nPolyEdit;
53 : bool bEditMode;
54 : bool bSdrMode;
55 : bool bAnim;
56 :
57 : DECL_LINK_TYPED( UpdateHdl, Idle*, void );
58 :
59 : SvxGraphCtrlAccessibleContext* mpAccContext;
60 :
61 : protected:
62 :
63 : SdrModel* pModel;
64 : SdrView* pView;
65 :
66 : virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
67 : virtual void Resize() SAL_OVERRIDE;
68 : virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
69 : virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
70 : virtual void MouseButtonUp(const MouseEvent& rMEvt) SAL_OVERRIDE;
71 : virtual void MouseMove(const MouseEvent& rMEvt) SAL_OVERRIDE;
72 :
73 : virtual void InitSdrModel();
74 :
75 : virtual void SdrObjCreated( const SdrObject& rObj );
76 : virtual void SdrObjChanged( const SdrObject& rObj );
77 : virtual void MarkListHasChanged();
78 :
79 : inline SdrObjUserCall* GetSdrUserCall();
80 :
81 : public:
82 :
83 : GraphCtrl( vcl::Window* pParent, WinBits nStyle );
84 : virtual ~GraphCtrl();
85 : virtual void dispose() SAL_OVERRIDE;
86 :
87 : void SetWinStyle( WinBits nWinBits );
88 : WinBits GetWinStyle() const { return nWinStyle; }
89 :
90 : void SetGraphic( const Graphic& rGraphic, bool bNewModel = true );
91 0 : const Graphic& GetGraphic() const { return aGraphic; }
92 0 : const Size& GetGraphicSize() const { return aGraphSize; }
93 :
94 0 : const Point& GetMousePos() const { return aMousePos; }
95 :
96 : void SetEditMode( const bool bEditMode );
97 : bool IsEditMode() const { return bEditMode; }
98 :
99 : void SetPolyEditMode( const sal_uInt16 nPolyEdit );
100 0 : sal_uInt16 GetPolyEditMode() const { return nPolyEdit; }
101 :
102 : void SetObjKind( const SdrObjKind eObjKind );
103 : SdrObjKind GetObjKind() const { return eObjKind; }
104 :
105 0 : SdrModel* GetSdrModel() const { return pModel; }
106 0 : SdrView* GetSdrView() const { return pView; }
107 : SdrObject* GetSelectedSdrObject() const;
108 0 : bool IsChanged() const { return bSdrMode && pModel->IsChanged(); }
109 :
110 0 : void SetMousePosLink( const Link<>& rLink ) { aMousePosLink = rLink; }
111 : const Link<>& GetMousePosLink() const { return aMousePosLink; }
112 :
113 0 : void SetGraphSizeLink( const Link<>& rLink ) { aGraphSizeLink = rLink; }
114 : const Link<>& GetGraphSizeLink() const { return aGraphSizeLink; }
115 :
116 : void SetMarkObjLink( const Link<>& rLink ) { aMarkObjLink = rLink; }
117 : const Link<>& GetMarkObjLink() const { return aMarkObjLink; }
118 :
119 0 : void SetUpdateLink( const Link<>& rLink ) { aUpdateLink = rLink; }
120 : const Link<>& GetUpdateLink() const { return aUpdateLink; }
121 :
122 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
123 : };
124 :
125 :
126 : class GraphCtrlUserCall : public SdrObjUserCall
127 : {
128 : GraphCtrl& rWin;
129 :
130 : public:
131 :
132 0 : GraphCtrlUserCall(GraphCtrl& rGraphWin)
133 0 : : rWin(rGraphWin)
134 0 : {}
135 :
136 0 : virtual ~GraphCtrlUserCall()
137 0 : {}
138 :
139 : virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle& rOldBoundRect) SAL_OVERRIDE;
140 : };
141 :
142 0 : SdrObjUserCall* GraphCtrl::GetSdrUserCall()
143 : {
144 0 : return pUserCall;
145 : }
146 :
147 : class GraphCtrlView : public SdrView
148 : {
149 : GraphCtrl& rGraphCtrl;
150 :
151 : protected:
152 :
153 0 : virtual void MarkListHasChanged() SAL_OVERRIDE
154 : {
155 0 : SdrView::MarkListHasChanged();
156 0 : rGraphCtrl.MarkListHasChanged();
157 0 : }
158 :
159 : public:
160 0 : GraphCtrlView(SdrModel* pModel, GraphCtrl* pWindow)
161 : : SdrView(pModel, pWindow)
162 0 : , rGraphCtrl(*pWindow)
163 0 : {}
164 :
165 0 : virtual ~GraphCtrlView()
166 0 : {}
167 : };
168 :
169 : #endif // INCLUDED_SVX_GRAPHCTL_HXX
170 :
171 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|