#!perl

use strict;
use warnings;
use Wx;

# ----------------------------------------------------------------

package MyGrid;
use base 'Wx::Grid';

my $GRID_WIDTH  = 353;
my $GRID_HEIGHT = 121;

sub new
{
    my $class = shift;
    my ($parent) = @_;
    my $self = $class->SUPER::new($parent, -1, [20, 20], [$GRID_WIDTH, $GRID_HEIGHT]);

    # Create the grid
    $self->CreateGrid(5, 3);

    # Set column widths
    $self->SetRowLabelSize(50);
    $self->SetColSize(0, 100);
    $self->SetColSize(1, 100);
    $self->SetColSize(2, 100);

    $self->SetCellValue(0,0, $self->GetColLabelSize);
    $self->SetCellValue(1,0, $self->GetRowSize(0));

    return $self;
}

# ----------------------------------------------------------------

package MyFrame;
use base 'Wx::Frame';

sub new
{
    my $class = shift;

    my $self = $class->SUPER::new(undef, -1, 'Grid test', [-1, -1], [400, 300]);

    my $panel = Wx::Panel->new($self, -1);
    my $grid = MyGrid->new($panel);

    return $self;
}

# ----------------------------------------------------------------

package MyApp;
use base 'Wx::App';

sub OnInit
{
    my $frame = MyFrame->new;
    $frame->Show(1);
}

# ----------------------------------------------------------------

package main;

my $app = MyApp->new;
$app->MainLoop;
