App-GUI-Notepad

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

inc/Module/Install/Fetch.pm
inc/Module/Install/Include.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/Scripts.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
inc/Test/NeedsDisplay.pm
lib/App/GUI/Notepad.pm
lib/App/GUI/Notepad/Frame.pm
lib/App/GUI/Notepad/MenuBar.pm
Makefile.PL
MANIFEST			This list of files
META.yml
t/01_compile.t
t/02_start_perlpad.t
t/03_newfile_and_save.t

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


=head1 AUTHOR

Ben Marsh E<lt>blm@woodheap.orgE<gt>

Created with the valuable assistance of Adam Kennedy E<lt>cpan@aliasE<gt> 


=head1 SEE ALSO

L<App::GUI::Notepad::Frame>, L<App::GUI::Notepad::MenuBar>

=head1 COPYRIGHT

Copyright (c) 2005 Ben Marsh, Adam Kennedy. All rights reserved.

This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the
LICENSE file included with this module.

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

package App::GUI::Notepad::Frame;

use strict;
use File::Spec  ();
use base qw/Wx::Frame/;
use Wx          qw/:allclasses wxTE_MULTILINE wxID_OK wxSAVE wxOK wxCENTRE wxFONTENCODING_SYSTEM wxMODERN wxNORMAL wxNullColour wxSWISS wxTE_RICH/;
use Wx::Event   qw/EVT_MENU/;


use App::GUI::Notepad::MenuBar;

use vars qw{$VERSION};
BEGIN {
	$VERSION = '0.01';
}

# This is the constructor for the object.
# It creates:
# 			- the menubar
#			- the textctrl which is where the text that is being edited is 

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

#			user 
# It associates actions to the various menu options, sets the application 
# icon and sets the font for displaying the file to a fixed width font.

sub new {
	my ($class) = shift;
	my ($title, $position, $size) = @_;
	my ($this) = $class->SUPER::new( undef, -1, $title, $position, $size );
	$this->SetIcon( Wx::GetWxPerlIcon() );

	$this->{menubar} = App::GUI::Notepad::MenuBar->new();
	$this->SetMenuBar( $this->{menubar}->menubar() );

	# Associate the various menu options with subroutines that are the 
	# actions to be carried out when the user clicks on the menu item.
	#
    # I wanted to do this in the MenuBar object but this function 
	# EVT_MENU need a reference to the frame and so they are called 
	# here

	EVT_MENU( $this, $this->{menubar}->{ID_NEW},    \&_menu_new    );
	EVT_MENU( $this, $this->{menubar}->{ID_OPEN},   \&_menu_open   );
	EVT_MENU( $this, $this->{menubar}->{ID_SAVE},   \&_menu_save   );
	EVT_MENU( $this, $this->{menubar}->{ID_SAVEAS}, \&_menu_saveas );
	EVT_MENU( $this, $this->{menubar}->{ID_CLOSE},  \&_menu_close  );
	EVT_MENU( $this, $this->{menubar}->{ID_EXIT},   \&_menu_exit   );
	EVT_MENU( $this, $this->{menubar}->{ID_UNDO},   \&_menu_undo   );

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

package App::GUI::Notepad::MenuBar;

use strict;
use Wx::Menu ();

use vars qw{$VERSION};
BEGIN {
	$VERSION = '0.01';
}

sub new {
	my $class = ref $_[0] ? ref shift : shift;
	my %args  = @_;

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

		ID_EXIT   => 120,
		ID_UNDO   => 123,
		ID_REDO   => 124,
		ID_CUT    => 125,
		ID_COPY   => 130,
		ID_PASTE  => 135,
		ID_ABOUT  => 140,
		}, $class;

	# Create the File menu
	$this->{filemenu} = Wx::Menu->new() or die();
	$this->{filemenu}->Append( $this->{ID_NEW},    "&New",     "Create a file" );
	$this->{filemenu}->Append( $this->{ID_OPEN},   "&Open",    "Open a file" );
	$this->{filemenu}->Append( $this->{ID_SAVE},   "&Save",    "Save current file" );
	$this->{filemenu}->Append( $this->{ID_SAVEAS}, "Save &As", "Save under different filename" );
	$this->{filemenu}->Append( $this->{ID_CLOSE},  "&Close",   "Close current file" );
	$this->{filemenu}->AppendSeparator();
	$this->{filemenu}->Append( $this->{ID_EXIT},   "E&xit",    "Quit this Program" );

	# Create the Edit menu
	$this->{editmenu} = Wx::Menu->new() or die();
	$this->{editmenu}->Append( $this->{ID_UNDO},   "&Undo",    "Undo" );
	$this->{editmenu}->Append( $this->{ID_REDO},   "&Redo",    "Redo" );
	$this->{editmenu}->AppendSeparator();
	$this->{editmenu}->Append( $this->{ID_CUT},    "&Cut",     "Cut selected text" );
	$this->{editmenu}->Append( $this->{ID_COPY},   "&Copy",    "Copy selected text" );
	$this->{editmenu}->Append( $this->{ID_PASTE},  "&Paste",   "Paste text" );

	# Create the Help menu
	$this->{helpmenu} = Wx::Menu->new();
	$this->{helpmenu}->Append( $this->{ID_ABOUT},  "&About",   "About this program" );	

	# Assemble the menubar
	$this->{menubar} = Wx::MenuBar->new() or die();
	$this->{menubar}->Append( $this->{filemenu}, "&File" );
	$this->{menubar}->Append( $this->{editmenu}, "&Edit" );
	$this->{menubar}->Append( $this->{helpmenu}, "&Help" );

	return $this;
}

sub menubar {
	$_[0]->{menubar};
}

t/01_compile.t  view on Meta::CPAN

			);
	}
}

use Test::NeedsDisplay;
use Test::More tests => 4;

ok( $] > 5.005, 'Perl version is 5.005 or newer' );
use_ok( 'App::GUI::Notepad' );
use_ok( 'App::GUI::Notepad::Frame' );
use_ok( 'App::GUI::Notepad::MenuBar' );

exit(0);

t/02_start_perlpad.t  view on Meta::CPAN

}

use Test::NeedsDisplay;
use Test::More tests => 8;

use App::GUI::Notepad;

my $app = App::GUI::Notepad->new();
ok(defined $app, 'Åpplication object instantiation');
isa_ok($app, 'App::GUI::Notepad');
ok(defined $app->{frame}, 'Menubar instantiation');
isa_ok($app->{frame}, 'App::GUI::Notepad::Frame');
my $frame = $app->{frame};
ok(defined $frame->{menubar}, 'Frame has a menubar');
isa_ok($frame->{menubar}, 'App::GUI::Notepad::MenuBar');
ok(defined $frame->{textctrl}, 'Frame has a menubar');
isa_ok($frame->{textctrl}, 'Wx::TextCtrl');

exit(0);



( run in 1.552 second using v1.01-cache-2.11-cpan-49f99fa48dc )