App-GUI-Notepad

 view release on metacpan or  search on metacpan

lib/App/GUI/Notepad/Frame.pm  view on Meta::CPAN

# The new filename is stored as the opened file's name

sub _menu_saveas {
	my ($this) = @_;
	my $saveasdialog = Wx::FileDialog->new($this, "Choose a file name and " . 
                                                  "location to save to", 
                                                  "", "", "*.*", 
                                                  wxSAVE, [0,0]);
	my $result = $saveasdialog->ShowModal();
	if ($result == wxID_OK) {
		$this->{textctrl}->SaveFile(File::Spec->catfile(
                                        $saveasdialog->GetDirectory(), 
                                        $saveasdialog->GetFilename()
                                                       )
                                   );
		$this->{filename} = File::Spec->catfile($saveasdialog->GetDirectory(), 
                                                $saveasdialog->GetFilename());
		$this->SetTitle("Perlpad - " . $this->{filename});
	}
}




# This sub is called when the user clicks on menu File item Close
# Does the same thing as File..New
# Clears on the text in the text control and changes the filename 
# of the curently opened file to ''
# TODO: Check if file was changed and ask if it needs to be saved.
sub _menu_close{
	my ($this) = @_;
	$this->SetTitle("Perlpad");
	$this->{textctrl}->SetValue("");
	$this->{filename} = "";

}

# This sub is called when the user clicks on menu Edit item Undo
# Causes text control to undo the last edit
sub _menu_undo {
	my ($this) = @_;
	$this->{textctrl}->Undo();

}

# This sub is called when the user clicks on menu Edit item Redo
# Causes text control to redo the last edit ie Undo the undo. :-)

sub _menu_redo {
	my ($this) = @_;
	$this->{textctrl}->Redo();
}

# This sub is called when the user clicks on menu Edit item Cut
# Causes text control to redo the last edit ie Undo the undo. :-)

sub _menu_cut {
	my ($this) = @_;
	$this->{textctrl}->Cut();
	print "Cut\n";
	#TODO: Put a message in the status "Cut text placed in clipboard"?
}

# This sub is called when the user clicks on menu Edit item Copy

sub _menu_copy{
	my ($this) = @_;
	$this->{textctrl}->Copy();
	print "Copy\n";
	#TODO: Put a message in the status "Copied text placed in clipboard"?
}

# This sub is called when the user clicks on menu Edit item Paste

sub _menu_paste{
	my ($this) = @_;
	$this->{textctrl}->Paste();
	print "Paste\n";
	#TODO: Put a message in the status "Copied text placed in clipboard"?
}

# This sub is called when the user clicks on menu Help item About
# Displays information about the application in a modal dialog

sub _menu_about{
	my ($this) = @_;

	my $dialogtext = "Copyright 2005 by \n" . 
				"\tBen Marsh <blm\@woodheap.org> \n" . 
				"\tAdam Kennedy <cpan\@ali.as>\n" . 
			"All rights reserved.  You can redistribute and/or modify this \n" .
			"bundle under the same terms as Perl itself\n\n" .
			"See http://www.perl.com/perl/misc/Artistic.html";

	Wx::MessageBox($dialogtext, "About perlpad", wxOK|wxCENTRE, $this);
}

1;



( run in 1.144 second using v1.01-cache-2.11-cpan-df04353d9ac )