/Users/ericb/Desktop/NATIVEPRINTDLG01/extensions/source/scanner/grid.hxx

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  OpenOffice.org - a multi-platform office productivity suite
00004  *
00005  *  $RCSfile: grid.hxx,v $
00006  *
00007  *  $Revision: 1.4 $
00008  *
00009  *  last change: $Author: kz $ $Date: 2006/12/12 16:44:01 $
00010  *
00011  *  The Contents of this file are made available subject to
00012  *  the terms of GNU Lesser General Public License Version 2.1.
00013  *
00014  *
00015  *    GNU Lesser General Public License Version 2.1
00016  *    =============================================
00017  *    Copyright 2005 by Sun Microsystems, Inc.
00018  *    901 San Antonio Road, Palo Alto, CA 94303, USA
00019  *
00020  *    This library is free software; you can redistribute it and/or
00021  *    modify it under the terms of the GNU Lesser General Public
00022  *    License version 2.1, as published by the Free Software Foundation.
00023  *
00024  *    This library is distributed in the hope that it will be useful,
00025  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00026  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00027  *    Lesser General Public License for more details.
00028  *
00029  *    You should have received a copy of the GNU Lesser General Public
00030  *    License along with this library; if not, write to the Free Software
00031  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00032  *    MA  02111-1307  USA
00033  *
00034  ************************************************************************/
00035 #ifndef _EXTENSIONS_SCANNER_GRID_HXX
00036 #define _EXTENSIONS_SCANNER_GRID_HXX
00037 
00038 #ifndef _SV_WINDOW_HXX  
00039 #include <vcl/window.hxx>
00040 #endif
00041 #ifndef _SV_BUTTON_HXX
00042 #include <vcl/button.hxx>
00043 #endif
00044 #ifndef _SV_LSTBOX_HXX
00045 #include <vcl/lstbox.hxx>
00046 #endif
00047 #ifndef _SV_DIALOG_HXX
00048 #include <vcl/dialog.hxx>
00049 #endif
00050 
00051 class GridWindow : public ModalDialog
00052 {
00053         // helper class for handles
00054         struct impHandle
00055         {
00056                 Point                   maPos;
00057                 sal_uInt16              mnOffX;
00058                 sal_uInt16              mnOffY;
00059 
00060                 impHandle(const Point& rPos, sal_uInt16 nX, sal_uInt16 nY) 
00061                 :       maPos(rPos), mnOffX(nX), mnOffY(nY) 
00062                 {
00063                 }
00064                 
00065                 bool operator<(const impHandle& rComp) const 
00066                 { 
00067                         return (maPos.X() < rComp.maPos.X()); 
00068                 }
00069 
00070                 void draw(Window& rWin, const BitmapEx& rBitmapEx) 
00071                 {
00072                         const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
00073                         rWin.DrawBitmapEx(maPos - aOffset, rBitmapEx);
00074                 }
00075 
00076                 bool isHit(Window& rWin, const Point& rPos)
00077                 {
00078                         const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
00079                         const Rectangle aTarget(maPos - aOffset, maPos + aOffset);
00080                         return aTarget.IsInside(rPos);
00081                 }
00082         };
00083 
00084         Rectangle               m_aGridArea;
00085 
00086         double                  m_fMinX;
00087         double                  m_fMinY;
00088         double                  m_fMaxX;
00089         double                  m_fMaxY;
00090 
00091         double                  m_fChunkX;
00092         double                  m_fMinChunkX;
00093         double                  m_fChunkY;
00094         double                  m_fMinChunkY;
00095 
00096         double*                 m_pXValues;
00097         double*                 m_pOrigYValues;
00098         int                             m_nValues;
00099         double*                 m_pNewYValues;
00100 
00101         sal_uInt16              m_BmOffX;
00102         sal_uInt16              m_BmOffY;
00103 
00104         BOOL                    m_bCutValues;
00105 
00106         // stuff for handles
00107         std::vector< impHandle >        m_aHandles;
00108         sal_uInt32                                      m_nDragIndex;
00109 
00110         BitmapEx                m_aMarkerBitmap;
00111 
00112         OKButton                m_aOKButton;
00113         CancelButton    m_aCancelButton;
00114 
00115         ListBox                 m_aResetTypeBox;
00116         PushButton              m_aResetButton;
00117 
00118 
00119         Point transform( double x, double y );
00120         void transform( const Point& rOriginal, double& x, double& y );
00121 
00122         double findMinX();
00123         double findMinY();
00124         double findMaxX();
00125         double findMaxY();
00126 
00127         void drawGrid();
00128         void drawOriginal();
00129         void drawNew();
00130         void drawHandles();
00131 
00132         void computeExtremes();
00133         void computeChunk( double fMin, double fMax, double& fChunkOut, double& fMinChunkOut );
00134         void computeNew();
00135         double interpolate( double x, double* pNodeX, double* pNodeY, int nNodes );
00136 
00137         DECL_LINK( ClickButtonHdl, Button* );
00138 
00139         virtual void MouseMove( const MouseEvent& );
00140         virtual void MouseButtonDown( const MouseEvent& );
00141         virtual void MouseButtonUp( const MouseEvent& );
00142 public:
00143         GridWindow( double* pXValues, double* pYValues, int nValues,
00144                                 Window* pParent, BOOL bCutValues = TRUE );
00145         ~GridWindow();
00146 
00147         void setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY );
00148         double getMinX() { return m_fMinX; }
00149         double getMinY() { return m_fMinY; }
00150         double getMaxX() { return m_fMaxX; }
00151         double getMaxY() { return m_fMaxY; }
00152 
00153         int countValues() { return m_nValues; }
00154         double* getXValues() { return m_pXValues; }
00155         double* getOrigYValues() { return m_pOrigYValues; }
00156         double* getNewYValues() { return m_pNewYValues; }
00157 
00158         void drawPoint( double x, double y );
00159         void drawLine( double x1, double y1, double x2, double y2 );
00160 
00161         virtual void Paint( const Rectangle& rRect );
00162 };
00163 
00164 #endif // _EXTENSIONS_SCANNER_GRID_HXX

Generated on Thu Feb 28 17:53:26 2008 for AquaScanner by  doxygen 1.5.1