// ======================================================================== // SNAPINFO // ------------------------------------------------------------------------ /// holds the data for calculating a modified window rect. Since it /// only works on coordinate rects, it can be used without any actual Windows. /// To use it: /// - call Init, specifying the initial position /// - call SnapHLine / SnapVLine for each (virtual) line to snap to /// - call EndSnap to retrieve the final position struct SNAPINFO { enum { MAXDELTA = (1<<30) }; DWORD snapWidth; ///< distance over which snapping works RECT rold; ///< original rect RECT rnew; ///< post-move rect (if specified) RECT rdelta; RECT rout; ///< accumulates the final rect /// Initialize, specifying a pre-move and post-move rect void Init(RECT const & oldRect, RECT const & newRect, DWORD snapwidth); /// Initialize, specifying only one rectangle void Init(RECT const & r, DWORD snapWidth, bool moveOnly = false); void SnapHLine(long y); ///< snap to a horizontal line void SnapVLine(long x); ///< snap to a vertical line RECT & EndSnap(); ///< ends snapping sequence and returns final coords };