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. private with Ada.Real_Time; 
  10.  
  11. package Widgets.Buttons.Pushes.Menu_Buttons is 
  12.  
  13.     -- A Menu_Button for Keen is a button specifically designed to match the 
  14.     -- look and feel of the options in the menus, with an animated glowing dot 
  15.     -- next to the focus menu item. 
  16.     type Menu_Button is new Push_Button and Animated with private; 
  17.     type A_Menu_Button is access all Menu_Button'Class; 
  18.  
  19.     -- Creates a new menu button. 
  20.     function Create_Menu_Button( view : not null access Game_Views.Game_View'Class; 
  21.                                  id   : String; 
  22.                                  text : String := "" ) return A_Button; 
  23.     pragma Precondition( id'Length > 0 ); 
  24.     pragma Postcondition( Create_Menu_Button'Result /= null ); 
  25.  
  26. private 
  27.  
  28.     use Ada.Real_Time; 
  29.  
  30.     type Menu_Button is new Push_Button and Animated with 
  31.         record 
  32.             focusTime : Time_Span;      -- last Tick upTime before getting focus 
  33.         end record; 
  34.  
  35.     procedure Construct( this : access Menu_Button; 
  36.                          view : not null access Game_Views.Game_View'Class; 
  37.                          id   : String; 
  38.                          text : String ); 
  39.     pragma Precondition( id'Length > 0 ); 
  40.  
  41.     procedure On_Blur( this : access Menu_Button ); 
  42.  
  43.     procedure On_Disabled( this : access Menu_Button ); 
  44.  
  45.     procedure On_Enabled( this : access Menu_Button ); 
  46.  
  47.     procedure On_Focus( this : access Menu_Button ); 
  48.  
  49.     procedure On_Key_Press( this    : access Menu_Button; 
  50.                             evt     : not null A_Key_Event; 
  51.                             handled : in out Boolean ); 
  52.  
  53.     procedure Tick( this : access Menu_Button; time : Tick_Time ); 
  54.  
  55. end Widgets.Buttons.Pushes.Menu_Buttons;