#!/usr/bin/perl 
use strict;
use warnings;


#############################################################################
##
##
## Copyright:   (c) The Padre development team
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################

my $app = Demo::ListView->new;
$app->MainLoop;


#####################
package Demo::ListView;
use strict;
use warnings;

use base 'Wx::App';


sub OnInit {
	my $frame = Demo::Frame->new;
	$frame->Show(1);
}

#####################
package Demo::Frame;
use strict;
use warnings;


use Wx ':everything';
use Wx::Event ':everything';

use Wx qw(:radiobutton :font wxDefaultPosition wxDefaultSize);
use Wx::Event qw(EVT_RADIOBUTTON EVT_BUTTON);
use Wx::Event qw(EVT_RADIOBOX);

use base 'Wx::Frame';
my $combo_selected_option =undef;     
sub new 
{
	
	my ($class) = @_;

	my $self = $class->SUPER::new(
		undef,
		-1,
		'Notebook ',
		[ -1,  -1 ],
		[ 750, 700 ],
	);
        
	
	  $self->SetIcon( Wx::GetWxPerlIcon());
	#
	# Creating the notebook with tabs (also called panes)
	my $nb = Wx::Notebook->new(
		$self, -1, wxDefaultPosition, wxDefaultSize,
		wxNO_FULL_REPAINT_ON_RESIZE | wxCLIP_CHILDREN
		
	);
      
        my $rb11 = Wx::RadioButton->new( $nb, -1, "Radio&10,300",
                                    [10, 300], wxDefaultSize,,wxRB_GROUP );
         
         
       my $rb21 = Wx::RadioButton->new( $nb, -1, "Radio&20,300",
                                    [10, 330] );        
                                   
                     
          my $combo_choices = [ 'This', 'is one of my',
                    'really', 'wonderful', 'examples', ];
               
        my $comboBox = Wx::ComboBox->new( $nb, -1,"lable combo", [10, 400], [-1, -1],$combo_choices);
	my $radioBoxchoices = ['first','seconed','third'];
        my $radiobox = Wx::RadioBox->new
             ( $nb, -1, "Radio box", [400, 400],
               wxDefaultSize, $radioBoxchoices, 3, wxRA_SPECIFY_COLS );

     
     
     EVT_RADIOBOX( $self	, $radiobox, \&OnRadio );
   sub OnRadio {
   my ( $self, $event ) = @_;

     Wx::LogMessage( join '', "RadioBox selection string is: ",
                              $event->GetString() );
}
				

                                              
                                                 
        my $wizard = Wx::Wizard->new( $self, -1, "Wizard test" ); 
        
        
        # first page
    my $page1 = Wx::WizardPageSimple->new( $wizard );
    Wx::TextCtrl->new( $page1, -1, "First page" );

    # second page
    my $page2 = Wx::WizardPageSimple->new( $wizard );
    Wx::TextCtrl->new( $page2, -1, "Second page",[0,0],[1000,40] );
    ###($self, -1, "", n, wxDefaultSize, wxTE_MULTILINE);

     Wx::WizardPageSimple::Chain( $page1, $page2 );
    EVT_RADIOBUTTON
          ( $self, $rb11,
            sub {
			my ( $self, $event ) = @_;
			print "printing to STDOUT\n";
			print STDERR "printing to STDERR\n";
		        $wizard->RunWizard( $page1 );
			##Wx::MessageBox( "This Radio Button 1 was selected", "Title", wxOK | wxCENTRE, $self );
	          }
		);


    EVT_WIZARD_PAGE_CHANGED( $self, $wizard, sub {
                                 Wx::LogMessage( "Wizard page changed" );
                             } );
        
        
        
	# creating the content of the first tab
	my $editor = Wx::TextCtrl->new(
		$nb, -1, '', Wx::wxDefaultPosition, Wx::wxDefaultSize,
		wxTE_MULTILINE | wxNO_FULL_REPAINT_ON_RESIZE
	);
   
	# add first tab
      $nb->AddPage( $editor, 'Editor', 0);
      $rb11->SetValue(0);
      $rb21->SetValue(0);
      
	my $choices = [
		'This example', 'was borrowed',
		'from an example', 'Hi David ', 'How are you ?'
	];
	my $listbox = Wx::ListBox->new( $nb, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, $choices );
	 $listbox->SetBackgroundColour( wxWHITE);
	$nb->AddPage( $listbox, 'Listbox', 1 );
	EVT_LISTBOX_DCLICK( $self, $listbox, \&on_listbox_double_click );
        
   
        EVT_RADIOBUTTON($self, $rb11, \&OnRadioButton_Daphna);
        EVT_BUTTON
          ( $self, $rb11,
            sub {
			my ( $self, $event ) = @_;
			print "printing to STDOUT\n";
			print STDERR "printing to STDERR\n";
			
	 		Wx::MessageBox( "This is the smell of an Onion", "Title", wxOK | wxCENTRE, $self );
	          }
		);
         EVT_RADIOBUTTON( $self, $rb21, \&OnRadioButton_Sel2 );
         EVT_COMBOBOX( $self, $comboBox, \&OnCombo);

	return $self;
}

sub OnRadioButton_Daphna{
	my( $self, $event ) = @_;
	print "printing to STDOUT\n";
	print STDERR "printing to STDERR\n";
	 Wx::MessageBox( "Using Radio Button 1 ", "Title", wxOK | wxCENTRE, $self);
}




sub on_listbox_double_click {
	my ( $self, $event ) = @_;
	Wx::MessageBox( "Double clicked: '" . $event->GetString() . "", '', Wx::wxOK | Wx::wxCENTRE, $self );
}



sub OnRadioButton_Sel2 {
    my( $self, $event ) = @_;
    $self->radiobut1_2->SetValue( 1 );
       
}

sub OnCombo {
    my( $self, $event ) = @_;
   $combo_selected_option = $event->GetString();
    Wx::LogMessage( join '', "ComboBox event selection string is: '",
                    $event->GetString(), "'" );
    
}

sub add_to_tags { qw(managed) }
sub title { 'wxWizard' }
