JBoolean JXWidget::ScrollToRectCentered ( const JRect& origRect, const JBoolean forceScroll ) { const JRect ap = GetAperture(); if (!forceScroll && ap.Contains(origRect)) { return kJFalse; } JRect r = origRect; const JCoordinate dw = ap.width() - r.width(); if (dw > 0) { r.Shrink(-dw/2, 0); } const JCoordinate dh = ap.height() - r.height(); if (dh > 0) { r.Shrink(0, -dh/2); } return ScrollToRect(r); }
JBoolean GetEnclosure ( const JArray<JRect>& rectList, const JIndex rectIndex, JIndex* enclIndex ) { const JRect theRect = rectList.GetElement(rectIndex); JBoolean found = kJFalse; *enclIndex = 0; JSize minArea = 0; const JSize count = rectList.GetElementCount(); for (JIndex i=1; i<=count; i++) { if (i != rectIndex) { const JRect r = rectList.GetElement(i); const JSize a = r.area(); if (r.Contains(theRect) && (a < minArea || minArea == 0)) { minArea = a; found = kJTrue; *enclIndex = i; } } } return found; }
void JXCheckbox::HandleMouseDrag ( const JPoint& pt, const JXButtonStates& buttonStates, const JXKeyModifiers& modifiers ) { if (buttonStates.left()) { const JRect frame = JXContainer::GlobalToLocal(GetFrameGlobal()); const JBoolean inside = frame.Contains(pt); if (inside && !itsIsPushedFlag) { itsIsPushedFlag = kJTrue; Redraw(); } else if (!inside && itsIsPushedFlag) { itsIsPushedFlag = kJFalse; Redraw(); } } }