1. package Widgets.Labels is 
  2.  
  3.     -- A Label widget is a simple text string with an optional icon to the left 
  4.     -- of the text. A label is intended for displaying static strings and isn't 
  5.     -- editable by the interface user. 
  6.     type Label is new Widget with private; 
  7.     type A_Label is access all Label'Class; 
  8.  
  9.     -- Creates a new Label within 'view' with id 'id'. Both 'text' and 'icon' 
  10.     -- are optional. 'icon' is the name of a frame in the Theme's tile library. 
  11.     -- The icon image can have an alpha channel for transparency. 
  12.     function Create_Label( view : not null access Game_Views.Game_View'Class; 
  13.                            id   : String; 
  14.                            text : String := ""; 
  15.                            icon : String := "" ) return A_Label; 
  16.     pragma Precondition( id'Length > 0 ); 
  17.     pragma Postcondition( Create_Label'Result /= null ); 
  18.  
  19.     -- Returns the label's text. 
  20.     function Get_Text( this : not null access Label'Class ) return String; 
  21.  
  22.     -- Sets the label's text alignment. Both the text and icon will be aligned 
  23.     -- according to 'align'. 
  24.     procedure Set_Align( this : not null access Label'Class; align : Align_Type ); 
  25.  
  26.     -- Sets the color for a particular purpose when drawing the label. To remove 
  27.     -- the color behind the icon text, set the Foreground color to transparent. 
  28.     procedure Set_Color( this    : access Label; 
  29.                          purpose : Color_Purpose; 
  30.                          color   : Color_Type ); 
  31.  
  32.     -- Sets the label's icon. Pass an empty string to remove it. 
  33.     procedure Set_Icon( this : not null access Label'Class; icon : String ); 
  34.  
  35.     -- Sets the label's text. 
  36.     procedure Set_Text( this : not null access Label'Class; text : String ); 
  37.  
  38. private 
  39.  
  40.     SPACING : constant Integer := 2; 
  41.  
  42.     ---------------------------------------------------------------------------- 
  43.  
  44.     type Label is new Widget with 
  45.         record 
  46.             align    : Align_Type := Align_Left; 
  47.             text     : Unbounded_String; 
  48.             icon     : Natural := 0; 
  49.         end record; 
  50.  
  51.     procedure Construct( this : access Label; 
  52.                          view : not null access Game_Views.Game_View'Class; 
  53.                          id   : String; 
  54.                          text : String; 
  55.                          icon : String ); 
  56.  
  57.     procedure Draw_Content( this : access Label; dc : Drawing_Context ); 
  58.  
  59.     -- Returns the label's minimum height. 
  60.     function Get_Min_Height( this : access Label ) return Natural; 
  61.  
  62.     -- Returns the label's minimum width. 
  63.     function Get_Min_Width( this : access Label ) return Natural; 
  64.  
  65. end Widgets.Labels;