Commits

Herbert Breunung  committed 1da5faf

expanding ruler example for chapter 1

  • Participants
  • Parent commits b275d63

Comments (0)

Files changed (3)

File chapter/TOC.txt

-0 Preparations
+I Preparations
 
  a Navigation - How to use that Book
  b Introduction - Prehistory and Goals
  d Documentation - Whats Where?
  e Rules And Terms - Of The Wx API
 
-1 Foundations
+II Foundations
 
  a Minimal Subset
  b Functions
  j Midsized Widgets
  k Subclassing Widgets
 
-2 Building An App
+III Building An App
 
  a Top Level Window
  b Status Bar
  h Selfmade Dialogs
  i Packaging
 
-3 Advanced Topics
+IV Advanced Topics
 
  a MDI - Russian Doll Windows
  b AUI - Floating Elements

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/02_ruler.pl

-use strict;
+use v5.12;
 use warnings;
 
 package App;
 
 sub OnInit {
 	my $app   = shift;
-	my $frame = Wx::Frame->new( undef, -1, 'Golden Proportion');
+	my $frame = Wx::Frame->new( undef, -1, 'Ruler');
 
-	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;
+	my $grid = Wx::FlexGridSizer->new(2,1,10,10);
+	my %txt;
+	for my $label (qw(X Y H W)) {
+		#$txt{ $label } = Wx::TextCtrl->new($frame, -1, $label, [-1,-1], [60, -1]);
+		$grid->Add( Wx::StaticText->new($frame, -1, $label.':'), 0, &Wx::wxGROW, 0 );
+		#$grid->Add( $txt{ $label } );
+	}
+	$grid->AddGrowableCol(1);
+	say $grid->GetCols;
+
+	Wx::Event::EVT_SIZE($frame, sub {
 	} );
+	Wx::Event::EVT_MOVE($frame, sub {
+	} );
+
+	#$frame->SetAutoLayout( 1 );
+	$frame->SetSizer( $grid );
+	#$grid->Fit( $frame );
+	#$grid->SetSizeHints( $frame );
 
 	$frame->Center();
 	$frame->Show(1);