/src/homponex/core/Style.hx
http://homponex.googlecode.com/ · Haxe · 208 lines · 174 code · 30 blank · 4 comment · 19 complexity · fe05ffda4a258d9d9a87d30c84e03321 MD5 · raw file
- /**
- * ...
- * @author alijaya
- */
-
- package homponex.core;
-
- #if flash9
- import flash.display.BitmapData;
- import flash.display.Bitmap;
- import flash.display.Sprite;
- import flash.utils.ByteArray;
- import heox.Rectangle;
- #end
-
- import homponex.utils.DynamicUtils;
-
- class Style
- {
-
- private static var _defaultStyle:Style;
- public static var defaultStyle(get_defaultStyle, null):Style;
- private static function get_defaultStyle() : Style
- {
- if (_defaultStyle == null) _defaultStyle = new DefaultStyle();
- return _defaultStyle;
- }
-
- public static var curStyle(default, null):Style;
-
- private static var _skinWhite:BitmapS9G;
- public static var skinWhite(get_skinWhite, null):BitmapS9G;
- private static function get_skinWhite() : BitmapS9G
- {
- if (_skinWhite == null) _skinWhite = new BitmapS9G(SW, new Rectangle(1, 1, 1, 1));
- return _skinWhite;
- }
-
-
-
- private var style:Hash<Hash<Dynamic>>;
-
- public function new()
- {
- style = new Hash<Hash<Dynamic>>();
- }
-
- public function setStyle(value:Dynamic, component:String, ?group:String = "default")
- {
- if (!style.exists(component)) style.set(component, new Hash<Dynamic>());
-
- var cStyle:Hash<Dynamic> = style.get(component);
- if (!cStyle.exists(group)) cStyle.set(group, { } );
- var s:Dynamic = cStyle.get(group);
- DynamicUtils.mergeDynamic(s, value);
- }
-
- public function getStyle(component:String, ?group:String = "default") : Dynamic
- {
- var value:Dynamic = { };
- var a:Array<String> = component.split(".");
- var curS:String = a.pop();
-
- if (a.length != 0)
- {
- var inheritS:String = a.join(".");
- DynamicUtils.mergeDynamic(value, getStyle(inheritS, group));
- }
-
- var cStyle:Hash<Dynamic> = style.get(component);
- if (cStyle == null) return null;
- if (!cStyle.exists(group))
- {
- if (group != "default")
- {
- group = "default";
- if (!cStyle.exists(group)) return null;
- }
- }
- var s:Dynamic = cStyle.get(group);
- DynamicUtils.mergeDynamic(value, s);
- return value;
- }
-
- }
-
-
-
- class DefaultStyle extends Style
- {
- public function new()
- {
- super();
- var component:Dynamic = { };
- setStyle(component, DynamicUtils.getClassTree(Component));
-
- var panel:Dynamic = { };
- #if flash9
- panel.background = new BitmapS9G(SP, new Rectangle(2, 2, 12, 12));
- #end
- panel.padTop = 2;
- panel.padBottom = 2;
- panel.padLeft = 2;
- panel.padRight = 2;
-
- setStyle(panel, DynamicUtils.getClassTree(Panel));
-
- var button:Dynamic = { };
- #if flash9
- button.up = new BitmapS9G(SBU, new Rectangle(2, 2, 12, 12));
- button.over = new BitmapS9G(SBO, new Rectangle(2, 2, 12, 12));
- button.down = new BitmapS9G(SBDn, new Rectangle(2, 2, 12, 12));
- button.disabled = new BitmapS9G(SBDs, new Rectangle(2, 2, 12, 12));
- #end
-
- setStyle(button, DynamicUtils.getClassTree(Button));
- }
- }
-
- #if flash9
- class SP extends Bitmap
- {
- public function new()
- {
- super(new BitmapData(16, 16, true, 0x00000000));
- var b:ByteArray = new ByteArray();
- var a:Array<Int> = [ -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, ];
- for (n in a)
- {
- b.writeInt(n);
- }
- b.position = 0;
- bitmapData.setPixels(bitmapData.rect, b);
- }
- }
-
- class SBU extends Bitmap
- {
- public function new()
- {
- super(new BitmapData(16, 16, true, 0x00000000));
- var b:ByteArray = new ByteArray();
- var a:Array<Int> = [ -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -13553615, -16249848, -16249848, -13553615, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -13553615, -16249848, -16249848, -13553615, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -13553615, -16249848, -16249848, -13553615, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -13553615, -16249848, -16249848, -13553615, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -13553615, -16249848, -16249848, -13553615, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -13553615, -16249848, -16249848, -13553615, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -13553615, -16249848, -16249848, -13553615, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -13553615, -16249848, -16249848, -13553615, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -13553615, -16249848, -16249848, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, ];
- for (n in a)
- {
- b.writeInt(n);
- }
- b.position = 0;
- bitmapData.setPixels(bitmapData.rect, b);
- }
- }
-
- class SBO extends Bitmap
- {
- public function new()
- {
- super(new BitmapData(16, 16, true, 0x00000000));
- var b:ByteArray = new ByteArray();
- var a:Array<Int> = [ -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -16249848, -16249848, -13553615, -1077557563, -1077557563, -1077557563, -1077557563, -1077557563, -1077557563, -1077557563, -1077557563, -1077557563, -1077557563, -1077557563, -1077557563, -13553615, -16249848, -16249848, -13553615, -1078150724, -1078150724, -1078150724, -1078150724, -1078150724, -1078150724, -1078150724, -1078150724, -1078150724, -1078150724, -1078150724, -1078150724, -13553615, -16249848, -16249848, -13553615, -1079202388, -1079202388, -1079202388, -1079202388, -1079202388, -1079202388, -1079202388, -1079202388, -1079202388, -1079202388, -1079202388, -1079202388, -13553615, -16249848, -16249848, -13553615, -1079729756, -1079729756, -1079729756, -1079729756, -1079729756, -1079729756, -1079729756, -1079729756, -1079729756, -1079729756, -1079729756, -1079729756, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -13553615, -16249848, -16249848, -13553615, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -13553615, -16249848, -16249848, -13553615, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -13553615, -16249848, -16249848, -13553615, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -13553615, -16249848, -16249848, -13553615, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -13553615, -16249848, -16249848, -13553615, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -13553615, -16249848, -16249848, -13553615, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -13553615, -16249848, -16249848, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, ];
- for (n in a)
- {
- b.writeInt(n);
- }
- b.position = 0;
- bitmapData.setPixels(bitmapData.rect, b);
- }
- }
-
- class SBDn extends Bitmap
- {
- public function new()
- {
- super(new BitmapData(16, 16, true, 0x00000000));
- var b:ByteArray = new ByteArray();
- var a:Array<Int> = [ -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -16249848, -16249848, -1594847, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1090058489, -1594847, -16249848, -16249848, -1594847, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1089531121, -1594847, -16249848, -16249848, -1594847, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1088413920, -1594847, -16249848, -16249848, -1594847, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1087886552, -1594847, -16249848, -16249848, -1594847, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1086834888, -1594847, -16249848, -16249848, -1594847, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1086241727, -1594847, -16249848, -16249848, -1594847, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1085189039, -1594847, -16249848, -16249848, -1594847, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1084006301, -1594847, -16249848, -16249848, -1594847, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1083478933, -1594847, -16249848, -16249848, -1594847, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1082427269, -1594847, -16249848, -16249848, -1594847, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1081899645, -1594847, -16249848, -16249848, -1594847, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1594847, -16249848, -16249848, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -1594847, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, ];
- for (n in a)
- {
- b.writeInt(n);
- }
- b.position = 0;
- bitmapData.setPixels(bitmapData.rect, b);
- }
- }
-
- class SBDs extends Bitmap
- {
- public function new()
- {
- super(new BitmapData(16, 16, true, 0x00000000));
- var b:ByteArray = new ByteArray();
- var a:Array<Int> = [ -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -1080846957, -13553615, -16249848, -16249848, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -13553615, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, -16249848, ];
- for (n in a)
- {
- b.writeInt(n);
- }
- b.position = 0;
- bitmapData.setPixels(bitmapData.rect, b);
- }
- }
-
- class SW extends Bitmap
- {
- public function new()
- {
- super(new BitmapData(3,3,true,0xffffffff));
- }
- }
- #end