1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef _EXTENSIONS_SCANNER_GRID_HXX 28*cdf0e10cSrcweir #define _EXTENSIONS_SCANNER_GRID_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <vcl/window.hxx> 31*cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 32*cdf0e10cSrcweir #include <vcl/button.hxx> 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 35*cdf0e10cSrcweir #include <vcl/dialog.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir class GridWindow : public ModalDialog 38*cdf0e10cSrcweir { 39*cdf0e10cSrcweir // helper class for handles 40*cdf0e10cSrcweir struct impHandle 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir Point maPos; 43*cdf0e10cSrcweir sal_uInt16 mnOffX; 44*cdf0e10cSrcweir sal_uInt16 mnOffY; 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir impHandle(const Point& rPos, sal_uInt16 nX, sal_uInt16 nY) 47*cdf0e10cSrcweir : maPos(rPos), mnOffX(nX), mnOffY(nY) 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir } 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir bool operator<(const impHandle& rComp) const 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir return (maPos.X() < rComp.maPos.X()); 54*cdf0e10cSrcweir } 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir void draw(Window& rWin, const BitmapEx& rBitmapEx) 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY))); 59*cdf0e10cSrcweir rWin.DrawBitmapEx(maPos - aOffset, rBitmapEx); 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir bool isHit(Window& rWin, const Point& rPos) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY))); 65*cdf0e10cSrcweir const Rectangle aTarget(maPos - aOffset, maPos + aOffset); 66*cdf0e10cSrcweir return aTarget.IsInside(rPos); 67*cdf0e10cSrcweir } 68*cdf0e10cSrcweir }; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir Rectangle m_aGridArea; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir double m_fMinX; 73*cdf0e10cSrcweir double m_fMinY; 74*cdf0e10cSrcweir double m_fMaxX; 75*cdf0e10cSrcweir double m_fMaxY; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir double m_fChunkX; 78*cdf0e10cSrcweir double m_fMinChunkX; 79*cdf0e10cSrcweir double m_fChunkY; 80*cdf0e10cSrcweir double m_fMinChunkY; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir double* m_pXValues; 83*cdf0e10cSrcweir double* m_pOrigYValues; 84*cdf0e10cSrcweir int m_nValues; 85*cdf0e10cSrcweir double* m_pNewYValues; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir sal_uInt16 m_BmOffX; 88*cdf0e10cSrcweir sal_uInt16 m_BmOffY; 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir sal_Bool m_bCutValues; 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir // stuff for handles 93*cdf0e10cSrcweir std::vector< impHandle > m_aHandles; 94*cdf0e10cSrcweir sal_uInt32 m_nDragIndex; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir BitmapEx m_aMarkerBitmap; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir OKButton m_aOKButton; 99*cdf0e10cSrcweir CancelButton m_aCancelButton; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir ListBox m_aResetTypeBox; 102*cdf0e10cSrcweir PushButton m_aResetButton; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir Point transform( double x, double y ); 106*cdf0e10cSrcweir void transform( const Point& rOriginal, double& x, double& y ); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir double findMinX(); 109*cdf0e10cSrcweir double findMinY(); 110*cdf0e10cSrcweir double findMaxX(); 111*cdf0e10cSrcweir double findMaxY(); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir void drawGrid(); 114*cdf0e10cSrcweir void drawOriginal(); 115*cdf0e10cSrcweir void drawNew(); 116*cdf0e10cSrcweir void drawHandles(); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir void computeExtremes(); 119*cdf0e10cSrcweir void computeChunk( double fMin, double fMax, double& fChunkOut, double& fMinChunkOut ); 120*cdf0e10cSrcweir void computeNew(); 121*cdf0e10cSrcweir double interpolate( double x, double* pNodeX, double* pNodeY, int nNodes ); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir DECL_LINK( ClickButtonHdl, Button* ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir virtual void MouseMove( const MouseEvent& ); 126*cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& ); 127*cdf0e10cSrcweir virtual void MouseButtonUp( const MouseEvent& ); 128*cdf0e10cSrcweir public: 129*cdf0e10cSrcweir GridWindow( double* pXValues, double* pYValues, int nValues, 130*cdf0e10cSrcweir Window* pParent, sal_Bool bCutValues = sal_True ); 131*cdf0e10cSrcweir ~GridWindow(); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir void setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY ); 134*cdf0e10cSrcweir double getMinX() { return m_fMinX; } 135*cdf0e10cSrcweir double getMinY() { return m_fMinY; } 136*cdf0e10cSrcweir double getMaxX() { return m_fMaxX; } 137*cdf0e10cSrcweir double getMaxY() { return m_fMaxY; } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir int countValues() { return m_nValues; } 140*cdf0e10cSrcweir double* getXValues() { return m_pXValues; } 141*cdf0e10cSrcweir double* getOrigYValues() { return m_pOrigYValues; } 142*cdf0e10cSrcweir double* getNewYValues() { return m_pNewYValues; } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir void drawLine( double x1, double y1, double x2, double y2 ); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect ); 147*cdf0e10cSrcweir }; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir #endif // _EXTENSIONS_SCANNER_GRID_HXX 150