1. with Associations;                      use Associations; 
  2. pragma Warnings( Off, Associations ); 
  3. with Widgets.Menu_Items;                use Widgets.Menu_Items; 
  4.  
  5. limited with Game_Views; 
  6.  
  7. private with Directions; 
  8. private with Widgets.Containers.Panels.Dialogs; 
  9.  
  10. package Widgets.Sprites.Ked is 
  11.  
  12.     type Ked_Sprite is new Sprite and Menu_Listener and  Visibility_Listener with private; 
  13.     type A_Ked_Sprite is access all Ked_Sprite'Class; 
  14.  
  15.     function Create_Ked_Sprite( view       : not null access Game_Views.Game_View'Class; 
  16.                                 eid        : Entity_Id; 
  17.                                 class      : String; 
  18.                                 x, y       : Float; 
  19.                                 width, 
  20.                                 height     : Natural; 
  21.                                 resizeable : Boolean; 
  22.                                 physical   : Boolean; 
  23.                                 libName    : String; 
  24.                                 frame      : Natural ) return A_Ked_Sprite; 
  25.     pragma Precondition( class'Length > 0 ); 
  26.     pragma Precondition( libName'Length > 0 ); 
  27.     pragma Postcondition( Create_Ked_Sprite'Result /= null ); 
  28.  
  29.     -- Consumes the attributes association. 
  30.     procedure Set_Attributes( this       : access Ked_Sprite; 
  31.                               attributes : in out A_Association ); 
  32.     pragma Precondition( attributes /= null ); 
  33.     pragma Postcondition( attributes = null ); 
  34.  
  35. private 
  36.  
  37.     use Directions; 
  38.     use Widgets.Containers.Panels.Dialogs; 
  39.  
  40.     type Drag_Action is (Drag_None, Drag_Move, Drag_Resize); 
  41.  
  42.     type Ked_Sprite is new Sprite and Menu_Listener and Visibility_Listener with 
  43.         record 
  44.             resizeable  : Boolean := False;    -- user can resize the sprite 
  45.             dragStartX,                        -- coordinates where the mouse is 
  46.             dragStartY  : Integer := -1;       --   attached to drag 
  47.             dragAction  : Drag_Action := Drag_None; 
  48.             resizeDir   : Direction_Type; 
  49.             dragged     : Boolean := False;    -- location has changed by a drag 
  50.             snapCenter  : Boolean := False;    -- snaps the center of the object to the grid 
  51.             popupMenu   : A_Widget := null;    -- right-click popup menu (belongs to this) 
  52.             dialog      : A_Dialog := null;    -- edit attributes dialog (belongs to Window) 
  53.         end record; 
  54.  
  55.     procedure Build_Popup( this : access Ked_Sprite ); 
  56.  
  57.     procedure Construct( this       : access Ked_Sprite; 
  58.                          view       : not null access Game_Views.Game_View'Class; 
  59.                          eid        : Entity_Id; 
  60.                          class      : String; 
  61.                          x, y       : Float; 
  62.                          width, 
  63.                          height     : Natural; 
  64.                          resizeable : Boolean; 
  65.                          physical   : Boolean; 
  66.                          libName    : String; 
  67.                          frame      : Natural ); 
  68.     pragma Precondition( class'Length > 0 ); 
  69.     pragma Precondition( libName'Length > 0 ); 
  70.  
  71.     procedure Delete( this : in out Ked_Sprite ); 
  72.  
  73.     procedure Handle_Action( this   : access Ked_Sprite; 
  74.                              action : A_Menu_Action ); 
  75.  
  76.     procedure Handle_Action( this   : access Ked_Sprite; 
  77.                              action : A_Visibility_Action ); 
  78.  
  79.     procedure Handle_Focus( this : access Ked_Sprite ); 
  80.  
  81.     function Handle_Key_Held( this : access Ked_Sprite; 
  82.                               evt  : not null A_Key_Event ) return Boolean; 
  83.  
  84.     function Handle_Key_Press( this : access Ked_Sprite; 
  85.                                evt  : not null A_Key_Event ) return Boolean; 
  86.  
  87.     function Handle_Key_Release( this : access Ked_Sprite; 
  88.                                  evt  : not null A_Key_Event ) return Boolean; 
  89.  
  90.     procedure Handle_Mouse_Move( this : access Ked_Sprite; 
  91.                                  evt  : not null A_Mouse_Event ); 
  92.  
  93.     procedure Handle_Mouse_Press( this : access Ked_Sprite; 
  94.                                   evt  : not null A_Mouse_Button_Event ); 
  95.  
  96.     procedure Handle_Mouse_Release( this : access Ked_Sprite; 
  97.                                     evt  : not null A_Mouse_Button_Event ); 
  98.  
  99.     procedure Resize( this : access Ked_Sprite; 
  100.                       dir  : Direction_Type; 
  101.                       xAmt, 
  102.                       yAmt : Integer ); 
  103.  
  104. end Widgets.Sprites.Ked;