ZooZ
view release on metacpan or search on metacpan
ZooZ/Project.pm view on Meta::CPAN
my $self = $_[0]{SHARED}{CUROBJ};
return unless $self->{SELECTED};
my $lab = $self->unselectCurrentWidget;
# delete the data structures.
my $rc = delete $self->{LABEL2GRID}{$lab};
my $ref = delete $self->{GRID}[$rc->[0]][$rc->[1]];
# delete the widgets.
$_->destroy for $lab, $ref->{LABFRAME};
$self->{CV}->delete($ref->{WINDOW});
# free up the space.
for my $r (0 .. $ref->{ROWS} - 1) {
for my $c (0 .. $ref->{COLS} - 1) {
$self->{GRID}[$rc->[0] + $r][$rc->[1] + $c] = {};
}
}
# clean up the hier list.
$self->{TREE}->delete(entry => "$self->{HIERTOP}.$ref->{LABEL}");
# clean up the widget properties window.
ZooZ::Forms->deleteWidget($self->{PROJID}, $ref->{NAME});
# remove it from the shared hash
delete $self->{SHARED}{ALL_WIDGETS}{$ref->{NAME}};
# clean up the preview window.
$ref->{PREVIEW}->destroy;
# update the preview window.
$self->updatePreviewWindow;
}
##############################
#
# This updates the preview window whenever
# something changes
#
##############################
sub updatePreviewWindow {
my $self = shift;
my $top = $self->{PREVIEW};
# first, the title.
$top->title($self->{TITLE}) unless $self->{ISCHILD};
# now iterate through all the objects and update.
for my $lab (keys %{$self->{LABEL2GRID}}) {
my ($row, $col) = @{$self->{LABEL2GRID}{$lab}};
my $ref = $self->{GRID}[$row][$col];
$ref->{PREVIEW}->grid(-row => $row,
-column => $col,
-rowspan => $ref->{ROWS},
-columnspan => $ref->{COLS},
);
}
$top->geometry('') unless $self->{ISCHILD};
}
######################
#
# This method creates the canvas (full-fledged ZooZ::Project object)
# for any container widgets when we want to add widgets to them.
#
######################
sub descendHier {
my $self = shift;
my $lab = shift || $self->{SELECTED};
# hide the current. unhide the child.
#$self->_hideCanvas;
$self->{SHARED}{SUBHIERS}{$lab}->_unhideCanvas;
}
#################
#
# This sub hides the canvas of the calling project
#
#################
#sub _hideCanvas { $_[0]{CV}->packForget }
sub _hideCanvas {}
#################
#
# This sub unhides the canvas of the calling project.
# It is IMPORTANT that it returns the project itself.
#
#################
sub _unhideCanvas {
my $self = shift;
# show the animation.
#ZooZ::Generic::animateOpen($self->{TOP}, 80, 80, $gridW, $gridH);
my $curObj = $self->{SHARED}{CUROBJ};
#print "Current obj is $curObj->{LEVEL}.\n" if $curObj;
#ZooZ::Generic::animateOpen($curObj->{CV}) if $curObj;
# show the correct frame.
$curObj->{PARENT}->packForget if $curObj;
#ref($_) eq 'Tk::Frame' && $_->packForget for $self->{TOP}->packSlaves;
$self->{PARENT}->pack(qw/-fill both -expand 1/);
$self->{SHARED}{HIERLABEL}->configure(-text => $self->{LEVEL});
#$self->{CV}->pack(qw/-side left -fill both -expand 1/);
$self->{SHARED}{CUROBJ} = $self;
return $self;
}
ZooZ/Project.pm view on Meta::CPAN
# Now get the value and ignore any undefined values.
my $v = $ref->{WCONF}{$k};
next unless defined $v && $v =~ /./; # match 0
# handle special cases:
# 1. Image
# 2. Callback
# 3. Variable ref.
if ($v && exists $ZooZ::Options::options{$k} &&
$ZooZ::Options::options{$k}[0] eq 'Image') {
next if $v eq 'image-zooz'; # empty image.
eval {$v = $ref->{WCONF}{$k}->cget('-file')};
my $imageName;
if (exists $self->{SHARED}{IMAGES}{$v}) {
$imageName = $self->{SHARED}{IMAGES}{$v};
} else {
$imageName = "Zimage" . $self->{SHARED}{IMAGEIDS}++;
$self->{SHARED}{IMAGES}{$v} = $imageName;
}
$v = $imageName;
} elsif ($v && exists $ZooZ::Options::options{$k} &&
$ZooZ::Options::options{$k}[0] eq 'Callback') {
$v = $::CALLBACKOBJ->code2name($v);
} elsif ($v && exists $ZooZ::Options::options{$k} &&
$ZooZ::Options::options{$k}[0] eq 'VarRef') {
$v = "\\" . $::VARREFOBJ->ref2name($v);
$v =~ s/main:://;
}
# quote it if it's a bareword. IE. Unless it's a ref or a number.
$v =~ s/'/\\'/g, $v = "'$v'" unless $v =~ m{
^[-\d]+$ # a number
|
^\\ # a reference
}x;
push @pairs => [$k, $v];
}
if (@pairs) {
print $fh "\n", ZooZ::Generic::lineUpCommas(@pairs), "\n )->grid(";
} else {
print $fh ")->grid(";
}
# Now place it via grid().
@pairs = ([-row => $row],
[-column => $col],
);
push @pairs => [-rowspan => $ref->{ROWS}] if $ref->{ROWS} > 1;
push @pairs => [-columnspan => $ref->{COLS}] if $ref->{COLS} > 1;
$ref->{PCONF}{$_} &&
push @pairs => [$_ => $ref->{PCONF}{$_} =~ /^\d+$/ ?
$ref->{PCONF}{$_} : "'$ref->{PCONF}{$_}'"
] for qw/-sticky -ipadx -ipady -padx -pady/;
print $fh "\n", ZooZ::Generic::lineUpCommas(@pairs), "\n );";
# if a container, then call recursively.
if (exists $self->{SHARED}{SUBHIERS}{$lab}) {
$self->{SHARED}{SUBHIERS}{$lab}->dumpPerl($fh, $module, '$ZWIDGETS{' . $ref->{NAME} . '}');
}
}
# Now output any row/col specific options like greediness, etc ..
{
my ($cols, $rows) = $self->{PREVIEW}->gridSize;
# first the columns.
for my $col (0 .. $cols - 1) {
# get the minsize/weight/pad data.
my %data = $self->{PREVIEW}->gridColumnconfigure($col);
my @data = map [$_, $data{$_}] => grep $data{$_} => keys %data;
@data or next;
print $fh "\n$spaces$parent->gridColumnconfigure($col,\n",
ZooZ::Generic::lineUpCommas(@data), "\n );\n";
}
# then the rows.
for my $row (0 .. $rows - 1) {
# get the minsize/weight/pad data.
my %data = $self->{PREVIEW}->gridRowconfigure($row);
my @data = map [$_, $data{$_}] => grep $data{$_} => keys %data;
@data or next;
print $fh "\n$spaces$parent->gridRowconfigure($row,\n",
ZooZ::Generic::lineUpCommas(@data), "\n );\n";
}
}
}
#############
#
# This method is called when a user closes a project.
# It destroys everything.
#
#############
sub closeMe {
my $self = shift;
$_ = undef for values %{$self->{SHARED}{SUBHIERS}};
# did I miss anything?
}
#############
( run in 0.767 second using v1.01-cache-2.11-cpan-39bf76dae61 )