File : output_windows.ads


-----------------------------------------------------------------------
--                              Win_IO                               --
--     A simple set of packages for graphical input and output       --
--                                                                   --
--                       Copyright (C) 2001-2010                     --
--                 Universidad de Cantabria, SPAIN                   --
--                                                                   --
-- Author: Michael Gonzalez       mgh@unican.es                      --
--                                                                   --
-- This is free software; you can redistribute it and/or             --
-- modify it under the terms of the GNU General Public               --
-- License as published by the Free Software Foundation; either      --
-- version 2 of the License, or (at your option) any later version.  --
--                                                                   --
-- This software 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 along with this program; if not, write to the             --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      --
-- Boston, MA 02111-1307, USA.                                       --
--                                                                   --
-----------------------------------------------------------------------
--                                                                   --
-- The Output_Windows package provides a simple window with          --
-- Outout capabilities for data of the types Integer, Float, and     --
-- String.                                                           --
-- Several data can be displayed on the same window                  --
--                                                                   --
-- This package requires Gtkada-2.2.0 or later                       --
--                                                                   --
-----------------------------------------------------------------------

with Named_Lists;
with Var_Strings;
with Output_Window_Pkg;
with Gtk.Label; use Gtk.Label;
with Gtk.Gentry; use Gtk.GEntry;
with Windows_Exceptions;

package Output_Windows is

   -----------------------------------------------------------------------
   --
   --                           OUTPUT_WINDOW
   --
   --  An Output_Window is a window that provides the following items:
   --
   --    - A scrollable area on which many output boxes may
   --      be created. Each box has a label and an area that
   --      is used to display a value of type Integer, Float, or String
   --
   --    - An OK button that indicates that the user has finished viewing
   --      the data
   --
   -----------------------------------------------------------------------

   type Output_Window_Type is private;

   -----------------------------------------------------------------------
   --                      OUTPUT_WINDOW Operations
   --
   --  Output_Window (Title)         --  Create the window, with the
   --                                --  specified title
   --
   --  Create_Box    (OW,            --  Create a display box on the OW window
   --                 Label,         --  with this label
   --                 Initial_Value) --  and this value (Integer)
   --                                --  may raise Repeated_Label
   --
   --  Create_Box    (OW,            --  Create a display box on the OW window
   --                 Label,         --  with this label
   --                 Initial_Value) --  and this value (Float)
   --                                --  may raise Repeated_Label
   --
   --  Create_Box    (OW,            --  Create a display box on the OW window
   --                 Label,         --  with this label
   --                 Initial_Value) --  and this initial value (String)
   --                                --  may raise Repeated_Label
   --
   --  Update_Box    (OW,            --  Update the display box on the OW window
   --                 Label,         --  with this label
   --                 Initial_Value) --  using this value (Integer)
   --                                --  may raise Label_Not_Found
   --
   --  Update_Box    (OW,            --  Update the display box on the OW window
   --                 Label,         --  with this label
   --                 Initial_Value) --  using this value (Float)
   --                                --  may raise Label_Not_Found
   --
   --  Update_Box    (OW,            --  Update the display box on the OW window
   --                 Label,         --  with this label
   --                 Initial_Value) --  using this initial value (String)
   --                                --  may raise Label_Not_Found
   --
   --  Draw          (OW)            --  Draws the window, and returns
   --                                --  immediately
   --
   --  Wait          (OW)            --  Draws the window and then
   --                                --  wait for the OK button to be pressed.
   --                                --  This will an indication that the data on
   --                                --  the entry boxes has been viewed
   --                                --  Before returning, it hides the window
   --
   --  Close         (OW)            --  Destroys the window, which now becomes
   --                                --  unavailable
   -----------------------------------------------------------------------

   function Output_Window
     (Title : String)
     return Output_Window_Type;

   procedure Create_Box
     (OW : in out Output_Window_Type;
      Label : String;
      Initial_Value : String);
   -- may raise Repeated_Label
   procedure Create_Box
     (OW : in out Output_Window_Type;
      Label : String;
      Initial_Value : Integer);
   -- may raise Repeated_Label
   procedure Create_Box
     (OW : in out Output_Window_Type;
      Label : String;
      Initial_Value : Float);
   -- may raise Repeated_Label

   procedure Update_Box
     (OW : in out Output_Window_Type;
      Label : String;
      New_Value : String);
   -- may raise Label_Not_Found
   procedure Update_Box
     (OW : in out Output_Window_Type;
      Label : String;
      New_Value : Integer);
   -- may raise Label_Not_Found
   procedure Update_Box
     (OW : in out Output_Window_Type;
      Label : String;
      New_Value : Float);
   -- may raise Label_Not_Found

   procedure Close
     (OW : in out Output_Window_Type);

   procedure Draw
     (OW : in out Output_Window_Type);

   procedure Wait
     (OW : in out Output_Window_Type);

   Label_Not_Found : exception renames Windows_Exceptions.Label_Not_Found;
   Repeated_Label : exception  renames Windows_Exceptions.Repeated_Label;

private

   type Output_Entry is record
      Name, Value : Var_Strings.Var_String;
      Text_Entry : Gtk_Entry;
      Text_Label : Gtk_Label;
   end record;

   function Name (E : Output_Entry ) return Var_Strings.Var_String;

   package Lists is new Named_Lists (Output_Entry,Name);

   type Output_Window_Type is record
      Win : Output_Window_Pkg.Output_Window_Access;
      Entries : Lists.List;
   end record;

end Output_Windows;