NAME

Tk::AppWindow::CookBook::ContentManager - Write your own content manager

OTHER RECIPIES

Tk::AppWindow::CookBook::Extension
Tk::AppWindow::CookBook::Plugin

A SIMPLE TEXT CONTENT MANAGER

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']);

   #########################################################
   # The options below also have to be defined during the  #
   # initialization of your application                    #
   #########################################################
   $self->ConfigSpecs(
      -contentbackground => [{-background => $text}],
      -contentforeground => [{-foreground => $text}],
      -contentfont => [{-font => $text}],
      -contenttabs => [{-tabs => $text}],
      -contentwrap => [{-wrap => $text}],
      -background => ['SELF', 'DESCENDANTS'],
      DEFAULT => [$text],
   );
}

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
}

sub doSelect {
   $_[0]->CWidg->focus
}

sub IsModified {
   my $self = shift;
   return $self->CWidg->editModified;	
}

AUTHOR

Hans Jeuken (hanje at cpan dot org)

SEE ALSO

Tk::AppWindow
Tk::AppWindow::BaseClasses::ContentManager
Tk::AppWindow::Ext::MDI