Commits

Herbert Breunung  committed cce65a2

put examples in subdir per chapter

  • Participants
  • Parent commits 96e33f0

Comments (0)

Files changed (13)

File example/00_start.pl

-use v5.12;
-use warnings;
-
-package App;
-use parent qw(Wx::App);
-use Wx;
-
-sub OnInit {
-	my $app   = shift;
-	my $frame = Wx::Frame->new( undef, -1, 'Greetings Wx');
-
-	$frame->Center();
-	$frame->Show(1);
-	$app->SetTopWindow($frame);
-	1;
-}
-
-package main;
-App->new->MainLoop;

File example/00_start_minimal.pl

-use Wx;
-
-App->new->MainLoop;
-
-package App;
-use parent qw(Wx::App);
-
-sub OnInit { Wx::Frame->new( undef, -1, 'Greetings Wx')->Show() }

File example/01_golden_button.pl

-use strict;
-use warnings;
-
-package App;
-use parent qw(Wx::App);
-use Wx;
-
-sub OnInit {
-	my $app   = shift;
-	my $frame = Wx::Frame->new( undef, -1, 'Golden Proportion');
-
-	my $button = Wx::Button->new($frame, -1,  'make it golden');
-	Wx::Event::EVT_BUTTON( $button, $button, sub {
-		my $size = $button->GetSize;
-		$size->SetWidth( $size->GetHeight * 1.618 ) ;
-		$button->SetSize( $size );
-		$frame->Fit;
-	} );
-
-	$frame->Center();
-	$frame->Show(1);
-	$app->SetTopWindow($frame);
-	1;
-}
-
-package main;
-App->new->MainLoop;

File example/01_golden_win.pl

-use strict;
-use warnings;
-
-package App;
-use parent qw(Wx::App);
-use Wx;
-
-sub OnInit {
-	my $app   = shift;
-	my $frame = Wx::Frame->new( undef, -1, 'Golden Proportion');
-
-	my $button = Wx::Button->new($frame, -1,  'make it golden');
-	Wx::Event::EVT_BUTTON( $button, $button, sub {
-		my $size = $frame->GetSize;
-		$size->SetWidth( $size->GetHeight * 1.618 ) ;
-		$frame->SetSize( $size );
-	} );
-
-	$frame->Center();
-	$frame->Show(1);
-	$app->SetTopWindow($frame);
-	1;
-}
-
-package main;
-App->new->MainLoop;

File example/01_ratio_selector.pl

-use v5.12;
-use warnings;
-
-package App;
-use parent qw(Wx::App);
-use Wx;
-
-my %ratio = (Golden => 1.618, Din => 1.41421, '2:3' => 1.5,  Square => 1);
-
-sub OnInit {
-	my $app   = shift;
-	my $frame = Wx::Frame->new( undef, -1, 'Golden Proportion');
-
-	my $button = Wx::Choice->new($frame, -1, [-1,-1], [-1,-1], [keys %ratio]);
-	Wx::Event::EVT_CHOICE( $button, $button, sub {
-		my $size = $frame->GetSize;
-		$size->SetWidth( $size->GetHeight * $ratio{ $_[1]->GetString } ) ;
-		$frame->SetSize( $size );
-	} );
-
-	$frame->Center();
-	$frame->Show(1);
-	$app->SetTopWindow($frame);
-	1;
-}
-
-package main;
-App->new->MainLoop;

File example/01_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;

File example/2a_minimal_subset/golden_button.pl

+use strict;
+use warnings;
+
+package App;
+use parent qw(Wx::App);
+use Wx;
+
+sub OnInit {
+	my $app   = shift;
+	my $frame = Wx::Frame->new( undef, -1, 'Golden Proportion');
+
+	my $button = Wx::Button->new($frame, -1,  'make it golden');
+	Wx::Event::EVT_BUTTON( $button, $button, sub {
+		my $size = $button->GetSize;
+		$size->SetWidth( $size->GetHeight * 1.618 ) ;
+		$button->SetSize( $size );
+		$frame->Fit;
+	} );
+
+	$frame->Center();
+	$frame->Show(1);
+	$app->SetTopWindow($frame);
+	1;
+}
+
+package main;
+App->new->MainLoop;

File example/2a_minimal_subset/golden_win.pl

+use strict;
+use warnings;
+
+package App;
+use parent qw(Wx::App);
+use Wx;
+
+sub OnInit {
+	my $app   = shift;
+	my $frame = Wx::Frame->new( undef, -1, 'Golden Proportion');
+
+	my $button = Wx::Button->new($frame, -1,  'make it golden');
+	Wx::Event::EVT_BUTTON( $button, $button, sub {
+		my $size = $frame->GetSize;
+		$size->SetWidth( $size->GetHeight * 1.618 ) ;
+		$frame->SetSize( $size );
+	} );
+
+	$frame->Center();
+	$frame->Show(1);
+	$app->SetTopWindow($frame);
+	1;
+}
+
+package main;
+App->new->MainLoop;

File example/2a_minimal_subset/ratio_button.pl

+use v5.12;
+use warnings;
+
+package App;
+use parent qw(Wx::App);
+use Wx;
+
+my %ratio = (Golden => 1.618, Din => 1.41421, '2:3' => 1.5,  Square => 1);
+
+sub OnInit {
+	my $app   = shift;
+	my $frame = Wx::Frame->new( undef, -1, 'Golden Proportion');
+
+	my $button = Wx::Choice->new($frame, -1, [-1,-1], [-1,-1], [keys %ratio]);
+	Wx::Event::EVT_CHOICE( $button, $button, sub {
+		my $size = $frame->GetSize;
+		$size->SetWidth( $size->GetHeight * $ratio{ $_[1]->GetString } ) ;
+		$frame->SetSize( $size );
+	} );
+
+	$frame->Center();
+	$frame->Show(1);
+	$app->SetTopWindow($frame);
+	1;
+}
+
+package main;
+App->new->MainLoop;

File example/2a_minimal_subset/ratio_selector.pl

+use v5.12;
+use warnings;
+
+package App;
+use parent qw(Wx::App);
+use Wx;
+
+my %ratio = (Golden => 1.618, Din => 1.41421, '2:3' => 1.5,  Square => 1);
+
+sub OnInit {
+	my $app   = shift;
+	my $frame = Wx::Frame->new( undef, -1, 'Golden Proportion');
+
+	my $button = Wx::Choice->new($frame, -1, [-1,-1], [-1,-1], [keys %ratio]);
+	Wx::Event::EVT_CHOICE( $button, $button, sub {
+		my $size = $frame->GetSize;
+		$size->SetWidth( $size->GetHeight * $ratio{ $_[1]->GetString } ) ;
+		$frame->SetSize( $size );
+	} );
+
+	$frame->Center();
+	$frame->Show(1);
+	$app->SetTopWindow($frame);
+	1;
+}
+
+package main;
+App->new->MainLoop;

File 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;

File example/2a_minimal_subset/start.pl

+use v5.12;
+use warnings;
+
+package App;
+use parent qw(Wx::App);
+use Wx;
+
+sub OnInit {
+	my $app   = shift;
+	my $frame = Wx::Frame->new( undef, -1, 'Greetings Wx');
+
+	$frame->Center();
+	$frame->Show(1);
+	$app->SetTopWindow($frame);
+	1;
+}
+
+package main;
+App->new->MainLoop;

File example/2a_minimal_subset/start_minimal.pl

+use Wx;
+
+App->new->MainLoop;
+
+package App;
+use parent qw(Wx::App);
+
+sub OnInit { Wx::Frame->new( undef, -1, 'Greetings Wx')->Show() }