| 1 | package SVG::DOM2::Element::Rect; | ||
| 2 | |||
| 3 | use base "SVG::DOM2::Element::Shape"; | ||
| 4 | use base "SVG::DOM2::Element::Shape::Fill"; | ||
| 5 | use base "SVG::DOM2::Element::Shape::Stroke"; | ||
| 6 | |||
| 7 | use SVG::DOM2::Attribute::Metric; | ||
| 8 | |||
| 9 | sub new | ||
| 10 | { | ||
| 11 | my ($proto, %args) = @_; | ||
| 12 | return $proto->SUPER::new('rect', %args); | ||
| 13 | } | ||
| 14 | |||
| 15 | sub _attribute_handle | ||
| 16 | { | ||
| 17 | my ($self, $name, %opts) = @_; | ||
| 18 | return SVG::DOM2::Attribute::Metric->new(%opts) | ||
| 19 | if $name eq 'x' or $name eq 'width' | ||
| 20 | or $name eq 'y' or $name eq 'height'; | ||
| 21 | return $self->SUPER::_attribute_handle($name, %opts); | ||
| 22 | } | ||
| 23 | |||
| 24 | sub attr | ||
| 25 | { | ||
| 26 | my ($self, $name, $set) = @_; | ||
| 27 | $self->setAttribute($name, $set) if defined($set); | ||
| 28 | return $self->getAttribute($name); | ||
| 29 | } | ||
| 30 | |||
| 31 | sub width { shift->attr('width', @_); } | ||
| 32 | sub height { shift->attr('height', @_); } | ||
| 33 | sub x { shift->attr('x', @_); } | ||
| 34 | sub y { shift->attr('y', @_); } | ||
| 35 | |||
| 36 | return 1; |