package SizerExampleFrame;
use strict;
use warnings;
use Wx qw /:everything/;
use Wx::Event qw/EVT_BUTTON/;
use base 'Wx::Frame';
sub new {
my $class = shift;
my $self = $class->SUPER::new( undef,
-1,
'SizerExampleFrame',
[-1,-1],
[600, 400],
);
####
my $vbox = Wx::BoxSizer->new( wxVERTICAL );
##
##
my $pnl1 = Wx::Panel->new($self, -1);
my $pnl2 = Wx::Panel->new($self, -1);
my $pnl3 = Wx::Panel->new($self, -1);
my $pnl4 = Wx::Panel->new($self, -1);
##
##
my $lbl1 = Wx::StaticText->new( $pnl1, # parent
-1, # id,
"Testing: 1", # label
[5,10], # position
);
##
##
my $lbl2 = Wx::StaticText->new( $pnl2, # parent
-1, # id,
"Testing: 2", # label
[5,10], # position
);
my $lbl3 = Wx::StaticText->new( $pnl3, # parent
-1, # id,
"Testing: 3", # label
[5,10], # position
);
##
##
# now we want to create a vbox for the 4th panel
# in this we will put button and other panels
my $pnl4Vbox = Wx::BoxSizer->new( wxVERTICAL );
##
##
my $btnBox = Wx::BoxSizer->new( wxHORIZONTAL );
my $pnlBtns = Wx::Panel->new( $pnl4, #parent
-1, # id
[-1,-1], # position [-1,-1], # size
0 # border style
);
##
##
my $btnButton1 = Wx::Button->new( $pnlBtns, -1, 'Button 1');
EVT_BUTTON( $pnlBtns, $btnButton1, \&btnButton1Clicked );
my $btnButton2 = Wx::Button->new( $pnlBtns, -1, 'Button 2');
EVT_BUTTON( $pnlBtns, $btnButton2, \&btnButton2Clicked );
##
##
$btnBox->Add( $btnButton1, 1, wxALIGN_BOTTOM, 0 );
$btnBox->Add( $btnButton2, 1, wxALIGN_BOTTOM, 0 );
##
##
$pnlBtns->SetSizer($btnBox);
##
##
$pnl4->SetSizer($pnl4Vbox);
##
##
$vbox->Add( $pnl1, 1, wxEXPAND | wxALL, 3);
$vbox->Add( $pnl2, 1, wxEXPAND | wxALL, 3);
$vbox->Add( $pnl3, 1, wxEXPAND | wxALL, 3);
$vbox->Add( $pnl4, 1, wxEXPAND | wxALL, 3);
##
##
$self->SetSizer( $vbox );
return $self;
}
##
##
sub btnButton1Clicked {
my( $self, $event ) = @_;
print "Button 1\n";
}
sub btnButton2Clicked {
my( $self, $event ) = @_;
print "Button 2\n";
}
##
##
package BoxSizerExampleFrame;
use strict;
use warnings;
use Wx qw /:everything/;
use Wx::Event qw/EVT_BUTTON/;
use base 'Wx::Frame';
sub new {
my $class = shift;
my $self = $class->SUPER::new( undef,
-1,
'Jabber Frame',
[-1,-1],
[600, 400],
);
my $vbox = Wx::BoxSizer->new( wxVERTICAL );
my $pnl1 = Wx::Panel->new($self, -1);
my $pnl2 = Wx::Panel->new($self, -1);
my $pnl3 = Wx::Panel->new($self, -1);
my $pnl4 = Wx::Panel->new($self, -1);
my $lbl1 = Wx::StaticText->new( $pnl1, # parent
-1, # id,
"Testing: 1", # label
[5,10], # position
);
my $lbl2 = Wx::StaticText->new( $pnl2, # parent
-1, # id,
"Testing: 2", # label
[5,10], # position
);
my $lbl3 = Wx::StaticText->new( $pnl3, # parent
-1, # id,
"Testing: 3", # label
[5,10], # position
);
# now we want to create a vbox for the 4th panel
# in this we will put button and other panels
my $pnl4Vbox = Wx::BoxSizer->new( wxVERTICAL );
# we'll create a button panel and place the buttons
# horizontally
my $btnBox = Wx::BoxSizer->new( wxHORIZONTAL );
my $pnlBtns = Wx::Panel->new( $pnl4, #parent
-1, # id
[-1,-1], # position
[-1,-1], # size
0 # border style
);
my $pnl4Text = Wx::Panel->new( $pnl4, #parent
-1, # id
[-1,-1], # position
[-1,-1], # size
0, #wxSIMPLE_BORDER # border style
);
my $btnButton1 = Wx::Button->new( $pnlBtns, -1, 'Button 1');
EVT_BUTTON( $pnlBtns, $btnButton1, \&btnButton1Clicked );
my $btnButton2 = Wx::Button->new( $pnlBtns, -1, 'Button 2');
EVT_BUTTON( $pnlBtns, $btnButton2, \&btnButton2Clicked );
$btnBox->Add( $btnButton1, 1, wxALIGN_BOTTOM, 0 );
$btnBox->Add( $btnButton2, 1, wxALIGN_BOTTOM, 0 );
$pnlBtns->SetSizer($btnBox);
$pnl4Vbox->Add( $pnl4Text,
1,
wxEXPAND,
0);
$pnl4Vbox->Add( $pnlBtns, # widget
1, # vertically stretchable
wxALIGN_BOTTOM | wxALIGN_RIGHT, # alignment
0 # border pixels
);
$pnl4->SetSizer($pnl4Vbox);
$vbox->Add( $pnl1, 1, wxEXPAND | wxALL, 3);
$vbox->Add( $pnl2, 1, wxEXPAND | wxALL, 3);
$vbox->Add( $pnl3, 1, wxEXPAND | wxALL, 3);
$vbox->Add( $pnl4, 1, wxEXPAND | wxALL, 3);
$self->SetSizer( $vbox );
return $self;
}
sub btnButton1Clicked {
my( $self, $event ) = @_;
print "Button 1\n";
}
sub btnButton2Clicked {
my( $self, $event ) = @_;
print "Button 2\n";
}
1;