PageRenderTime 176ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/SparrowTest/src/sparrowGui/uiStyle/UIStyleMgr.as

http://sparrowgui.googlecode.com/
ActionScript | 642 lines | 558 code | 33 blank | 51 comment | 2 complexity | 72b815bd68e9aae0bbe25ac816d7cf44 MD5 | raw file
  1. package sparrowGui.uiStyle
  2. {
  3. import asSkinStyle.ArrayToStyleParser;
  4. import asSkinStyle.AsSkinStyle;
  5. import asSkinStyle.XMLSkinParser;
  6. import flash.display.Sprite;
  7. import flash.geom.Rectangle;
  8. import flash.text.TextField;
  9. import flash.text.TextFieldAutoSize;
  10. import flash.text.TextFieldType;
  11. import flash.text.TextFormat;
  12. import sparrowGui.uiStyle.draw.ArrowRectDraw;
  13. import sparrowGui.uiStyle.draw.CrossRectDraw;
  14. import sparrowGui.uiStyle.draw.HookRectDraw;
  15. import sparrowGui.uiStyle.draw.RadioCircleDraw;
  16. /**
  17. * ???????
  18. * @author Pelephone
  19. */
  20. public class UIStyleMgr extends AsSkinStyle
  21. {
  22. // ??
  23. private static var instance:UIStyleMgr = new UIStyleMgr();
  24. /**
  25. * ???????
  26. */
  27. public function UIStyleMgr()
  28. {
  29. var skinTag:XML = getSkinTag();
  30. var styleArr:Array = getStyleArr();
  31. super(skinTag, styleArr, new XMLSkinParser(), new ArrayToStyleParser());
  32. }
  33. //????
  34. public static function getIns():UIStyleMgr {
  35. if (instance == null) instance = new UIStyleMgr();
  36. return instance;
  37. }
  38. /**
  39. * ??????
  40. */
  41. override protected function initRegisterTags():void
  42. {
  43. super.initRegisterTags();
  44. // registerTag("rect",RectDraw);
  45. // registerTag("circle",CircleDraw);
  46. registerTag("hookRect",HookRectDraw);
  47. registerTag("crossRect",CrossRectDraw);
  48. registerTag("radioCircle",RadioCircleDraw);
  49. registerTag("arrowRect",ArrowRectDraw);
  50. registerTag("sprite",Sprite);
  51. registerTag("text",TextField);
  52. // registerTag("fourState",ItemSkin);
  53. // registerTag("sixState",RichItemSkin);
  54. // registerTag("radioItem",RadioItemSkin);
  55. // registerTag("checkItem",CheckItemSkin);
  56. // registerTag("hScroll",HScrollSkin);
  57. // registerTag("vScroll",VScrollSkin);
  58. }
  59. /**
  60. * ???????xml
  61. * @return
  62. */
  63. private function getSkinTag():XML
  64. {
  65. var skinXML:XML = XML(
  66. <root>
  67. <rect name="component" />
  68. <!-- ????????? -->
  69. <sprite name="item">
  70. <rectSR name="hitTestState" />
  71. <rect name="upState" />
  72. <rect name="overState" />
  73. <rect name="downState" />
  74. </sprite>
  75. <sprite name="button" reference="item" />
  76. <sprite name="txtItem" reference="item">
  77. <text name="txtField" />
  78. </sprite>
  79. <sprite name="richItem">
  80. <rectSR name="hitTestState" />
  81. <rect name="upState" />
  82. <rect name="overState" />
  83. <rect name="downState" />
  84. <rect name="selectState" />
  85. <rect name="enabledState" />
  86. <text name="txtField" />
  87. </sprite>
  88. <sprite name="richButton" reference="richItem" />
  89. <!-- ???? -->
  90. <sprite name="radioItem">
  91. <rectSR name="hitTestState" />
  92. <radioCircle name="upState" />
  93. <radioCircle name="overState" />
  94. <radioCircle name="downState" />
  95. <radioCircle name="selectState" />
  96. <radioCircle name="enabledState" />
  97. <text name="txtField" />
  98. </sprite>
  99. <sprite name="checkItem">
  100. <rectSR name="hitTestState" />
  101. <hookRect name="upState" />
  102. <hookRect name="overState" />
  103. <hookRect name="downState" />
  104. <hookRect name="selectState" />
  105. <hookRect name="enabledState" />
  106. <text name="txtField" />
  107. </sprite>
  108. <!-- combobox???? -->
  109. <sprite name="combobox" reference="arrowItem">
  110. <arrowRect name="enabledState" />
  111. <arrowRect name="selectState" />
  112. <text name="txtField" />
  113. </sprite>
  114. <sprite name="comboboxItem" reference="richItem" />
  115. <!-- ????? -->
  116. <sprite name="arrowItem">
  117. <rectSR name="hitTestState" />
  118. <arrowRect name="upState" />
  119. <arrowRect name="overState" />
  120. <arrowRect name="downState" />
  121. </sprite>
  122. <sprite name="hScroll">
  123. <rectSR name="skinbg" />
  124. <sprite name="slider" reference="item" />
  125. <sprite name="leftBtn" reference="arrowItem" />
  126. <sprite name="rightBtn" reference="arrowItem" />
  127. </sprite>
  128. <sprite name="vScroll">
  129. <rectSR name="skinbg" />
  130. <sprite name="slider" reference="item" />
  131. <sprite name="upBtn" reference="arrowItem" />
  132. <sprite name="downBtn" reference="arrowItem" />
  133. </sprite>
  134. <!-- ???? -->
  135. <sprite name="radioGroup" />
  136. <sprite name="checkBox" />
  137. <sprite name="itemList" />
  138. <sprite name="pageList" />
  139. <sprite name="tree" />
  140. <sprite name="scrollList" reference="scrollPanel" />
  141. <sprite name="scrollTree" reference="scrollPanel" />
  142. <sprite name="pageBox">
  143. <sprite name="btn_first" reference="txtItem" />
  144. <sprite name="btn_prev" reference="txtItem" />
  145. <sprite name="btn_next" reference="txtItem" />
  146. <sprite name="btn_last" reference="txtItem" />
  147. <text name="txt_inputNum" />
  148. <text name="txt_showNum" />
  149. <sprite name="btn_go" reference="txtItem" />
  150. </sprite>
  151. <!-- ?????? -->
  152. <sprite name="foldItem" >
  153. <rectSR name="hitTestState" />
  154. <crossRect name="upState" />
  155. <crossRect name="overState" />
  156. <crossRect name="downState" />
  157. <crossRect name="selectState" />
  158. <crossRect name="enabledState" />
  159. </sprite>
  160. <sprite name="treeItem" >
  161. <sprite name="foldBtn" reference="foldItem" />
  162. <sprite name="selectBtn" reference="richItem" />
  163. </sprite>
  164. <!-- ?????? -->
  165. <sprite name="scrollPanel">
  166. <sprite name="vScroll" reference="vScroll" />
  167. <sprite name="hScroll" reference="hScroll" />
  168. </sprite>
  169. <!-- ?????? -->
  170. <sprite name="toolTip">
  171. <rect name="skinBG" />
  172. <text name="txtTip" />
  173. </sprite>
  174. <!-- ???? -->
  175. <sprite name="window">
  176. <rect name="skinBG" />
  177. <sprite name="contDP" />
  178. <rectSR name="dragBG" />
  179. <sprite name="foldSkin" reference="foldItem" />
  180. <sprite name="closeSkin" reference="foldItem" />
  181. </sprite>
  182. <!-- ????? -->
  183. <rectSR name="translucent" />
  184. <rectSR name="alert">
  185. <text name="txtAlert" />
  186. <rect name="posBtn" />
  187. </rectSR>
  188. <rectSR name="inputAlert">
  189. <text name="txtAlert" />
  190. <text name="txtInput" />
  191. <rect name="posBtn" />
  192. </rectSR>
  193. <!-- ???? -->
  194. <sprite name="richText">
  195. <text name="txtField" />
  196. </sprite>
  197. <sprite name="textArea" reference="richText" />
  198. </root>
  199. );
  200. return skinXML;
  201. }
  202. /**
  203. * ????
  204. * @return
  205. */
  206. private function getStyleArr():Array
  207. {
  208. // ????
  209. var tformat:TextFormat = new TextFormat();
  210. tformat.align = "center";
  211. var lformat:TextFormat = new TextFormat();
  212. lformat.align = "left";
  213. var grid:Rectangle = new Rectangle(5, 5, 4, 4);
  214. // ??????????????
  215. var defaultUI:Array = [
  216. // ????
  217. "component",{
  218. bgColor:0xFFFFFF,
  219. width:20,
  220. height:20
  221. }
  222. /////////////////////////////////////////////////
  223. // ?,??????
  224. ,"baseItem",{
  225. bgColor:0xFFFFFF,
  226. width:60,
  227. height:20,
  228. border:1,
  229. borderColor:0x707070
  230. }
  231. ,"item upState#baseItem",{}
  232. ,"item hitTestState#baseItem",{
  233. alpha:0
  234. }
  235. ,"item overState#baseItem",{
  236. bgColor:0xCCD5D5,
  237. borderColor:0x3C7FB1
  238. }
  239. ,"item downState#baseItem",{
  240. borderColor:0x3C7FB1,
  241. bgColor:0xC0CBCB
  242. }
  243. ,"txtItem#item txtField",{
  244. width:60,
  245. height:20,
  246. mouseEnabled:false,
  247. defaultTextFormat:tformat
  248. }
  249. ,"richItem#item selectState#baseItem",{
  250. bgColor:0xAFBDBD
  251. }
  252. ,"richItem#item enabledState#baseItem",{
  253. bgColor:0xCCCCCC
  254. }
  255. ,"richItem#item txtField",{
  256. width:60,
  257. height:20,
  258. defaultTextFormat:tformat
  259. }
  260. ,"button#item,richButton#richItem",{}
  261. /////////////////////////////////////////////////
  262. // ?????
  263. ,"radioItemBase",{
  264. bgColor:0xFFFFFF,
  265. border:1,
  266. borderColor:0x707070,
  267. width:12,
  268. height:12,
  269. inCirleColor:-1,
  270. inBorder:0,
  271. hookThick:0,
  272. y:3
  273. }
  274. ,"radioItem upState#radioItemBase",{}
  275. ,"radioItem hitTestState#baseItem",{
  276. alpha:0
  277. }
  278. ,"radioItem overState#radioItemBase",{
  279. bgColor:0xEFEFEF,
  280. borderColor:0x3C7FB1
  281. }
  282. ,"radioItem downState#radioItemBase",{
  283. bgColor:0xCCD5D5,
  284. borderColor:0x3C7FB1
  285. }
  286. ,"radioItem selectState#radioItemBase",{
  287. bgColor:0xEFEFEF,
  288. inCirleColor:0x202020,
  289. padding:3
  290. }
  291. ,"radioItem enabledState#radioItemBase",{
  292. bgColor:0xCCCCCC
  293. }
  294. ,"radioItem txtField",{
  295. x:14,
  296. width:46,
  297. height:20
  298. }
  299. ,"checkItem#radioItem selectState",{
  300. bgColor:0xEFEFEF,
  301. hookThick:2,
  302. hookThickColor:0x202020,
  303. padding:3
  304. }
  305. /////////////////////////////////////////////////
  306. // ????
  307. ,"cbxBase",{
  308. bgColor:0xFFFFFF,
  309. border:1,
  310. borderColor:0x707070,
  311. width:14,
  312. height:14,
  313. isNextDraw:false,
  314. padding:3,
  315. y:3,
  316. x:(80-3-14)
  317. }
  318. ,"combobox upState#cbxBase",{
  319. arrowColor:0x202020
  320. }
  321. ,"combobox overState#cbxBase",{
  322. bgColor:0xEFEFEF,
  323. arrowColor:0x202050
  324. }
  325. ,"combobox downState#cbxBase",{
  326. bgColor:0xCCD5D5,
  327. arrowColor:0x000000
  328. }
  329. ,"combobox hitTestState#baseItem",{
  330. width:80,
  331. height:20
  332. }
  333. ,"combobox selectState#cbxBase",{
  334. bgColor:0xCCD5D5,
  335. arrowColor:0x202020
  336. }
  337. ,"combobox txtField",{
  338. width:80,
  339. height:20,
  340. selectable:false,
  341. mouseEnabled:false
  342. }
  343. // ?????
  344. ,"combobox upState,combobox overState,combobox downState,combobox selectState",{
  345. arrowDirct:1
  346. }
  347. ,"comboboxItem#richItem",{
  348. width:80,
  349. height:20
  350. }
  351. ,"comboboxItem txtField",{
  352. defaultTextFormat:lformat
  353. }
  354. /////////////////////////////////////////////////
  355. // ?????
  356. ,"arrowBase",{
  357. bgColor:0xFFFFFF,
  358. border:1,
  359. borderColor:0x707070,
  360. width:14,
  361. height:14,
  362. isNextDraw:false,
  363. padding:3
  364. }
  365. ,"arrowItem upState#arrowBase",{
  366. arrowColor:0x202020
  367. }
  368. ,"arrowItem overState#arrowBase",{
  369. bgColor:0xEFEFEF,
  370. arrowColor:0x202050
  371. }
  372. ,"arrowItem downState#arrowBase",{
  373. bgColor:0xCCD5D5,
  374. arrowColor:0x000000
  375. }
  376. ,"arrowItem hitTestState#baseItem",{
  377. width:14,
  378. height:14,
  379. alpha:0
  380. }
  381. // ?????
  382. ,"upArrow#arrowItem upState,upArrow#arrowItem overState,upArrow#arrowItem downState",{
  383. arrowDirct:0
  384. }
  385. // ?????
  386. ,"downArrow#arrowItem upState,downArrow#arrowItem overState,downArrow#arrowItem downState",{
  387. arrowDirct:1
  388. }
  389. // ?????
  390. ,"leftArrow#arrowItem upState,leftArrow#arrowItem overState,leftArrow#arrowItem downState",{
  391. arrowDirct:2
  392. }
  393. // ?????
  394. ,"rightArrow#arrowItem upState,rightArrow#arrowItem overState,rightArrow#arrowItem downState",{
  395. arrowDirct:3
  396. }
  397. ,"vScroll upBtn#upArrow,hScroll leftBtn#leftArrow",{}
  398. ,"vScroll downBtn#downArrow,hScroll rightBtn#rightArrow",{}
  399. ,"sliderBase",{
  400. bgColor:0xFFFFFF,
  401. border:1,
  402. borderColor:0x707070,
  403. width:14,
  404. isNextDraw:false,
  405. height:14
  406. }
  407. ,"sliderItem",{
  408. // scale9Grid:grid
  409. }
  410. ,"sliderItem upState#sliderBase",{}
  411. ,"sliderItem hitTestState#baseItem",{
  412. width:14,
  413. height:14,
  414. alpha:0
  415. }
  416. ,"sliderItem overState#sliderBase",{
  417. bgColor:0xEFEFEF,
  418. borderColor:0x3C7FB1
  419. }
  420. ,"sliderItem downState#sliderBase",{
  421. bgColor:0xCCD5D5,
  422. borderColor:0x3C7FB1
  423. }
  424. ,"vScroll slider#sliderItem,hScroll slider#sliderItem",{}
  425. ,"vScroll skinbg,hScroll skinbg",{
  426. bgColor:0xF0F0F0,
  427. border:0,
  428. borderColor:0,
  429. width:14,
  430. height:14
  431. }
  432. // ????
  433. ,"scrollPanel hScroll#hScroll,scrollPanel vScroll#vScroll" +
  434. ",scrollList hScroll#hScroll,scrollList vScroll#vScroll" +
  435. ",scrollTree hScroll#hScroll,scrollTree vScroll#vScroll",{}
  436. // ????
  437. ,"crossBase",{
  438. bgColor:0xFFFFFF,
  439. width:14,
  440. height:14,
  441. border:1,
  442. borderColor:0x707070,
  443. inBorder:1,
  444. inBorderColor:0x202020,
  445. isNextDraw:false,
  446. type:0,
  447. y:3,
  448. padding:3
  449. }
  450. ,"foldItem hitTestState#baseItem",{
  451. width:14,
  452. height:14,
  453. alpha:0
  454. }
  455. ,"foldItem upState#crossBase",{
  456. bgColor:0xFFFFFF,
  457. inBorderColor:0x202020
  458. }
  459. ,"foldItem overState#crossBase",{
  460. bgColor:0xEFEFEF,
  461. inBorderColor:0x202050
  462. }
  463. ,"foldItem downState#crossBase",{
  464. bgColor:0xCCD5D5,
  465. inBorderColor:0x000000
  466. }
  467. ,"foldItem selectState#crossBase",{
  468. bgColor:0xCCD5D5,
  469. type:1,
  470. inBorderColor:0x000000
  471. }
  472. ,"foldItem enabledState#crossBase",{
  473. bgColor:0xCCCCCC
  474. }
  475. ,"treeItem foldBtn#foldItem",{}
  476. ,"treeItem selectBtn#richItem",{x:20}
  477. // ???
  478. ,"toolTip txtTip",{
  479. autoSize:TextFieldAutoSize.LEFT,
  480. textColor:0x000000,
  481. wordWrap:false
  482. }
  483. ,"toolTip skinBG",{
  484. bgColor:0xE9E9F2,
  485. border:1,
  486. borderColor:0xA0A0A0
  487. }
  488. // ????
  489. ,"window skinBG",{
  490. bgColor:0xFFFFFF,
  491. border:1,
  492. borderColor:0x66656D,
  493. width:150,
  494. height:120
  495. }
  496. ,"window dragBG",{
  497. bgColor:0x77A0B2,
  498. border:1,
  499. borderColor:0x7F9BA6,
  500. width:150,
  501. height:20
  502. }
  503. ,"window contDP",{
  504. y:18
  505. }
  506. ,"window foldSkin#foldItem",{
  507. width:14,
  508. height:14,
  509. x:118,
  510. y:2
  511. }
  512. ,"window foldSkin hitTestState",{
  513. width:14,
  514. height:14
  515. }
  516. ,"window closeSkin#foldItem",{
  517. // y:1,
  518. x:(150-14-2)
  519. }
  520. ,"window closeSkin hitTestState",{
  521. width:14,height:14
  522. }
  523. // ???
  524. ,"translucent",{
  525. bgColor:0x000000,
  526. bgAlpha:0.3
  527. }
  528. ,"alert",{
  529. width:200,
  530. height:150,
  531. bgColor:0xFFFFFF,
  532. border:1,
  533. borderColor:0x7F9BA6
  534. }
  535. ,"alert txtAlert",{
  536. height:80,
  537. x:5,
  538. y:5,
  539. selectable:false,
  540. mouseEnabled:false,
  541. defaultTextFormat:tformat
  542. }
  543. ,"alert posBtn",{
  544. x:100,
  545. y:145
  546. }
  547. ,"inputAlert#alert inputAlert",{
  548. y:85
  549. }
  550. ,"pageBox btn_first#txtItem",{
  551. y:25
  552. }
  553. ,"pageBox btn_last#txtItem",{
  554. x:65,
  555. y:25
  556. }
  557. ,"pageBox btn_prev#txtItem",{
  558. }
  559. ,"pageBox btn_next#txtItem",{
  560. x:65
  561. }
  562. ,"pageTxt",{
  563. width:60,
  564. height:20
  565. }
  566. ,"pageBox txt_inputNum#pageTxt",{
  567. restrict:"0-9",
  568. text:"1",
  569. type:TextFieldType.INPUT,
  570. border:true,
  571. x:130
  572. }
  573. ,"pageBox txt_showNum#pageTxt",{
  574. border:true,
  575. selectable:false,
  576. mouseEnabled:false,
  577. x:130,
  578. y:25
  579. }
  580. ,"pageBox btn_go#txtItem",{
  581. x:195
  582. }
  583. ,"pageBox btn_prev#txtItem txtField",{
  584. text:"???"
  585. }
  586. ,"pageBox btn_next#txtItem txtField",{
  587. text:"???"
  588. }
  589. ,"pageBox btn_first#txtItem txtField",{
  590. text:"??"
  591. }
  592. ,"pageBox btn_last#txtItem txtField",{
  593. text:"??"
  594. }
  595. ,"pageBox btn_go#txtItem txtField",{
  596. text:"??"
  597. }
  598. ,"richText txtField",{
  599. width:80,
  600. height:80,
  601. multiline:true,
  602. wordWrap:true
  603. }
  604. ,"textArea#richText",{}
  605. ];
  606. return defaultUI;
  607. }
  608. }
  609. }