1. with Widgets.Menu_Items;                use Widgets.Menu_Items; 
  2.  
  3. package Widgets.Containers.Panels.Popups is 
  4.  
  5.     -- A Popup widget is a menu widget that contains a single column of 
  6.     -- Menu_Items. It allows widgets to register for notifications when the 
  7.     -- widget loses visibility. It's minimum size is calculated from the minimum 
  8.     -- size of its children so its size can be computed automatically. The popup 
  9.     -- widget registers itself as a listener for menu items added to it, and 
  10.     -- hides automatically when a menu item in it is activated. 
  11.     type Popup is new Panel and Menu_Listener with private; 
  12.     type A_Popup is access all Popup'Class; 
  13.  
  14.     -- Creates a new Popup menu within 'view' with id 'id'. If 'title' or 'icon' 
  15.     -- are given a value, the menu will have a title bar like a standard panel, 
  16.     -- displaying the popup menu's title text and/or icon. 'icon' is the 
  17.     -- filename of the icon in the theme's tile library. 
  18.     function Create_Popup( view  : not null access Game_Views.Game_View'Class; 
  19.                            id    : String; 
  20.                            title : String := ""; 
  21.                            icon  : String := "" ) return A_Popup; 
  22.     pragma Precondition( id'Length > 0 ); 
  23.     pragma Postcondition( Create_Popup'Result /= null ); 
  24.  
  25.     -- Appends an item to the menu. Note that a Constraint_Error will be raised 
  26.     -- if 'child' is not a Menu_Item. Otherwise, if 'consume' is True then 
  27.     -- 'child' will be consumed. Regardless of the value of 'consume', 'child' 
  28.     -- will belong to the Popup widget. 
  29.     procedure Add( this    : access Popup; 
  30.                    child   : in out A_Widget; 
  31.                    consume : Boolean := True ); 
  32.     pragma Precondition( child /= null ); 
  33.     pragma Postcondition( consume xor child /= null ); 
  34.  
  35. private 
  36.  
  37.     type Popup is new Panel and Menu_Listener with null record; 
  38.  
  39.     procedure Construct( this  : access Popup; 
  40.                          view  : not null access Game_Views.Game_View'Class; 
  41.                          id    : String; 
  42.                          title : String; 
  43.                          icon  : String ); 
  44.     pragma Precondition( id'Length > 0 ); 
  45.  
  46.     -- Returns the minimum height of the Popup menu, calculated as a sum of the 
  47.     -- heights of the menu's items. If the minimum height of the Popup was 
  48.     -- manually specified, it will override. 
  49.     function Get_Min_Height( this : access Popup ) return Natural; 
  50.  
  51.     -- Returns the minimum width of the Popup menu, calculated as the maximum 
  52.     -- width of the menu's items. If the minimum width of the Popup was 
  53.     -- manually specified, it will override. 
  54.     function Get_Min_Width( this : access Popup ) return Natural; 
  55.  
  56.     -- Hides the widget when a child menu item is activated. 
  57.     procedure Handle_Action( this   : access Popup; 
  58.                              action : A_Menu_Action ); 
  59.  
  60.     -- Packs the Popup menu, automatically adjusting the layout of each item 
  61.     -- to fit in the menu. If the height of the popup menu was specified to be 
  62.     -- larger than the space needed by its children, the empty space will be at 
  63.     -- the bottom. The children will fill the entire width of the menu. 
  64.     procedure Pack( this : access Popup ); 
  65.  
  66. end Widgets.Containers.Panels.Popups;