2011-02-17 18:34:45 -05:00
|
|
|
PathStyle = Base.extend(new function() {
|
|
|
|
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;
|
|
|
|
if(style) {
|
|
|
|
for (var i = 0, l = keys.length; i < l; i++) {
|
|
|
|
var key = keys[i];
|
2011-02-18 03:04:20 -05:00
|
|
|
if(style[key] !== undefined)
|
2011-02-16 16:09:51 -05:00
|
|
|
this[key] = style[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-17 18:34:45 -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-02-17 18:34:45 -05:00
|
|
|
|
|
|
|
fields['set' + key.capitalize()] = function(value) {
|
2011-02-16 16:09:51 -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++) {
|
|
|
|
this.item.children[i].style[key] = value;
|
|
|
|
}
|
2011-02-16 16:09:51 -05:00
|
|
|
} else {
|
|
|
|
this['_' + key] = value;
|
|
|
|
}
|
|
|
|
};
|
2011-02-17 18:34:45 -05:00
|
|
|
|
|
|
|
fields['get' + key.capitalize()] = function() {
|
2011-02-16 16:09:51 -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++) {
|
|
|
|
if(!style) {
|
|
|
|
style = this.item.children[i].style[key];
|
|
|
|
} else if(style != this.item.children[i].style[key]) {
|
|
|
|
// If there is another item with a different style:
|
2011-02-19 07:07:24 -05:00
|
|
|
// TODO: Shouldn't this be undefined instead? null often
|
|
|
|
// has meaning for styles.
|
2011-02-17 18:37:21 -05:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return style;
|
2011-02-16 16:09:51 -05:00
|
|
|
} else {
|
|
|
|
return this['_' + key];
|
|
|
|
}
|
|
|
|
};
|
2011-02-16 16:15:19 -05:00
|
|
|
|
2011-02-18 02:58:59 -05:00
|
|
|
this['set' + key.capitalize()] = function(value) {
|
2011-02-16 16:09:51 -05:00
|
|
|
this.style[key] = value;
|
|
|
|
};
|
2011-02-17 18:34:45 -05:00
|
|
|
|
2011-02-18 02:58:59 -05:00
|
|
|
this['get' + key.capitalize()] = function() {
|
2011-02-16 16:09:51 -05:00
|
|
|
return this.style[key];
|
|
|
|
};
|
2011-02-18 02:58:59 -05:00
|
|
|
}, { beans: true }));
|
2011-02-17 18:34:45 -05:00
|
|
|
|
|
|
|
return fields;
|
|
|
|
});
|