#!sdl_chomik

let sdl chomik widgets prefix=value integer 0;
include "sdl_chomik_widgets.sdl_chomik"

<create new image "background_tile.png">;
let my background tile image index = <the created image index>;

<create new image "chomik.png">;
let my chomik image index = <the created image index>;


<<sdl chomik widgets prefix> please create new window widget at 32 and 32 of width 6 and height 6>;
let my window A index = <<sdl chomik widgets prefix> the made widget index>;

<<sdl chomik widgets prefix> please create new window widget at 350 and 32 of width 3 and height 1>;
let my window B index = <<sdl chomik widgets prefix> the made widget index>;

<<sdl chomik widgets prefix> please create new window widget at 400 and 100 of width 3 and height 3>;
let my window C index = <<sdl chomik widgets prefix> the made widget index>;

<<sdl chomik widgets prefix> please create new window widget at 500 and 150 of width 3 and height 2>;
let my window D index = <<sdl chomik widgets prefix> the made widget index>;

#<<sdl chomik widgets prefix> please create new button widget at 100 and 100 of width 3 and height 1 and text "HELLO">;
#let my button X hello index = <<sdl chomik widgets prefix> the made widget index>;

#<<sdl chomik widgets prefix> please create new button widget at 332 and 96 of width 3 and height 1 and text "EXIT">;
#let my button Y exit index = <<sdl chomik widgets prefix> the made widget index>;

#<<sdl chomik widgets prefix> please create new icon widget at 600 and 100 with image <my chomik image index>>;
#let my special icon 1 index = <<sdl chomik widgets prefix> the made widget index>;

#<<sdl chomik widgets prefix> please create new icon widget at 600 and 164 with image <my chomik image index>>;
#let my special icon 2 index = <<sdl chomik widgets prefix> the made widget index>;

<<sdl chomik widgets prefix> please create new icon widget at 0 and 0 with image <<sdl chomik widgets prefix> the widget resize tile image index>>;
let my special icon resize A index = <<sdl chomik widgets prefix> the made widget index>;

<<sdl chomik widgets prefix> please create new icon widget at 0 and 0 with image <<sdl chomik widgets prefix> the widget resize tile image index>>;
let my special icon resize B index = <<sdl chomik widgets prefix> the made widget index>;

<<sdl chomik widgets prefix> please create new text widget at 64 and 132 of width 5 and height 2>;
let my text widget A index = <<sdl chomik widgets prefix> the made widget index>;

<<sdl chomik widgets prefix> please add text line "THIS IS MY FIRST TEXT WIDGET" to the widget <my text widget A index>>;
<<sdl chomik widgets prefix> please add text line "AND HERE IS THE SECOND TEXT LINE" to the widget <my text widget A index>>;



#let <sdl chomik widgets prefix> the widget <my special icon 1 index> is movable = value boolean false;
#let <sdl chomik widgets prefix> the widget <my special icon 1 index> is clickable = value boolean true;

#let <sdl chomik widgets prefix> the widget <my special icon 2 index> is movable = value boolean false;
#let <sdl chomik widgets prefix> the widget <my special icon 2 index> is clickable = value boolean true;

let <sdl chomik widgets prefix> the widget <my text widget A index> is movable = value boolean false;
let <sdl chomik widgets prefix> the widget <my text widget A index> is clickable = value boolean false;

<<sdl chomik widgets prefix> please attach widget <my text widget A index> to <my window A index>>;
#<<sdl chomik widgets prefix> please attach widget <my button X hello index> to <my window A index>>;
#<<sdl chomik widgets prefix> please attach widget <my button Y exit index> to <my window B index>>;
<<sdl chomik widgets prefix> please attach widget <my special icon resize A index> to <my window A index>>;
<<sdl chomik widgets prefix> please attach widget <my special icon resize B index> to <my window B index>>;

<<sdl chomik widgets prefix> please put the widget <my special icon resize A index> at the right down corner of the window <my window A index>>;
<<sdl chomik widgets prefix> please put the widget <my special icon resize B index> at the right down corner of the window <my window B index>>;


#<<sdl chomik widgets prefix> please register on click { <print "hello">; } for the widget index <my button X hello index>>;
#<<sdl chomik widgets prefix> please register on click { <print "exit">; } for the widget index <my button Y exit index>>;
#<<sdl chomik widgets prefix> please register on click { <print "special" (N:range 1..2)>; } for the widget index <my special icon (N:range 1..2) index>>;
<<sdl chomik widgets prefix> please register on click
    {
        <<sdl chomik widgets prefix> please keep the widget <my special icon resize A index> at the right down corner of the window <my window A index> while resizing>;
        <<sdl chomik widgets prefix> please switch to resizing widget <my window A index>>;
    }
    for the widget index <my special icon resize A index>>;

<<sdl chomik widgets prefix> please register on click
    {
        <<sdl chomik widgets prefix> please keep the widget <my special icon resize B index> at the right down corner of the window <my window B index> while resizing>;
        <<sdl chomik widgets prefix> please switch to resizing widget <my window B index>>;
    }
    for the widget index <my special icon resize B index>>;


let on mouse motion = value code
{
    <<sdl chomik widgets prefix> please handle mouse motion on <<sdl chomik widgets prefix> the widget mode>>;
};

let on mouse button left=value code
{
    <<sdl chomik widgets prefix> please handle mouse left click on <<sdl chomik widgets prefix> the widget mode>>;
};

let on key space = value code
{
    <<sdl chomik widgets prefix> please print the widgets display order>;
};

let sdl loop body = value code
{
    <show image <my background tile image index> 0 0>;
    <<sdl chomik widgets prefix> please show all widgets>;
    <show image <my chomik image index> 0 0>;
};

#<print "the amount of widgets" <<sdl chomik widgets prefix> the amount of widgets>>;

<sdl loop>;

