Tk-AppWindow
view release on metacpan or search on metacpan
bin/mdi_editor view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
#########################################
# First define the content manager. a content manager handles the basic tasks like loading, saving,
# displaying and modifying files. The content manager does the actual work.
package TextManager;
use base qw(Tk::Derived Tk::AppWindow::BaseClasses::ContentManager);
Construct Tk::Widget 'TextManager';
require Tk::TextUndo;
sub Populate {
my ($self,$args) = @_;
$self->SUPER::Populate($args);
my $text = $self->Scrolled('TextUndo',
-scrollbars => 'ose',
)->pack(-expand => 1, -fill => 'both');
$self->CWidg($text);
$text->bind('<Control-a>', [$text, 'selectAll']);
$text->bind('<Control-Z>', [$text, 'redo']);
$self->ConfigSpecs(
-contentbackground => [{-background => $text}],
-contentforeground => [{-foreground => $text}],
-contentfont => [{-font => $text}],
-contenttabs => [{-tabs => $text}],
-contentwrap => [{-wrap => $text}],
-background => ['SELF', 'DESCENDANTS'],
DEFAULT => [$text],
);
}
sub ConfigureCM {
my $self = shift;
my $plug = $self->Extension;
my $cmopt = $plug->configGet('-contentmanageroptions');
for (@$cmopt) {
my $val = $plug->configGet($_);
if ((defined $val) and ($val ne '')) {
# $val = [$val] if $_ eq '-contenttabs';
$self->configure($_, $val) ;
}
}
}
sub doClear {
my $self = shift;
my $t = $self->CWidg;
$t->delete('0.0', 'end');
$t->editReset;
}
sub doLoad {
my ($self, $file) = @_;
my $t = $self->CWidg;
$t->Load($file);
$t->editModified(0);
return 1
}
sub doSave {
my ($self, $file) = @_;
my $t = $self->CWidg;
$t->Save($file);
$t->editModified(0);
return 1
( run in 0.452 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )