package Widgets.Containers.Panels is
-- A Panel is a simple container for multiple widgets. It can optionally
-- have a border, a background color to display when its children don't fill
-- its content area, and a title bar on the top, with an icon and/or text.
-- The Panel's title bar is displayed automatically if the Panel has either
-- an icon or title text.
--
-- Panels are useful for visually grouping objects together so that a group
-- of them can be moved or shown/hidden simultaneously by performing the
-- operation once on their Panel container.
--
-- The Panel class is also extended for more specialized uses as a modal
-- dialog and a context-sensitive popup.
type Panel is new Container with private;
type A_Panel is access all Panel'Class;
-- Creates a new Panel within 'view' with id 'id'. If either 'title' or
-- 'icon' are passed a value, the panel will be displayed with a title bar
-- at the top, showing its icon and/or title text using left justification.
function Create_Panel( view : not null access Game_Views.Game_View'Class;
id : String;
title : String := "";
icon : String := "" ) return A_Panel;
pragma Precondition( id'Length > 0 );
pragma Postcondition( Create_Panel'Result /= null );
-- Returns the panel's title string.
function Get_Title( this : access Panel ) return String;
-- Sets the panel's border style.
procedure Set_Border( this : access Panel; border : Border_Type );
-- Sets the color to be used for a specific purpose when drawing the panel.
procedure Set_Color( this : access Panel;
purpose : Color_Purpose;
color : Color_Type );
-- Sets the icon to display in the Panel's title bar, by filename. If 'icon'
-- is an empty string, the icon will be removed. The display state of the
-- panel's title bar will be automatically updated as necessary.
procedure Set_Icon( this : access Panel; icon : String );
-- Sets the title text to display in the Panel's title bar. If 'icon' is an
-- empty string, the icon will be removed. The display state of the panel's
-- title bar will be automatically updated as necessary.
procedure Set_Title( this : access Panel; title : String );
private
type Panel is new Container with
record
-- constant for the life of the widget
titlePadding : Natural := 4;
title : Unbounded_String; -- optional title text
icon : Natural := 0; -- optional icon's tile id
-- top of the children content area in pixels from the real top
contentTop : Integer := 0;
end record;
procedure Construct( this : access Panel;
view : not null access Game_Views.Game_View'Class;
id : String;
title : String;
icon : String );
pragma Precondition( id'Length > 0 );
-- Draws the Panel's background color, and its border and title bar, if has
-- either.
procedure Draw_Content( this : access Panel; dc : Drawing_Context );
-- Returns the set minimum height, or computed minimum height, without
-- accounting for child widgets.
function Get_Min_Height( this : access Panel ) return Natural;
-- Returns the set minimum width, or computed minimum width, without
-- accounting for child widgets.
function Get_Min_Width( this : access Panel ) return Natural;
end Widgets.Containers.Panels;