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 maximize button in the TitleBar 23 * of a WindowedApplication or Window. 24 * 25 * @playerversion AIR 1.1 26 */ 27public class WindowMaximizeButtonSkin extends UIComponent 28{ 29 include "../../core/Version.as"; 30 31 //-------------------------------------------------------------------------- 32 // 33 // Class assets 34 // 35 //-------------------------------------------------------------------------- 36 37 [Embed(source="../../../../assets/mac_max_up.png")] 38 private static var macMaxUpSkin:Class; 39 40 [Embed(source="../../../../assets/win_max_up.png")] 41 private static var winMaxUpSkin:Class; 42 43 [Embed(source="../../../../assets/mac_max_over.png")] 44 private static var macMaxOverSkin:Class; 45 46 [Embed(source="../../../../assets/win_max_over.png")] 47 private static var winMaxOverSkin:Class; 48 49 [Embed(source="../../../../assets/mac_max_down.png")] 50 private static var macMaxDownSkin:Class; 51 52 [Embed(source="../../../../assets/win_max_down.png")] 53 private static var winMaxDownSkin:Class; 54 55 [Embed(source="../../../../assets/mac_max_dis.png")] 56 private static var macMaxDisabledSkin:Class; 57 58 [Embed(source="../../../../assets/win_max_dis.png")] 59 private static var winMaxDisabledSkin:Class; 60 61 [Embed(source="../../../../assets/win_restore_up.png")] 62 private static var winRestoreUpSkin:Class; 63 64 [Embed(source="../../../../assets/win_restore_down.png")] 65 private static var winRestoreDownSkin:Class; 66 67 [Embed(source="../../../../assets/win_restore_over.png")] 68 private static var winRestoreOverSkin:Class; 69 70 //-------------------------------------------------------------------------- 71 // 72 // Constructor 73 // 74 //-------------------------------------------------------------------------- 75 76 /** 77 * Constructor. 78 */ 79 public function WindowMaximizeButtonSkin() 80 { 81 super(); 82 83 isMac = Capabilities.os.substring(0,3) == "Mac"; 84 } 85 86 //-------------------------------------------------------------------------- 87 // 88 // Variables 89 // 90 //-------------------------------------------------------------------------- 91 92 /** 93 * @private 94 */ 95 private var isMac:Boolean; 96 97 /** 98 * @private 99 */ 100 private var skinImage:Image; 101 102 //-------------------------------------------------------------------------- 103 // 104 // Overridden properties: UIComponent 105 // 106 //-------------------------------------------------------------------------- 107 108 //---------------------------------- 109 // measuredHeight 110 //---------------------------------- 111 112 /** 113 * @private 114 */ 115 override public function get measuredHeight():Number 116 { 117 if (skinImage.measuredHeight) 118 return skinImage.measuredHeight; 119 else 120 return 13; 121 } 122 123 //---------------------------------- 124 // measuredWidth 125 //---------------------------------- 126 127 /** 128 * @private 129 */ 130 override public function get measuredWidth():Number 131 { 132 if (skinImage.measuredWidth) 133 return skinImage.measuredWidth; 134 else 135 return 12; 136 } 137 138 //-------------------------------------------------------------------------- 139 // 140 // Overridden methods: UIComponent 141 // 142 //-------------------------------------------------------------------------- 143 144 /** 145 * @private 146 */ 147 override protected function createChildren():void 148 { 149 skinImage = new Image(); 150 addChild(skinImage); 151 152 initializeStates(); 153 154 skinImage.setActualSize(12, 13); 155 skinImage.move(0, 0); 156 } 157 158 //-------------------------------------------------------------------------- 159 // 160 // Methods 161 // 162 //-------------------------------------------------------------------------- 163 164 /** 165 * @private 166 */ 167 private function initializeStates():void 168 { 169 var upState:State = new State(); 170 upState.name = "up"; 171 var upProp:SetProperty = new SetProperty(); 172 upProp.name = "source"; 173 upProp.target = skinImage; 174 upProp.value = isMac ? macMaxUpSkin : winMaxUpSkin; 175 upState.overrides.push(upProp); 176 states.push(upState); 177 178 var downState:State = new State(); 179 downState.name = "down"; 180 var downProp:SetProperty = new SetProperty(); 181 downProp.name = "source"; 182 downProp.target = skinImage; 183 downProp.value = isMac ? macMaxDownSkin : winMaxDownSkin; 184 downState.overrides.push(downProp); 185 states.push(downState); 186 187 var overState:State = new State(); 188 overState.name = "over"; 189 var overProp:SetProperty = new SetProperty(); 190 overProp.name = "source"; 191 overProp.target = skinImage; 192 overProp.value = isMac ? macMaxOverSkin : winMaxOverSkin; 193 overState.overrides.push(overProp); 194 states.push(overState); 195 196 var disabledState:State = new State(); 197 disabledState.name = "disabled"; 198 var disabledProp:SetProperty = new SetProperty(); 199 disabledProp.name = "source"; 200 disabledProp.target = skinImage; 201 disabledProp.value = isMac ? macMaxDisabledSkin : winMaxDisabledSkin; 202 disabledState.overrides.push(disabledProp); 203 states.push(disabledState); 204 } 205} 206 207} 208