public ShiftArrowInfo(ShiftArrow type, bool hilite, bool mousedown, Bitmap bm) { Type = type; Hilite = hilite; MouseDown = mousedown; ArrowBitmap = bm; }
/// <summary> /// Handle the mouse move events when the mouse button is not pressed. /// This needs to hilight/unhilight the shift arrows as appropriate. /// </summary> /// <param name="pxX"></param> /// <param name="pxY"></param> /// <returns>True if we need to redraw the screen</returns> public override bool HandleMouseMove(int pxX, int pxY) { ShiftArrow eNewSelection = ShiftArrow.None; // Make sure the mouse is in the shift-arrow area if (pxX >= k_pxToolboxIndent && pxY >= k_pxToolboxIndent && pxX < k_pxToolboxWidth && pxY < k_pxToolboxHeight) { pxX -= k_pxShiftArrowBoxOriginX; pxY -= k_pxShiftArrowBoxOriginY; // If we just use the bounding box rects, we'll get strange results // because the rects overlap and some rects will take precedence // over the others. // \ t / // To avoid this, we use the diagonals to divide \ / // up the area into top,left,bottom,right triangles l X r // before applying the rectangle check. / \ // / b \ int pxX0 = pxX - k_pxShiftArrowInsetX; int pxY0 = pxY - k_pxShiftArrowInsetY; int pxX2 = k_pxShiftArrowBoxWidth - k_pxShiftArrowInsetX - pxX; // Bottom: pxX0 < pxY0 && pxX2 < pxY0 // Left: pxX0 < pxY0 && pxX2 > pxY0 // Right: pxX0 > pxY0 && pxX2 < pxY0 // Top: pxX0 > pxY0 && pxX2 > pxY0 if ((pxX0 < pxY0 && pxX2 > pxY0) || // Left triangle (pxX0 > pxY0 && pxX2 < pxY0) // Right triangle ) { // Note that k_pxShiftArrowWidth/Height are reversed because the // left/right arrows are rotated. int pxLeft = k_pxShiftArrowInsetX; int pxRight = pxLeft + k_pxShiftArrowHeight; int pxTop = (k_pxShiftArrowBoxHeight - k_pxShiftArrowWidth) / 2; int pxBottom = pxTop + k_pxShiftArrowWidth; if (pxX >= pxLeft && pxX < pxRight && pxY >= pxTop && pxY < pxBottom) { eNewSelection = ShiftArrow.Left; } pxRight = k_pxShiftArrowBoxWidth - k_pxShiftArrowInsetX; pxLeft = pxRight - k_pxShiftArrowHeight; if (pxX >= pxLeft && pxX < pxRight && pxY >= pxTop && pxY < pxBottom) { eNewSelection = ShiftArrow.Right; } } else { int pxLeft = (k_pxShiftArrowBoxWidth - k_pxShiftArrowWidth) / 2; int pxRight = pxLeft + k_pxShiftArrowWidth; int pxTop = k_pxShiftArrowInsetY; int pxBottom = pxTop + k_pxShiftArrowHeight; if (pxX >= pxLeft && pxX < pxRight && pxY >= pxTop && pxY < pxBottom) { eNewSelection = ShiftArrow.Up; } pxBottom = k_pxShiftArrowBoxHeight - k_pxShiftArrowInsetY; pxTop = pxBottom - k_pxShiftArrowHeight; if (pxX >= pxLeft && pxX < pxRight && pxY >= pxTop && pxY < pxBottom) { eNewSelection = ShiftArrow.Down; } } } // If the new selection is the same as the current selection, we're done. if (m_eHilightedShiftArrow == eNewSelection) { return(false); } else { // Remove current selection. m_eHilightedShiftArrow = eNewSelection; return(true); } }
/// <summary> /// Handle the mouse move events when the mouse button is not pressed. /// This needs to hilight/unhilight the shift arrows as appropriate. /// </summary> /// <param name="pxX"></param> /// <param name="pxY"></param> /// <returns>True if we need to redraw the screen</returns> public override bool HandleMouseMove(int pxX, int pxY) { ShiftArrow eNewSelection = ShiftArrow.None; // Make sure the mouse is in the shift-arrow area if (pxX >= k_pxToolboxIndent && pxY >= k_pxToolboxIndent && pxX < k_pxToolboxWidth && pxY < k_pxToolboxHeight) { pxX -= k_pxShiftArrowBoxOriginX; pxY -= k_pxShiftArrowBoxOriginY; // If we just use the bounding box rects, we'll get strange results // because the rects overlap and some rects will take precedence // over the others. // \ t / // To avoid this, we use the diagonals to divide \ / // up the area into top,left,bottom,right triangles l X r // before applying the rectangle check. / \ // / b \ int pxX0 = pxX - k_pxShiftArrowInsetX; int pxY0 = pxY - k_pxShiftArrowInsetY; int pxX2 = k_pxShiftArrowBoxWidth - k_pxShiftArrowInsetX - pxX; // Bottom: pxX0 < pxY0 && pxX2 < pxY0 // Left: pxX0 < pxY0 && pxX2 > pxY0 // Right: pxX0 > pxY0 && pxX2 < pxY0 // Top: pxX0 > pxY0 && pxX2 > pxY0 if ((pxX0 < pxY0 && pxX2 > pxY0) // Left triangle || (pxX0 > pxY0 && pxX2 < pxY0) // Right triangle ) { // Note that k_pxShiftArrowWidth/Height are reversed because the // left/right arrows are rotated. int pxLeft = k_pxShiftArrowInsetX; int pxRight = pxLeft + k_pxShiftArrowHeight; int pxTop = (k_pxShiftArrowBoxHeight - k_pxShiftArrowWidth) / 2; int pxBottom = pxTop + k_pxShiftArrowWidth; if (pxX >= pxLeft && pxX < pxRight && pxY >= pxTop && pxY < pxBottom) eNewSelection = ShiftArrow.Left; pxRight = k_pxShiftArrowBoxWidth - k_pxShiftArrowInsetX; pxLeft = pxRight - k_pxShiftArrowHeight; if (pxX >= pxLeft && pxX < pxRight && pxY >= pxTop && pxY < pxBottom) eNewSelection = ShiftArrow.Right; } else { int pxLeft = (k_pxShiftArrowBoxWidth - k_pxShiftArrowWidth) / 2; int pxRight = pxLeft + k_pxShiftArrowWidth; int pxTop = k_pxShiftArrowInsetY; int pxBottom = pxTop + k_pxShiftArrowHeight; if (pxX >= pxLeft && pxX < pxRight && pxY >= pxTop && pxY < pxBottom) eNewSelection = ShiftArrow.Up; pxBottom = k_pxShiftArrowBoxHeight - k_pxShiftArrowInsetY; pxTop = pxBottom - k_pxShiftArrowHeight; if (pxX >= pxLeft && pxX < pxRight && pxY >= pxTop && pxY < pxBottom) eNewSelection = ShiftArrow.Down; } } // If the new selection is the same as the current selection, we're done. if (m_eHilightedShiftArrow == eNewSelection) return false; else { // Remove current selection. m_eHilightedShiftArrow = eNewSelection; return true; } }