### ----------------------------------------------------
### -- GTK::Simple
### -- Licenses: Artistic-2.0
### -- Authors: Jonathan Worthington, Moritz Lenz, Timo Paulssen, Ahmad M. Zawawi, Jonathan Stowe, ab5tract, momozor, Zoffix Znet, Nick Logan, finanalyst aka Richard Hainsworth
### -- File: examples/20-calendar.raku
### ----------------------------------------------------

use GTK::Simple;
use GTK::Simple::App;

my $app = GTK::Simple::App.new(title => 'Calendar', height => 300, width => 600);
my $calendar = GTK::Simple::Calendar.new;

my $month-entry = GTK::Simple::Entry.new(text => ~$calendar.month);
my $year-entry  = GTK::Simple::Entry.new(text => ~$calendar.year);
my $day-entry   = GTK::Simple::Entry.new(text => ~$calendar.day);

$calendar.day-selected.tap: {
    $year-entry.text    = .year.Str;
    $month-entry.text   = .month.Str;
    $day-entry.text     = .day.Str;
};

my $date-view = GTK::Simple::Grid.new(
    [0, 0, 1, 1] => GTK::Simple::Label.new(text => "Day"),
    [1, 0, 1, 1] => $day-entry,
    [2, 0, 1, 1] => GTK::Simple::Label.new(text => "Month"),
    [3, 0, 1, 1] => $month-entry,
    [4, 0, 1, 1] => GTK::Simple::Label.new(text => "Year"),
    [5, 0, 1, 1] => $year-entry
);

$date-view.column-spacing = 8;

my $structure = GTK::Simple::Grid.new(
    [0, 0, 1, 1] => $calendar,
    [1, 0, 1, 1] => $date-view
);

$structure.column-spacing = 16;

$app.set-content($structure);

($day-entry, $month-entry).map: { .width-chars = 2 };
$year-entry.width-chars = 4;

$date-view.size-request(300, 120);
$calendar.size-request(300,300);

$app.run;


