1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _GRAPHCTL_HXX 24 #define _GRAPHCTL_HXX 25 26 // include --------------------------------------------------------------- 27 28 #include <vcl/ctrl.hxx> 29 #include <vcl/graph.hxx> 30 #include "svx/svxdllapi.h" 31 32 #include <svx/svdview.hxx> 33 #include <svx/svdobj.hxx> 34 35 /************************************************************************* 36 |* 37 |* 38 |* 39 \************************************************************************/ 40 41 class GraphCtrlUserCall; 42 class SvxGraphCtrlAccessibleContext; 43 44 #define WB_SDRMODE ((WinBits)0x0080) 45 #define WB_ANIMATION ((WinBits)0x0100) 46 47 class SVX_DLLPUBLIC GraphCtrl : public Control 48 { 49 friend class GraphCtrlView; 50 friend class GraphCtrlUserCall; 51 52 Graphic aGraphic; 53 Timer aUpdateTimer; 54 Link aMousePosLink; 55 Link aGraphSizeLink; 56 Link aMarkObjLink; 57 Link aUpdateLink; 58 MapMode aMap100; 59 Size aGraphSize; 60 Point aMousePos; 61 GraphCtrlUserCall* pUserCall; 62 WinBits nWinStyle; 63 SdrObjKind eObjKind; 64 sal_uInt16 nPolyEdit; 65 sal_Bool bEditMode; 66 sal_Bool bSdrMode; 67 sal_Bool bAnim; 68 69 DECL_LINK( UpdateHdl, Timer* ); 70 71 SvxGraphCtrlAccessibleContext* mpAccContext; 72 73 protected: 74 75 SdrModel* pModel; 76 SdrView* pView; 77 78 virtual void Paint( const Rectangle& rRect ); 79 virtual void Resize(); 80 virtual void KeyInput(const KeyEvent& rKEvt); 81 virtual void MouseButtonDown(const MouseEvent& rMEvt); 82 virtual void MouseButtonUp(const MouseEvent& rMEvt); 83 virtual void MouseMove(const MouseEvent& rMEvt); 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 GetSdrUserCall()91 SdrObjUserCall* GetSdrUserCall() { return (SdrObjUserCall*) pUserCall; } 92 93 public: 94 95 GraphCtrl( Window* pParent, const WinBits nWinBits = 0 ); 96 GraphCtrl( Window* pParent, const ResId& rResId ); 97 ~GraphCtrl(); 98 99 void SetWinStyle( WinBits nWinBits ); GetWinStyle() const100 WinBits GetWinStyle() const { return nWinStyle; } 101 102 void SetGraphic( const Graphic& rGraphic, sal_Bool bNewModel = sal_True ); GetGraphic() const103 const Graphic& GetGraphic() const { return aGraphic; } GetGraphicSize() const104 const Size& GetGraphicSize() const { return aGraphSize; } 105 GetMousePos() const106 const Point& GetMousePos() const { return aMousePos; } 107 108 void SetEditMode( const sal_Bool bEditMode ); IsEditMode() const109 sal_Bool IsEditMode() const { return bEditMode; } 110 111 void SetPolyEditMode( const sal_uInt16 nPolyEdit ); GetPolyEditMode() const112 sal_uInt16 GetPolyEditMode() const { return nPolyEdit; } 113 114 void SetObjKind( const SdrObjKind eObjKind ); GetObjKind() const115 SdrObjKind GetObjKind() const { return eObjKind; } 116 GetSdrModel() const117 SdrModel* GetSdrModel() const { return pModel; } GetSdrView() const118 SdrView* GetSdrView() const { return pView; } 119 SdrObject* GetSelectedSdrObject() const; IsChanged() const120 sal_Bool IsChanged() const { return bSdrMode ? pModel->IsChanged() : sal_False; } 121 SetMousePosLink(const Link & rLink)122 void SetMousePosLink( const Link& rLink ) { aMousePosLink = rLink; } GetMousePosLink() const123 const Link& GetMousePosLink() const { return aMousePosLink; } 124 SetGraphSizeLink(const Link & rLink)125 void SetGraphSizeLink( const Link& rLink ) { aGraphSizeLink = rLink; } GetGraphSizeLink() const126 const Link& GetGraphSizeLink() const { return aGraphSizeLink; } 127 SetMarkObjLink(const Link & rLink)128 void SetMarkObjLink( const Link& rLink ) { aMarkObjLink = rLink; } GetMarkObjLink() const129 const Link& GetMarkObjLink() const { return aMarkObjLink; } 130 SetUpdateLink(const Link & rLink)131 void SetUpdateLink( const Link& rLink ) { aUpdateLink = rLink; } GetUpdateLink() const132 const Link& GetUpdateLink() const { return aUpdateLink; } 133 134 static String GetStringFromDouble( const double& rDouble ); 135 136 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 137 }; 138 139 //#if 0 // _SOLAR__PRIVATE 140 141 /************************************************************************* 142 |* 143 |* 144 |* 145 \************************************************************************/ 146 147 class GraphCtrlUserCall : public SdrObjUserCall 148 { 149 GraphCtrl& rWin; 150 151 public: 152 GraphCtrlUserCall(GraphCtrl & rGraphWin)153 GraphCtrlUserCall( GraphCtrl& rGraphWin ) : rWin( rGraphWin ) {}; ~GraphCtrlUserCall()154 virtual ~GraphCtrlUserCall() {}; 155 156 virtual void Changed( const SdrObject& rObj, SdrUserCallType eType, const Rectangle& rOldBoundRect ); 157 }; 158 159 /************************************************************************* 160 |* 161 |* 162 |* 163 \************************************************************************/ 164 165 class GraphCtrlView : public SdrView 166 { 167 GraphCtrl& rGraphCtrl; 168 169 protected: 170 MarkListHasChanged()171 virtual void MarkListHasChanged() 172 { 173 SdrView::MarkListHasChanged(); 174 rGraphCtrl.MarkListHasChanged(); 175 } 176 177 public: 178 GraphCtrlView(SdrModel * pModel,GraphCtrl * pWindow)179 GraphCtrlView( SdrModel* pModel, GraphCtrl* pWindow) : 180 SdrView ( pModel, pWindow ), 181 rGraphCtrl ( *pWindow ) {}; 182 ~GraphCtrlView()183 virtual ~GraphCtrlView() {}; 184 }; 185 186 //#endif // __PRIVATE 187 188 #endif // _GRAPHCTL_HXX 189 190