WxPerlBook / example / 2a_minimal_subset / ruler.pl

use v5.14;
use warnings;

package App;
use Wx qw/ :everything /;
use parent qw(Wx::App);

sub OnInit {
	my $app   = shift;
	my $frame = Wx::Frame->new( undef, -1, 'Ruler');
	my $grid = Wx::FlexGridSizer->new(2, 4, 1, 1 );
	$grid->AddGrowableCol(1);
	$grid->AddGrowableCol(3);
	my %txt;
	for my $label (qw(X Y H W)) {
		$txt{ $label } = Wx::TextCtrl->new($frame, -1, $label);
		$grid->Add( Wx::StaticText->new($frame, -1, $label.' :'), 0, &Wx::wxGROW | &Wx::wxALL, 5);
		$grid->Add( $txt{ $label }, 1, &Wx::wxGROW | &Wx::wxALL | wxALIGN_CENTRE_VERTICAL, 0 );
	}

	Wx::Event::EVT_SIZE($frame, sub {
		my $size = $frame->GetSize;
		$txt{ 'H' }->SetValue( $size->GetHeight );
		$txt{ 'W' }->SetValue( $size->GetWidth );
		$_[1]->Skip;
	} );
	Wx::Event::EVT_MOVE($frame, sub {
		my $pos = $frame->GetPosition;
		$txt{ 'X' }->SetValue( $pos->x );
		$txt{ 'Y' }->SetValue( $pos->y );
		$_[1]->Skip;
	} );
	
	$frame->SetSizer( $grid );
	$frame->Center();
	$frame->Show(1);
	$app->SetTopWindow($frame);
	1;
}

package main;
App->new->MainLoop;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.