background.anubis 1.38 KB

                                  The Anubis Project. 
   
                              A Widget System (4th version). 
                                 The 'background' widget.
   
                             Copyright (c) Alain Proute' 2005. 
   
   
   Authors: Alain Proute'

   
read widget.anubis   
   
public define Widget   
   background
     (
       Word32    margin,
       RGB      color,
       Widget   content
     ).
   
   --- That's all for the public part ! --------------------------------------------------
   
public define Widget
   background
     (
       Word32    margin,
       RGB      color,
       Widget   content
     ) =
   with margin2 = margin*2, 
   create_widget
     (
       /* getting the stretching capabilities */
       (One u) |-> if size(content) is (w,h) then stretch_cap(w,h,w,h), 
   
       /* stretching the background widget */
       (Word32 w, Word32 h) |-> unique, 
   
       /* getting the size */
       (One u) |-> if size(content) is (cw,ch) then (cw+margin2,ch+margin2),
   
       (WidgetDrawToolBox dtb) |-> 
          if size(content) is (cw,ch) then 
          draw(dtb)(rect(0,0,cw+margin2,ch+margin2),color);
          draw(dtb)(content,margin,margin), 
   
       (WidgetEventToolBox etb, WidgetEvent e) |-> 
          transmit(etb)(content,margin,margin,e),
   
       (One u) |-> registrations(content)(unique)
     ).