private package Widgets.Layouts is
-- Centers the widget with the given size within the parent.
type Layout_Center is new Layout with private;
-- Creates a Layout_Center. If 'width' or 'height' is 0 then the widget's
-- minimum width or height, respectively, will be used.
--
-- width
-- +----------+
-- +----------------------+
-- | |
-- | +----------+ | +
-- | | | | | height
-- | +----------+ | +
-- | |
-- +----------------------+
function Create_Layout_Center( width, height : Natural ) return A_Layout;
pragma Postcondition( Create_Layout_Center'Result /= null );
----------------------------------------------------------------------------
-- Centers the widget with the given width horizontally within the parent.
-- Top and bottom are distances relative to the top and bottom edges of the
-- parent.
--
-- width
-- +---------------+
-- +-----------------------+ + +
-- | | | top | -bottom
-- | | | |
-- | +---------------+ | + | +
-- | | | | | |
-- | +---------------+ | + + |
-- | | | | -top
-- | | | bottom |
-- | | | |
-- +-----------------------+ + +
type Layout_CenterH is new Layout with private;
-- Creates a Layout_CenterH. If 'top' < 0 then the widget's top will be
-- offset from the bottom of its container instead of the top.
-- If 'bottom' < 0 then the widget's bottom will be offset from the top of
-- its container, instead of the the bottom.
function Create_Layout_CenterH( width : Natural;
top, bottom : Integer ) return A_Layout;
pragma Precondition( top >=0 or else bottom >= 0 );
pragma Postcondition( Create_Layout_CenterH'Result /= null );
----------------------------------------------------------------------------
-- Centers the widget with the given width horizontally within the parent,
-- using absolute vertical positioning.
--
-- width
-- +---------------+
-- +-----------------------+ + +
-- | | | y1 |
-- | +---------------+ | + | y2
-- | | | | |
-- | +---------------+ | +
-- | |
-- | |
-- +-----------------------+
type Layout_CenterHY is new Layout with private;
-- Creates a Layout_CenterHY. If 'width' is 0 the widget's minimum width
-- will be used. 'y1' is an absolute value within the parent's content
-- region for the top of the widget and 'y2' is the absolute location of the
-- bottom of the widget. If 'y1' or 'y2' is negative, then part of the
-- widget will lie outside of its container's content region.
function Create_Layout_CenterHY( width : Natural;
y1, y2 : Integer ) return A_Layout;
pragma Precondition( y2 >= y1 );
pragma Postcondition( Create_Layout_CenterHY'Result /= null );
----------------------------------------------------------------------------
-- Positions the widget using offsets from the parent's edges; left, top,
-- right, and bottom.
--
-- -left
-- +----------------+
-- -right
-- +--------------+
-- left right
-- +------+ +--------+
-- +-----------------------+ + +
-- | | | top | -bottom
-- | +-------+ | + | +
-- | | | | | |
-- | +-------+ | + + |
-- | | | bottom | -top
-- | | | |
-- +-----------------------+ + +
type Layout_LTRB is new Layout with private;
-- Creates a Layout_LTRB. 'left', 'top', 'right', and 'bottom' are distances
-- from the container's corresponding edge. If the value is negative, the
-- distance will be relative to the opposite side. For example, if 'top' is
-- negative then the widget's top will be offset from the container's bottom
-- edge.
function Create_Layout_LTRB( left, top, right, bottom : Integer ) return A_Layout;
pragma Precondition( left >= 0 or else right >= 0 );
pragma Precondition( top >= 0 or else bottom >= 0 );
pragma Postcondition( Create_Layout_LTRB'Result /= null );
----------------------------------------------------------------------------
-- Positions the widget using offsets from the parent's top left and sized
-- using the given width and height.
--
-- width
-- left +-------+ -left
-- +------+ +--------+
-- +-----------------------+ +
-- | | | top
-- | +-------+ | + +
-- | | | | | height
-- | +-------+ | + +
-- | | |
-- | | | -top
-- +-----------------------+ +
type Layout_LTWH is new Layout with private;
-- Creates a Layout_LTWH. 'left' and 'top' are offsets from the container's
-- corresponding edge. Negative values for 'top' and 'left' are retreated as
-- relative to the bottom and right, respectively. If 'width' or 'height' is
-- 0 then the widget's minimum width or height, respectively, will be used.
-- For example, a negative value for 'top' indicates the offset of the
-- bottom of the widget from its container's bottom.
function Create_Layout_LTWH( left, top : Integer;
width, height : Natural ) return A_Layout;
pragma Postcondition( Create_Layout_LTWH'Result /= null );
----------------------------------------------------------------------------
-- Positions the widget's top left corner using offsets from the container's
-- top left, and sized using the given width and height. This layout is
-- identical to Layout_LTWH for non-negative offsets.
--
-- width
-- x +-------+
-- +------+
-- +-----------------------+ +
-- | | | y
-- | +-------+ | + +
-- | | | | | height
-- | +-------+ | +
-- | |
-- | |
-- +-----------------------+
type Layout_XYWH is new Layout with private;
-- Creates a Layout_XYWH. 'x' and 'y' are the absolute position of the top
-- left corner of the widget, relative to the top left corner of the
-- container. For negative values of 'x' or 'y', the widget will partially
-- lie outside the content region of its container. If 'width' or 'height'
-- is 0 then the widget's minimum width or height, respectively, will be
-- used.
function Create_Layout_XYWH( x, y : Integer;
width, height : Natural ) return A_Layout;
pragma Postcondition( Create_Layout_XYWH'Result /= null );
----------------------------------------------------------------------------
-- Deletes the Layout.
procedure Delete( this : in out A_Layout );
pragma Postcondition( this = null );
private
type Layout_Center is new Layout with
record
width,
height : Natural := 0;
end record;
type A_Layout_Center is access all Layout_Center'Class;
procedure Apply( this : access Layout_Center; widget : not null A_Widget );
procedure Construct( this : access Layout_Center;
width,
height : Natural );
----------------------------------------------------------------------------
type Layout_CenterH is new Layout with
record
width : Natural := 0;
top,
bottom : Integer := 0;
end record;
type A_Layout_CenterH is access all Layout_CenterH'Class;
procedure Apply( this : access Layout_CenterH; widget : not null A_Widget );
procedure Construct( this : access Layout_CenterH;
width : Natural;
top,
bottom : Integer );
pragma Precondition( top >=0 or else bottom >= 0 );
----------------------------------------------------------------------------
type Layout_CenterHY is new Layout with
record
width : Natural := 0;
y1, y2 : Integer := 0;
end record;
type A_Layout_CenterHY is access all Layout_CenterHY'Class;
procedure Apply( this : access Layout_CenterHY; widget : not null A_Widget );
procedure Construct( this : access Layout_CenterHY;
width : Natural;
y1, y2 : Integer );
----------------------------------------------------------------------------
type Layout_LTRB is new Layout with
record
left,
top,
right,
bottom : Integer := 0;
end record;
type A_Layout_LTRB is access all Layout_LTRB'Class;
procedure Apply( this : access Layout_LTRB; widget : not null A_Widget );
procedure Construct( this : access Layout_LTRB;
left,
top,
right,
bottom : Integer );
pragma Precondition( left >= 0 or else right >= 0 );
pragma Precondition( top >= 0 or else bottom >= 0 );
----------------------------------------------------------------------------
type Layout_LTWH is new Layout with
record
left,
top : Integer := 0;
width,
height : Natural := 0;
end record;
type A_Layout_LTWH is access all Layout_LTWH'Class;
procedure Apply( this : access Layout_LTWH; widget : not null A_Widget );
procedure Construct( this : access Layout_LTWH;
left,
top : Integer;
width,
height : Natural );
----------------------------------------------------------------------------
type Layout_XYWH is new Layout with
record
x, y : Integer := 0;
width,
height : Natural := 0;
end record;
type A_Layout_XYWH is access all Layout_XYWH'Class;
procedure Apply( this : access Layout_XYWH; widget : not null A_Widget );
procedure Construct( this : access Layout_XYWH;
x, y : Integer;
width,
height : Natural );
end Widgets.Layouts;