PageRenderTime 27ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 1ms

/FD3/FlashDevelop/Bin/Debug/Library/AS3/frameworks/FlashIDE/fl/controls/LabelButton.as

https://bitbucket.org/kkszysiu/flashdevelop
ActionScript | 238 lines | 75 code | 4 blank | 159 comment | 0 complexity | b236457cad6ba35c0b6e3425cf6acc3d MD5 | raw file
  1. package fl.controls
  2. {
  3. import fl.controls.BaseButton;
  4. import fl.controls.ButtonLabelPlacement;
  5. import fl.controls.TextInput;
  6. import fl.core.InvalidationType;
  7. import fl.core.UIComponent;
  8. import fl.events.ComponentEvent;
  9. import fl.managers.IFocusManagerComponent;
  10. import flash.events.Event;
  11. import flash.events.KeyboardEvent;
  12. import flash.events.MouseEvent;
  13. import flash.display.DisplayObject;
  14. import flash.display.Sprite;
  15. import flash.geom.Point;
  16. import flash.text.TextField;
  17. import flash.text.TextFieldType;
  18. import flash.text.TextFormat;
  19. import flash.ui.Keyboard;
  20. /**
  21. * Dispatched after the toggle button receives input from * a mouse device or from the spacebar. * * @eventType flash.events.MouseEvent.CLICK * * @includeExample examples/LabelButton.click.1.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  22. */
  23. [Event(name="click", type="flash.events.MouseEvent")]
  24. /**
  25. * Dispatched after the label value changes. * * @eventType fl.events.ComponentEvent.LABEL_CHANGE * * @includeExample examples/LabelButton.labelChange.1.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  26. */
  27. [Event(name="labelChange", type="fl.events.ComponentEvent")]
  28. /**
  29. * Name of the class to use as the skin for the background and border * when the button is not selected and is disabled. * * @default Button_disabledSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  30. */
  31. [Style(name="disabledSkin", type="Class")]
  32. /**
  33. * Name of the class to use as the skin for the background and border * when the button is not selected and the mouse is not over the component. * * @default Button_upSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  34. */
  35. [Style(name="upSkin", type="Class")]
  36. /**
  37. * Name of the class to use as the skin for the background and border * when the button is not selected and the mouse button is down. * * @default Button_downSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  38. */
  39. [Style(name="downSkin", type="Class")]
  40. /**
  41. * Name of the class to use as the skin for the background and border * when the button is not selected and the mouse is over the component. * * @default Button_overSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  42. */
  43. [Style(name="overSkin", type="Class")]
  44. /**
  45. * Name of the class to use as the skin for the background and border * when a toggle button is selected and disabled. * * @default Button_selectedDisabledSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  46. */
  47. [Style(name="selectedDisabledSkin", type="Class")]
  48. /**
  49. * Name of the class to use as the skin for the background and border * when a toggle button is selected and the mouse is not over the component. * * @default Button_selectedUpSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  50. */
  51. [Style(name="selectedUpSkin", type="Class")]
  52. /**
  53. * Name of the class to use as the skin for the background and border * when a toggle button is selected and the mouse button is down. * * @default Button_selectedDownSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  54. */
  55. [Style(name="selectedDownSkin", type="Class")]
  56. /**
  57. * Name of the class to use as the skin for the background and border * when a toggle button is selected and the mouse is over the component. * * @default Button_selectedOverSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  58. */
  59. [Style(name="selectedOverSkin", type="Class")]
  60. /**
  61. * The spacing between the text and the edges of the component, and the * spacing between the text and the icon, in pixels. * * @default 5 * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  62. */
  63. [Style(name="textPadding", type="Number", format="Length")]
  64. /**
  65. * @copy fl.controls.BaseButton#style:repeatDelay * * @default 500 * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  66. */
  67. [Style(name="repeatDelay", type="Number", format="Time")]
  68. /**
  69. * @copy fl.controls.BaseButton#style:repeatInterval * * @default 35 * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  70. */
  71. [Style(name="repeatInterval", type="Number", format="Time")]
  72. /**
  73. * Name of the class to use as the icon when a toggle button is not selected * and the mouse is not over the button. * * @default null * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  74. */
  75. [Style(name="icon", type="Class")]
  76. /**
  77. * Name of the class to use as the icon when a toggle button is not selected and the mouse is not over the button. * * @default null * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  78. */
  79. [Style(name="upIcon", type="Class")]
  80. /**
  81. * Name of the class to use as the icon when the button is not selected and the mouse button is down. * * @default null * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  82. */
  83. [Style(name="downIcon", type="Class")]
  84. /**
  85. * Name of the class to use as the icon when the button is not selected and the mouse is over the component. * * @default null * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  86. */
  87. [Style(name="overIcon", type="Class")]
  88. /**
  89. * Name of the class to use as the icon when the button is not disabled. * * @default null * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  90. */
  91. [Style(name="disabledIcon", type="Class")]
  92. /**
  93. * Name of the class to use as the icon when the button is selected and disabled. * * @default null * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  94. */
  95. [Style(name="selectedDisabledIcon", type="Class")]
  96. /**
  97. * Name of the class to use as the icon when the button is selected and the mouse button is up. * * @default null * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  98. */
  99. [Style(name="selectedUpIcon", type="Class")]
  100. /**
  101. * Name of the class to use as the icon when the button is selected and the mouse button is down. * * @default null * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  102. */
  103. [Style(name="selectedDownIcon", type="Class")]
  104. /**
  105. * Name of the class to use as the icon when the button is selected and the mouse is over the component. * * @default null * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  106. */
  107. [Style(name="selectedOverIcon", type="Class")]
  108. /**
  109. * Indicates whether embedded font outlines are used to render the text field. * If this value is <code>true</code>, Flash Player renders the text field * by using embedded font outlines. If this value is <code>false</code>, * Flash Player renders the text field by using device fonts. * * <p>If you set the <code>embedFonts</code> property to <code>true</code> * for a text field, you must specify a font for that text by using the * <code>font</code> property of a TextFormat object that is applied to the text field. * If the specified font is not embedded in the SWF file, the text is not displayed.</p> * * @default false * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  110. */
  111. [Style(name="embedFonts", type="Boolean")]
  112. /**
  113. * The LabelButton class is an abstract class that extends the * BaseButton class by adding a label, an icon, and toggle functionality. * The LabelButton class is subclassed by the Button, CheckBox, RadioButton, and * CellRenderer classes. * * <p>The LabelButton component is used as a simple button class that can be * combined with custom skin states that support ScrollBar buttons, NumericStepper * buttons, ColorPicker swatches, and so on.</p> * * @includeExample examples/LabelButtonExample.as -noswf * @includeExample examples/IconWithToolTip.as * * @see fl.controls.BaseButton * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  114. */
  115. public class LabelButton extends BaseButton implements IFocusManagerComponent
  116. {
  117. /**
  118. * A reference to the component's internal text field. * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  119. */
  120. public var textField : TextField;
  121. /**
  122. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  123. */
  124. protected var _labelPlacement : String;
  125. /**
  126. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  127. */
  128. protected var _toggle : Boolean;
  129. /**
  130. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  131. */
  132. protected var icon : DisplayObject;
  133. /**
  134. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  135. */
  136. protected var oldMouseState : String;
  137. /**
  138. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  139. */
  140. protected var _label : String;
  141. /**
  142. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  143. */
  144. protected var mode : String;
  145. /**
  146. * @private * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  147. */
  148. private static var defaultStyles : Object;
  149. /**
  150. * @private * Method for creating the Accessibility class. * This method is called from UIComponent. * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  151. */
  152. public static var createAccessibilityImplementation : Function;
  153. /**
  154. * Gets or sets the text label for the component. By default, the label * text appears centered on the button. * * <p><strong>Note:</strong> Setting this property triggers the <code>labelChange</code> * event object to be dispatched.</p> * * @default "Label" * * @see #event:labelChange * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  155. */
  156. public function get label () : String;
  157. /**
  158. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  159. */
  160. public function set label (value:String) : void;
  161. /**
  162. * Position of the label in relation to a specified icon. * * <p>In ActionScript, you can use the following constants to set this property:</p> * * <ul> * <li><code>ButtonLabelPlacement.RIGHT</code></li> * <li><code>ButtonLabelPlacement.LEFT</code></li> * <li><code>ButtonLabelPlacement.BOTTOM</code></li> * <li><code>ButtonLabelPlacement.TOP</code></li> * </ul> * * @default ButtonLabelPlacement.RIGHT * * @includeExample examples/LabelButton.labelPlacement.1.as -noswf * * @see ButtonLabelPlacement * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  163. */
  164. public function get labelPlacement () : String;
  165. /**
  166. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  167. */
  168. public function set labelPlacement (value:String) : void;
  169. /**
  170. * Gets or sets a Boolean value that indicates whether a button * can be toggled. A value of <code>true</code> indicates that it * can; a value of <code>false</code> indicates that it cannot. * * <p>If this value is <code>true</code>, clicking the button * toggles it between selected and unselected states. You can get * or set this state programmatically by using the <code>selected</code> * property.</p> * * <p>If this value is <code>false</code>, the button does not * stay pressed after the user releases it. In this case, its * <code>selected</code> property is always <code>false</code>.</p> * * <p><strong>Note:</strong> When the <code>toggle</code> is set to <code>false</code>, * <code>selected</code> is forced to <code>false</code> because only * toggle buttons can be selected.</p> * * @default false * * @includeExample examples/LabelButton.toggle.2.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  171. */
  172. public function get toggle () : Boolean;
  173. /**
  174. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  175. */
  176. public function set toggle (value:Boolean) : void;
  177. /**
  178. * Gets or sets a Boolean value that indicates whether * a toggle button is toggled in the on or off position. * A value of <code>true</code> indicates that it is * toggled in the on position; a value of <code>false</code> indicates * that it is toggled in the off position. This property can be * set only if the <code>toggle</code> property is set to <code>true</code>. * * <p>For a CheckBox component, this value indicates whether the box * displays a check mark. For a RadioButton component, this value * indicates whether the component is selected.</p> * * <p>The user can change this property by clicking the component, * but you can also set this property programmatically.</p> * * <p>If the <code>toggle</code> property is set to <code>true</code>, * changing this property also dispatches a <code>change</code> event.</p> * * @default false * * @includeExample examples/LabelButton.toggle.1.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  179. */
  180. public function get selected () : Boolean;
  181. /**
  182. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  183. */
  184. public function set selected (value:Boolean) : void;
  185. /**
  186. * @copy fl.core.UIComponent#getStyleDefinition() * * @includeExample ../core/examples/UIComponent.getStyleDefinition.1.as -noswf * * @see fl.core.UIComponent#getStyle() * @see fl.core.UIComponent#setStyle() * @see fl.managers.StyleManager * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  187. */
  188. public static function getStyleDefinition () : Object;
  189. /**
  190. * Creates a new LabelButton component instance. * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  191. */
  192. public function LabelButton ();
  193. /**
  194. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  195. */
  196. protected function toggleSelected (event:MouseEvent) : void;
  197. /**
  198. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  199. */
  200. protected function configUI () : void;
  201. /**
  202. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  203. */
  204. protected function draw () : void;
  205. /**
  206. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  207. */
  208. protected function drawIcon () : void;
  209. /**
  210. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  211. */
  212. protected function drawTextFormat () : void;
  213. /**
  214. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  215. */
  216. protected function setEmbedFont ();
  217. /**
  218. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  219. */
  220. protected function drawLayout () : void;
  221. /**
  222. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  223. */
  224. protected function keyDownHandler (event:KeyboardEvent) : void;
  225. /**
  226. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  227. */
  228. protected function keyUpHandler (event:KeyboardEvent) : void;
  229. /**
  230. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  231. */
  232. protected function initializeAccessibility () : void;
  233. }
  234. }