-------------------------------------------------------------------
--           RAPID - RAPID ADA PORTABLE INTERFACE DESIGNER         
--           MCC GUI PACKAGE LIBRARY                               
--           GWINDOWS PEER IMPLEMENTATION                               
--           Copyright (C) 2001 Martin C. Carlisle.                
--                                                                 
-- RAPID is free software;  you can  redistribute it  and/or modify
-- it under terms of the  GNU General Public License as published  
-- by the Free Software  Foundation;  either version 2,  or (at your
-- option) any later version.  RAPID 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 General Public License for more details.  
-- You should have  received  a copy of the GNU General Public License
-- distributed with RAPID; see file COPYING.  If not, write to the 
-- Free Software Foundation,  59 Temple Place - Suite 330,  Boston, 
-- MA 02111-1307, USA.                                                 
--                                                                     
-- As a special exception, if other files instantiate generics from
-- this unit, or you link this unit with other files to produce an 
-- executable, this unit does not by itself cause the resulting 
-- executable to be covered by the GNU General Public License.  
-- This exception does not however invalidate any other reasons 
-- why the executable file might be covered by the GNU Public 
-- License.  This exception does not apply to executables which
-- are GUI design tools, or that could act as a replacement
-- for RAPID.
------------------------------------------------------------------------------
with Gwindows.Application;
with Gwindows.Multi_Media;
with Gwindows.Base;
with Peer;
use Peer;
package body Mcc.Gui is

   ----------
   -- Bell --
   ----------

   procedure Bell is
   begin
      Gwindows.Multi_Media.Play_Sound_From_Alias(
         Alias_Name => +(".Default"));
   end Bell;

   -------------
   -- Destroy --
   -------------

   procedure Destroy (Obj : in Object) is
      Ptr : Object_Pointer := Obj'Unrestricted_Access;
   begin
      Gwindows.Base.Close(Gwindows.Base.Base_Window_Type(Obj.My_Peer.all));
      Ptr.My_Peer := null;
   end Destroy;

   ----------------------
   -- Get_Key_Listener --
   ----------------------

   function Get_Key_Listener
     (Obj : in Sized_Object'Class)
      return Key_Listener
   is
   begin
      return Obj.Key_Handler;
   end Get_Key_Listener;

   ------------------------
   -- Get_Mouse_Listener --
   ------------------------

   function Get_Mouse_Listener
     (Obj : in Sized_Object'Class)
      return Mouse_Listener
   is
   begin
      return Obj.Mouse_Handler;
   end Get_Mouse_Listener;

   --------------
   -- Get_Peer --
   --------------

   function Get_Peer (Obj : in Object) return Peer.Peer is
   begin
      return Obj.My_Peer;
   end Get_Peer;

   ---------------------------
   -- Get_Screen_Dimensions --
   ---------------------------

   procedure Get_Screen_Dimensions
     (Width  : out Integer;
      Height : out Integer)
   is
   begin
      Width := Gwindows.Application.Desktop_Width;
      Height:= Gwindows.Application.Desktop_Height;
   end Get_Screen_Dimensions;

   --------------
   -- Get_Size --
   --------------

   procedure Get_Size
     (Obj    : in     Sized_Object;
      Width  :    out Integer;
      Height :    out Integer)
   is
   begin
      Width := Gwindows.Base.Width(
         Gwindows.Base.Base_Window_Type(Obj.My_Peer.all));
      Height := Gwindows.Base.Height(
         Gwindows.Base.Base_Window_Type(Obj.My_Peer.all));
   end Get_Size;

   ----------
   -- Move --
   ----------

   procedure Move
     (Obj : in out Sized_Object;
      X   : in     Integer;
      Y   : in     Integer)
   is
   begin
      Gwindows.Base.Left(
         Gwindows.Base.Base_Window_Type(Obj.My_Peer.all),X);
      Gwindows.Base.Top(
         Gwindows.Base.Base_Window_Type(Obj.My_Peer.all),Y);
   end Move;

   ------------
   -- Resize --
   ------------

   procedure Resize
     (Obj    : in out Sized_Object;
      Width  : in     Integer;
      Height : in     Integer)
   is
   begin
      Gwindows.Base.Size(
         Window => Gwindows.Base.Base_Window_Type(Obj.My_Peer.all),
         Width  => Width,
         Height => Height);
   end Resize;

   --------------------------
   -- Set_Background_Color --
   --------------------------

   procedure Set_Background_Color
     (Obj       : in out Sized_Object;
      New_Color : in     Color)
   is
   begin
      null;
   end Set_Background_Color;

   ----------------
   -- Set_Cursor --
   ----------------

   procedure Set_Cursor
     (Obj    : in Sized_Object;
      Cursor : in Cursor_Type)
   is
   begin
      null;
   end Set_Cursor;

   ----------------------
   -- Set_Key_Listener --
   ----------------------

   procedure Set_Key_Listener
     (Obj      : in Sized_Object_Pointer;
      Listener : in Key_Listener)
   is
   begin
      if Obj.Key_Handler = null then
         null;
      end if;
      Obj.Key_Handler := Listener;
   end Set_Key_Listener;

   ------------------------
   -- Set_Mouse_Listener --
   ------------------------

   procedure Set_Mouse_Listener
     (Obj      : in Sized_Object_Pointer;
      Listener : in Mouse_Listener)
   is
   begin
      if Obj.Mouse_Handler = null then
         null;
      end if;
      Obj.Mouse_Handler := Listener;
   end Set_Mouse_Listener;


end Mcc.Gui;

