From: Richard K. <ric...@us...> - 2005-05-24 21:46:33
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27199 Modified Files: NSView.as Log Message: add scrolling methods and visualrect Index: NSView.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSView.as,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NSView.as 24 May 2005 20:39:56 -0000 1.9 --- NSView.as 24 May 2005 21:46:25 -0000 1.10 *************** *** 39,42 **** --- 39,45 ---- import org.actionstep.NSEvent; + import org.actionstep.NSClipView; + import org.actionstep.NSScrollView; + class org.actionstep.NSView extends NSResponder { *************** *** 306,310 **** if (superview == null) return; ! //! superview.setNeedsDisplayInRect(frame()); for (view = m_window.firstResponder();view != null && view["superview"] != undefined; --- 309,313 ---- if (superview == null) return; ! superview.setNeedsDisplay(true); for (view = m_window.firstResponder();view != null && view["superview"] != undefined; *************** *** 699,702 **** --- 702,718 ---- //****************************************************** + public function scrollPoint(point:NSPoint) { + var view:NSView = m_superview; + while (view != null && view.getClass()!=NSClipView) { + view = view.superview(); + } + if (view != null) { + point = convertPointToView(point, view); + if (!point.equalTo(view.bounds().origin)) { + NSClipView(view).scrollToPoint(point); + } + } + } + /** * Scrolls this view's drawing surface the minimum distance for *************** *** 705,714 **** * Returns TRUE if scrolling is performed, FALSE otherwise. */ ! public function scrollRectToVisible(aRect:NSRect):Boolean ! { ! //! IMPLEMENT return false; } //****************************************************** --- 721,784 ---- * Returns TRUE if scrolling is performed, FALSE otherwise. */ ! public function scrollRectToVisible(aRect:NSRect):Boolean { ! var view:NSView = m_superview; ! while (view != null && view.getClass()!=NSClipView) { ! view = view.superview(); ! } ! if (view != null) { ! var vRect:NSRect = visibleRect(); ! var scrollPoint:NSPoint = vRect.origin.clone(); ! if (vRect.size.width == 0 && vRect.size.height == 0) { ! return false; ! } ! var ldiff = vRect.minX() - aRect.minX(); ! var rdiff = aRect.maxX() - vRect.maxX(); ! var tdiff = vRect.minY() - aRect.minY(); ! var bdiff = aRect.maxY() - vRect.maxY(); ! ! if ((ldiff*rdiff) > 0) ldiff = rdiff = 0; ! if ((tdiff*bdiff) > 0) tdiff = bdiff = 0; ! scrollPoint.x += (Math.abs(ldiff) < Math.abs(rdiff)) ? (-ldiff) : rdiff; ! scrollPoint.y += (Math.abs(tdiff) < Math.abs(bdiff)) ? (-tdiff) : bdiff; ! if (!vRect.origin.equalTo(scrollPoint)) { ! scrollPoint = convertPointToView(scrollPoint, view); ! NSClipView(view).scrollToPoint(scrollPoint); ! return true; ! } ! } return false; } + public function autoscroll(event:NSEvent):Boolean { + if (m_superview) { + return m_superview.autoscroll(event); + } else { + return false; + } + } + + public function adjustScroll(proposedRect:NSRect):NSRect { + return proposedRect; + } + + public function scrollRectBy(rect:NSRect, size:NSSize) { + // DO NOTHING + } + + public function enclosingScrollView():NSScrollView { + var view:NSView = m_superview; + while (view != null && view.getClass()!=NSScrollView) { + view = view.superview(); + } + return view == null ? null : NSScrollView(view); + } + + public function scrollClipViewToPoint(clipView:NSClipView, point:NSPoint) { + //DO NOTHING + } + + public function reflectScrolledClipView(clipView:NSClipView) { + //DO NOTHING + } //****************************************************** *************** *** 836,847 **** public function drawRect(rect:NSRect) { } //! which other functions in the drawing group are needed? - // â visibleRect // â canDraw // â shouldDrawColor // â getRectsBeingDrawn:count: // â needsToDrawRect: - // â wantsDefaultClipping // Managing live resize --- 906,929 ---- public function drawRect(rect:NSRect) { } + + public function visibleRect():NSRect { + if (m_window == null) { + return NSRect.ZeroRect; + } + if (m_superview == null) { + return m_bounds; + } + return convertRectFromView(m_superview.visibleRect(), m_superview).intersectionRect(m_bounds); + } + + public function wantsDefaultClipping():Boolean { + return true; + } //! which other functions in the drawing group are needed? // â canDraw // â shouldDrawColor // â getRectsBeingDrawn:count: // â needsToDrawRect: // Managing live resize |