From: Richard K. <ric...@us...> - 2005-05-25 22:07:22
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19587 Modified Files: NSScrollView.as Log Message: most of the functions are in place Index: NSScrollView.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSScrollView.as,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NSScrollView.as 24 May 2005 20:31:34 -0000 1.1 --- NSScrollView.as 25 May 2005 22:07:14 -0000 1.2 *************** *** 35,114 **** + contentSizeForFrameSize:hasHorizontalScroller:hasVerticalScroller:borderType: + frameSizeForContentSize:hasHorizontalScroller:hasVerticalScroller:borderType: - Determining component sizes - â contentSize - â documentVisibleRect - Managing graphics attributes - â setBackgroundColor: - â backgroundColor - â drawsBackground - â setDrawsBackground: - â setBorderType: - â borderType - â setDocumentCursor: - â documentCursor - Managing the scrolled views - â setContentView: - â contentView - â setDocumentView: - â documentView - Managing scrollers - â setHorizontalScroller: - â horizontalScroller - â setHasHorizontalScroller: - â hasHorizontalScroller - â setVerticalScroller: - â verticalScroller - â setHasVerticalScroller: - â hasVerticalScroller - â setAutohidesScrollers: - â autohidesScrollers - Managing rulers - + setRulerViewClass: - + rulerViewClass - â setHasHorizontalRuler: - â hasHorizontalRuler - â setHorizontalRulerView: - â horizontalRulerView - â setHasVerticalRuler: - â hasVerticalRuler - â setVerticalRulerView: - â verticalRulerView - â setRulersVisible: - â rulersVisible - Setting scrolling behavior - â setLineScroll: - â lineScroll - â setHorizontalLineScroll: - â horizontalLineScroll - â setVerticalLineScroll: - â verticalLineScroll - â setPageScroll: - â pageScroll - â setHorizontalPageScroll: - â horizontalPageScroll - â setVerticalPageScroll: - â verticalPageScroll - â setScrollsDynamically: - â scrollsDynamically - â scrollWheel: - Updating display after scrolling - â reflectScrolledClipView: - Arranging components - â tile */ import org.actionstep.NSView; import org.actionstep.NSRect; class org.actionstep.NSScrollView extends NSView { // Determining component sizes ! public function contentSize():NSRect { ! return null; } public function reflectScrolledClipView(view:NSView) { //! implement } } \ No newline at end of file --- 35,379 ---- + contentSizeForFrameSize:hasHorizontalScroller:hasVerticalScroller:borderType: + frameSizeForContentSize:hasHorizontalScroller:hasVerticalScroller:borderType: */ + import org.actionstep.constants.NSBorderType; import org.actionstep.NSView; + import org.actionstep.NSClipView; + import org.actionstep.NSScroller; + import org.actionstep.NSSize; + import org.actionstep.NSColor; import org.actionstep.NSRect; + import org.actionstep.NSEvent; class org.actionstep.NSScrollView extends NSView { + + private var m_contentView:NSClipView; + private var m_borderType:NSBorderType; + private var m_horizontalScroller:NSScroller; + private var m_verticalScroller:NSScroller; + private var m_hasHorizontalScroller:Boolean; + private var m_hasVerticalScroller:Boolean; + private var m_autohidesScrollers:Boolean; + private var m_scrollsDynamically:Boolean; + + private var m_horizontalLineScroll:Number; + private var m_verticalLineScroll:Number + private var m_horizontalPageScroll:Number; + private var m_verticalPageScroll:Number; + + public function init():NSScrollView { + return initWithFrame(NSRect.ZeroRect); + } + + public function initWithFrame(rect:NSRect):NSScrollView { + super.initWithFrame(rect); + setContentView(new NSClipView()); + m_borderType = NSBorderType.NSNoBorder; + m_autohidesScrollers = false; + m_horizontalLineScroll = 10; + m_verticalLineScroll = 10; + m_horizontalPageScroll = 10; + m_verticalPageScroll = 10; + m_scrollsDynamically = true; + tile(); + return this; + } + // Determining component sizes ! ! public function contentSize():NSSize { ! return m_contentView.bounds().size; ! } ! ! public function documentVisibleRect():NSRect { ! return m_contentView.documentVisibleRect(); ! } ! ! // Managing graphics attributes ! ! public function setBackgroundColor(color:NSColor) { ! m_contentView.setBackgroundColor(color); ! } ! ! public function backgroundColor():NSColor { ! return m_contentView.backgroundColor(); ! } ! ! public function drawsBackground():Boolean { ! return m_contentView.drawsBackground(); ! } ! ! public function setDrawsBackground(value:Boolean) { ! m_contentView.setDrawsBackground(value); ! } ! ! public function setBorderType(value:NSBorderType) { ! m_borderType = value; ! tile(); ! } ! ! public function borderType():NSBorderType { ! return m_borderType; ! } ! ! // Managing the scrolled views ! ! public function setContentView(view:NSClipView) { ! if (view == null || !(view instanceof NSView)) { ! throw new Error("You cannot set a content view to anything other than an NSView"); ! } ! if (view != m_contentView) { ! var docView:NSView = view.documentView(); ! m_contentView.removeFromSuperview(); ! m_contentView = view; ! addSubview(m_contentView); ! if (docView != null) { ! setDocumentView(docView); ! } ! } ! m_contentView.setAutoresizingMask(NSView.WidthSizable | NSView.HeightSizable); ! tile(); ! } ! ! public function contentView():NSClipView { ! return m_contentView; } + public function setDocumentView(view:NSView) { + m_contentView.setDocumentView(view); + tile(); + } + + public function documentView():NSView { + return m_contentView.documentView(); + } + + // Managing scrollers + + public function setHorizontalScroller(scroller:NSScroller) { + if (m_horizontalScroller != null) { + m_horizontalScroller.removeFromSuperview(); + } + m_horizontalScroller = scroller; + if (m_horizontalScroller != null) { + m_horizontalScroller.setAutoresizingMask(NSView.WidthSizable); + m_horizontalScroller.setTarget(this); + m_horizontalScroller.setAction("scrollAction"); + } + } + + public function horizontalScroller():NSScroller { + return m_horizontalScroller; + } + + public function setHasHorizontalScroller(value:Boolean) { + if (m_hasHorizontalScroller == value) { + return; + } + m_hasHorizontalScroller = value; + if (m_hasHorizontalScroller) { + if (m_horizontalScroller == null) { + setHorizontalScroller(new NSScroller()); + } + addSubview(m_horizontalScroller); + } else { + m_horizontalScroller.removeFromSuperview(); + } + tile(); + } + + public function hasHorizontalScroller():Boolean { + return m_hasHorizontalScroller; + } + + public function setVerticalScroller(scroller:NSScroller) { + if (m_verticalScroller != null) { + m_verticalScroller.removeFromSuperview(); + } + m_verticalScroller = scroller; + if (m_verticalScroller != null) { + m_verticalScroller.setAutoresizingMask(NSView.WidthSizable); + m_verticalScroller.setTarget(this); + m_verticalScroller.setAction("scrollAction"); + } + } + + public function verticalScroller():NSScroller { + return m_verticalScroller; + } + + public function setHasVerticalScroller(value:Boolean) { + if (m_hasVerticalScroller == value) { + return; + } + m_hasVerticalScroller = value; + if (m_hasVerticalScroller) { + if (m_verticalScroller == null) { + setVerticalScroller(new NSScroller()); + } + addSubview(m_verticalScroller); + } else { + m_verticalScroller.removeFromSuperview(); + } + tile(); + } + + public function hasVerticalScroller():Boolean { + return m_hasVerticalScroller; + } + + public function setAutohidesScrollers(value:Boolean) { + if (m_autohidesScrollers == value) { + return; + } + m_autohidesScrollers = value; + tile(); + } + + public function autohidesScrollers():Boolean { + return m_autohidesScrollers; + } + + // Setting scrolling behavior + /* + â scrollWheel: + */ + + + public function setLineScroll(value:Number) { + m_horizontalLineScroll = value; + m_verticalLineScroll = value; + } + + public function lineScroll():Number { + if (m_horizontalLineScroll != m_verticalLineScroll) { + throw new Error("Horizontal and vertical line scroll values are not the same"); + } + return m_horizontalLineScroll; + } + + public function setHorizontalLineScroll(value:Number) { + m_horizontalLineScroll = value; + } + + public function horizontalLineScroll():Number { + return m_horizontalLineScroll; + } + + public function setVerticalLineScroll(value:Number) { + m_verticalLineScroll = value; + } + + public function verticalLineScroll():Number { + return m_verticalLineScroll; + } + + public function setPageScroll(value:Number) { + m_horizontalPageScroll = value; + m_verticalPageScroll = value; + } + + public function pageScroll():Number { + if (m_horizontalPageScroll != m_verticalPageScroll) { + throw new Error("Horizontal and vertical page scroll values are not the same"); + } + return m_horizontalPageScroll; + } + + public function setHorizontalPageScroll(value:Number) { + m_horizontalPageScroll = value; + } + + public function horizontalPageScroll():Number { + return m_horizontalPageScroll; + } + + public function setVerticalPageScroll(value:Number) { + m_verticalPageScroll = value; + } + + public function verticalPageScroll():Number { + return m_verticalPageScroll; + } + + public function setScrollsDynamically(value:Boolean) { + if (m_scrollsDynamically == value) { + return true; + } + m_scrollsDynamically = value; + } + + public function scrollsDynamically():Boolean { + return m_scrollsDynamically; + } + + public function scrollWheel(event:NSEvent) { + //! Implement this? + } + + public function scrollAction(scroller:NSScroller) { + //! implement + } + + // Updating display after scrolling + public function reflectScrolledClipView(view:NSView) { //! implement } + + // Arranging components + + public function tile() { + var contentRect:NSRect; + var vScrollerRect:NSRect; + var hScrollerRect:NSRect; + var scrollerWidth = NSScroller.scrollerWidth(); + contentRect = m_bounds.insetRect(m_borderType.size.width, m_borderType.size.height); + if (m_hasVerticalScroller) { + vScrollerRect = new NSRect(contentRect.maxX() - scrollerWidth, contentRect.minY(), scrollerWidth, contentRect.size.height - scrollerWidth); + m_verticalScroller.setFrame(vScrollerRect); + contentRect.size.width -= (vScrollerRect.size.width); + } + if (m_hasHorizontalScroller) { + hScrollerRect = new NSRect(contentRect.minX(), contentRect.maxY() - scrollerWidth, contentRect.size.width - scrollerWidth, scrollerWidth); + m_horizontalScroller.setFrame(hScrollerRect); + contentRect.size.height -= (hScrollerRect.size.height); + } + m_contentView.setFrame(contentRect); + setNeedsDisplay(true); + } + + // Overridden functions + + public function drawRect(rect:NSRect) { + //! draw borders + } + + public function willRemoveSubview(view:NSView) { + if (view == m_contentView) { + m_contentView = null; + } + } + + public function setFrame(rect:NSRect) { + super.setFrame(rect); + tile(); + } + + public function setFrameSize(size:NSSize) { + super.setFrameSize(size); + tile(); + } + + public function resizeSubviewsWithOldSize(size:NSSize) { + super.resizeSubviewsWithOldSize(size); + tile(); + } + + public function isOpaque():Boolean { + return true; + } + } \ No newline at end of file |