PageRenderTime 54ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/kkszysiu/flashdevelop
ActionScript | 421 lines | 126 code | 4 blank | 291 comment | 0 complexity | bed434228e6910ac881f002fd92e9f5c MD5 | raw file
  1. package fl.controls
  2. {
  3. import fl.core.UIComponent;
  4. import fl.core.InvalidationType;
  5. import fl.controls.BaseButton;
  6. import fl.controls.TextInput;
  7. import fl.controls.TextArea;
  8. import fl.events.ComponentEvent;
  9. import fl.events.ColorPickerEvent;
  10. import fl.managers.IFocusManager;
  11. import fl.managers.IFocusManagerComponent;
  12. import flash.events.MouseEvent;
  13. import flash.events.Event;
  14. import flash.events.KeyboardEvent;
  15. import flash.events.FocusEvent;
  16. import flash.display.DisplayObject;
  17. import flash.display.Graphics;
  18. import flash.display.Sprite;
  19. import flash.geom.ColorTransform;
  20. import flash.geom.Point;
  21. import flash.geom.Rectangle;
  22. import flash.text.TextField;
  23. import flash.text.TextFieldType;
  24. import flash.text.TextFormat;
  25. import flash.ui.Keyboard;
  26. import flash.system.IME;
  27. /**
  28. * Dispatched when the user opens the color palette. * * @eventType flash.events.Event.OPEN * * @includeExample examples/ColorPicker.open.2.as -noswf * * @see #event:close * @see #open() * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  29. */
  30. [Event(name="open", type="flash.events.Event")]
  31. /**
  32. * Dispatched when the user closes the color palette. * * @eventType flash.events.Event.CLOSE * * @see #event:open * @see #close() * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  33. */
  34. [Event(name="close", type="flash.events.Event")]
  35. /**
  36. * Dispatched when the user clicks a color in the palette. * * @includeExample examples/ColorPicker.hexValue.1.as -noswf * * @eventType fl.events.ColorPickerEvent.CHANGE * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  37. */
  38. [Event(name="change", type="fl.events.ColorPickerEvent")]
  39. /**
  40. * Dispatched when the user rolls over a swatch in the color palette. * * @eventType fl.events.ColorPickerEvent.ITEM_ROLL_OVER * * @see #event:itemRollOut * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  41. */
  42. [Event(name="itemRollOver", type="fl.events.ColorPickerEvent")]
  43. /**
  44. * Dispatched when the user rolls out of a swatch in the color palette. * * @eventType fl.events.ColorPickerEvent.ITEM_ROLL_OUT * * @see #event:itemRollOver * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  45. */
  46. [Event(name="itemRollOut", type="fl.events.ColorPickerEvent")]
  47. /**
  48. * Dispatched when the user presses the Enter key after editing the internal text field of the ColorPicker component. * * @eventType fl.events.ColorPickerEvent.ENTER * * @includeExample examples/ColorPicker.enter.1.as -noswf * * @see #editable * @see #textField * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  49. */
  50. [Event(name="enter", type="fl.events.ColorPickerEvent")]
  51. /**
  52. * Defines the padding that appears around each swatch in the color palette, in pixels. * * @default 1 * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  53. */
  54. [Style(name="swatchPadding", type="Number", format="Length")]
  55. /**
  56. * The class that provides the skin for a disabled button in the ColorPicker. * * @default ColorPicker_disabledSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 * * @internal [kenos] Changed description from "Disabled skin for the ColorPicker button" to the current. * Is this correct?
  57. */
  58. [Style(name="disabledSkin", type="Class")]
  59. /**
  60. * The padding that appears around the color TextField, in pixels. * * @default 3 * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  61. */
  62. [Style(name="textPadding", type="Number", format="Length")]
  63. /**
  64. * The class that provides the skin for the color well when the pointing device rolls over it. * * @default ColorPicker_overSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  65. */
  66. [Style(name="overSkin", type="Class")]
  67. /**
  68. * The padding that appears around the group of color swatches, in pixels. * * @default 5 * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  69. */
  70. [Style(name="backgroundPadding", type="Number", format="Length")]
  71. /**
  72. * The class that provides the skin for the color well when it is filled with a color. * * @default ColorPicker_colorWell * * @langversion 3.0 * @playerversion Flash 9.0.28.0 *
  73. */
  74. [Style(name="colorWell", type="Class")]
  75. /**
  76. * The class that provides the skin for the ColorPicker button when it is in the down position. * * @default ColorPicker_downSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 * * @internal [kenos] Description was "Down skin for the ColorPicker button." Is the revised description correct?
  77. */
  78. [Style(name="downSkin", type="Class")]
  79. /**
  80. * The class that provides the background for the text field of the ColorPicker component. * * @default ColorPicker_textFieldSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  81. */
  82. [Style(name="textFieldSkin", type="Class")]
  83. /**
  84. * The class that provides the background of the palette that appears in the ColorPicker component. * * @default ColorPicker_backgroundSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  85. */
  86. [Style(name="background", type="Class")]
  87. /**
  88. * The class that provides the skin which is used to draw the swatches contained in the ColorPicker component. * * @default ColorPicker_swatchSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  89. */
  90. [Style(name="swatchSkin", type="Class")]
  91. /**
  92. * The class that provides the skin which is used to highlight the currently selected color. * * @default ColorPicker_swatchSelectedSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  93. */
  94. [Style(name="swatchSelectedSkin", type="Class")]
  95. /**
  96. * The width of each swatch, in pixels. * * @default 10 * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  97. */
  98. [Style(name="swatchWidth", type="Number", format="Length")]
  99. /**
  100. * The height of each swatch, in pixels. * * @default 10 * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  101. */
  102. [Style(name="swatchHeight", type="Number", format="Length")]
  103. /**
  104. * The number of columns to be drawn in the ColorPicker color palette. * * @default 18 * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  105. */
  106. [Style(name="columnCount", type="Number", format="Length")]
  107. /**
  108. * The class that provides the skin for the ColorPicker button when it is in the up position. * * @default ColorPicker_upSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 * * @internal [kenos] The previous description was "Up skin for the ColorPicker button." Is the revised description * correct?
  109. */
  110. [Style(name="upSkin", type="Class")]
  111. /**
  112. * @copy fl.controls.LabelButton#style:embedFonts * * @default false * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  113. */
  114. [Style(name="embedFonts", type="Boolean")]
  115. /**
  116. * The ColorPicker component displays a list of one or more swatches * from which the user can select a color. * * <p>By default, the component displays a single swatch of color on a * square button. When the user clicks this button, a panel opens to * display the complete list of swatches.</p> * * @includeExample examples/ColorPickerExample.as * * @see fl.events.ColorPickerEvent ColorPickerEvent * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  117. */
  118. public class ColorPicker extends UIComponent implements IFocusManagerComponent
  119. {
  120. /**
  121. * A reference to the internal text field of the ColorPicker component. * * @see #showTextField * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  122. */
  123. public var textField : TextField;
  124. /**
  125. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  126. */
  127. protected var customColors : Array;
  128. /**
  129. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  130. */
  131. public static var defaultColors : Array;
  132. /**
  133. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  134. */
  135. protected var colorHash : Object;
  136. /**
  137. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  138. */
  139. protected var paletteBG : DisplayObject;
  140. /**
  141. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  142. */
  143. protected var selectedSwatch : Sprite;
  144. /**
  145. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  146. */
  147. protected var _selectedColor : uint;
  148. /**
  149. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  150. */
  151. protected var rollOverColor : int;
  152. /**
  153. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  154. */
  155. protected var _editable : Boolean;
  156. /**
  157. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  158. */
  159. protected var _showTextField : Boolean;
  160. /**
  161. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  162. */
  163. protected var isOpen : Boolean;
  164. /**
  165. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  166. */
  167. protected var doOpen : Boolean;
  168. /**
  169. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  170. */
  171. protected var swatchButton : BaseButton;
  172. /**
  173. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  174. */
  175. protected var colorWell : DisplayObject;
  176. /**
  177. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  178. */
  179. protected var swatchSelectedSkin : DisplayObject;
  180. /**
  181. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  182. */
  183. protected var palette : Sprite;
  184. /**
  185. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  186. */
  187. protected var textFieldBG : DisplayObject;
  188. /**
  189. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  190. */
  191. protected var swatches : Sprite;
  192. /**
  193. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  194. */
  195. protected var swatchMap : Array;
  196. /**
  197. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  198. */
  199. protected var currRowIndex : int;
  200. /**
  201. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  202. */
  203. protected var currColIndex : int;
  204. /**
  205. * @private * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  206. */
  207. private static var defaultStyles : Object;
  208. /**
  209. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  210. */
  211. protected static const POPUP_BUTTON_STYLES : Object;
  212. /**
  213. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  214. */
  215. protected const SWATCH_STYLES : Object;
  216. /**
  217. * Gets or sets the swatch that is currently highlighted in the palette of the ColorPicker component. * * @default 0x000000 * * @includeExample examples/ColorPicker.selectedColor.1.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  218. */
  219. public function get selectedColor () : uint;
  220. /**
  221. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  222. */
  223. public function set selectedColor (value:uint) : void;
  224. /**
  225. * Gets the string value of the current color selection. * * @includeExample examples/ColorPicker.hexValue.1.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  226. */
  227. public function get hexValue () : String;
  228. /**
  229. * @copy fl.core.UIComponent#enabled * * @default true * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  230. */
  231. public function get enabled () : Boolean;
  232. /**
  233. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  234. */
  235. public function set enabled (value:Boolean) : void;
  236. /**
  237. * Gets or sets a Boolean value that indicates whether the internal text field of the * ColorPicker component is editable. A value of <code>true</code> indicates that * the internal text field is editable; a value of <code>false</code> indicates * that it is not. * * @default true * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  238. */
  239. public function get editable () : Boolean;
  240. /**
  241. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  242. */
  243. public function set editable (value:Boolean) : void;
  244. /**
  245. * Gets or sets a Boolean value that indicates whether the internal text field * of the ColorPicker component is displayed. A value of <code>true</code> indicates * that the internal text field is displayed; a value of <code>false</code> indicates * that it is not. * * @default true * * @includeExample examples/ColorPicker.showTextField.1.as -noswf * * @see #textField * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  246. */
  247. public function get showTextField () : Boolean;
  248. /**
  249. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  250. */
  251. public function set showTextField (value:Boolean) : void;
  252. /**
  253. * Gets or sets the array of custom colors that the ColorPicker component * provides. The ColorPicker component draws and displays the colors that are * described in this array. * * <p><strong>Note:</strong> The maximum number of colors that the ColorPicker * component can display is 1024.</p> * * <p>By default, this array contains 216 autogenerated colors.</p> * * @includeExample examples/ColorPicker.colors.1.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0 *
  254. */
  255. public function get colors () : Array;
  256. /**
  257. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  258. */
  259. public function set colors (value:Array) : void;
  260. /**
  261. * @copy fl.controls.TextArea#imeMode * * @see flash.system.IMEConversionMode IMEConversionMode * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  262. */
  263. public function get imeMode () : String;
  264. /**
  265. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  266. */
  267. public function set imeMode (value:String) : void;
  268. /**
  269. * @copy fl.core.UIComponent#getStyleDefinition() * * @includeExample ../core/examples/UIComponent.getStyleDefinition.1.as -noswf * * @see fl.core.UIComponent#getStyle() UIComponent.getStyle() * @see fl.core.UIComponent#setStyle() UIComponent.setStyle() * @see fl.managers.StyleManager StyleManager * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  270. */
  271. public static function getStyleDefinition () : Object;
  272. /**
  273. * Shows the color palette. Calling this method causes the <code>open</code> * event to be dispatched. If the color palette is already open or disabled, * this method has no effect. * * @includeExample examples/ColorPicker.open.2.as -noswf * * @see #close() * @see #event:open * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  274. */
  275. public function open () : void;
  276. /**
  277. * Hides the color palette. Calling this method causes the <code>close</code> * event to be dispatched. If the color palette is already closed or disabled, * this method has no effect. * * @see #event:close * @see #open() * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  278. */
  279. public function close () : void;
  280. /**
  281. * @private * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  282. */
  283. private function addCloseListener (event:Event);
  284. /**
  285. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  286. */
  287. protected function onStageClick (event:MouseEvent) : void;
  288. /**
  289. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  290. */
  291. protected function setStyles () : void;
  292. /**
  293. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  294. */
  295. protected function cleanUpSelected () : void;
  296. /**
  297. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  298. */
  299. protected function onPopupButtonClick (event:MouseEvent) : void;
  300. /**
  301. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  302. */
  303. protected function draw () : void;
  304. /**
  305. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  306. */
  307. protected function showPalette () : void;
  308. /**
  309. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  310. */
  311. protected function setEmbedFonts () : void;
  312. /**
  313. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  314. */
  315. protected function drawSwatchHighlight () : void;
  316. /**
  317. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  318. */
  319. protected function drawPalette () : void;
  320. /**
  321. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  322. */
  323. protected function drawTextField () : void;
  324. /**
  325. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  326. */
  327. protected function drawSwatches () : void;
  328. /**
  329. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  330. */
  331. protected function drawBG () : void;
  332. /**
  333. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  334. */
  335. protected function positionPalette () : void;
  336. /**
  337. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  338. */
  339. protected function setTextEditable () : void;
  340. /**
  341. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  342. */
  343. protected function keyUpHandler (event:KeyboardEvent) : void;
  344. /**
  345. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  346. */
  347. protected function positionTextField () : void;
  348. /**
  349. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  350. */
  351. protected function setColorDisplay () : void;
  352. /**
  353. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  354. */
  355. protected function setSwatchHighlight (swatch:Sprite) : void;
  356. /**
  357. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  358. */
  359. protected function findSwatch (color:uint) : Sprite;
  360. /**
  361. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  362. */
  363. protected function onSwatchClick (event:MouseEvent) : void;
  364. /**
  365. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  366. */
  367. protected function onSwatchOver (event:MouseEvent) : void;
  368. /**
  369. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  370. */
  371. protected function onSwatchOut (event:MouseEvent) : void;
  372. /**
  373. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  374. */
  375. protected function setColorText (color:uint) : void;
  376. /**
  377. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  378. */
  379. protected function colorToString (color:uint) : String;
  380. /**
  381. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  382. */
  383. protected function setColorWellColor (colorTransform:ColorTransform) : void;
  384. /**
  385. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  386. */
  387. protected function createSwatch (color:uint) : Sprite;
  388. /**
  389. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  390. */
  391. protected function addStageListener (event:Event = null) : void;
  392. /**
  393. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  394. */
  395. protected function removeStageListener (event:Event = null) : void;
  396. /**
  397. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  398. */
  399. protected function focusInHandler (event:FocusEvent) : void;
  400. /**
  401. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  402. */
  403. protected function focusOutHandler (event:FocusEvent) : void;
  404. /**
  405. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  406. */
  407. protected function isOurFocus (target:DisplayObject) : Boolean;
  408. /**
  409. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  410. */
  411. protected function keyDownHandler (event:KeyboardEvent) : void;
  412. /**
  413. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  414. */
  415. protected function configUI () : void;
  416. }
  417. }