--------------------------------------------------------------------------------
--                                                                            --
-- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers.               --
--                                                                            --
-- This library is free software; you can redistribute it and/or              --
-- modify it under the terms of the GNU Lesser General Public                 --
-- License as published by the Free Software Foundation; either               --
-- version 2.1 of the License, or (at your option) any later version.         --
--                                                                            --
-- This library is distributed in the hope that it will be useful,            --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of             --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           --
-- Lesser General Public License for more details.                            --
--                                                                            --
-- You should have received a copy of the GNU Lesser General Public           --
-- License along with this library; if not, write to the Free Software        --
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    --
--                                                                            --
--------------------------------------------------------------------------------

-- @brief TaskWindow related types and methods.
-- $Author$
-- $Date$
-- $Revision$

with System.Unsigned_Types;
with Interfaces.C;           use Interfaces.C;

with RASCAL.OS;              use RASCAL.OS;

package RASCAL.TaskWindow is

   --
   -- This message is used to give input data (key presses) to the child task.
   --Larger amounts of data can be sent with the Data Transfer Protocol.
   --Just send a DataSave message, and wait for RamFetch message.
   --
   type Message_TW_Input is
   record
   Header         : Message_Event_Header;
   Size           : Integer;
   Data           : Char_Array(1..208);
   end record;
   pragma Convention (C, Message_TW_Input);

   type Message_TW_Input_Pointer is access Message_TW_Input;

   type AMEL_Message_TW_Input is abstract new
        Message_EventListener(Message_Event_TW_Input) with
   record
   Event : Message_TW_Input_Pointer;
   end record;

   --
   -- This message is sent when the child has produced output data.
   --Acknowledge message, and display data.
   --
   type Message_TW_Output is
   record
   Header         : Message_Event_Header;
   Size           : Integer;
   Data           : Char_Array(1..208);
   end record;
   pragma Convention (C, Message_TW_Output);

   type Message_TW_Output_Pointer is access Message_TW_Output;

   type AMEL_Message_TW_Output is abstract new
        Message_EventListener(Message_Event_TW_Output) with
   record
   Event : Message_TW_Output_Pointer;
   end record;

   --
   -- This message is sent to your task after you've issued a {fcode}*StartTask .... -txt &xxxxxxxx{f} command.
   --This is the first and last time the txt-handle will be used. From now on, the child's task-id will be used instead.
   --
   type Message_TW_Ego is
   record
   Header         : Message_Event_Header;
   Parent_Handle  : Integer;
   end record;
   pragma Convention (C, Message_TW_Ego);

   type Message_TW_Ego_Pointer is access Message_TW_Ego;

   type AMEL_Message_TW_Ego is abstract new
        Message_EventListener(Message_Event_TW_Ego) with
   record
   Event : Message_TW_Ego_Pointer;
   end record;

   --
   -- This message is sent to the parent when the child exits.
   --
   type Message_TW_Morio is
   record
   Header         : Message_Event_Header;
   end record;
   pragma Convention (C, Message_TW_Morio);

   type Message_TW_Morio_Pointer is access Message_TW_Morio;

   type AMEL_Message_TW_Morio is abstract new
        Message_EventListener(Message_Event_TW_Morio) with
   record
   Event : Message_TW_Morio_Pointer;
   end record;

   --
   -- This message is sent by parent to kill the child.
   --
   type Message_TW_Morite is
   record
   Header         : Message_Event_Header;
   end record;
   pragma Convention (C, Message_TW_Morite);

   type Message_TW_Morite_Pointer is access Message_TW_Morite;

   type AMEL_Message_TW_Morite is abstract new
        Message_EventListener(Message_Event_TW_Morite) with
   record
   Event : Message_TW_Morite_Pointer;
   end record;

   --
   -- This message is broadcasted by the Taskwindow module when a {fcode}*TaskWindow{f} command has been executed without proper -task and -txt flags.
   --If receiving task can support taskwindows, it should acknowledge this message, and use {fcode}Wimp_StartTask \<Your Task Handle (hex)\> \<Unique texthandle (hex)\> {f}.
   --Note the extra space after the texthandle.
   --
   type Message_TW_NewTask is
   record
   Header         : Message_Event_Header;
   Command        : Char_Array(1..208);
   end record;
   pragma Convention (C, Message_TW_NewTask);

   type Message_TW_NewTask_Pointer is access Message_TW_NewTask;

   type AMEL_Message_TW_NewTask is abstract new
        Message_EventListener(Message_Event_TW_NewTask) with
   record
   Event : Message_TW_NewTask_Pointer;
   end record;

   --
   -- This message is sent by the parent to suspend the child.
   --
   type Message_TW_Suspend is
   record
   Header         : Message_Event_Header;
   end record;
   pragma Convention (C, Message_TW_Suspend);

   type Message_TW_Suspend_Pointer is access Message_TW_Suspend;

   type AMEL_Message_TW_Suspend is abstract new
        Message_EventListener(Message_Event_TW_Suspend) with
   record
   Event : Message_TW_Suspend_Pointer;
   end record;

   --
   -- This message is sent by the parent to resume a previously suspended child. 
   --
   type Message_TW_Resume is
   record
   Header         : Message_Event_Header;
   end record;
   pragma Convention (C, Message_TW_Resume);

   type Message_TW_Resume_Pointer is access Message_TW_Resume;

   type AMEL_Message_TW_Resume is abstract new
        Message_EventListener(Message_Event_TW_Resume) with
   record
   Event : Message_TW_Resume_Pointer;
   end record;

end RASCAL.TaskWindow;
