1//////////////////////////////////////////////////////////////////////////////// 2// 3// ADOBE SYSTEMS INCORPORATED 4// Copyright 2007 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 mx.skins.halo 13{ 14 15import flash.system.Capabilities; 16import mx.controls.Image; 17import mx.core.UIComponent; 18import mx.states.SetProperty; 19import mx.states.State; 20 21/** 22 * The skin for the minimize button in the TitleBar 23 * of a WindowedApplication or Window. 24 * 25 * @playerversion AIR 1.1 26 */ 27public class WindowMinimizeButtonSkin extends UIComponent 28{ 29 include "../../core/Version.as"; 30 31 //-------------------------------------------------------------------------- 32 // 33 // Class assets 34 // 35 //-------------------------------------------------------------------------- 36 37 [Embed(source="../../../../assets/mac_min_up.png")] 38 private static var macMinUpSkin:Class; 39 40 [Embed(source="../../../../assets/win_min_up.png")] 41 private static var winMinUpSkin:Class; 42 43 [Embed(source="../../../../assets/mac_min_over.png")] 44 private static var macMinOverSkin:Class; 45 46 [Embed(source="../../../../assets/win_min_over.png")] 47 private static var winMinOverSkin:Class; 48 49 [Embed(source="../../../../assets/mac_min_down.png")] 50 private static var macMinDownSkin:Class; 51 52 [Embed(source="../../../../assets/win_min_down.png")] 53 private static var winMinDownSkin:Class; 54 55 [Embed(source="../../../../assets/mac_min_dis.png")] 56 private static var macMinDisabledSkin:Class; 57 58 [Embed(source="../../../../assets/win_min_dis.png")] 59 private static var winMinDisabledSkin:Class; 60 61 //-------------------------------------------------------------------------- 62 // 63 // Constructor 64 // 65 //-------------------------------------------------------------------------- 66 67 /** 68 * Constructor. 69 */ 70 public function WindowMinimizeButtonSkin() 71 { 72 super(); 73 74 isMac = Capabilities.os.substring(0,3) == "Mac"; 75 } 76 77 //-------------------------------------------------------------------------- 78 // 79 // Variables 80 // 81 //-------------------------------------------------------------------------- 82 83 /** 84 * @private 85 */ 86 private var isMac:Boolean; 87 88 /** 89 * @private 90 */ 91 private var skinImage:Image; 92 93 //-------------------------------------------------------------------------- 94 // 95 // Overridden properties: UIComponent 96 // 97 //-------------------------------------------------------------------------- 98 99 //---------------------------------- 100 // measuredHeight 101 //---------------------------------- 102 103 /** 104 * @private 105 */ 106 override public function get measuredHeight():Number 107 { 108 if (skinImage.measuredHeight) 109 return skinImage.measuredHeight; 110 else 111 return 13; 112 } 113 114 //---------------------------------- 115 // measuredWidth 116 //---------------------------------- 117 118 /** 119 * @private 120 */ 121 override public function get measuredWidth():Number 122 { 123 if (skinImage.measuredWidth) 124 return skinImage.measuredWidth; 125 else 126 return 12; 127 } 128 129 //-------------------------------------------------------------------------- 130 // 131 // Overridden methods: UIComponent 132 // 133 //-------------------------------------------------------------------------- 134 135 /** 136 * @private 137 */ 138 override protected function createChildren():void 139 { 140 skinImage = new Image(); 141 addChild(skinImage); 142 143 initializeStates(); 144 145 skinImage.setActualSize(12, 13); 146 skinImage.move(0, 0); 147 } 148 149 //-------------------------------------------------------------------------- 150 // 151 // Methods 152 // 153 //-------------------------------------------------------------------------- 154 155 /** 156 * @private 157 */ 158 private function initializeStates():void 159 { 160 var upState:State = new State(); 161 upState.name = "up"; 162 var upProp:SetProperty = new SetProperty(); 163 upProp.name = "source"; 164 upProp.target = skinImage; 165 upProp.value = isMac ? macMinUpSkin : winMinUpSkin; 166 upState.overrides.push(upProp); 167 states.push(upState); 168 169 var downState:State = new State(); 170 downState.name = "down"; 171 var downProp:SetProperty = new SetProperty(); 172 downProp.name = "source"; 173 downProp.target = skinImage; 174 downProp.value = isMac ? macMinDownSkin : winMinDownSkin; 175 downState.overrides.push(downProp); 176 states.push(downState); 177 178 var overState:State = new State(); 179 overState.name = "over"; 180 var overProp:SetProperty = new SetProperty(); 181 overProp.name = "source"; 182 overProp.target = skinImage; 183 overProp.value = isMac ? macMinOverSkin : winMinOverSkin; 184 overState.overrides.push(overProp); 185 states.push(overState); 186 187 var disabledState:State = new State(); 188 disabledState.name = "disabled"; 189 var disabledProp:SetProperty = new SetProperty(); 190 disabledProp.name = "source"; 191 disabledProp.target = skinImage; 192 disabledProp.value = isMac ? macMinDisabledSkin : winMinDisabledSkin; 193 disabledState.overrides.push(disabledProp); 194 states.push(disabledState); 195 } 196} 197 198} 199