Example #1
0
        public override HitTestInfo GetHitTestInfo(IGraphics gr, int x, int y, Point pt)
        {
            if (!GetHorizontalRect(x, y).Contains(pt))
            {
                return(null);
            }

            // is the X pos of the cursor in same vertical rect as start tag
            if (startTag.GetBoundingRect(x, y).Contains(new Point(pt.X, y)))
            {
                return(startTag.GetHitTestInfo(gr, x, y, pt));
            }

            Point lastLocation = Point.Empty;
            int   pos          = x + startTag.Width;

            foreach (TableCell cell in cells)
            {
                int width = ParentTable[cell.ElementNode].Column.Width;

                // here we override default behaviour and check if region contains
                // point, because don't want a line to grab the point and think the
                // cursor is beyond the end of the line

                Rectangle rcCell = cell.GetBoundingRect(pos, y);
                lastLocation = rcCell.Location;
                // ensure cell is full-height
                Rectangle rcTest = rcCell;
                rcTest.Height = Height;
                rcTest.Width  = width;

                // check to see if the cursor is in the grab area of the cell (right edge)
                Rectangle rcGrabTest = rcTest;
                rcGrabTest.Width = 6;
                rcGrabTest.X    += width - 3;
                if (rcGrabTest.Contains(pt))
                {
                    HitTestInfo hti = endTag.GetHitTestInfo(gr, pos, y, pt);
                    hti.Type = HitTestType.TableColumnResize;
                    return(hti);
                }

                // we need to test each cell here otherwise first cell will grab
                // everything across horizontal region
                if (rcTest.Contains(pt))
                {
                    if (pt.Y >= rcCell.Bottom)
                    {
                        pt.Y = rcCell.Bottom - 1;
                    }

                    HitTestInfo ret = cell.GetHitTestInfo(gr, pos, y, pt);
                    if (ret != null)
                    {
                        return(ret);
                    }
                }

                pos += width;
            }

            // it must be in the end tag
            return(endTag.GetHitTestInfo(gr, pos, y, pt));
        }