1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _GRAPHCTL_HXX 28 #define _GRAPHCTL_HXX 29 30 // include --------------------------------------------------------------- 31 32 #include <vcl/ctrl.hxx> 33 #include <vcl/graph.hxx> 34 #include "svx/svxdllapi.h" 35 36 #include <svx/svdview.hxx> 37 #include <svx/svdobj.hxx> 38 39 /************************************************************************* 40 |* 41 |* 42 |* 43 \************************************************************************/ 44 45 class GraphCtrlUserCall; 46 class SvxGraphCtrlAccessibleContext; 47 48 #define WB_SDRMODE ((WinBits)0x0080) 49 #define WB_ANIMATION ((WinBits)0x0100) 50 51 class SVX_DLLPUBLIC GraphCtrl : public Control 52 { 53 friend class GraphCtrlView; 54 friend class GraphCtrlUserCall; 55 56 Graphic aGraphic; 57 Timer aUpdateTimer; 58 Link aMousePosLink; 59 Link aGraphSizeLink; 60 Link aMarkObjLink; 61 Link aUpdateLink; 62 MapMode aMap100; 63 Size aGraphSize; 64 Point aMousePos; 65 GraphCtrlUserCall* pUserCall; 66 WinBits nWinStyle; 67 SdrObjKind eObjKind; 68 sal_uInt16 nPolyEdit; 69 sal_Bool bEditMode; 70 sal_Bool bSdrMode; 71 sal_Bool bAnim; 72 73 DECL_LINK( UpdateHdl, Timer* ); 74 75 SvxGraphCtrlAccessibleContext* mpAccContext; 76 77 protected: 78 79 SdrModel* pModel; 80 SdrView* pView; 81 82 virtual void Paint( const Rectangle& rRect ); 83 virtual void Resize(); 84 virtual void KeyInput(const KeyEvent& rKEvt); 85 virtual void MouseButtonDown(const MouseEvent& rMEvt); 86 virtual void MouseButtonUp(const MouseEvent& rMEvt); 87 virtual void MouseMove(const MouseEvent& rMEvt); 88 89 virtual void InitSdrModel(); 90 91 virtual void SdrObjCreated( const SdrObject& rObj ); 92 virtual void SdrObjChanged( const SdrObject& rObj ); 93 virtual void MarkListHasChanged(); 94 95 SdrObjUserCall* GetSdrUserCall() { return (SdrObjUserCall*) pUserCall; } 96 97 public: 98 99 GraphCtrl( Window* pParent, const WinBits nWinBits = 0 ); 100 GraphCtrl( Window* pParent, const ResId& rResId ); 101 ~GraphCtrl(); 102 103 void SetWinStyle( WinBits nWinBits ); 104 WinBits GetWinStyle() const { return nWinStyle; } 105 106 void SetGraphic( const Graphic& rGraphic, sal_Bool bNewModel = sal_True ); 107 const Graphic& GetGraphic() const { return aGraphic; } 108 const Size& GetGraphicSize() const { return aGraphSize; } 109 110 const Point& GetMousePos() const { return aMousePos; } 111 112 void SetEditMode( const sal_Bool bEditMode ); 113 sal_Bool IsEditMode() const { return bEditMode; } 114 115 void SetPolyEditMode( const sal_uInt16 nPolyEdit ); 116 sal_uInt16 GetPolyEditMode() const { return nPolyEdit; } 117 118 void SetObjKind( const SdrObjKind eObjKind ); 119 SdrObjKind GetObjKind() const { return eObjKind; } 120 121 SdrModel* GetSdrModel() const { return pModel; } 122 SdrView* GetSdrView() const { return pView; } 123 SdrObject* GetSelectedSdrObject() const; 124 sal_Bool IsChanged() const { return bSdrMode ? pModel->IsChanged() : sal_False; } 125 126 void SetMousePosLink( const Link& rLink ) { aMousePosLink = rLink; } 127 const Link& GetMousePosLink() const { return aMousePosLink; } 128 129 void SetGraphSizeLink( const Link& rLink ) { aGraphSizeLink = rLink; } 130 const Link& GetGraphSizeLink() const { return aGraphSizeLink; } 131 132 void SetMarkObjLink( const Link& rLink ) { aMarkObjLink = rLink; } 133 const Link& GetMarkObjLink() const { return aMarkObjLink; } 134 135 void SetUpdateLink( const Link& rLink ) { aUpdateLink = rLink; } 136 const Link& GetUpdateLink() const { return aUpdateLink; } 137 138 static String GetStringFromDouble( const double& rDouble ); 139 140 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 141 }; 142 143 //#if 0 // _SOLAR__PRIVATE 144 145 /************************************************************************* 146 |* 147 |* 148 |* 149 \************************************************************************/ 150 151 class GraphCtrlUserCall : public SdrObjUserCall 152 { 153 GraphCtrl& rWin; 154 155 public: 156 157 GraphCtrlUserCall( GraphCtrl& rGraphWin ) : rWin( rGraphWin ) {}; 158 virtual ~GraphCtrlUserCall() {}; 159 160 virtual void Changed( const SdrObject& rObj, SdrUserCallType eType, const Rectangle& rOldBoundRect ); 161 }; 162 163 /************************************************************************* 164 |* 165 |* 166 |* 167 \************************************************************************/ 168 169 class GraphCtrlView : public SdrView 170 { 171 GraphCtrl& rGraphCtrl; 172 173 protected: 174 175 virtual void MarkListHasChanged() 176 { 177 SdrView::MarkListHasChanged(); 178 rGraphCtrl.MarkListHasChanged(); 179 } 180 181 public: 182 183 GraphCtrlView( SdrModel* pModel, GraphCtrl* pWindow) : 184 SdrView ( pModel, pWindow ), 185 rGraphCtrl ( *pWindow ) {}; 186 187 virtual ~GraphCtrlView() {}; 188 }; 189 190 //#endif // __PRIVATE 191 192 #endif // _GRAPHCTL_HXX 193 194