use Win32::GUI;
use Win32::GUI::CardLayout;

$Window = new GUI::Window(
    -name   => "MainWindow",
    -text   => "Card Layout Window",
    -height => 200, 
    -width  => 300,
    -left   => 100, 
    -top    => 100,
);
$card1 = new CardLayout($Window, "main");


#
# Card One
#

$Window->AddLabel(
    -text => "Open Second Window",
    -name => "OpenSecond",
    -left => 10, 
    -top  => 10,
);
$card1->add("OpenSecond", "main");

$Window->AddButton(
    -text => "Open", 
    -name => "OpenButton",
    -width => 50,
    -left => 130, 
    -top  => 7
);
$card1->add("OpenButton", "main");

$Window->AddLabel(
    -text => "See Second Card",
    -name => "SecondCard",
    -left => 10, 
    -top  => 40,
);
$card1->add("SecondCard", "main");

$Window->AddButton(
    -text => "Flip", 
    -name => "FlipButton",
    -width => 50,
    -left => 130, 
    -top  => 35 
);
$card1->add("FlipButton", "main");


#
# Card Two
#

$Window->AddLabel(
    -text => "Back to First Card",
    -name => "FirstCard",
    -left => 20, 
    -top  => 70,
);
$card1->add("FirstCard", "two");

$Window->AddButton(
    -text => "Back", 
    -name => "FlipButtonBack",
    -width => 50,
    -left => 150, 
    -top  => 65 
);
$card1->add("FlipButtonBack", "two");
                            
                            



#
# WINDOW 2
#

$Window2 = new GUI::Window(
    -text   => "Second Window",
    -name   => "Window 2",
    -width  => 200,
    -height => 100, 
    -left   => 110, 
    -top    => 110,
);
$card2 = new CardLayout($Window2, "secondMain");


#
# Card One, Window Two
#

$Window2->AddLabel(
    -name => "FlipCard2",
    -text => "Show Card Two",
    -left => 10, 
    -top  => 10,
);
$card2->add("FlipCard2", "secondMain");

$Window2->AddTextfield(
    -name   =>  "Textbox",
    -left   =>  10, 
    -top    => 40,
    -width  => 100, 
    -height => 25,
);
$card2->add("Textbox", "secondMain");

$Window2->AddButton(
    -name => "ShowCardTwo",
    -text => "Push", 
    -left => 130, 
    -top  => 40
);
$card2->add("ShowCardTwo", "secondMain");

   
#
# Card Two, Window Two
#

$Window2->AddLabel(
    -name => "Window2Label2",
    -text => "Show Card 2",
    -left => 5, 
    -top  => 5,
);
$card2->add("Window2Label2", "second");

$Window2->AddButton(
    -name => "ShowCardOne",
    -text => "Push", 
    -left => 115, 
    -top  => 2
);
$card2->add("ShowCardOne", "second");

$Window2->AddLabel(
    -name => "Window2Label3",
    -text => "Close Window Two",
    -left => 5, 
    -top  => 35,
);
$card2->add("Window2Label3", "second");

$Window2->AddButton(
    -name => "CloseWindowTwo",
    -text => "Close", 
    -left => 115, 
    -top  => 31
);
$card2->add("CloseWindowTwo", "second");



$Window->Show();


Win32::GUI::Dialog();


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


sub OpenButton_Click {
  $Window2->Show();
}

sub FlipButton_Click {
  $card1->showCard("two");
}

sub FlipButtonBack_Click {
  $card1->showCard("main");
}

sub ShowCardTwo_Click {
  $card2->showCard("second");
}

sub ShowCardOne_Click {
  $card2->showCard("secondMain");
}

sub CloseWindowTwo_Click {
  $Window2->Hide();
}
