merged tag ooo/OOO330_m14
[LibreOffice.git] / extensions / source / scanner / grid.hxx
blob42791f3554932997ca820b7ca055ef9eda2f0c38
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
27 #ifndef _EXTENSIONS_SCANNER_GRID_HXX
28 #define _EXTENSIONS_SCANNER_GRID_HXX
30 #include <vcl/window.hxx>
31 #ifndef _SV_BUTTON_HXX
32 #include <vcl/button.hxx>
33 #endif
34 #include <vcl/lstbox.hxx>
35 #include <vcl/dialog.hxx>
37 class GridWindow : public ModalDialog
39 // helper class for handles
40 struct impHandle
42 Point maPos;
43 sal_uInt16 mnOffX;
44 sal_uInt16 mnOffY;
46 impHandle(const Point& rPos, sal_uInt16 nX, sal_uInt16 nY)
47 : maPos(rPos), mnOffX(nX), mnOffY(nY)
51 bool operator<(const impHandle& rComp) const
53 return (maPos.X() < rComp.maPos.X());
56 void draw(Window& rWin, const BitmapEx& rBitmapEx)
58 const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
59 rWin.DrawBitmapEx(maPos - aOffset, rBitmapEx);
62 bool isHit(Window& rWin, const Point& rPos)
64 const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
65 const Rectangle aTarget(maPos - aOffset, maPos + aOffset);
66 return aTarget.IsInside(rPos);
70 Rectangle m_aGridArea;
72 double m_fMinX;
73 double m_fMinY;
74 double m_fMaxX;
75 double m_fMaxY;
77 double m_fChunkX;
78 double m_fMinChunkX;
79 double m_fChunkY;
80 double m_fMinChunkY;
82 double* m_pXValues;
83 double* m_pOrigYValues;
84 int m_nValues;
85 double* m_pNewYValues;
87 sal_uInt16 m_BmOffX;
88 sal_uInt16 m_BmOffY;
90 BOOL m_bCutValues;
92 // stuff for handles
93 std::vector< impHandle > m_aHandles;
94 sal_uInt32 m_nDragIndex;
96 BitmapEx m_aMarkerBitmap;
98 OKButton m_aOKButton;
99 CancelButton m_aCancelButton;
101 ListBox m_aResetTypeBox;
102 PushButton m_aResetButton;
105 Point transform( double x, double y );
106 void transform( const Point& rOriginal, double& x, double& y );
108 double findMinX();
109 double findMinY();
110 double findMaxX();
111 double findMaxY();
113 void drawGrid();
114 void drawOriginal();
115 void drawNew();
116 void drawHandles();
118 void computeExtremes();
119 void computeChunk( double fMin, double fMax, double& fChunkOut, double& fMinChunkOut );
120 void computeNew();
121 double interpolate( double x, double* pNodeX, double* pNodeY, int nNodes );
123 DECL_LINK( ClickButtonHdl, Button* );
125 virtual void MouseMove( const MouseEvent& );
126 virtual void MouseButtonDown( const MouseEvent& );
127 virtual void MouseButtonUp( const MouseEvent& );
128 public:
129 GridWindow( double* pXValues, double* pYValues, int nValues,
130 Window* pParent, BOOL bCutValues = TRUE );
131 ~GridWindow();
133 void setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY );
134 double getMinX() { return m_fMinX; }
135 double getMinY() { return m_fMinY; }
136 double getMaxX() { return m_fMaxX; }
137 double getMaxY() { return m_fMaxY; }
139 int countValues() { return m_nValues; }
140 double* getXValues() { return m_pXValues; }
141 double* getOrigYValues() { return m_pOrigYValues; }
142 double* getNewYValues() { return m_pNewYValues; }
144 void drawLine( double x1, double y1, double x2, double y2 );
146 virtual void Paint( const Rectangle& rRect );
149 #endif // _EXTENSIONS_SCANNER_GRID_HXX