image.anubis 1.6 KB

   
   
                             The Anubis/Paradize Project.
   
                                   The image widget. 
   
                          Copyright (c) Alain Prouté 2004-2005. 

   
   Authors:   Alain Prouté
              Olivier Duvernois

   
   
   In this file the 'image' widget is  defined. The image widget is created either from an
   'HostImage', or from the path of a JPEG  file. If the JPEG file is not found an 'alert'
   is generated.
   

 read widgets3/widget.anubis 
read widget.anubis   
        
public define Widget
   create_image
     (
       HostImage i
     ). 
   
public define Widget
   create_image
     (
       String path_to_JPEG_file
     ). 
   
   
   
   --- That's all for the public part ! --------------------------------------------------
   
   
   
   
public define Widget
   create_image
     (
       HostImage im
     ) = 
   if size(im) is (w,h) then 
   create_widget
     (
       (WidgetPositionToolBox ptb) |-> unique,
       (One u) |-> (w,h), 
       (WidgetDrawToolBox dtb) |-> draw(dtb)(im,position(0,0)), 
       (One u) |-> create_image(im), 
       (Int32 w1, Int32 h1) |-> unique, 
       (WidgetEventToolBox etb, WidgetNormalEvent e) |-> not_handled([]),
       []
     ). 
   
   
public define Widget
   create_image
     (
       String path
     ) =
   if read_image_from_JPEG_file(path) is 
     {
       cannot_open_file then print("Cannot open file "+path+".\n"); alert, 
       decompress_error then print("Error while decompressing "+path+".\n"); alert, 
       ok(jpeg_image) then 
         create_image(to_host_image(jpeg_image,1))
     }.