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