From: Richard K. <ric...@us...> - 2005-05-15 04:28:25
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22659 Modified Files: NSTabView.as NSTabViewItem.as NSView.as NSWindow.as Log Message: got tabs working! Index: NSView.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSView.as,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NSView.as 5 May 2005 16:30:03 -0000 1.3 --- NSView.as 15 May 2005 04:28:16 -0000 1.4 *************** *** 118,122 **** m_notificationCenter = m_notificationCenter; m_frame = newFrame.clone(); ! m_bounds = new NSRect(0, 0,m_frame.size.width, m_frame.size.height); return this; } --- 118,122 ---- m_notificationCenter = m_notificationCenter; m_frame = newFrame.clone(); ! m_bounds = new NSRect(0, 0, m_frame.size.width, m_frame.size.height); return this; } *************** *** 479,482 **** --- 479,483 ---- public function setFrame(newFrame:NSRect):Void { m_frame = newFrame.clone(); + m_bounds.size = m_frame.size.clone(); updateFrameMovieClipSize(); if(m_postsFrameChangeNotifications) { *************** *** 500,503 **** --- 501,505 ---- public function setFrameSize(size:NSSize) { m_frame.size = size.clone(); + m_bounds.size = size.clone(); updateFrameMovieClipSize(); if(m_postsFrameChangeNotifications) { *************** *** 529,533 **** public function bounds():NSRect { ! return bounds.clone(); } --- 531,535 ---- public function bounds():NSRect { ! return m_bounds.clone(); } Index: NSWindow.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSWindow.as,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** NSWindow.as 10 May 2005 02:17:28 -0000 1.6 --- NSWindow.as 15 May 2005 04:28:16 -0000 1.7 *************** *** 316,324 **** case NSEvent.NSLeftMouseDown: if (event.view.acceptsFirstResponder()) { ! //if (!m_fieldEditor.isEditing()) { ! makeFirstResponder(event.view); ! //} ! event.view.mouseDown(event); } break; case NSEvent.NSLeftMouseUp: --- 316,322 ---- case NSEvent.NSLeftMouseDown: if (event.view.acceptsFirstResponder()) { ! makeFirstResponder(event.view); } + event.view.mouseDown(event); break; case NSEvent.NSLeftMouseUp: Index: NSTabView.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSTabView.as,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NSTabView.as 14 May 2005 04:47:21 -0000 1.1 --- NSTabView.as 15 May 2005 04:28:16 -0000 1.2 *************** *** 34,37 **** --- 34,38 ---- import org.actionstep.NSRect; import org.actionstep.NSSize; + import org.actionstep.NSEvent; import org.actionstep.NSFont; import org.actionstep.NSTabViewItem; *************** *** 43,46 **** --- 44,49 ---- class org.actionstep.NSTabView extends NSView { + + public static var TAB_HEIGHT = 20; private var m_delegate:Object; *************** *** 59,62 **** --- 62,66 ---- m_drawsBackground = true; m_controlSize = NSControlSize.NSRegularControlSize; + m_tabViewType = NSTabViewType.NSTopTabsBezelBorder; m_allowsTruncatedLabels = false; } *************** *** 107,110 **** --- 111,115 ---- return i; } + i++; } return NSNotFound; *************** *** 228,234 **** public function contentRect():NSRect { ! var rect:NSRect = bounds().clone(); switch(m_tabViewType) { case NSTabViewType.NSTopTabsBezelBorder: break; case NSTabViewType.NSNoTabsBezelBorder: --- 233,243 ---- public function contentRect():NSRect { ! var rect:NSRect = bounds(); switch(m_tabViewType) { case NSTabViewType.NSTopTabsBezelBorder: + rect.origin.y+=TAB_HEIGHT+5; + rect.size.height-=(TAB_HEIGHT+10); + rect.origin.x+=5; + rect.size.width-=10; break; case NSTabViewType.NSNoTabsBezelBorder: *************** *** 281,294 **** return tabViewItem; } } return null; } // Drawing public function drawRect(rect:NSRect) { ! //m_mcBounds } } \ No newline at end of file --- 290,415 ---- return tabViewItem; } + i++; } return null; } + + /* - (void) mouseDown: (NSEvent *)theEvent + { + NSPoint location = [theEvent locationInWindow]; + NSTabViewItem *anItem = [self tabViewItemAtPoint: location]; + + if (anItem != nil && ![anItem isEqual: _selected]) + { + [self selectTabViewItem: anItem]; + } + }*/ + + public function mouseDown(event:NSEvent) { + var location:NSPoint = event.mouseLocation.clone(); + mcBounds().globalToLocal(location); + var item:NSTabViewItem = tabViewItemAtPoint(location); + if (item != null && item != m_selected) { + selectTabViewItem(item); + } + } // Drawing public function drawRect(rect:NSRect) { ! var i = 0; ! var tabViewItem; ! var tx = 5; ! var labelSize:NSSize; ! var selectedRect; ! var tabRect:NSRect = null; ! var fillColor = 0xdddddd; ! var x = rect.origin.x; ! var y = rect.origin.y; ! var width = rect.size.width-1; ! var height = rect.size.height-1; ! ! m_mcBounds.clear(); ! ! while ( (tabViewItem=tabViewItemAtIndex(i)) != null) { ! labelSize = tabViewItem.sizeOfLabel(); ! tabRect = new NSRect(x + tx, y, labelSize.width+14, TAB_HEIGHT); ! if (tabViewItem.tabState() == NSTabState.NSSelectedTab) { ! selectedRect = tabRect; ! } ! drawTabViewItemInRect(tabViewItem, tabRect); ! tx += labelSize.width+16 ! i++; ! } ! with (m_mcBounds) { ! beginFill(fillColor, 100); ! lineStyle(1, 0, 100); ! moveTo(x, y+TAB_HEIGHT); ! if (selectedRect != null) { ! lineTo(selectedRect.origin.x, y+TAB_HEIGHT); ! lineStyle(undefined, 0, 100); ! lineTo(selectedRect.origin.x+selectedRect.size.width, y+TAB_HEIGHT); ! lineStyle(1, 0, 100); ! } ! lineTo(x+width, y+TAB_HEIGHT); ! lineTo(x+width, y+height); ! lineTo(x, y+height); ! lineTo(x,y+TAB_HEIGHT); ! endFill(); ! } } + // PRIVATE FUNCTIONS + + private function drawTabViewItemInRect(item:NSTabViewItem, rect:NSRect) { + //function roundedRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, cornerRadius:Number, fillColor:Number, fillAlpha:Number):Void { + var fillColor:Number; + var fillAlpha:Number = 100; + if (item.tabState() == NSTabState.NSBackgroundTab) { + fillColor = 0xaaaaaa; + } else { + fillColor = 0xdddddd; + } + var x = rect.origin.x; + var y = rect.origin.y; + var width = rect.size.width; + var height = rect.size.height; + with (m_mcBounds) { + lineStyle(1, 0, 100); + beginFill(fillColor, fillAlpha); + moveTo(x,y); + lineTo(x+width, y); + lineTo(x+width, y+height); + lineStyle(undefined, 0, 100); + lineTo(x, y+height); + lineStyle(1, 0, 100); + lineTo(x,y); + endFill(); + } + item.drawLabelInRect(m_allowsTruncatedLabels, rect); + + /* + var cornerRadius = 5; + + with (m_mcBounds) { + beginFill(fillColor, fillAlpha); + moveTo(x+cornerRadius, y); + lineTo(x+width-cornerRadius, y); + curveTo(boxWidth, 0, boxWidth, cornerRadius); + lineTo(boxWidth, cornerRadius); + lineTo(boxWidth, boxHeight-cornerRadius); + curveTo(boxWidth, boxHeight, boxWidth-cornerRadius, boxHeight); + lineTo(boxWidth-cornerRadius, boxHeight); + lineTo(cornerRadius, boxHeight); + curveTo(0, boxHeight, 0, boxHeight-cornerRadius); + lineTo(0, boxHeight-cornerRadius); + lineTo(0, cornerRadius); + curveTo(0, 0, cornerRadius, 0); + lineTo(cornerRadius, 0); + endFill(); + } + */ + } + } \ No newline at end of file Index: NSTabViewItem.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSTabViewItem.as,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NSTabViewItem.as 14 May 2005 04:47:21 -0000 1.1 --- NSTabViewItem.as 15 May 2005 04:28:16 -0000 1.2 *************** *** 65,69 **** m_textField = m_tabView.createBoundsTextField(); m_textFormat = m_tabView.font().textFormat(); - m_textField.self = this; m_textField.text = tlabel; m_textField.selectable = false; --- 65,68 ---- *************** *** 76,81 **** m_textField.setTextFormat(m_textFormat); } ! m_textField.x = (rect.size.width - size.width)/2 + rect.origin.x; ! m_textField.y = (rect.size.height - size.height)/2 + rect.origin.y; } --- 75,80 ---- m_textField.setTextFormat(m_textFormat); } ! m_textField._x = (rect.size.width - size.width)/2 + rect.origin.x; ! m_textField._y = 12;//(rect.size.height - size.height)/2 + rect.origin.y; } |