1. private package Widgets.Layouts is 
  2.  
  3.     -- Centers the widget with the given size within the parent. 
  4.     type Layout_Center is new Layout with private; 
  5.  
  6.     -- If width or height are 0 then the widget's minimum width or height will 
  7.     -- be used. 
  8.     function Create_Layout_Center( width, height : Natural ) return A_Layout; 
  9.     pragma Postcondition( Create_Layout_Center'Result /= null ); 
  10.  
  11.     ---------------------------------------------------------------------------- 
  12.  
  13.     -- Centers the widget with the given width horizontally within the parent. 
  14.     -- Top and bottom are distances relative to the top and bottom edges of the 
  15.     -- parent. 
  16.     type Layout_CenterH is new Layout with private; 
  17.  
  18.     function Create_Layout_CenterH( width       : Natural; 
  19.                                     top, bottom : Integer ) return A_Layout; 
  20.     pragma Postcondition( Create_Layout_CenterH'Result /= null ); 
  21.  
  22.     ---------------------------------------------------------------------------- 
  23.  
  24.     -- Centers the widget with the given width horizontally within the parent. 
  25.     -- y1 is an absolute value within the parent's content region for the top of 
  26.     -- the widget and y2 is the absolute location of the bottom of the widget. 
  27.     -- If width is zero the widget's minimum width will be used. 
  28.     type Layout_CenterHY is new Layout with private; 
  29.  
  30.     function Create_Layout_CenterHY( width  : Natural; 
  31.                                      y1, y2 : Integer ) return A_Layout; 
  32.     pragma Postcondition( Create_Layout_CenterHY'Result /= null ); 
  33.  
  34.     ---------------------------------------------------------------------------- 
  35.  
  36.     -- Positions the widget using offsets from the parent's edges. 
  37.     type Layout_LTRB is new Layout with private; 
  38.  
  39.     function Create_Layout_LTRB( left, top, right, bottom : Integer ) return A_Layout; 
  40.     pragma Postcondition( Create_Layout_LTRB'Result /= null ); 
  41.  
  42.     ---------------------------------------------------------------------------- 
  43.  
  44.     -- Positions the widget using offsets from the parent's top left and sized 
  45.     -- using the given width and height. Negative values for 'top' or 'left' are 
  46.     -- retreated as relative to the bottom or right, respectively. 
  47.     type Layout_LTWH is new Layout with private; 
  48.  
  49.     function Create_Layout_LTWH( left, top     : Integer; 
  50.                                  width, height : Natural ) return A_Layout; 
  51.     pragma Postcondition( Create_Layout_LTWH'Result /= null ); 
  52.  
  53.     ---------------------------------------------------------------------------- 
  54.  
  55.     -- Positions the widget's using offsets from the parent's top left and sized 
  56.     -- using the given width and height. x and y specify the absolute location 
  57.     -- of the widget's top left corner within the parent's content region. 
  58.     type Layout_XYWH is new Layout with private; 
  59.  
  60.     function Create_Layout_XYWH( x, y          : Integer; 
  61.                                  width, height : Natural ) return A_Layout; 
  62.     pragma Postcondition( Create_Layout_XYWH'Result /= null ); 
  63.  
  64.     ---------------------------------------------------------------------------- 
  65.  
  66.     -- Deletes a layout. 
  67.     procedure Delete( this : in out A_Layout ); 
  68.     pragma Postcondition( this = null ); 
  69.  
  70. private 
  71.  
  72.     type Layout_Center is new Layout with 
  73.         record 
  74.             width, 
  75.             height : Natural := 0; 
  76.         end record; 
  77.     type A_Layout_Center is access all Layout_Center'Class; 
  78.  
  79.     procedure Apply( this : access Layout_Center; widget : not null A_Widget ); 
  80.  
  81.     procedure Construct( this   : access Layout_Center; 
  82.                          width, 
  83.                          height : Natural ); 
  84.  
  85.     ---------------------------------------------------------------------------- 
  86.  
  87.     type Layout_CenterH is new Layout with 
  88.         record 
  89.             width  : Natural := 0; 
  90.             top, 
  91.             bottom : Integer := 0; 
  92.         end record; 
  93.     type A_Layout_CenterH is access all Layout_CenterH'Class; 
  94.  
  95.     procedure Apply( this : access Layout_CenterH; widget : not null A_Widget ); 
  96.  
  97.     procedure Construct( this   : access Layout_CenterH; 
  98.                          width  : Natural; 
  99.                          top, 
  100.                          bottom : Integer ); 
  101.  
  102.     ---------------------------------------------------------------------------- 
  103.  
  104.     type Layout_CenterHY is new Layout with 
  105.         record 
  106.             width  : Natural := 0; 
  107.             y1, y2 : Integer := 0; 
  108.         end record; 
  109.     type A_Layout_CenterHY is access all Layout_CenterHY'Class; 
  110.  
  111.     procedure Apply( this : access Layout_CenterHY; widget : not null A_Widget ); 
  112.  
  113.     procedure Construct( this   : access Layout_CenterHY; 
  114.                          width  : Natural; 
  115.                          y1, y2 : Integer ); 
  116.  
  117.     ---------------------------------------------------------------------------- 
  118.  
  119.     type Layout_LTRB is new Layout with 
  120.         record 
  121.             left, 
  122.             top, 
  123.             right, 
  124.             bottom : Integer := 0; 
  125.         end record; 
  126.     type A_Layout_LTRB is access all Layout_LTRB'Class; 
  127.  
  128.     procedure Apply( this : access Layout_LTRB; widget : not null A_Widget ); 
  129.  
  130.     procedure Construct( this   : access Layout_LTRB; 
  131.                          left, 
  132.                          top, 
  133.                          right, 
  134.                          bottom : Integer ); 
  135.  
  136.     ---------------------------------------------------------------------------- 
  137.  
  138.     type Layout_LTWH is new Layout with 
  139.         record 
  140.             left, 
  141.             top    : Integer := 0; 
  142.             width, 
  143.             height : Natural := 0; 
  144.         end record; 
  145.     type A_Layout_LTWH is access all Layout_LTWH'Class; 
  146.  
  147.     procedure Apply( this : access Layout_LTWH; widget : not null A_Widget ); 
  148.  
  149.     procedure Construct( this   : access Layout_LTWH; 
  150.                          left, 
  151.                          top    : Integer; 
  152.                          width, 
  153.                          height : Natural ); 
  154.  
  155.     ---------------------------------------------------------------------------- 
  156.  
  157.     type Layout_XYWH is new Layout with 
  158.         record 
  159.             x, y   : Integer := 0; 
  160.             width, 
  161.             height : Natural := 0; 
  162.         end record; 
  163.     type A_Layout_XYWH is access all Layout_XYWH'Class; 
  164.  
  165.     procedure Apply( this : access Layout_XYWH; widget : not null A_Widget ); 
  166.  
  167.     procedure Construct( this   : access Layout_XYWH; 
  168.                          x, y   : Integer; 
  169.                          width, 
  170.                          height : Natural ); 
  171.  
  172. end Widgets.Layouts;