From: Richard K. <ric...@us...> - 2005-05-17 15:31:56
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9063 Modified Files: ASTheme.as ASThemeProtocol.as NSButtonCell.as Log Message: moved button cell drawing to ASTheme Index: ASThemeProtocol.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/ASThemeProtocol.as,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASThemeProtocol.as 17 May 2005 01:42:08 -0000 1.1 --- ASThemeProtocol.as 17 May 2005 15:31:40 -0000 1.2 *************** *** 49,51 **** --- 49,62 ---- */ public function drawFillWithRectColorInView(aRect:NSRect, aColor:NSColor, inView:NSView):Void; + + /** + * Draws a NSButton bezel with the supplied colorset (up, down, disabled) in the view. + */ + public function drawButtonBezeledWithRectColorsetInView(rect:NSRect, colorSet:String, view:NSView); + + /** + * Draws a NSButton bordered with the supplied colorset (up, down, disabled) in the view. + */ + public function drawButtonBorderedWithRectColorsetInView(rect:NSRect, colorSet:String, view:NSView); + } Index: NSButtonCell.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSButtonCell.as,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** NSButtonCell.as 12 May 2005 19:38:26 -0000 1.12 --- NSButtonCell.as 17 May 2005 15:31:40 -0000 1.13 *************** *** 28,31 **** --- 28,34 ---- * POSSIBILITY OF SUCH DAMAGE. */ + + import org.actionstep.ASTheme; + import org.actionstep.NSActionCell; *************** *** 40,44 **** import org.actionstep.NSSize; import org.actionstep.NSControl; - import org.actionstep.ASDraw; import org.actionstep.NSColor; import org.actionstep.NSCell; --- 43,46 ---- *************** *** 565,579 **** } - var colors; - if (m_enabled) { - if (m_highlighted) { - colors = g_buttonColors.down; - } else { - colors = g_buttonColors.up; - } - } else { - colors = g_buttonColors.disabled; - } - if (m_bordered) { borderSize = new NSSize(3,3); --- 567,570 ---- *************** *** 636,647 **** if (!m_bordered && !m_bezeled && m_backgroundColor != null) { ! ASDraw.drawFill(mc, m_backgroundColor.toHex(), x, y, width, height); } if (m_bordered) { ! ASDraw.drawFill(mc, colors.middle, x, y, width, height); ! ASDraw.drawRect(mc, 1, 0, x, y, width, height); } else if (m_bezeled) { - //draw top lines if (m_highlighted || !m_enabled) { m_textField._x += 1; --- 627,647 ---- if (!m_bordered && !m_bezeled && m_backgroundColor != null) { ! ASTheme.current().drawFillWithRectColorInView(cellFrame, m_backgroundColor, inView); ! } ! ! var colorset; ! if (m_enabled) { ! if (m_highlighted) { ! colorset = "down"; ! } else { ! colorset = "up"; ! } ! } else { ! colorset = "disabled"; } if (m_bordered) { ! ASTheme.current().drawButtonBorderedWithRectColorsetInView(cellFrame, colorset, inView); } else if (m_bezeled) { if (m_highlighted || !m_enabled) { m_textField._x += 1; *************** *** 650,673 **** imageLocation.y += 1; } ! ASDraw.drawFill(mc, colors.middle, x, y, width, height); ! ASDraw.drawHLine(mc, colors.top , x, x+width, y); ! ASDraw.drawHLine(mc, colors.top1, x, x+width, y+1); ! ASDraw.drawHLine(mc, colors.top2, x, x+width, y+2); ! ASDraw.drawHLine(mc, colors.top3, x, x+width, y+3); ! ! //draw bottom lines ! ASDraw.drawHLine(mc, colors.bottom , x, x+width, y+height ); ! ASDraw.drawHLine(mc, colors.bottom1, x, x+width, y+height-1); ! ASDraw.drawHLine(mc, colors.bottom2, x, x+width, y+height-2); ! ASDraw.drawHLine(mc, colors.bottom3, x, x+width, y+height-3); ! ! //draw left lines ! ASDraw.drawVLine(mc, colors.left , y, y+height, x ); ! ASDraw.drawVLineEdgeFade(mc, colors.left1, y, y+height, x+1, 5); ! ! //draw right lines ! ASDraw.drawVLine(mc, colors.right , y, y+height, x+width ); ! ASDraw.drawVLineEdgeFade(mc, colors.right1, y, y+height, x+width-1, 5); } if (image != null) { image.lockFocus(mc); --- 650,656 ---- imageLocation.y += 1; } ! ASTheme.current().drawButtonBezeledWithRectColorsetInView(cellFrame, colorset, inView); } + if (image != null) { image.lockFocus(mc); Index: ASTheme.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/ASTheme.as,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTheme.as 17 May 2005 01:42:08 -0000 1.1 --- ASTheme.as 17 May 2005 15:31:40 -0000 1.2 *************** *** 46,54 **** { private static var g_current:ASThemeProtocol; /** * Constructs a new instance of ASTheme. */ ! private function ASDrawer() { } --- 46,100 ---- { private static var g_current:ASThemeProtocol; + + private static var g_buttonColors = { + up: { + top: 0x82858E, + top1: 0xDFE2E9, + top2: 0xEEF2F5, + top3: 0xD4D8D9, + bottom: 0xD3D6DB, + bottom1: 0x858992, + bottom2: 0x9599A2, + bottom3: 0xACB1B7, + left: 0x82858E, + left1: 0xDFE2E9, + right: 0xD3D6DB, + right1: 0x858992, + middle: 0xC7CAD1}, + down: { + top: 0x6A6E79, + top1: 0x747883, + top2: 0x7C838B, + top3: 0x939AA2, + bottom: 0xBEC1C6, + bottom1: 0xCACED1, + bottom2: 0xDADDE2, + bottom3: 0xBEC1C6, + left: 0x6A6E79, + left1: 0x747883, + right: 0xBEC1C6, + right1: 0xCACED1, + middle: 0xB0B4BD}, + disabled: { + top: 0x81858E, + top1: 0x858992, + top2: 0x9599A2, + top3: 0xABAFB6, + bottom: 0xD3D6DB, + bottom1: 0xDDE0E4, + bottom2: 0xEFF2F6, + bottom3: 0xD2D5DA, + left: 0x82858C, + left1: undefined, + right: 0x82858A, + right1: 0xE9ECF1, + middle: 0xC7CACF} + }; + /** * Constructs a new instance of ASTheme. */ ! private function ASTheme() { } *************** *** 71,74 **** --- 117,161 ---- } + public function drawButtonBorderedWithRectColorsetInView(rect:NSRect, colorSet:String, view:NSView) { + var x = rect.origin.x; + var y = rect.origin.y; + var width = rect.size.width; + var height = rect.size.height; + var mc = view.mcBounds(); + var colors = g_buttonColors[colorSet]; + ASDraw.drawFill(mc, colors.middle, x, y, width, height); + ASDraw.drawRect(mc, 1, 0, x, y, width, height); + } + + + public function drawButtonBezeledWithRectColorsetInView(rect:NSRect, colorSet:String, view:NSView) { + var x = rect.origin.x; + var y = rect.origin.y; + var width = rect.size.width; + var height = rect.size.height; + var mc = view.mcBounds(); + var colors = g_buttonColors[colorSet]; + + //draw top lines + ASDraw.drawFill(mc, colors.middle, x, y, width, height); + ASDraw.drawHLine(mc, colors.top , x, x+width, y); + ASDraw.drawHLine(mc, colors.top1, x, x+width, y+1); + ASDraw.drawHLine(mc, colors.top2, x, x+width, y+2); + ASDraw.drawHLine(mc, colors.top3, x, x+width, y+3); + + //draw bottom lines + ASDraw.drawHLine(mc, colors.bottom , x, x+width, y+height ); + ASDraw.drawHLine(mc, colors.bottom1, x, x+width, y+height-1); + ASDraw.drawHLine(mc, colors.bottom2, x, x+width, y+height-2); + ASDraw.drawHLine(mc, colors.bottom3, x, x+width, y+height-3); + + //draw left lines + ASDraw.drawVLine(mc, colors.left , y, y+height, x ); + ASDraw.drawVLineEdgeFade(mc, colors.left1, y, y+height, x+1, 5); + + //draw right lines + ASDraw.drawVLine(mc, colors.right , y, y+height, x+width ); + ASDraw.drawVLineEdgeFade(mc, colors.right1, y, y+height, x+width-1, 5); + } /** *************** *** 77,81 **** public function description():String { ! return "ASDrawer"; } --- 164,168 ---- public function description():String { ! return "ASTheme"; } |