1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _EXTENSIONS_SCANNER_GRID_HXX
20 #define _EXTENSIONS_SCANNER_GRID_HXX
22 #include <vcl/window.hxx>
23 #include <vcl/button.hxx>
24 #include <vcl/lstbox.hxx>
25 #include <vcl/dialog.hxx>
27 class GridWindow
: public ModalDialog
29 // helper class for handles
36 impHandle(const Point
& rPos
, sal_uInt16 nX
, sal_uInt16 nY
)
37 : maPos(rPos
), mnOffX(nX
), mnOffY(nY
)
41 bool operator<(const impHandle
& rComp
) const
43 return (maPos
.X() < rComp
.maPos
.X());
46 void draw(Window
& rWin
, const BitmapEx
& rBitmapEx
)
48 const Point
aOffset(rWin
.PixelToLogic(Point(mnOffX
, mnOffY
)));
49 rWin
.DrawBitmapEx(maPos
- aOffset
, rBitmapEx
);
52 bool isHit(Window
& rWin
, const Point
& rPos
)
54 const Point
aOffset(rWin
.PixelToLogic(Point(mnOffX
, mnOffY
)));
55 const Rectangle
aTarget(maPos
- aOffset
, maPos
+ aOffset
);
56 return aTarget
.IsInside(rPos
);
60 Rectangle m_aGridArea
;
73 double* m_pOrigYValues
;
75 double* m_pNewYValues
;
80 sal_Bool m_bCutValues
;
83 std::vector
< impHandle
> m_aHandles
;
84 sal_uInt32 m_nDragIndex
;
86 BitmapEx m_aMarkerBitmap
;
89 CancelButton m_aCancelButton
;
91 ListBox m_aResetTypeBox
;
92 PushButton m_aResetButton
;
95 Point
transform( double x
, double y
);
96 void transform( const Point
& rOriginal
, double& x
, double& y
);
108 void computeExtremes();
109 void computeChunk( double fMin
, double fMax
, double& fChunkOut
, double& fMinChunkOut
);
111 double interpolate( double x
, double* pNodeX
, double* pNodeY
, int nNodes
);
113 DECL_LINK( ClickButtonHdl
, Button
* );
115 virtual void MouseMove( const MouseEvent
& );
116 virtual void MouseButtonDown( const MouseEvent
& );
117 virtual void MouseButtonUp( const MouseEvent
& );
119 GridWindow( double* pXValues
, double* pYValues
, int nValues
,
120 Window
* pParent
, sal_Bool bCutValues
= sal_True
);
123 void setBoundings( double fMinX
, double fMinY
, double fMaxX
, double fMaxY
);
124 double getMinX() { return m_fMinX
; }
125 double getMinY() { return m_fMinY
; }
126 double getMaxX() { return m_fMaxX
; }
127 double getMaxY() { return m_fMaxY
; }
129 int countValues() { return m_nValues
; }
130 double* getXValues() { return m_pXValues
; }
131 double* getOrigYValues() { return m_pOrigYValues
; }
132 double* getNewYValues() { return m_pNewYValues
; }
134 void drawLine( double x1
, double y1
, double x2
, double y2
);
136 virtual void Paint( const Rectangle
& rRect
);
139 #endif // _EXTENSIONS_SCANNER_GRID_HXX
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */