2011-03-04 08:34:31 -05:00
|
|
|
var PathStyle = this.PathStyle = Base.extend(new function() {
|
2011-02-17 18:34:45 -05:00
|
|
|
var keys = ['windingRule', 'resolution', 'strokeColor', 'strokeWidth',
|
|
|
|
'strokeCap', 'strokeJoin', 'dashOffset','dashArray', 'miterLimit',
|
|
|
|
'strokeOverprint', 'fillColor', 'fillOverprint'];
|
|
|
|
|
|
|
|
var fields = {
|
|
|
|
beans: true,
|
2011-02-16 16:09:51 -05:00
|
|
|
|
|
|
|
initialize: function(item, style) {
|
|
|
|
this.item = item;
|
2011-02-20 21:32:39 -05:00
|
|
|
if (style) {
|
2011-02-16 16:09:51 -05:00
|
|
|
for (var i = 0, l = keys.length; i < l; i++) {
|
|
|
|
var key = keys[i];
|
2011-02-20 21:32:39 -05:00
|
|
|
if (style[key] !== undefined)
|
2011-02-16 16:09:51 -05:00
|
|
|
this[key] = style[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-19 11:25:16 -05:00
|
|
|
};
|
2011-02-16 16:15:19 -05:00
|
|
|
|
2011-02-18 02:58:59 -05:00
|
|
|
Item.inject(Base.each(keys, function(key) {
|
2011-03-04 19:23:16 -05:00
|
|
|
var isColor = !!(key.match(/Color$/)),
|
|
|
|
set = 'set' + Base.capitalize(key),
|
|
|
|
get = 'get' + Base.capitalize(key);
|
2011-02-17 18:34:45 -05:00
|
|
|
|
2011-03-04 19:23:16 -05:00
|
|
|
fields[set] = function(value) {
|
2011-02-20 21:32:39 -05:00
|
|
|
if (this.item && this.item.children) {
|
2011-02-17 18:37:21 -05:00
|
|
|
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
2011-03-04 20:36:27 -05:00
|
|
|
this.item.children[i]._style[set](value);
|
2011-02-17 18:37:21 -05:00
|
|
|
}
|
2011-02-16 16:09:51 -05:00
|
|
|
} else {
|
2011-02-19 11:25:16 -05:00
|
|
|
this['_' + key] = isColor ? Color.read(arguments) : value;
|
2011-02-16 16:09:51 -05:00
|
|
|
}
|
|
|
|
};
|
2011-02-17 18:34:45 -05:00
|
|
|
|
2011-03-04 19:23:16 -05:00
|
|
|
fields[get] = function() {
|
2011-02-20 21:32:39 -05:00
|
|
|
if (this.item && this.item.children) {
|
2011-02-17 18:37:21 -05:00
|
|
|
var style;
|
|
|
|
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
2011-03-04 20:36:27 -05:00
|
|
|
var childStyle = this.item.children[i]._style[get]();
|
2011-02-20 21:32:39 -05:00
|
|
|
if (!style) {
|
2011-03-04 19:24:32 -05:00
|
|
|
style = childStyle;
|
|
|
|
} else if (style != childStyle) {
|
2011-02-17 18:37:21 -05:00
|
|
|
// If there is another item with a different style:
|
2011-03-04 19:23:16 -05:00
|
|
|
return undefined;
|
2011-02-17 18:37:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return style;
|
2011-02-16 16:09:51 -05:00
|
|
|
} else {
|
|
|
|
return this['_' + key];
|
|
|
|
}
|
|
|
|
};
|
2011-02-16 16:15:19 -05:00
|
|
|
|
2011-03-04 19:23:16 -05:00
|
|
|
this[set] = function(value) {
|
|
|
|
this.getStyle()[set](value);
|
2011-02-16 16:09:51 -05:00
|
|
|
};
|
2011-02-17 18:34:45 -05:00
|
|
|
|
2011-03-04 19:23:16 -05:00
|
|
|
this[get] = function() {
|
|
|
|
return this.getStyle()[get]();
|
2011-02-16 16:09:51 -05:00
|
|
|
};
|
2011-02-18 02:58:59 -05:00
|
|
|
}, { beans: true }));
|
2011-02-17 18:34:45 -05:00
|
|
|
|
|
|
|
return fields;
|
2011-03-03 11:32:55 -05:00
|
|
|
});
|