1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. package Widgets.Menu_Items.Menu_Checkboxes is 
  10.  
  11.     -- Extends Menu_Item, implementing a toggle-able menu item. Menu checkboxes 
  12.     -- display a checkbox to the left of their label and toggle their state 
  13.     -- when clicked. 'Selected' actions will fire when the checkbox becomes 
  14.     -- checked, and 'Unselected' actions will fire when the checkbox becomes 
  15.     -- unchecked. 
  16.     type Menu_Checkbox is new Menu_Item with private; 
  17.     type A_Menu_Checkbox is access all Menu_Checkbox'Class; 
  18.  
  19.     -- Creates a new menu checkbox widget within 'view' with id 'id'. 'text' is 
  20.     -- the item's display text. 'checked' is the initial state of the checkbox. 
  21.     function Create_Menu_Checkbox( view    : not null access Game_Views.Game_View'Class; 
  22.                                    id      : String; 
  23.                                    text    : String := ""; 
  24.                                    checked : Boolean := False 
  25.                                  ) return A_Menu_Checkbox; 
  26.     pragma Precondition( id'Length > 0 ); 
  27.     pragma Postcondition( Create_Menu_Checkbox'Result /= null ); 
  28.  
  29. private 
  30.  
  31.     type Menu_Checkbox is new Menu_Item with 
  32.         record 
  33.             checked : Boolean := False;    -- stated of the checkbox 
  34.         end record; 
  35.  
  36.     procedure Construct( this    : access Menu_Checkbox; 
  37.                          view    : not null access Game_Views.Game_View'Class; 
  38.                          id      : String; 
  39.                          text    : String; 
  40.                          checked : Boolean ); 
  41.     pragma Precondition( id'Length > 0 ); 
  42.  
  43.     procedure Draw_Content( this : access Menu_Checkbox ); 
  44.  
  45.     procedure On_Mouse_Release( this : access Menu_Checkbox; 
  46.                                 evt  : not null A_Mouse_Button_Event ); 
  47.  
  48. end Widgets.Menu_Items.Menu_Checkboxes;