1. package Widgets.Containers.Panels is 
  2.  
  3.     -- A Panel is a simple container for multiple widgets. It can optionally 
  4.     -- have a border, a background color to display when its children don't fill 
  5.     -- its content area, and a title bar on the top, with an icon and/or text. 
  6.     -- The Panel's title bar is displayed automatically if the Panel has either 
  7.     -- an icon or title text. 
  8.     -- 
  9.     -- Panels are useful for visually grouping objects together so that a group 
  10.     -- of them can be moved or shown/hidden simultaneously by performing the 
  11.     -- operation once on their Panel container. 
  12.     -- 
  13.     -- The Panel class is also extended for more specialized uses as a modal 
  14.     -- dialog and a context-sensitive popup. 
  15.     type Panel is new Container with private; 
  16.     type A_Panel is access all Panel'Class; 
  17.  
  18.     -- Creates a new Panel within 'view' with id 'id'. If either 'title' or 
  19.     -- 'icon' are passed a value, the panel will be displayed with a title bar 
  20.     -- at the top, showing its icon and/or title text using left justification. 
  21.     function Create_Panel( view  : not null access Game_Views.Game_View'Class; 
  22.                            id    : String; 
  23.                            title : String := ""; 
  24.                            icon  : String := "" ) return A_Panel; 
  25.     pragma Precondition( id'Length > 0 ); 
  26.     pragma Postcondition( Create_Panel'Result /= null ); 
  27.  
  28.     -- Returns the panel's title string. 
  29.     function Get_Title( this : access Panel ) return String; 
  30.  
  31.     -- Sets the panel's border style. 
  32.     procedure Set_Border( this : access Panel; border : Border_Type ); 
  33.  
  34.     -- Sets the color to be used for a specific purpose when drawing the panel. 
  35.     procedure Set_Color( this    : access Panel; 
  36.                          purpose : Color_Purpose; 
  37.                          color   : Color_Type ); 
  38.  
  39.     -- Sets the icon to display in the Panel's title bar, by filename. If 'icon' 
  40.     -- is an empty string, the icon will be removed. The display state of the 
  41.     -- panel's title bar will be automatically updated as necessary. 
  42.     procedure Set_Icon( this : access Panel; icon : String ); 
  43.  
  44.     -- Sets the title text to display in the Panel's title bar. If 'icon' is an 
  45.     -- empty string, the icon will be removed. The display state of the panel's 
  46.     -- title bar will be automatically updated as necessary. 
  47.     procedure Set_Title( this : access Panel; title : String ); 
  48.  
  49. private 
  50.  
  51.     type Panel is new Container with 
  52.         record 
  53.             -- constant for the life of the widget 
  54.             titlePadding : Natural := 4; 
  55.  
  56.             title        : Unbounded_String;  -- optional title text 
  57.             icon         : Natural := 0;      -- optional icon's tile id 
  58.  
  59.             -- top of the children content area in pixels from the real top 
  60.             contentTop   : Integer := 0; 
  61.         end record; 
  62.  
  63.     procedure Construct( this  : access Panel; 
  64.                          view  : not null access Game_Views.Game_View'Class; 
  65.                          id    : String; 
  66.                          title : String; 
  67.                          icon  : String ); 
  68.     pragma Precondition( id'Length > 0 ); 
  69.  
  70.     -- Draws the Panel's background color, and its border and title bar, if has 
  71.     -- either. 
  72.     procedure Draw_Content( this : access Panel; dc : Drawing_Context ); 
  73.  
  74.     -- Returns the set minimum height, or computed minimum height, without 
  75.     -- accounting for child widgets. 
  76.     function Get_Min_Height( this : access Panel ) return Natural; 
  77.  
  78.     -- Returns the set minimum width, or computed minimum width, without 
  79.     -- accounting for child widgets. 
  80.     function Get_Min_Width( this : access Panel ) return Natural; 
  81.  
  82. end Widgets.Containers.Panels;