#!/usr/bin/perl -w -- 
# generated by wxGlade 0.3.2 on Tue Apr 13 17:05:27 2004
# To get wxPerl visit http://wxPerl.sourceforge.net/

use Wx 0.15 qw[:allclasses];
use strict;

package TestDlg;

use Wx qw[:everything];
use base qw(Wx::Dialog);
use strict;

use Wx::Event qw(EVT_BUTTON EVT_PAINT);

###
use Wx::Polygon;
###

sub new {
	my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_;
	$parent = undef              unless defined $parent;
	$id     = -1                 unless defined $id;
	$title  = ""                 unless defined $title;
	$pos    = wxDefaultPosition  unless defined $pos;
	$size   = wxDefaultSize      unless defined $size;
	$name   = ""                 unless defined $name;

# begin wxGlade: TestDlg::new

	$style = wxDEFAULT_DIALOG_STYLE 
		unless defined $style;

	$self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name );
	$self->{panel_1} = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefaultSize, );
	$self->{static_line_1} = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, );
	$self->{button_2} = Wx::Button->new($self, 1000, "&StopStart");
	$self->{button_1} = Wx::Button->new($self, wxID_OK, "&OK");

	$self->__set_properties();
	$self->__do_layout();

	return $self;

# end wxGlade
}


sub __set_properties {
	my $self = shift;

# begin wxGlade: TestDlg::__set_properties

	$self->SetTitle("TestDlg");
	$self->{panel_1}->SetSize($self->{panel_1}->ConvertDialogSizeToPixels(Wx::Size->new(176, 160)));
	$self->{button_2}->SetDefault();

# end wxGlade

	$self->{"leaf"}=new Wx::Polygon( 'ELLIPSE' => [75,0,50,25] );
	$self->{"leaf"}->add_point(0,0);
	$self->{'degrees'}=0;
	$self->{"stopped"}=0;

	print "IN    : ",$self->{"leaf"}->in(50,10),"\n";
	print "NOT IN: ",$self->{"leaf"}->in(20,5),"\n";

	EVT_PAINT($self->{panel_1},sub { paint($self,@_); });
	EVT_BUTTON($self,$self->{button_2},\&StopStart);
}

sub __do_layout {
	my $self = shift;

# begin wxGlade: TestDlg::__do_layout

	$self->{sizer_1} = Wx::FlexGridSizer->new(3, 1, 5, 5);
	$self->{grid_sizer_1} = Wx::GridSizer->new(1, 2, 5, 5);
	$self->{sizer_1}->Add($self->{panel_1}, 1, wxEXPAND, 0);
	$self->{sizer_1}->Add($self->{static_line_1}, 0, wxEXPAND, 0);
	$self->{grid_sizer_1}->Add($self->{button_2}, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
	$self->{grid_sizer_1}->Add($self->{button_1}, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
	$self->{sizer_1}->Add($self->{grid_sizer_1}, 1, wxEXPAND, 0);
	$self->SetAutoLayout(1);
	$self->SetSizer($self->{sizer_1});
	$self->{sizer_1}->Fit($self);
	$self->{sizer_1}->SetSizeHints($self);
	$self->{sizer_1}->AddGrowableRow(0);
	$self->{sizer_1}->AddGrowableCol(0);
	$self->Layout();

# end wxGlade
}

# end of class TestDlg

sub StopStart {
  my $self=shift;
  if ($self->{"stopped"}) { $self->{"stopped"}=0;$self->Refresh(); }
  else { $self->{"stopped"}=1; }
}

sub paint {
  my $self=shift;
  my $window=shift;
  my $dc=new Wx::PaintDC($window);

  my ($w,$h)=$dc->GetSizeWH();
  $w/=2;
  $h/=2;

  my $r=$self->{'degrees'}/5;
  if ($r>255) { $r=255; }

  $self->{'leaf'}->offset($w,$h);
  $self->{"leaf"}->draw($dc);
  $self->{'degrees'}+=5;
  $self->{"leaf"}->set_color($r,0,0);

  my ($midx,$midy)=$self->{'leaf'}->mid();
  $dc->DrawText("midx=$midx, midy=$midy",10,10);
  $self->{"leaf"}->rotate($self->{'degrees'});

  if (not $self->{"stopped"}) {
    $self->Refresh();
  }
}

1;

##############################################################################

package TestApp;

use base 'Wx::App';

sub OnInit {
    my $self=shift;
    my $frame=new TestDlg();
    $frame->ShowModal();
return 0;
}

package main;

my $a= new TestApp;
$a->MainLoop();

END {
  exit(0);
}
