1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: grid.hxx,v $
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>
37 #include <vcl/lstbox.hxx>
38 #include <vcl/dialog.hxx>
40 class GridWindow
: public ModalDialog
42 // helper class for handles
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
;
86 double* m_pOrigYValues
;
88 double* m_pNewYValues
;
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
);
121 void computeExtremes();
122 void computeChunk( double fMin
, double fMax
, double& fChunkOut
, double& fMinChunkOut
);
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
& );
132 GridWindow( double* pXValues
, double* pYValues
, int nValues
,
133 Window
* pParent
, BOOL bCutValues
= TRUE
);
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