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>
34 #include <vcl/lstbox.hxx>
35 #include <vcl/dialog.hxx>
37 class GridWindow
: public ModalDialog
39 // helper class for handles
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
;
83 double* m_pOrigYValues
;
85 double* m_pNewYValues
;
93 std::vector
< impHandle
> m_aHandles
;
94 sal_uInt32 m_nDragIndex
;
96 BitmapEx m_aMarkerBitmap
;
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
);
118 void computeExtremes();
119 void computeChunk( double fMin
, double fMax
, double& fChunkOut
, double& fMinChunkOut
);
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
& );
129 GridWindow( double* pXValues
, double* pYValues
, int nValues
,
130 Window
* pParent
, BOOL bCutValues
= TRUE
);
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