# Copyright (c) 2007 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: Replicator.pm,v 1.1 2007/03/10 23:12:12 nagler Exp $ package Bivio::UI::Widget::Replicator; use strict; use Bivio::Base 'Bivio::UI::Widget::ControlBase'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.1 $ =~ /\d+/g); my($_ATTRS) = [qw(count value)]; sub control_on_render { my($self, $source, $buffer) = @_; my($c) = $self->render_simple_attr('count', $source); $self->die($source, $c, ': count did not render as an integer') unless $c =~ /^-?\d*$/s; $self->die($source, "$c: count too large") unless $c + 0 < 1_000_000; $$buffer .= $self->render_simple_attr('value', $source) x $c if $c > 0; return; } sub initialize { my($self) = @_; $self->map_invoke(initialize_attr => $_ATTRS); return shift->SUPER::initialize(@_); } sub internal_as_string { return shift->unsafe_get(@$_ATTRS); } sub internal_new_args { shift; return { map({ my($x) = shift(@_); return qq{"$_" must be defined} unless defined($x); ($_ => $x); } @{$_ATTRS}), %{shift(@_) || {}}, }; } 1;