with JEWL.Simple_Windows;
use  JEWL.Simple_Windows;
procedure Pokaz_Obraz is
  F : Frame_Type := Frame(300,300,"Test",'X');
      M : Menu_Type := Menu (F, "Plik");
          O : Menuitem_Type := Menuitem (M, "Otwórz", 'O');
          X : Menuitem_Type := Menuitem (M, "Wyjście", 'X');
      C : Canvas_Type := Canvas (F, (0,0), 0, 0, 'R');
  Otworz : Open_Dialog_Type := Open_Dialog ("Wybierz mape bitowa");
  Obrazek  : Image_Type;
  OdPunktu : Point_Type;
  DoPunktu   : Point_Type;
begin
  Add_Filter (Otworz, "Pliki bmp (*.bmp)", "*.bmp");
  Add_Filter (Otworz, "Wszystkie pliki (*.*)", "*.*");
  Save (C);
  loop
    case Next_Command is
      when 'O' =>
        if Execute (Otworz) then
          Obrazek := Image (Get_Name(Otworz));
          if Valid(Obrazek) then
            Set_Size (F, Width  => Width(Obrazek)  + Frame_Width,
                         Height => Height(Obrazek) + Frame_Height + Menu_Height);
            Show_Message ("Bitmap:" & Integer'Image(Width(Obrazek)) &
                          " x" & Integer'Image(Height(Obrazek)) &
                          " przeciagnij, by zmienic rozmiar");
            Restore(C);
            Draw_Image(C, (0,0), Obrazek);
          else
            Show_Message (Get_Name(Otworz) & " nie jest prawidlowym plikiem bmp");
          end if;
        end if;
      when 'X' =>
        Close(F);
        exit;
      when 'R' =>
        while Mouse_Down(C) loop
          OdPunktu := Start_Point(C);
          if Mouse_Moved(C) then
            DoPunktu := End_Point(C);
            Restore(C);
            Draw_Image (C, OdPunktu, DoPunktu, Obrazek);
          end if;
        end loop;
      when others =>
        null;
    end case;
  end loop;
end Pokaz_Obraz;