1//////////////////////////////////////////////////////////////////////////////// 2// 3// ADOBE SYSTEMS INCORPORATED 4// Copyright 2003-2006 Adobe Systems Incorporated 5// All Rights Reserved. 6// 7// NOTICE: Adobe permits you to use, modify, and distribute this file 8// in accordance with the terms of the license agreement accompanying it. 9// 10//////////////////////////////////////////////////////////////////////////////// 11 12package haloclassic 13{ 14 15import flash.display.DisplayObject; 16import flash.display.GradientType; 17import mx.containers.ApplicationControlBar; 18import mx.core.Application; 19import mx.skins.Border; 20import mx.styles.IStyleClient; 21 22/** 23 * Documentation is not currently available. 24 * @review 25 */ 26public class ActivatorSkin extends Border 27{ 28 include "../mx/core/Version.as"; 29 30 //-------------------------------------------------------------------------- 31 // 32 // Constructor 33 // 34 //-------------------------------------------------------------------------- 35 36 /** 37 * Constructor. 38 */ 39 public function ActivatorSkin() 40 { 41 super(); 42 } 43 44 //-------------------------------------------------------------------------- 45 // 46 // Overridden methods 47 // 48 //-------------------------------------------------------------------------- 49 50 /** 51 * @private 52 */ 53 override protected function updateDisplayList(w:Number, h:Number):void 54 { 55 super.updateDisplayList(w, h); 56 57 if (!getStyle("translucent")) 58 drawHaloRect(width, height); 59 else 60 drawTranslucentHaloRect(w, h); 61 } 62 63 //-------------------------------------------------------------------------- 64 // 65 // Methods 66 // 67 //-------------------------------------------------------------------------- 68 69 /** 70 * @private 71 */ 72 private function drawHaloRect(w:Number, h:Number):void 73 { 74 var themeColor:uint = getStyle("themeColor"); 75 76 graphics.clear(); 77 78 switch (name) 79 { 80 case "itemUpSkin": // up/disabled 81 { 82 // invisible hit area 83 drawRoundRect( 84 x, y, w, h, 0, 85 0xFFFFFF, 0); 86 break; 87 } 88 89 case "itemDownSkin": 90 { 91 // outer border 92 drawRoundRect( 93 x, y, w, h, 0, 94 0x919999, 1); 95 96 drawRoundRect( 97 x + 1, y + 1, w - 2, h - 2, 0, 98 [ 0x333333, 0xFCFCFC ], 1, 99 rotatedGradientMatrix(0, 0, w, h, -90), 100 GradientType.RADIAL); 101 102 drawRoundRect( 103 x + 1, y + 1, w - 2, h - 2, 0, 104 themeColor, 0.5); 105 106 // highlight 107 drawRoundRect( 108 x + 3, y + 3, w - 6, h - 6, 0, 109 0xFFFFFF, 1); 110 111 // face 112 drawRoundRect( 113 x + 3, y + 4, w - 6, h - 7, 0, 114 themeColor, 0.2); 115 116 break; 117 } 118 119 case "itemOverSkin": 120 { 121 // OuterBorder 122 drawRoundRect( 123 x, y, w, h, 0, 124 0x919999, 1); 125 126 // OuterBorder 127 drawRoundRect( 128 x, y, w, h, 0, 129 themeColor, 0.5); 130 131 drawRoundRect( 132 x + 1, y + 1, w - 2, h - 2, 0, 133 [ 0xFFFFFF, 0xDDDDDD ], 1, 134 verticalGradientMatrix(0, 0, w, h), 135 GradientType.RADIAL); 136 137 // highlight 138 drawRoundRect( 139 x + 3, y + 3, w - 6, h - 6, 0, 140 0xFFFFFF, 1); 141 142 // face 143 drawRoundRect( 144 x + 3, y + 4, w - 6, h - 7, 0, 145 0xF8F8F8, 1); 146 147 break; 148 } 149 } 150 } 151 152 /** 153 * @private 154 * The drawTranslucentHaloRect function is called when the "translucent" 155 * style is set to true, which happens when a MenuBar is inside an ACB. 156 */ 157 private function drawTranslucentHaloRect(w:Number,h:Number):void 158 { 159 // Find the parent app bar's colors 160 var p:IStyleClient = parent as IStyleClient; 161 while (p && !(p is ApplicationControlBar)) 162 { 163 p = DisplayObject(p).parent as IStyleClient; 164 } 165 if (!p) 166 return; 167 168 var fillColor:Object = p.getStyle("fillColor"); 169 var backgroundColor:Object = 170 p.getStyle("backgroundColor"); 171 var backgroundAlpha:Number = 172 p.getStyle("backgroundAlpha"); 173 174 var radius:Number = p.getStyle("cornerRadius"); 175 var docked:Boolean = p.getStyle("docked"); 176 177 if (backgroundColor == "") 178 backgroundColor = null; 179 180 if (docked && !backgroundColor) 181 { 182 // the docked bar always has a background, so take the 183 // main application's background color 184 var pabc:Object = 185 Application.application.getStyle("backgroundColor"); 186 backgroundColor = pabc ? pabc : 0x919999; 187 } 188 189 graphics.clear(); 190 191 switch (name) 192 { 193 case "itemUpSkin": // up/disabled 194 { 195 drawRoundRect( 196 1, 1, w - 2, h - 1, 0, 197 0, 0); 198 199 break; 200 } 201 202 case "itemOverSkin": 203 { 204 if (backgroundColor) 205 { 206 drawRoundRect( 207 1, 1, w - 2, h - 1, 0, 208 backgroundColor, backgroundAlpha); 209 } 210 211 drawRoundRect( 212 1, 1, w - 2, h - 1, 0, 213 [ fillColor, fillColor, fillColor, fillColor, fillColor ], 214 [ 1, 0.75, 0.60, 0.70, 0.90 ], 215 verticalGradientMatrix(0, 0, w, h), 216 GradientType.LINEAR, 217 [ 0, 0x5F, 0x7F, 0xBF, 0xFF ]); 218 219 break; 220 } 221 222 case "itemDownSkin": 223 { 224 if (backgroundColor) 225 { 226 drawRoundRect( 227 1, 1, w - 2, h - 1, 0, 228 backgroundColor, backgroundAlpha); 229 } 230 231 drawRoundRect( 232 1, 1, w - 2, h - 1, 0, 233 [ fillColor, fillColor, fillColor, fillColor, fillColor ], 234 [ 0.85, 0.60, 0.45, 0.55, 0.75 ], 235 verticalGradientMatrix(0, 0, w, h), 236 GradientType.LINEAR, 237 [ 0, 0x5F, 0x7F, 0xBF, 0xFF ]); 238 239 break; 240 } 241 } 242 } 243} 244 245} 246