use Win32::GUI;

$Menu = new Win32::GUI::Menu(
    File => "&File",
    Text =>"",
    );

 $Window = new Win32::GUI::Window(
        -name   => "Window",
        -title  => "Steve's Window",
        -left   => 100,  
        -top    => 100,
        -width  => 500, 
        -height => 400,         
        -menu   => $Menu,
    );
  
$Window ->AddProgressBar(
    -name => "Progbar",
    -width=>250,
    -height=>20,
    -top =>100,
    -left=>125,
    -smooth =>0,
    -vertical =>0
    );
    
$Window->Progbar->SetPos  (0);
$Window->Progbar->SetRange(0,10);
$Window->Progbar->SetStep (1);

$Window->AddLabel(
        -name =>"ProgLabel",
        -align => "center",
        -text =>"Overall Progress",
        -width => 100,
        -height =>50,
        -top => 150,
        -left=>150 
        );

$Window->AddLabel(
        -name =>"PendLabel",
        -align => "left",
        -text =>"Pending",
        -width => 100,
        -height =>20,
        -top => 25,
        -left=>0 
        );
        
$Window->AddLabel(
        -name =>"FinLabel",
        -align => "center",
        -text =>"Completed Jobs",
        -width => 100,
        -height =>20,
        -top => 25,
        -left=>400 
        );
        
$Window->AddListbox (
    
    -name           => "Done",
    -align          => "center",
    -width          => 100,
    -height         => 200,
    -left           => 400,
    -top            => 50,
    -multisel       => 1,
    -autohscroll    => 0,
        -vscroll    => 1,
        -hscroll    => 1,
    -sort =>1
    );
    

$Window->AddListbox (
    -name => "Agenda",
    -align => "center",
    -top   => 50,
    -width => 100,
    -height => 200,
    -multisel => 1,
    -autohscroll => 0,
        -vscroll   => 1,
        -hscroll   => 1,
    -sort =>1
    );

$Window->AddButton(
        -name => "Remove",
        -align => "center",
        -text  => "Remove",
        -left  => 200,
        -top   => 200
        -width => 100,
        -height =>50,
    );

    
$Textfield = $Window->AddTextfield(
    -name     => "Textfield",
    -left     => 50,
    -top      => 300,
    -text     => "sample text",
    -width    => 180,
    -height   => 22,
    -prompt   => "Sample TextField:",
    #-foreground => [0,255,0],
    #-background => [0,0,0],
);

#$Multitext = $Window->AddTextfield(
#    -name     => "Multitext",
#    -multiline => 1,
#    -autohscroll => 0,
#        -vscroll   => 1,
#        -hscroll   => 1,
#    -left     => 200,
#    -top      => 280,
#    -width    => 180,
#    -height   => 180,
#);






$Window->Show();

@Stuff = ("First","Second","Third", "Fourth");

foreach $item (@Stuff)
    {   
        
        $Window->Agenda->Add($item);
    }


$screen = $Window->GetDC();
$i=1;
$fin =0;

#while( ($fin == 0 ))
 #   {
  #    $i++; 
   #   Win32::GUI::DoEvents();   
    #  $position = int ($Window->Done->Count() * 10 / (4));
     # $Window->Progbar->SetPos($position);
      #$screen->TextOut(200,250,"Overall Progress : $position");
    #}

Win32::GUI::Dialog();

sub Done_DblClick
    {
        &Done_GotFocus;
        &Remove_Click;
    }

sub Done_GotFocus
    {
       $removefrom = "Done";    
    }

sub Agenda_DblClick
    {
        &Agenda_GotFocus;
        &Remove_Click;
    }

sub Agenda_GotFocus
    {
       $removefrom = "Agenda";
    }



sub Remove_Click
    {
        # which one is selected ?
        
        if ($removefrom eq "Done")
            {
                $todo = $Window->Done->SelectedItem();
                if (($todo == -1)|| ($Window->Done->Count() == 0))
                    {
                    }
                else
                    {
                        $item = $Window->Done->GetString($todo);
                        $Window->Done->RemoveItem($todo);
                        $Window->Agenda->Add($item);
                        $todo = -1;
                    }
            }
        else
            {
              $todo = $Window->Agenda->SelectedItem();
              if (($todo == -1)|| ($Window->Agenda->Count() == 0))
                {
                }
              else
                {
                    $item = $Window->Agenda->GetString($todo);
                    $Window->Agenda->RemoveItem($todo);
                    $Window->Done->Add($item);
                    $todo = -1;
                }
            }
                        
    }
                    
                
sub Window_Terminate
    {
        print "Terminated !!!!!\n";
        $fin = 1;   
        return -1;
    }
