This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ada/8088: Internal error in GCC 3.2 ada compiler


>Number:         8088
>Category:       ada
>Synopsis:       Internal error in GCC 3.2 ada compiler
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 29 08:46:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jon Ashley
>Release:        3.2
>Organization:
>Environment:
System: Linux zelatrix 2.4.18-pre7-ac2 #4 Sun May 12 11:15:55 BST 2002 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.2/configure --prefix=/home/ash/gcc-3-ada/local --enable-languages=c,ada
>Description:
gcc -c -I../ -O2 -gnatn -gnatwuwl -fPIC -I- ../gtk-extra-plot_data.adb
+===========================GNAT BUG DETECTED==============================+
| 3.2 20020814 (release) (i686-pc-linux-gnu) GCC error:                    |
| Internal compiler error in assign_stack_temp_for_type, at                |
|    function.c:674                                                        |
| Error detected at
/home/ash/gcc-3-ada/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/adainclude/s-secsta.ads:66:14|
| Please submit a bug report, see http://gcc.gnu.org/bugs.html.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact gcc or gnatmake command that you entered.              |
| Also include sources listed below in gnatchop format                     |
| (concatenated together with no headers between files).                   |
+==========================================================================+
>How-To-Repeat:
	I got this trying to build GtkAda-1.2.12. The files requested in this error message are below (after the "Fix:" line). Can repeat using both glibc-2.2.4 and 2.2.5.
>Fix:
	Program can be built fine using the gnat-3.14p-i686-pc-linux-gnu-bin.tar.gz prepackaged binary (which I used to bootstrap the build of the Ada compiler).

-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--                     Copyright (C) 2000                            --
--        Emmanuel Briot, Joel Brobecker and Arnaud Charlet          --
--                                                                   --
-- This library 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 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 --
-- General Public License for more details.                          --
--                                                                   --
-- You should have received a copy of the GNU 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.                                       --
--                                                                   --
-- 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.     --
-----------------------------------------------------------------------

with Glib;         use Glib;
with Gtk.Widget;   use Gtk.Widget;
with Gtkada.Types; use Gtkada.Types;
with Gdk.Color;    use Gdk.Color;
with Interfaces.C; use Interfaces.C;

package body Gtk.Extra.Plot_Data is

   -------------
   -- Gtk_New --
   -------------

   procedure Gtk_New
     (Data : out Gtk_Plot_Data; Func : Plot_Function := null) is
   begin
      Data := new Gtk_Plot_Data_Record;
      Initialize (Data, Func);
   end Gtk_New;

   ----------------
   -- Initialize --
   ----------------

   procedure Initialize
     (Data : access Gtk_Plot_Data_Record'Class; Func : Plot_Function := null)
   is
      function Internal return System.Address;
      pragma Import (C, Internal, "gtk_plot_data_new");

      function Internal2 (Func : Plot_Function) return System.Address;
      pragma Import (C, Internal2, "gtk_plot_data_new_function");
   begin
      if Func = null then
         Set_Object (Data, Internal);
      else
         Set_Object (Data, Internal2 (Func));
      end if;
      Initialize_User_Data (Data);
   end Initialize;

   --------------
   -- Set_Name --
   --------------

   procedure Set_Name (Data : access Gtk_Plot_Data_Record; Name : String) is
      procedure Internal (Data : System.Address; Name : in String);
      pragma Import (C, Internal, "gtk_plot_data_set_name");
   begin
      Internal (Get_Object (Data), Name & ASCII.NUL);
   end Set_Name;

   -----------
   -- Paint --
   -----------

   procedure Paint (Data : access Gtk_Plot_Data_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_paint");
   begin
      Internal (Get_Object (Data));
   end Paint;

   -----------------
   -- Draw_Points --
   -----------------

   procedure Draw_Points (Data : access Gtk_Plot_Data_Record; N : Gint) is
      procedure Internal (Data : System.Address; N : Gint);
      pragma Import (C, Internal, "gtk_plot_data_draw_points");
   begin
      Internal (Get_Object (Data), N);
   end Draw_Points;

   -----------------
   -- Draw_Symbol --
   -----------------

   procedure Draw_Symbol
     (Data : access Gtk_Plot_Data_Record; X, Y : Gdouble)
   is
      procedure Internal (Data : System.Address; X, Y : Gdouble);
      pragma Import (C, Internal, "gtk_plot_data_draw_symbol");
   begin
      Internal (Get_Object (Data), X, Y);
   end Draw_Symbol;

   ----------------
   -- Set_Points --
   ----------------

   procedure Set_Points
     (Data : access Gtk_Plot_Data_Record;
      X    : Gdouble_Array_Access;
      Y    : Gdouble_Array_Access;
      Dx   : Gdouble_Array_Access;
      Dy   : Gdouble_Array_Access)
   is
      procedure Internal (Data       : in System.Address;
                          X          : in System.Address;
                          Y          : in System.Address;
                          Dx         : in System.Address;
                          Dy         : in System.Address;
                          Num_Points : in Gint);
      pragma Import (C, Internal, "gtk_plot_data_set_points");
      Xa, Ya, Dxa, Dya : System.Address := System.Null_Address;
   begin
      if X /= null then
         Xa := X (X'First)'Address;
      end if;

      if Y /= null then
         Ya := Y (Y'First)'Address;
      end if;

      if Dx /= null then
         Dxa := Dx (Dx'First)'Address;
      end if;

      if Dy /= null then
         Dya := Dy (Dy'First)'Address;
      end if;

      Internal (Get_Object (Data), Xa, Ya, Dxa, Dya, X'Length);
   end Set_Points;

   ----------------
   -- Get_Points --
   ----------------

   procedure Get_Points
     (Data : access Gtk_Plot_Data_Record;
      X    : out Points_Array;
      Y    : out Points_Array;
      Dx   : out Points_Array;
      Dy   : out Points_Array)
   is
      procedure Internal (Data       : in System.Address;
                          X          : out System.Address;
                          Y          : out System.Address;
                          Dx         : out System.Address;
                          Dy         : out System.Address;
                          Num_Points : out Gint);
      pragma Import (C, Internal, "gtk_plot_data_get_points");
      Num_Points : Gint;
      X1, Y1, Dx1, Dy1 : System.Address;
   begin
      Internal (Get_Object (Data), X1, Y1, Dx1, Dy1, Num_Points);
      X  := (Points => To_Double_Array (X1),  Num_Points => Num_Points);
      Y  := (Points => To_Double_Array (Y1),  Num_Points => Num_Points);
      Dx := (Points => To_Double_Array (Dx1), Num_Points => Num_Points);
      Dy := (Points => To_Double_Array (Dy1), Num_Points => Num_Points);
   end Get_Points;

   -----------
   -- Set_X --
   -----------

   procedure Set_X
     (Data : access Gtk_Plot_Data_Record; X : Gdouble_Array_Access)
   is
      procedure Internal (Data : System.Address; X : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_x");
   begin
      pragma Assert (Get_Numpoints (Data) = X'Length);
      Internal (Get_Object (Data), X (X'First)'Address);
   end Set_X;

   -----------
   -- Set_Y --
   -----------

   procedure Set_Y
     (Data : access Gtk_Plot_Data_Record; Y : Gdouble_Array_Access)
   is
      procedure Internal (Data : System.Address; Y : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_y");
   begin
      pragma Assert (Get_Numpoints (Data) = Y'Length);
      Internal (Get_Object (Data), Y (Y'First)'Address);
   end Set_Y;

   -----------
   -- Set_Z --
   -----------

   procedure Set_Z
     (Data : access Gtk_Plot_Data_Record; Z : Gdouble_Array_Access)
   is
      procedure Internal (Data : System.Address; Z : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_z");
   begin
      pragma Assert (Get_Numpoints (Data) = Z'Length);
      Internal (Get_Object (Data), Z (Z'First)'Address);
   end Set_Z;

   -----------
   -- Set_A --
   -----------

   procedure Set_A
     (Data : access Gtk_Plot_Data_Record; A : Gdouble_Array_Access)
   is
      procedure Internal (Data : System.Address; A : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_a");
   begin
      pragma Assert (Get_Numpoints (Data) = A'Length);
      Internal (Get_Object (Data), A (A'First)'Address);
   end Set_A;

   ------------
   -- Set_Dx --
   ------------

   procedure Set_Dx
     (Data : access Gtk_Plot_Data_Record; Dx : Gdouble_Array_Access)
   is
      procedure Internal (Data : System.Address; Dx : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_dx");
   begin
      pragma Assert (Get_Numpoints (Data) = Dx'Length);
      Internal (Get_Object (Data), Dx (Dx'First)'Address);
   end Set_Dx;

   ------------
   -- Set_Dy --
   ------------

   procedure Set_Dy
     (Data : access Gtk_Plot_Data_Record; Dy : Gdouble_Array_Access)
   is
      procedure Internal (Data : System.Address; Dy : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_dy");
   begin
      pragma Assert (Get_Numpoints (Data) = Dy'Length);
      Internal (Get_Object (Data), Dy (Dy'First)'Address);
   end Set_Dy;

   ------------
   -- Set_Dz --
   ------------

   procedure Set_Dz
     (Data : access Gtk_Plot_Data_Record; Dz : Gdouble_Array_Access)
   is
      procedure Internal (Data : System.Address; Dz : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_dz");
   begin
      pragma Assert (Get_Numpoints (Data) = Dz'Length);
      Internal (Get_Object (Data), Dz (Dz'First)'Address);
   end Set_Dz;

   ------------
   -- Set_Da --
   ------------

   procedure Set_Da
     (Data : access Gtk_Plot_Data_Record; Da : Gdouble_Array_Access)
   is
      procedure Internal (Data : System.Address; Da : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_da");
   begin
      pragma Assert (Get_Numpoints (Data) = Da'Length);
      Internal (Get_Object (Data), Da (Da'First)'Address);
   end Set_Da;

   -----------
   -- Get_X --
   -----------

   function Get_X (Data : access Gtk_Plot_Data_Record) return Points_Array is
      function Internal (Data : System.Address; Num_Points : System.Address)
         return System.Address;
      pragma Import (C, Internal, "gtk_plot_data_get_x");

      Num_Points : aliased Gint;
      S : System.Address := Internal (Get_Object (Data), Num_Points'Address);
   begin
      return (Points => To_Double_Array (S), Num_Points => Num_Points);
   end Get_X;

   -----------
   -- Get_Y --
   -----------

   function Get_Y (Data : access Gtk_Plot_Data_Record) return Points_Array is
      function Internal (Data : System.Address; Num_Points : System.Address)
         return System.Address;
      pragma Import (C, Internal, "gtk_plot_data_get_y");

      Num_Points : aliased Gint;
      S : System.Address := Internal (Get_Object (Data), Num_Points'Address);
   begin
      return (Points => To_Double_Array (S), Num_Points => Num_Points);
   end Get_Y;

   -----------
   -- Get_Z --
   -----------

   function Get_Z (Data : access Gtk_Plot_Data_Record) return Points_Array is
      function Internal (Data : System.Address; Num_Points : System.Address)
         return System.Address;
      pragma Import (C, Internal, "gtk_plot_data_get_z");

      Num_Points : aliased Gint;
      S : System.Address := Internal (Get_Object (Data), Num_Points'Address);
   begin
      return (Points => To_Double_Array (S), Num_Points => Num_Points);
   end Get_Z;

   -----------
   -- Get_A --
   -----------

   function Get_A (Data : access Gtk_Plot_Data_Record) return Points_Array is
      function Internal (Data : System.Address; Num_Points : System.Address)
         return System.Address;
      pragma Import (C, Internal, "gtk_plot_data_get_a");

      Num_Points : aliased Gint;
      S : System.Address := Internal (Get_Object (Data), Num_Points'Address);
   begin
      return (Points => To_Double_Array (S), Num_Points => Num_Points);
   end Get_A;

   ------------
   -- Get_Dx --
   ------------

   function Get_Dx (Data : access Gtk_Plot_Data_Record) return Points_Array is
      function Internal (Data : System.Address; Num_Points : System.Address)
         return System.Address;
      pragma Import (C, Internal, "gtk_plot_data_get_dx");

      Num_Points : aliased Gint;
      S : System.Address := Internal (Get_Object (Data), Num_Points'Address);
   begin
      return (Points => To_Double_Array (S), Num_Points => Num_Points);
   end Get_Dx;

   ------------
   -- Get_Dy --
   ------------

   function Get_Dy (Data : access Gtk_Plot_Data_Record) return Points_Array is
      function Internal (Data : System.Address; Num_Points : System.Address)
         return System.Address;
      pragma Import (C, Internal, "gtk_plot_data_get_dy");

      Num_Points : aliased Gint;
      S : System.Address := Internal (Get_Object (Data), Num_Points'Address);
   begin
      return (Points => To_Double_Array (S), Num_Points => Num_Points);
   end Get_Dy;

   ------------
   -- Get_Dz --
   ------------

   function Get_Dz (Data : access Gtk_Plot_Data_Record) return Points_Array is
      function Internal (Data : System.Address; Num_Points : System.Address)
         return System.Address;
      pragma Import (C, Internal, "gtk_plot_data_get_dz");

      Num_Points : aliased Gint;
      S : System.Address := Internal (Get_Object (Data), Num_Points'Address);
   begin
      return (Points => To_Double_Array (S), Num_Points => Num_Points);
   end Get_Dz;

   ------------
   -- Get_Da --
   ------------

   function Get_Da  (Data : access Gtk_Plot_Data_Record) return Points_Array is
      function Internal (Data : System.Address; Num_Points : System.Address)
         return System.Address;
      pragma Import (C, Internal, "gtk_plot_data_get_da");

      Num_Points : aliased Gint;
      S : System.Address := Internal (Get_Object (Data), Num_Points'Address);
   begin
      return (Points => To_Double_Array (S), Num_Points => Num_Points);
   end Get_Da;

   -------------------
   -- Set_Numpoints --
   -------------------

   procedure Set_Numpoints (Data : access Gtk_Plot_Data_Record; Num : Gint) is
      procedure Internal (Data : System.Address; Num : Gint);
      pragma Import (C, Internal, "gtk_plot_data_set_numpoints");
   begin
      Internal (Get_Object (Data), Num);
   end Set_Numpoints;

   -------------------
   -- Get_Numpoints --
   -------------------

   function Get_Numpoints (Data : access Gtk_Plot_Data_Record) return Gint is
      function Internal (Data : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_plot_data_get_numpoints");
   begin
      return Internal (Get_Object (Data));
   end Get_Numpoints;

   ----------------
   -- Set_Labels --
   ----------------

   procedure Set_Labels
     (Data : access Gtk_Plot_Data_Record;
      Labels : Gtkada.Types.Chars_Ptr_Array)
   is
      procedure Internal (Data : System.Address; Labels : Chars_Ptr_Array);
      pragma Import (C, Internal, "gtk_plot_data_set_labels");
   begin
      Internal (Get_Object (Data), Labels);
   end Set_Labels;

   ----------------
   -- Get_Labels --
   ----------------

   function Get_Labels (Data : access Gtk_Plot_Data_Record)
      return Gtkada.Types.Chars_Ptr_Array
   is
      type Str_Array is array (Natural) of Chars_Ptr;
      function Internal (Data : System.Address) return Str_Array;
      pragma Import (C, Internal, "gtk_plot_data_get_labels");

      N : constant size_t := size_t (Get_Numpoints (Data));
   begin
      return Chars_Ptr_Array
        (Internal (Get_Object (Data))(0 .. Integer (N) - 1));
   end Get_Labels;

   -----------------
   -- Show_Labels --
   -----------------

   procedure Show_Labels
     (Data : access Gtk_Plot_Data_Record; Show : Boolean)
   is
      procedure Internal (Data : System.Address; Show : Gint);
      pragma Import (C, Internal, "gtk_plot_data_show_labels");
   begin
      Internal (Get_Object (Data), Boolean'Pos (Show));
   end Show_Labels;

   ---------------------------
   -- Labels_Set_Attributes --
   ---------------------------

   procedure Labels_Set_Attributes
     (Data : access Gtk_Plot_Data_Record;
      Font : String;
      Height : Gint;
      Angle  : Gint;
      Foreground : Gdk.Color.Gdk_Color;
      Background : Gdk.Color.Gdk_Color)
   is
      procedure Internal
        (Data : System.Address;
         Font : String;
         Height, Angle : Gint;
         Foreground, Background : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_labels_set_attributes");

      F : aliased Gdk_Color := Foreground;
      B : aliased Gdk_Color := Background;
   begin
      Internal (Get_Object (Data), Font & ASCII.NUL, Height, Angle,
                F'Address, B'Address);
   end Labels_Set_Attributes;

   ----------------
   -- Set_Symbol --
   ----------------

   procedure Set_Symbol
     (Data         : access Gtk_Plot_Data_Record;
      The_Type     : Plot_Symbol_Type;
      Style        : Plot_Symbol_Style;
      Size         : Gint;
      Line_Width   : Gfloat;
      Color        : Gdk.Color.Gdk_Color;
      Border_Color : Gdk.Color.Gdk_Color)
   is
      procedure Internal
        (Data                  : System.Address;
         The_Type, Style, Size : Gint;
         Line_Width            : Gfloat;
         Color, Border_Color   : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_symbol");
      C : aliased Gdk_Color := Color;
      B : aliased Gdk_Color := Border_Color;
   begin
      Internal (Get_Object (Data), Plot_Symbol_Type'Pos (The_Type),
                Plot_Symbol_Style'Pos (Style), Size, Line_Width,
                C'Address, B'Address);
   end Set_Symbol;

   ----------------
   -- Get_Symbol --
   ----------------

   procedure Get_Symbol
     (Data         : access Gtk_Plot_Data_Record;
      The_Type     : out Plot_Symbol_Type;
      Style        : out Plot_Symbol_Style;
      Size         : out Gint;
      Line_Width   : out Gint;
      Color        : out Gdk.Color.Gdk_Color;
      Border_Color : out Gdk.Color.Gdk_Color)
   is
      procedure Internal
        (Data         : System.Address;
         The_Type     : out Plot_Symbol_Type;
         Style        : out Plot_Symbol_Style;
         Size         : out Gint;
         Line_Width   : out Gint;
         Color        : System.Address;
         Border_Color : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_get_symbol");
      C, B : aliased Gdk_Color;
   begin
      Internal (Get_Object (Data), The_Type, Style, Size, Line_Width,
                C'Address, B'Address);
      Color := C;
      Border_Color := B;
   end Get_Symbol;

   -------------------
   -- Set_Connector --
   -------------------

   procedure Set_Connector
     (Data : access Gtk_Plot_Data_Record; Connector : Plot_Connector)
   is
      procedure Internal (Data : System.Address; Connector : Gint);
      pragma Import (C, Internal, "gtk_plot_data_set_connector");
   begin
      Internal (Get_Object (Data), Plot_Connector'Pos (Connector));
   end Set_Connector;

   -------------------
   -- Get_Connector --
   -------------------

   function Get_Connector (Data : access Gtk_Plot_Data_Record)
      return Plot_Connector
   is
      function Internal (Data : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_plot_data_get_connector");
   begin
      return Plot_Connector'Val (Internal (Get_Object (Data)));
   end Get_Connector;

   -------------------------
   -- Set_Line_Attributes --
   -------------------------

   procedure Set_Line_Attributes
     (Data  : access Gtk_Plot_Data_Record;
      Style : Plot_Line_Style;
      Width : Gfloat;
      Color : Gdk.Color.Gdk_Color)
   is
      procedure Internal
        (Data  : System.Address;
         Style : Gint;
         Width : Gfloat;
         Color : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_line_attributes");
      C : aliased Gdk_Color := Color;
   begin
      Internal (Get_Object (Data), Plot_Line_Style'Pos (Style), Width,
                C'Address);
   end Set_Line_Attributes;

   -------------------------
   -- Get_Line_Attributes --
   -------------------------

   procedure Get_Line_Attributes
     (Data  : access Gtk_Plot_Data_Record;
      Style : out Plot_Line_Style;
      Width : out Gfloat;
      Color : out Gdk.Color.Gdk_Color)
   is
      procedure Internal
        (Data  : System.Address;
         Style : out Plot_Line_Style;
         Width : out Gfloat;
         Color : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_get_line_attributes");
      C : aliased Gdk_Color;
   begin
      Internal (Get_Object (Data), Style, Width, C'Address);
      Color := C;
   end Get_Line_Attributes;

   ----------------------
   -- Set_X_Attributes --
   ----------------------

   procedure Set_X_Attributes
     (Data  : access Gtk_Plot_Data_Record;
      Style : Plot_Line_Style;
      Width : Gfloat;
      Color : Gdk.Color.Gdk_Color)
   is
      procedure Internal
        (Data  : System.Address;
         Style : Gint;
         Width : Gfloat;
         Color : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_x_attributes");
      C : aliased Gdk_Color := Color;
   begin
      Internal (Get_Object (Data), Plot_Line_Style'Pos (Style), Width,
                C'Address);
   end Set_X_Attributes;

   ----------------------
   -- Set_Y_Attributes --
   ----------------------

   procedure Set_Y_Attributes
     (Data  : access Gtk_Plot_Data_Record;
      Style : Plot_Line_Style;
      Width : Gfloat;
      Color : Gdk.Color.Gdk_Color)
   is
      procedure Internal
        (Data  : System.Address;
         Style : Gint;
         Width : Gfloat;
         Color : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_y_attributes");
      C : aliased Gdk_Color := Color;
   begin
      Internal (Get_Object (Data), Plot_Line_Style'Pos (Style), Width,
                C'Address);
   end Set_Y_Attributes;

   ----------------------
   -- Set_Z_Attributes --
   ----------------------

   procedure Set_Z_Attributes
     (Data  : access Gtk_Plot_Data_Record;
      Style : Plot_Line_Style;
      Width : Gfloat;
      Color : Gdk.Color.Gdk_Color)
   is
      procedure Internal
        (Data  : System.Address;
         Style : Gint;
         Width : Gfloat;
         Color : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_z_attributes");
      C : aliased Gdk_Color := Color;
   begin
      Internal (Get_Object (Data), Plot_Line_Style'Pos (Style), Width,
                C'Address);
   end Set_Z_Attributes;

   -------------------
   -- Show_Xerrbars --
   -------------------

   procedure Show_Xerrbars (Data : access Gtk_Plot_Data_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_show_xerrbars");
   begin
      Internal (Get_Object (Data));
   end Show_Xerrbars;

   -------------------
   -- Show_Yerrbars --
   -------------------

   procedure Show_Yerrbars (Data : access Gtk_Plot_Data_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_show_yerrbars");
   begin
      Internal (Get_Object (Data));
   end Show_Yerrbars;

   -------------------
   -- Show_Zerrbars --
   -------------------

   procedure Show_Zerrbars (Data : access Gtk_Plot_Data_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_show_zerrbars");
   begin
      Internal (Get_Object (Data));
   end Show_Zerrbars;

   -------------------
   -- Hide_Xerrbars --
   -------------------

   procedure Hide_Xerrbars (Data : access Gtk_Plot_Data_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_hide_xerrbars");
   begin
      Internal (Get_Object (Data));
   end Hide_Xerrbars;

   -------------------
   -- Hide_Yerrbars --
   -------------------

   procedure Hide_Yerrbars (Data : access Gtk_Plot_Data_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_hide_yerrbars");
   begin
      Internal (Get_Object (Data));
   end Hide_Yerrbars;

   -------------------
   -- Hide_Zerrbars --
   -------------------

   procedure Hide_Zerrbars (Data : access Gtk_Plot_Data_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_hide_zerrbars");
   begin
      Internal (Get_Object (Data));
   end Hide_Zerrbars;

   ---------------
   -- Fill_Area --
   ---------------

   procedure Fill_Area (Data : access Gtk_Plot_Data_Record; Fill : Boolean) is
      procedure Internal (Data : System.Address; Fill : Gint);
      pragma Import (C, Internal, "gtk_plot_data_fill_area");
   begin
      Internal (Get_Object (Data), Boolean'Pos (Fill));
   end Fill_Area;

   --------------------
   -- Area_Is_Filled --
   --------------------

   function Area_Is_Filled (Data : access Gtk_Plot_Data_Record)
      return Boolean
   is
      function Internal (Data : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_plot_data_area_is_filled");
   begin
      return Boolean'Val (Internal (Get_Object (Data)));
   end Area_Is_Filled;

   ----------------
   -- Set_Legend --
   ----------------

   procedure Set_Legend (Data : access Gtk_Plot_Data_Record; Legend : String)
   is
      procedure Internal (Data : System.Address; Legend : String);
      pragma Import (C, Internal, "gtk_plot_data_set_legend");
   begin
      Internal (Get_Object (Data), Legend & ASCII.NUL);
   end Set_Legend;

   -----------------
   -- Show_Legend --
   -----------------

   procedure Show_Legend (Data : access Gtk_Plot_Data_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_show_legend");
   begin
      Internal (Get_Object (Data));
   end Show_Legend;

   -----------------
   -- Hide_Legend --
   -----------------

   procedure Hide_Legend (Data : access Gtk_Plot_Data_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_hide_legend");
   begin
      Internal (Get_Object (Data));
   end Hide_Legend;

   --------------------------
   -- Set_Legend_Precision --
   --------------------------

   procedure Set_Legend_Precision
     (Data : access Gtk_Plot_Data_Record; Precision : Gint)
   is
      procedure Internal (Data : System.Address; Precision : Gint);
      pragma Import (C, Internal, "gtk_plot_data_set_legend_precision");
   begin
      Internal (Get_Object (Data), Precision);
   end Set_Legend_Precision;

   --------------------------
   -- Get_Legend_Precision --
   --------------------------

   function Get_Legend_Precision (Data : access Gtk_Plot_Data_Record)
      return Gint
   is
      function Internal (Data : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_plot_data_get_legend_precision");
   begin
      return Internal (Get_Object (Data));
   end Get_Legend_Precision;

   -----------------------
   -- Set_Gradient_Mask --
   -----------------------

   procedure Set_Gradient_Mask
     (Data : access Gtk_Plot_Data_Record; Mask : Plot_Gradient)
   is
      procedure Internal (Data : System.Address; Mask : Gint);
      pragma Import (C, Internal, "gtk_plot_data_set_gradient_mask");
   begin
      Internal (Get_Object (Data), Plot_Gradient'Pos (Mask));
   end Set_Gradient_Mask;

   -----------------------
   -- Get_Gradient_Mask --
   -----------------------

   function Get_Gradient_Mask (Data : access Gtk_Plot_Data_Record)
      return Plot_Gradient
   is
      function Internal (Data : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_plot_data_get_gradient_mask");
   begin
      return Plot_Gradient'Val (Internal (Get_Object (Data)));
   end Get_Gradient_Mask;

   --------------------------
   -- Gradient_Set_Visible --
   --------------------------

   procedure Gradient_Set_Visible
     (Data : access Gtk_Plot_Data_Record; Visible : Boolean)
   is
      procedure Internal (Data : System.Address; Visible : Gint);
      pragma Import (C, Internal, "gtk_plot_data_gradient_set_visible");
   begin
      Internal (Get_Object (Data), Boolean'Pos (Visible));
   end Gradient_Set_Visible;

   ----------------------
   -- Gradient_Visible --
   ----------------------

   function Gradient_Visible (Data : access Gtk_Plot_Data_Record)
      return Boolean
   is
      function Internal (Data : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_plot_data_gradient_visible");
   begin
      return Boolean'Val (Internal (Get_Object (Data)));
   end Gradient_Visible;

   -------------------------
   -- Set_Gradient_Colors --
   -------------------------

   procedure Set_Gradient_Colors
     (Data : access Gtk_Plot_Data_Record;
      Min, Max : Gdk.Color.Gdk_Color)
   is
      procedure Internal (Data, Min, Max : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_gradient_colors");
      Mi : aliased Gdk_Color := Min;
      Ma : aliased Gdk_Color := Max;
   begin
      Internal (Get_Object (Data), Mi'Address, Ma'Address);
   end Set_Gradient_Colors;

   -------------------------
   -- Get_Gradient_Colors --
   -------------------------

   procedure Get_Gradient_Colors
     (Data : access Gtk_Plot_Data_Record;
      Min, Max : out Gdk.Color.Gdk_Color)
   is
      procedure Internal (Data, Min, Max : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_get_gradient_colors");
      Mi, Ma : aliased Gdk_Color;
   begin
      Internal (Get_Object (Data), Mi'Address, Ma'Address);
      Min := Mi;
      Max := Ma;
   end Get_Gradient_Colors;

   ------------------
   -- Set_Gradient --
   ------------------

   procedure Set_Gradient
     (Data     : access Gtk_Plot_Data_Record;
      Min, Max : Gdouble;
      Nlevels  : Gint)
   is
      procedure Internal (Data : System.Address; Min, Max : Gdouble; N : Gint);
      pragma Import (C, Internal, "gtk_plot_data_set_gradient");
   begin
      Internal (Get_Object (Data), Min, Max, Nlevels);
   end Set_Gradient;

   ------------------
   -- Get_Gradient --
   ------------------

   procedure Get_Gradient
     (Data     : access Gtk_Plot_Data_Record;
      Min, Max : out Gdouble;
      Nlevels  : out Gint)
   is
      procedure Internal (Data : System.Address;
                          Min, Max : out Gdouble;
                          N : out Gint);
      pragma Import (C, Internal, "gtk_plot_data_get_gradient");
   begin
      Internal (Get_Object (Data), Min, Max, Nlevels);
   end Get_Gradient;

   ------------------------
   -- Get_Gradient_Level --
   ------------------------

   procedure Get_Gradient_Level
     (Data  : access Gtk_Plot_Data_Record;
      Level : Gdouble;
      Color : out Gdk.Color.Gdk_Color)
   is
      procedure Internal (Data : System.Address;
                          Level : Gdouble;
                          Color : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_get_gradient_level");
      C : aliased Gdk_Color;
   begin
      Internal (Get_Object (Data), Level, C'Address);
      Color := C;
   end Get_Gradient_Level;

   --------------
   -- Set_Link --
   --------------

   procedure Set_Link
     (Data : access Gtk_Plot_Data_Record;
      Link : System.Address)
   is
      procedure Internal (Data, Link : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_set_link");
   begin
      Internal (Get_Object (Data), Link);
   end Set_Link;

   --------------
   -- Get_Link --
   --------------

   function Get_Link (Data : access Gtk_Plot_Data_Record)
      return System.Address
   is
      function Internal (Data : System.Address) return System.Address;
      pragma Import (C, Internal, "gtk_plot_data_get_link");
   begin
      return Internal (Get_Object (Data));
   end Get_Link;

   -----------------
   -- Remove_Link --
   -----------------

   procedure Remove_Link (Data : access Gtk_Plot_Data_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_data_remove_link");
   begin
      Internal (Get_Object (Data));
   end Remove_Link;
end Gtk.Extra.Plot_Data;
-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--                     Copyright (C) 2000                            --
--        Emmanuel Briot, Joel Brobecker and Arnaud Charlet          --
--                                                                   --
-- This library 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 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 --
-- General Public License for more details.                          --
--                                                                   --
-- You should have received a copy of the GNU 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.                                       --
--                                                                   --
-- 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.     --
-----------------------------------------------------------------------

--  <description>
--  This package defines the root of the plot hierarchy. It defines several
--  display strategies that can be used to show scientific data on the
--  screen (see the children for 3D, polar, bars,...)
--
--  All coordinates are in percent of the total size allocates for the data
--  set (ie the actual position is (x * width, y * height), where (x, y) is
--  the value stored in the data set and (width, height) its allocated screen
--  size.
--  </description>
--  <c_version>gtk+extra 0.99.14<c_version>

with Glib; use Glib;
with Gtk.Widget;
with Gtkada.Types;
with Gdk.Color;
with Unchecked_Conversion;

package Gtk.Extra.Plot_Data is

   type Gtk_Plot_Data_Record is new Gtk.Widget.Gtk_Widget_Record with private;
   type Gtk_Plot_Data is access all Gtk_Plot_Data_Record'Class;
   --  A set of values that can be represented on the screen. There are
   --  several strategies to set the values, either explicitely in your
   --  application, or by having them automatically generated by a function.

   -----------
   -- Types --
   -----------

   type No_Range_Gdouble_Array is array (Natural) of Gdouble;
   --  An array of values.
   --  This is used to represent the data values displayed in the plot.
   --  This array does not have any range information (so that it can be
   --  easily returned from a C function, without requiring an extra
   --  copy of the table). You can not use 'Range on this array.

   type No_Range_Gdouble_Array_Access is access all No_Range_Gdouble_Array;
   --  An access to a flat array.

   type Gdouble_Array_Access is access all Glib.Gdouble_Array;
   --  The reason we use this type in the functions below is because
   --  gtk+-extra does not keep a copy of the arrays, but points to the one
   --  given in argument. Thus, the Ada arrays should not be allocated on the
   --  stack, or at least they should be at library level. Using this 'Access
   --  will force the compiler to do the check for us.

   type Points_Array is record
      Points     : No_Range_Gdouble_Array_Access;
      Num_Points : Gint := 0;
   end record;
   --  The points are indexed from 0 to Num_Points-1.
   --  Note that you can't use 'Range, 'First or 'Last on Points.


   type Plot_Connector is (Connect_None,
                           --  No connection

                           Connect_Straight,
                           --  straight line

                           Connect_Spline,
                           --  spline or Bezier curve

                           Connect_Hv_Step,
                           --  Horizontal then vertical

                           Connect_Vh_Step,
                           --  Vertical then horizontal

                           Connect_Middle_Step
                           --  Split in the middle
                           );
   --  The type of connection between two adjacent points in a graph.

   type Plot_Gradient is new Integer;
   --  Indicate which color components vary along the gradient

   Gradient_H : constant Plot_Gradient; --  Hue
   Gradient_V : constant Plot_Gradient; --  Value
   Gradient_S : constant Plot_Gradient; --  Saturation

   type Plot_Symbol_Type is (Symbol_None,
                             Symbol_Square,
                             Symbol_Circle,
                             Symbol_Up_Triangle,
                             Symbol_Down_Triangle,
                             Symbol_Right_Triangle,
                             Symbol_Left_Triangle,
                             Symbol_Diamond,
                             Symbol_Plus,
                             Symbol_Cross,
                             Symbol_Star,
                             Symbol_Dot,
                             Symbol_Impulse);
   --  Type of symbol used to represent the points in a graph.

   type Plot_Symbol_Style is (Symbol_Empty,
                              Symbol_Filled,
                              Symbol_Opaque);
   --  Style used to draw the points in a graph.

   type Plot_Line_Style is (Line_None,
                            Line_Solid,
                            Line_Dotted,
                            Line_Dashed,
                            Line_Dot_Dash,
                            Line_Dot_Dot_Dash,
                            Line_Dot_Dash_Dash);
   --  Lines used to connect two adjacent points in a graph.

   --------------------
   -- Plot functions --
   --------------------
   --  Plot functions should generate a unique Y value given a parameter.
   --  These can be used for instance to represent exactly mathematical
   --  functions.
   --  Note that due to the C interface, the subprograms in Gtk.Extra.Plot and
   --  in this package expect functions that take a System.Address as a
   --  parameter. However, since it is much more convenient in your application
   --  to get a Gtk_Plot_Record directly, GtkAda includes a generic function
   --  that automatically does the conversion for you (see
   --  Gtk.Plot.Generic_Plot_Function).

   type Plot_Function is access function
     (Plot  : System.Address;
      Set   : Gtk_Plot_Data;
      X     : Gdouble;
      Error : access Gboolean)
     return Gdouble;
   --  Function used for plotting.
   --  It should return the value associated with X in its graph, and set
   --  Error to True if there was an error while calculating the value.

   pragma Convention (C, Plot_Function);

   -------------------------
   -- Creating a Data set --
   -------------------------

   procedure Gtk_New (Data : out Gtk_Plot_Data; Func : Plot_Function := null);
   --  Creates a new data set. Its values can either be generated automatically
   --  from Func, or will have to be set explicitely using the other
   --  subprograms in this package.

   procedure Initialize
     (Data : access Gtk_Plot_Data_Record'Class; Func : Plot_Function := null);
   --  Internal initialization function.
   --  See the section "Creating your own widgets" in the documentation.

   function Get_Type return Gtk.Gtk_Type;
   --  Return the internal value associated with a Gtk_Plot_Data.

   procedure Set_Name (Data : access Gtk_Plot_Data_Record; Name : String);
   --  Set the name used internally for that dataset.
   --  This name does not appear anywhere on the screen, but it is easier to
   --  find the dataset afterward by using this name.

   -------------------
   -- Drawing a set --
   -------------------
   --  Although a set is basically a list of values, it is closely associated
   --  with its representation on the screen (see the children of Gtk_Plot_Data
   --  for various possible representations).
   --  The Gtk.Extra packages are designed so that the drawing can be done
   --  either to the screen (through a Gdk adapter), to a postscript file for
   --  easy printing, or to any other media.

   procedure Paint (Data : access Gtk_Plot_Data_Record);
   --  Emits the "draw_data" signal to request a redrawing of the data set.

   procedure Draw_Points (Data : access Gtk_Plot_Data_Record; N : Gint);
   --  Draw at most N values of the Data set on the screen. If N is greater
   --  than the actual number of values in Data, then they are all displayed.

   procedure Draw_Symbol (Data : access Gtk_Plot_Data_Record; X, Y : Gdouble);
   --  Draw the current symbol (see Set_Symbol) at specific coordinates on
   --  the screen.

   -------------------------
   -- Manipulating values --
   -------------------------

   procedure Set_Points
     (Data : access Gtk_Plot_Data_Record;
      X    : Gdouble_Array_Access;
      Y    : Gdouble_Array_Access;
      Dx   : Gdouble_Array_Access;
      Dy   : Gdouble_Array_Access);
   --  Set some explicit points in the set.
   --  Note that the set must not be associated with a function, or the points
   --  will simply be ignored.
   --  All of the arrays must have the same length, the behavior is undefined
   --  otherwise.
   --  X and Y are the list of coordinates of the points.
   --  Dx and Dy are the list of size (precision) of these points. A bigger
   --  symbol will be displayed for the point whose (Dx, Dy) value is bigger.

   procedure Get_Points
     (Data : access Gtk_Plot_Data_Record;
      X    : out Points_Array;
      Y    : out Points_Array;
      Dx   : out Points_Array;
      Dy   : out Points_Array);
   --  Return the value of the points in the set.
   --  Null-length arrays are returned if the set is associated with a
   --  function, since no explicit point has been set.
   --  See Set_Points for a definition of X, Y, Dx and Dy.

   procedure Set_X
     (Data : access Gtk_Plot_Data_Record; X : Gdouble_Array_Access);
   procedure Set_Y
     (Data : access Gtk_Plot_Data_Record; Y : Gdouble_Array_Access);
   procedure Set_Z
     (Data : access Gtk_Plot_Data_Record; Z : Gdouble_Array_Access);
   procedure Set_A
     (Data : access Gtk_Plot_Data_Record; A : Gdouble_Array_Access);
   --  Set the values for one specific coordinate in the set.
   --  The array must have a length of Get_Numpoints (if GtkAda was
   --  compiled with assertions enabled, an exception will be raised if the
   --  length are different).
   --  No copy of the array is made for efficiency reasons, thus modifying
   --  the array content later on will also modify the plot.
   --
   --  "A" is used to specify the size of the symbols. When plotting boxes in
   --  two dimensions, "Z" is used to specify the size of the box.

   procedure Set_Dx
     (Data : access Gtk_Plot_Data_Record; Dx : Gdouble_Array_Access);
   procedure Set_Dy
     (Data : access Gtk_Plot_Data_Record; Dy : Gdouble_Array_Access);
   procedure Set_Dz
     (Data : access Gtk_Plot_Data_Record; Dz : Gdouble_Array_Access);
   --  Set the precision of the points in the set. A bigger symbol is displayed
   --  for the points whose (Dx, Dy, Dz) is bigger.
   --  The array must have a length of Get_Numpoints (if GtkAda was
   --  compiled with assertions enabled, an exception will be raised if the
   --  length are different).
   --  No copy of the array is made for efficiency reasons, thus modifying
   --  the array content later on will also modify the plot.

   procedure Set_Da
     (Data : access Gtk_Plot_Data_Record; Da : Gdouble_Array_Access);
   --  Specifies the colors to use for the points.
   --  The color of the symbols is detemined using the gradient. the gradient
   --  has (min, max) values, and corresponding colors. The symbol's color is
   --  interpolated between these values using hue/saturation/value depending
   --  on the gradient_mask.

   function Get_X  (Data : access Gtk_Plot_Data_Record) return Points_Array;
   function Get_Y  (Data : access Gtk_Plot_Data_Record) return Points_Array;
   function Get_Z  (Data : access Gtk_Plot_Data_Record) return Points_Array;
   function Get_A  (Data : access Gtk_Plot_Data_Record) return Points_Array;
   function Get_Dx (Data : access Gtk_Plot_Data_Record) return Points_Array;
   function Get_Dy (Data : access Gtk_Plot_Data_Record) return Points_Array;
   function Get_Dz (Data : access Gtk_Plot_Data_Record) return Points_Array;
   function Get_Da (Data : access Gtk_Plot_Data_Record) return Points_Array;
   --  Return the coordinates for the points in the set.
   --  This is a direct access to the underlying C array, thus modifying this
   --  array's contents also modifies the graph.
   --  See the corresponding Set_* functions for a definition of the
   --  coordinates

   procedure Set_Numpoints (Data : access Gtk_Plot_Data_Record; Num : Gint);
   --  Set the number of points that should be expected in the graph.
   --  Note that this does not automatically resize all the internal structure,
   --  it just indicates what size the parameters to Set_X, Set_Y,... should
   --  have.

   function Get_Numpoints (Data : access Gtk_Plot_Data_Record) return Gint;
   --  Return the number of points expected in the graph.

   ------------
   -- Labels --
   ------------
   --  Each point in the data set can be associated with a label that describes
   --  it. This is only relevant for data sets where you explicitely give
   --  values, not when the values are generated by a function.

   procedure Set_Labels
     (Data : access Gtk_Plot_Data_Record;
      Labels : Gtkada.Types.Chars_Ptr_Array);
   --  Set the labels associated which each point in the canvas.
   --  There must be at least Get_Numpoints elements in Labels, or the
   --  behavior is undefined

   function Get_Labels (Data : access Gtk_Plot_Data_Record)
      return Gtkada.Types.Chars_Ptr_Array;
   --  Return the labels associated with the points in the data set.
   --  Note that this returns a *copy* of the actual array, and thus might
   --  be expensive to call.

   procedure Show_Labels (Data : access Gtk_Plot_Data_Record; Show : Boolean);
   --  Indicate whether the labels should be displayed next to each point in
   --  the data set. This has no effect if no labels were specified.

   procedure Labels_Set_Attributes
     (Data : access Gtk_Plot_Data_Record;
      Font : String;
      Height : Gint;
      Angle  : Gint;
      Foreground : Gdk.Color.Gdk_Color;
      Background : Gdk.Color.Gdk_Color);
   --  Set the properties of the labels

   ----------------------------
   -- Symbols and Connectors --
   ----------------------------
   --  Each point that is explicitely set in the data set through the
   --  Set_X, Set_Y,... subprograms is visually associated with a symbol. There
   --  are several representations for the symbols.
   --
   --  All these symbols are then connected by a line, a curve or any other
   --  link. These are called connectors.
   --
   --  Each symbol, in addition to being connected to the next one with a
   --  connector, can also be linked to the axis X=0, Y=0 or Z=0 so that it is
   --  easier to read its coordinates. These are called errbars, and they must
   --  be explicitely shown.

   procedure Set_Symbol
     (Data         : access Gtk_Plot_Data_Record;
      The_Type     : Plot_Symbol_Type;
      Style        : Plot_Symbol_Style;
      Size         : Gint;
      Line_Width   : Gfloat;
      Color        : Gdk.Color.Gdk_Color;
      Border_Color : Gdk.Color.Gdk_Color);
   --  Set the visual aspect of the symbols.

   procedure Get_Symbol
     (Data         : access Gtk_Plot_Data_Record;
      The_Type     : out Plot_Symbol_Type;
      Style        : out Plot_Symbol_Style;
      Size         : out Gint;
      Line_Width   : out Gint;
      Color        : out Gdk.Color.Gdk_Color;
      Border_Color : out Gdk.Color.Gdk_Color);
   --  Return the visual characteristics of the symbols.

   procedure Set_Connector
     (Data : access Gtk_Plot_Data_Record; Connector : Plot_Connector);
   --  Set the style of the connectors.

   function Get_Connector (Data : access Gtk_Plot_Data_Record)
      return Plot_Connector;
   --  Return the connector style used for the data set.

   procedure Set_Line_Attributes
     (Data  : access Gtk_Plot_Data_Record;
      Style : Plot_Line_Style;
      Width : Gfloat;
      Color : Gdk.Color.Gdk_Color);
   --  Set the line style used for the connectors.

   procedure Get_Line_Attributes
     (Data  : access Gtk_Plot_Data_Record;
      Style : out Plot_Line_Style;
      Width : out Gfloat;
      Color : out Gdk.Color.Gdk_Color);
   --  Return the line attributes used for the connectors.

   procedure Set_X_Attributes
     (Data  : access Gtk_Plot_Data_Record;
      Style : Plot_Line_Style;
      Width : Gfloat;
      Color : Gdk.Color.Gdk_Color);
   --  Set the style of the lines used to connect the symbols to the X axis.

   procedure Set_Y_Attributes
     (Data  : access Gtk_Plot_Data_Record;
      Style : Plot_Line_Style;
      Width : Gfloat;
      Color : Gdk.Color.Gdk_Color);
   --  Set the style of the lines used to connect the symbols to the Y axis.

   procedure Set_Z_Attributes
     (Data  : access Gtk_Plot_Data_Record;
      Style : Plot_Line_Style;
      Width : Gfloat;
      Color : Gdk.Color.Gdk_Color);
   --  Set the style of the lines used to connect the symbols to the Z axis.

   procedure Show_Xerrbars (Data : access Gtk_Plot_Data_Record);
   procedure Show_Yerrbars (Data : access Gtk_Plot_Data_Record);
   procedure Show_Zerrbars (Data : access Gtk_Plot_Data_Record);
   --  Indicate that each symbol should be connected to the various axis

   procedure Hide_Xerrbars (Data : access Gtk_Plot_Data_Record);
   procedure Hide_Yerrbars (Data : access Gtk_Plot_Data_Record);
   procedure Hide_Zerrbars (Data : access Gtk_Plot_Data_Record);
   --  Indicate the the symbol should not be connected to the axis.

   procedure Fill_Area (Data : access Gtk_Plot_Data_Record; Fill : Boolean);
   --  Indicate whether the area between two points should be filled or not.

   function Area_Is_Filled (Data : access Gtk_Plot_Data_Record)
      return Boolean;
   --  Indicate whether the area between two points is filled.

   -------------
   -- Legends --
   -------------
   --  In addition to the drawing corresponding to the data set, it is possible
   --  to display a box that contains a legend. This is particulary useful when
   --  multiple data sets are displayed on the same plot.

   procedure Set_Legend (Data : access Gtk_Plot_Data_Record; Legend : String);
   --  Set the string printed in the legend for that data set.
   --  Note that an entry can exist in the legend even if there is no name
   --  associated with the graph.

   procedure Show_Legend (Data : access Gtk_Plot_Data_Record);
   --  An entry will be made in the plot's legend for that dataset.

   procedure Hide_Legend (Data : access Gtk_Plot_Data_Record);
   --  No entry will appear in the plot's legend for that dataset.

   procedure Set_Legend_Precision
     (Data : access Gtk_Plot_Data_Record; Precision : Gint);
   --  Number of digits to display when the legends is associated with values,
   --  as is the case for gradients.

   function Get_Legend_Precision (Data : access Gtk_Plot_Data_Record)
      return Gint;
   --  Return the number of digits used for values in the legend

   ---------------
   -- Gradients --
   ---------------
   --  The symbols displayed in the plot can be assigned specific colors. But
   --  they can also compute their own color by picking it in a gradient,
   --  depending on the value.

   procedure Set_Gradient_Mask
     (Data : access Gtk_Plot_Data_Record; Mask : Plot_Gradient);
   --  Indicates which component of the colors vary along the gradient.

   function Get_Gradient_Mask (Data : access Gtk_Plot_Data_Record)
      return Plot_Gradient;
   --  Return the mask used for the gradient.

   procedure Gradient_Set_Visible
     (Data : access Gtk_Plot_Data_Record; Visible : Boolean);
   --  Indicates whether the gradient should be visible

   function Gradient_Visible (Data : access Gtk_Plot_Data_Record)
      return Boolean;
   --  Return True if the gradient is currently visible

   procedure Set_Gradient_Colors
     (Data : access Gtk_Plot_Data_Record;
      Min, Max : Gdk.Color.Gdk_Color);
   --  Set the colors that define the gradient. The colors will vary from
   --  Min to Max along the components specified in Set_Gradient_Mask.

   procedure Get_Gradient_Colors
     (Data : access Gtk_Plot_Data_Record;
      Min, Max : out Gdk.Color.Gdk_Color);
   --  Return the colors that define the range

   procedure Set_Gradient
     (Data     : access Gtk_Plot_Data_Record;
      Min, Max : Gdouble;
      Nlevels  : Gint);
   --  Define the values associated with the minimal color and the maximal
   --  color. Any value in between will have a color computed in between.
   --  Nlevels is the number of ticks to display in the gradient.

   procedure Get_Gradient
     (Data     : access Gtk_Plot_Data_Record;
      Min, Max : out Gdouble;
      Nlevels  : out Gint);
   --  Return the values associated with the minimal and maximal colors.

   procedure Get_Gradient_Level
     (Data  : access Gtk_Plot_Data_Record;
      Level : Gdouble;
      Color : out Gdk.Color.Gdk_Color);
   --  Return the color associated with a specific level.
   --  The color depends on the parameters to Set_Gradient and
   --  Set_Gradient_Colors.

   ---------------
   -- User Data --
   ---------------
   --  It is possible to associated your own user data with a plot. This is
   --  the mechanism provided by the C version of gtkextra. However, the best
   --  way to do this in Ada is to inherit from Gtk_Plot_Data_Record (or one
   --  of its children), and add your own fields.

   procedure Set_Link
     (Data : access Gtk_Plot_Data_Record;
      Link : System.Address);
   --  Associate some user data with Data.
   --  It is the responsability of the user to do some convert conversion to
   --  System.Address.

   function Get_Link (Data : access Gtk_Plot_Data_Record)
      return System.Address;
   --  Return the user data associated with Data, or Null_Address if there is
   --  none.

   procedure Remove_Link (Data : access Gtk_Plot_Data_Record);
   --  Remove the user data associated with Data.


   --  <doc_ignore>
   function To_Double_Array is new Unchecked_Conversion
     (System.Address, No_Range_Gdouble_Array_Access);
   --  </doc_ignore>

private
   type Gtk_Plot_Data_Record is new Gtk.Widget.Gtk_Widget_Record with
     null record;

   Gradient_H : constant Plot_Gradient := 1;
   Gradient_V : constant Plot_Gradient := 2;
   Gradient_S : constant Plot_Gradient := 4;

   pragma Import (C, Get_Type, "gtk_plot_data_get_type");
end Gtk.Extra.Plot_Data;
-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--                     Copyright (C) 2000                            --
--        Emmanuel Briot, Joel Brobecker and Arnaud Charlet          --
--                                                                   --
-- This library 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 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 --
-- General Public License for more details.                          --
--                                                                   --
-- You should have received a copy of the GNU 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.                                       --
--                                                                   --
-- 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.     --
-----------------------------------------------------------------------

--  <description>
--  This is the top level package of the Gtk.Extra widget hierarchy.
--  </description>

package Gtk.Extra is
end Gtk.Extra;
-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--                     Copyright (C) 1998-2001                       --
--        Emmanuel Briot, Joel Brobecker and Arnaud Charlet          --
--                                                                   --
-- This library 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 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 --
-- General Public License for more details.                          --
--                                                                   --
-- You should have received a copy of the GNU 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.                                       --
--                                                                   --
-- 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.     --
-----------------------------------------------------------------------

--  <description>
--
--  This package provides some basic Gtk+ functionalities such as getting the
--  version number. This is the top level package of the Gtk widget hierarchy.
--  For general GtkAda initializations, @pxref{Package_Gtk.Main}.
--
--  </description>
--  <c_version>1.2.7</c_version>

with Glib;                use Glib;
with Gdk;                 use Gdk;
with System;

package Gtk is

   type Root_Type is tagged private;
   --  The base type of the hierarchy in GtkAda. It basically gives access
   --  to an underlying C object. This is not a controlled type, for efficiency
   --  reasons, and because gtk+ takes care of memory management on its own.

   --  <doc_ignore>
   type Root_Type_Access is access all Root_Type'Class;
   --  </doc_ignore>

   type Gtk_Rc_Style is new Gdk.C_Proxy;
   --  Type used to handle resource styles.
   --  See package Gtk.Rc for more details.

   function Major_Version return Guint;
   --  Return the major version number for Gtk+.
   --  Note that this is not necessarily the same as for GtkAda.
   --  If the version is 1.2.6, returns 1.

   function Minor_Version return Guint;
   --  Return the minor version number for Gtk+.
   --  Note that this is not necessarily the same as for GtkAda.
   --  If the version is 1.2.6, returns 2.

   function Micro_Version return Guint;
   --  Return the micro version number for Gtk+.
   --  Note that this is not necessarily the same as for GtkAda.
   --  If the version is 1.2.6, returns 6.

   type Gtk_Type is new Guint;
   --  This type describes an internal type in Gtk+.
   --  You shouldn't have to use it in your own applications, however it might
   --  be useful sometimes.
   --  Every widget type is associated with a specific value, created
   --  dynamically at run time the first time you instantiate a widget of that
   --  type (thus if you have never used a Gtk_File_Selection, it won't have
   --  any Gtk_Type associated with it).
   --  You can get the exact type value for each type by using the functions
   --  Get_Type provided in all the packages in GtkAda.
   --  You can get the specific value for an existing widget by using the
   --  function Gtk.Object.Get_Type.

   Gtk_Type_Invalid : constant Gtk_Type := 0;
   Gtk_Type_None    : constant Gtk_Type := 1;
   Gtk_Type_Char    : constant Gtk_Type := 2;
   Gtk_Type_Uchar   : constant Gtk_Type := 3;
   Gtk_Type_Bool    : constant Gtk_Type := 4;
   Gtk_Type_Int     : constant Gtk_Type := 5;
   Gtk_Type_Uint    : constant Gtk_Type := 6;
   Gtk_Type_Long    : constant Gtk_Type := 7;
   Gtk_Type_Ulong   : constant Gtk_Type := 8;
   Gtk_Type_Float   : constant Gtk_Type := 9;
   Gtk_Type_Double  : constant Gtk_Type := 10;
   Gtk_Type_String  : constant Gtk_Type := 11;  --  Null terminated string.
   Gtk_Type_Enum    : constant Gtk_Type := 12;
   Gtk_Type_Flags   : constant Gtk_Type := 13;
   Gtk_Type_Boxed   : constant Gtk_Type := 14;
   Gtk_Type_Pointer : constant Gtk_Type := 15;  --  a general pointer type.
   Gtk_Type_Object  : constant Gtk_Type := 21;  --  One of the widgets/objects

   type Gtk_Notebook_Page is new Gdk.C_Proxy;
   --  A page of the notebook.
   --  It can contain a single child, and is also associated with a tab
   --  label used to select that page in the notebook.

   function Gtk_Type_Gdk_Event return Gtk_Type;
   --  Return the type corresponding to a Gdk_Event.
   --  Note that this function must be called after Gtk+ has been initialized.

   function Type_Name (Type_Num : in Gtk_Type) return String;
   --  Return the type name corresponding to a Gtk_Type.
   --  This might be useful in debug messages.

   function Type_From_Name (Name : in String) return Gtk_Type;
   --  Convert a string to the matching type.
   --  Name should be the C widget's name, such as GtkScrollbar or GtkButton,
   --  rather than the Ada name.

   function Is_Created (Object : in Root_Type'Class) return Boolean;
   --  Return True if the associated C object has been created, False if no
   --  C object is associated with Object.
   --  This is not the same as testing whether an access type (for instance
   --  any of the widgets) is "null", since this relates to the underlying
   --  C object.

   ------------------------
   -- Interfacing with C --
   ------------------------
   --  The following functions are made public so that one can easily create
   --  new widgets outside the Gtk package hierarchy.
   --  Only experienced users should make use of these functions.

   function Get_Object (Object : access Root_Type'Class) return System.Address;
   --  Access the underlying C pointer.

   procedure Set_Object
     (Object : access Root_Type'Class;
      Value  : in     System.Address);
   --  Modify the underlying C pointer.

   procedure Initialize_User_Data (Obj : access Root_Type'Class);
   --  Sets a user data field for the C object associated with Obj.
   --  This field will be used so that it is possible, knowing a
   --  C object, to get the full ada object.

   function Get_User_Data
     (Obj  : in System.Address;
      Stub : in Root_Type'Class) return Root_Type_Access;
   --  Get the user data that was set by GtkAda.
   --  If the Data is not set, return a new access type, that points to
   --  a structure with the same tag as Stub.

   function Unchecked_Cast
     (Obj  : access Root_Type'Class;
      Stub : Root_Type'Class) return Root_Type_Access;
   --  Cast Obj in an object of tag Stub'Class.
   --  Return the resulting object and free the memory pointed by Obj.

   function Count_Arguments
     (The_Type : Gtk_Type; Name : in String) return Guint;
   --  Return the number of arguments used in the handlers for the signal.
   --  Note that in the Connect functions, we always test whether the user
   --  has asked for *at most* the number of arguments defined by gtk+ for the
   --  callback. This is because having less argument is authorized (the
   --  extra parameters passed by gtk+ will simply be ignored), whereas having
   --  more arguments is impossible (they would never be set).
   --  Note that we provide this procedure here to avoid circularities.

   function Argument_Type
     (The_Type : Gtk_Type;
      Name     : in String;
      Num      : in Gint) return Gtk_Type;
   --  Return the type of the num-th argument for the handlers of signal name.
   --  If Num is negative, return the type returned by the handlers for this
   --  signal.
   --  Note that we provide this procedure here to avoid circularities.

private

   type Root_Type is tagged record
      Ptr : System.Address := System.Null_Address;
   end record;

   --  <doc_ignore>

   --  Note: the following functions and types should only be used
   --  for internal usage, not in the user's applications.
   --  If you use type inheritance for new widgets, you should not need
   --  these functions.

   GtkAda_String : constant String := "_GtkAda" & ASCII.NUL;
   GtkAda_String_Quark : Glib.GQuark := Glib.Unknown_Quark;
   --  The name for the user data that we set in the objects.
   --  The Quark version is to speed up the string lookup (this is done
   --  only once).

   function Conversion_Function
     (Obj : System.Address; Stub : Root_Type'Class) return Root_Type_Access;
   --  This function has to convert a C object to an Ada object.
   --  It will first try all the registered functions (in
   --  Gtk.Type_Conversion_Hooks) and by default, will create a Stub'Class
   --  object, no matter what the real C type is.
   --  Stub is the expected type.

   --  </doc_ignore>

   pragma Inline (Get_Object);
   pragma Inline (Set_Object);

   pragma Import (C, Major_Version, "ada_gtk_major_version");
   pragma Import (C, Minor_Version, "ada_gtk_minor_version");
   pragma Import (C, Micro_Version, "ada_gtk_micro_version");
   pragma Import (C, Gtk_Type_Gdk_Event, "ada_gtk_type_gdk_event");
end Gtk;
-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--                     Copyright (C) 1998-2000                       --
--        Emmanuel Briot, Joel Brobecker and Arnaud Charlet          --
--                                                                   --
-- This library 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 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 --
-- General Public License for more details.                          --
--                                                                   --
-- You should have received a copy of the GNU 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.                                       --
--                                                                   --
-- 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.     --
-----------------------------------------------------------------------

--  <description>
--
--  This package provides definitions for the basic types used in Glib,
--  Gdk and Gtk.
--
--  </description>

with Ada.Unchecked_Deallocation;
with Ada.Unchecked_Conversion;
with System;
with Interfaces.C;

package Glib is
   pragma Preelaborate;

   package C renames Interfaces.C;
   use type C.int;
   use type C.unsigned;

   -------------------------------------
   -- The basic types defined by glib --
   -------------------------------------

   type Gshort is new C.short;
   type Glong  is new C.long;
   type Gint   is new C.int;
   type Gchar  is new C.char;
   type Gboolean is new Gint;

   type Gushort is new C.unsigned_short;
   type Gulong  is new C.unsigned_long;
   type Guint   is new C.unsigned;
   type Guchar  is new C.unsigned_char;

   type Gfloat  is new C.C_float;
   type Gdouble is new C.double;

   subtype Gint8  is Gint range -(2 ** 7) .. (2 ** 7 - 1);
   subtype Gint16 is Gint range -(2 ** 15) .. (2 ** 15 - 1);
   subtype Gint32 is Gint range -(2 ** 31) .. (2 ** 31 - 1);

   subtype Guint8  is Guint range Guint'First .. (2 ** 8 - 1);
   subtype Guint16 is Guint range Guint'First .. (2 ** 16 - 1);
   subtype Guint32 is Guint range Guint'First .. (2 ** 32 - 1);

   ----------------------
   -- Some Array types --
   ----------------------

   type Gboolean_Array is array (Natural range <>) of Gboolean;
   type Gshort_Array   is array (Natural range <>) of Gshort;
   type Glong_Array    is array (Natural range <>) of Glong;
   type Gint_Array     is array (Natural range <>) of Gint;
   type Guint_Array    is array (Natural range <>) of Guint;
   type Guint32_Array  is array (Natural range <>) of Guint32;
   type Gushort_Array  is array (Natural range <>) of Gushort;
   type Gulong_Array   is array (Natural range <>) of Gulong;
   type Gfloat_Array   is array (Natural range <>) of Gfloat;
   type Guchar_Array   is array (Natural range <>) of Guchar;
   type Gdouble_Array  is array (Natural range <>) of Gdouble;

   type Boolean_Array  is array (Natural range <>) of Boolean;

   type Short_Array    is array (Natural range <>) of C.short;
   type Long_Array     is array (Natural range <>) of C.long;

   -------------------------
   -- Conversion services --
   -------------------------

   function To_Boolean_Array (A : in Gboolean_Array) return Boolean_Array;
   --  Convert a C-style boolean array into an Ada-style array.

   function To_Boolean (Value : in Gboolean) return Boolean;
   --  Convert a C boolean into an Ada boolean.

   function To_Boolean (Value : in Gint) return Boolean;
   --  Convert a C int into an Ada boolean.

   function To_Boolean (Value : in Guint) return Boolean;
   --  Convert a C uint into an Ada boolean.

   function To_Gboolean (Bool : in Boolean) return Gboolean;
   --  Convert an Ada boolean into a C boolean.

   function To_Gint (Bool : in Boolean) return Gint;
   --  Convert an Ada boolean into a C int.

   -----------------------
   -- Some Access types --
   -----------------------

   type Guchar_Array_Access is access Guchar_Array;

   type String_Ptr is access all String;

   --  <doc_ignore>
   procedure Free is new Ada.Unchecked_Deallocation
     (Object => Guchar_Array, Name => Guchar_Array_Access);

   procedure Free is new Ada.Unchecked_Deallocation
     (Object => String, Name => String_Ptr);
   --  </doc_ignore>

   --  <doc_ignore>
   type C_Dummy is limited private;
   --  </doc_ignore>

   type C_Proxy is access C_Dummy;
   --  General proxy for C structures.
   --  This type is used instead of System.Address so that the variables are
   --  automatically initialized to 'null'.
   --  The value pointed to is irrelevant, and in fact should not be accessed.
   --  It has thus been made limited private with no subprogram to access it.
   --  C_Proxy is a public type so that one can compare directly the value
   --  of the variables with 'null'.

   --  <doc_ignore>
   pragma Convention (C, C_Proxy);

   function Convert is new Ada.Unchecked_Conversion (System.Address, C_Proxy);
   function Convert is new Ada.Unchecked_Conversion (C_Proxy, System.Address);
   --  Converts from a System.Address returned by a C function to an
   --  internal C_Proxy.

   --  </doc_ignore>

   ------------
   -- Quarks --
   ------------

   type GQuark is new Guint32;
   --  Represents a string internally in GtkAda. Once you know the
   --  equivalent for a string, you can always use it instead of the string,
   --  which provides a faster access for all the functions that use htables
   --  in GtkAda.
   --  There is a global htable that contains all the quarks defined in
   --  your application and GtkAda itself.

   Unknown_Quark : constant GQuark := 0;

   function Quark_From_String (Id : in String) return GQuark;
   --  Return, or create the quark associated with the string.
   --  Note that if the quark does not already exist, an entry is created for
   --  it in the global htable for quarks.

   function Quark_Try_String (Id : in String) return GQuark;
   --  Return the quark associated with the string, if it exists.
   --  If it does not exist, return Unknown_Quark.

private
   type C_Dummy is null record;
   --  This array can contain anything, since it is never used on the Ada side
   --  anyway.

end Glib;
-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--                     Copyright (C) 1998-2000                       --
--        Emmanuel Briot, Joel Brobecker and Arnaud Charlet          --
--                                                                   --
-- This library 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 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 --
-- General Public License for more details.                          --
--                                                                   --
-- You should have received a copy of the GNU 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.                                       --
--                                                                   --
-- 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.     --
-----------------------------------------------------------------------

--  <description>
--
--  This is the top level package of the Gdk hierarchy.
--  It provides the type definitions used to access underlying C structures.
--
--  </description>

with Glib;

package Gdk is
   pragma Preelaborate;

   subtype C_Proxy is Glib.C_Proxy;
   type Gdk_GC is new C_Proxy;
   type Gdk_Window is new C_Proxy;
   subtype Gdk_Drawable is Gdk_Window;
   subtype Gdk_Pixmap is Gdk_Drawable;
   subtype Gdk_Bitmap is Gdk_Drawable;

end Gdk;
-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--                     Copyright (C) 1998-2000                       --
--        Emmanuel Briot, Joel Brobecker and Arnaud Charlet          --
--                                                                   --
-- This library 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 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 --
-- General Public License for more details.                          --
--                                                                   --
-- You should have received a copy of the GNU 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.                                       --
--                                                                   --
-- 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.     --
-----------------------------------------------------------------------

--  <description>
--
--  This widget is the base of the tree for displayable objects.
--  (A displayable object is one which takes up some amount
--  of screen real estate). It provides a common base and interface
--  which actual widgets must adhere to.
--
--  This package provides some services which might have been more appropriate
--  in some other packages, but could not because of dependency circularities
--  (there are for instance some functions relating to colors and colormaps).
--  We have tried to reference these functions in the other packages as well.
--
--  </description>
--  <c_version>1.2.6</c_version>

with Gdk.Color;
with Gdk.Event;
with Gdk.Bitmap;
with Gdk.Rectangle;
with Gdk.Types;
with Gdk.Visual;
with Gdk.Window;
with Gtk.Accel_Group;
with Gtk.Adjustment;
with Gtk.Enums;
with Gtk.Object;
with Gtk.Style;
with Glib.Glist;
with Glib.GSlist;
with System;
pragma Elaborate_All (Glib.GSlist);

package Gtk.Widget is

   type Gtk_Widget_Record is new Object.Gtk_Object_Record with private;
   type Gtk_Widget is access all Gtk_Widget_Record'Class;

   type Gtk_Requisition is record
      Width  : Gint16;
      Height : Gint16;
   end record;
   --  Gtk_Requisition is the desired amount of screen real-estate a widget
   --  requests to the server. Its real allocated size might be different.
   --  See the section in the GtkAda user guide on how to create new widgets
   --  in Ada, and the examples/base_widget directory for an example on how to
   --  use this.
   pragma Pack (Gtk_Requisition);

   type Gtk_Requisition_Access is access all Gtk_Requisition;
   --  This type is used to create new widgets.

   type Gtk_Allocation is record
      X      : Gint16;
      Y      : Gint16;
      Width  : Guint16;
      Height : Guint16;
   end record;
   --  Gtk_Allocation indicates a size and position a widget was allocated.
   --  See the section in the user guide on how to create new widgets for more
   --  information.
   pragma Pack (Gtk_Allocation);

   type Gtk_Allocation_Access is access all Gtk_Allocation;
   --  This type is used to create new widgets.

   -------------------------
   -- Widgets' life cycle --
   -------------------------

   procedure Initialize_Widget (Widget : access Gtk_Widget_Record'Class);
   --  Internal initialization function.
   --  See the section "Creating your own widgets" in the documentation.

   procedure Destroy_Cb (Widget : access Gtk_Widget_Record'Class);
   --  This function should be used as a callback to destroy a widget.
   --  All it does is call Destroy on its argument, but its profile is
   --  compatible with the handlers found in Gtk.Handlers.

   procedure Unparent (Widget : access Gtk_Widget_Record'Class);
   --  Detach the widget from its parent.
   --  As a side effect, the widget will be erased from the screen.
   --  Note that Widget will be destroyed if its reference count reaches 0.
   --  Thus, if you want to reuse it, you should first Gtk.Object.Ref it,
   --  before calling Unparent.

   procedure Show (Widget : access Gtk_Widget_Record);
   --  Schedule the widget to be displayed on the screen when its parent is
   --  also shown (emits the "show" signal).
   --  If its ancestors are already mapped to the screen, then the widget is
   --  immediately displayed through a call to Map below.

   procedure Show_Now (Widget : access Gtk_Widget_Record);
   --  Show the widget.
   --  If it is an unmapped toplevel widget, wait for it to be mapped. This
   --  creates a recursive main_loop.

   procedure Hide (Widget : access Gtk_Widget_Record);
   --  Hide the widget from the screen (emits the "hide" signal).
   --  If Widget was visible, it is immediately hidden.
   --  If one of its ancestor is later shown on the screen, Widget won't
   --  appear.

   procedure Show_All (Widget : access Gtk_Widget_Record);
   --  Show Widget and all its children recursively.

   procedure Hide_All (Widget : access Gtk_Widget_Record);
   --  Hide Widget and all its children.
   --  Note that if you simply want to delete Widget from the screen, you can
   --  simply call the Hide subprogram on it. This procedure Hide_All should
   --  only be used if you want to unschedule a widget to be displayed later,
   --  not to remove an actual widget from the screen.

   procedure Map (Widget : access Gtk_Widget_Record);
   --  Map a widget to the screen.
   --  A window is created for it on the screen (through a call to Realize) and
   --  Widget is then drawn on the screen (if its ancestors are also mapped).
   --  This function is recursive and will also map all the children of Widget.
   --
   --  It is recommended to use the higher-level Show instead.

   procedure Unmap (Widget : access Gtk_Widget_Record);
   --  Unmap a widget from the screen.
   --  This results in the widget being hidden, but not destroyed. It can be
   --  shown again any time through a call to Map (provided its ancestors are
   --  also mapped).
   --
   --  It is recommended to use the higher-level Hide instead.

   procedure Realize (Widget : access Gtk_Widget_Record);
   --  Create a window for Widget and its ancestors (emit the "realize" signal)
   --  This does not mean that the widget will appear on the screen, but
   --  resources such as colormaps, etc. become available.
   --  Some routines require that the widget is realized before any call.
   --  You must set the Event_Mask before calling this routine if you want to
   --  change it from its default value.

   procedure Unrealize (Widget : access Gtk_Widget_Record);
   --  Hide the widget from the screen and deletes the associated window.
   --  This does not destroy the widget itself, only its server-side
   --  resources.

   generic
      type Widget_Type is new Gtk_Widget_Record with private;
      with procedure Realize_Proc (Widget : access Widget_Type'Class);
   package Realize_Handling is

      procedure Set_Realize (Widget : access Gtk_Widget_Record'Class);
      --  Set the realize handler at the low level.
      --  This is needed to replace the default realize in new widgets.

   end Realize_Handling;

   function Get_Type return Gtk.Gtk_Type;
   --  Return the internal value associated with a Gtk_Widget.

   ----------------------
   -- Drawing a widget --
   ----------------------

   procedure Queue_Draw (Widget : access Gtk_Widget_Record);
   --  Add a drawing request to the event queue for the whole widget.
   --  This is more efficient than calling Draw directly, since GtkAda groups
   --  drawing requests as much as possible to speed up the drawing process.
   --  The actual drawing will take place as soon as GtkAda is not busy
   --  processing other events, but before idle events.

   procedure Queue_Draw_Area
     (Widget : access Gtk_Widget_Record;
      X      : Gint;
      Y      : Gint;
      Width  : Gint;
      Height : Gint);
   --  Add a drawing request to the event queue for part of the widget.
   --  This is more efficient that calling Draw directly (see Queue_Draw).

   procedure Queue_Clear (Widget : access Gtk_Widget_Record);
   --  Add a clear request to the event queue for the whole widget.
   --  This is added to the same list as for Queue_Draw, and thus is coalesced
   --  as much as possible with other drawing requests.

   procedure Queue_Clear_Area
     (Widget : access Gtk_Widget_Record;
      X      : Gint;
      Y      : Gint;
      Width  : Gint;
      Height : Gint);
   --  Add a clear request to the event queue for part of the widget.
   --  This is added to the same list as for Queue_Draw, and thus is coalesced
   --  as much as possible with other drawing requests.

   procedure Queue_Resize (Widget : access Gtk_Widget_Record);
   --  Queue drawing requests after a resizing of the widget.
   --  This clears the widget, and its parent if any, so that everything is
   --  correctly redrawn.
   --  You should not have to call this function directly.

   procedure Draw
     (Widget : access Gtk_Widget_Record;
      Area   : in Gdk.Rectangle.Gdk_Rectangle := Gdk.Rectangle.Full_Area);
   --  Emit a "draw" signal for a specific area of the widget.
   --  The visual aspect might be different whether the widget has the focus
   --  or not.

   procedure Draw_Focus (Widget : access Gtk_Widget_Record);
   --  Emit a "draw_focus" signal for the widget.
   --  The widget will be painted as it appears when it has the focus.

   procedure Draw_Default (Widget : access Gtk_Widget_Record);
   --  Emit a "draw_default" signal for the widget.
   --  The widget will be painted as it appears when it doesn't have the focus.

   -----------------------
   -- Size and position --
   -----------------------

   procedure Size_Request
     (Widget      : access Gtk_Widget_Record;
      Requisition : in out Gtk_Requisition);
   --  Emit a "size_request" event for the widget

   procedure Size_Allocate
     (Widget     : access Gtk_Widget_Record;
      Allocation : in out Gtk_Allocation);
   --  Emit a "size_allocate" event for the widget.
   --  Allocation'size is first constrained to a range between 1x1 and
   --  32767x32767.
   --  A clear and draw request is also queued if required.

   function Get_Child_Requisition
     (Widget : access Gtk_Widget_Record) return Gtk_Requisition;
   --  Return the size requests by the widget.
   --  This is the ideal size for the widget, not necessarily its actual size.
   --  See the user guide's section on how to create new widgets for more
   --  information on the size requisition and allocation.

   procedure Set_UPosition
     (Widget : access Gtk_Widget_Record;
      X, Y   : in Gint);
   --  Modify the position of the widget.
   --  This should be used only for toplevel widgets (windows and dialogs),
   --  since other widgets' positions are handled by their parent.

   procedure Set_USize
     (Widget : access Gtk_Widget_Record;
      Width, Height : in Gint);
   --  Modify the size of the widget.
   --  This sets an absolute size for the widget, no matter what its requested
   --  size would be. For Gtk_Windows, you should consider using
   --  Set_Default_Size instead, which sets a minimal size, but use the
   --  widget's requested size if it is bigger.
   --  If Width or Height is negative, they are ignored, and the widget's
   --  default width is kept.

   function Get_Allocation_Width
     (Widget : access Gtk_Widget_Record) return Guint;
   --  Return the current width of the widget.

   function Get_Allocation_Height
     (Widget : access Gtk_Widget_Record) return Guint;
   --  Return the current height of the widget.

   function Get_Allocation_X (Widget : access Gtk_Widget_Record) return Gint;
   --  Return the current position of the widget, relative to its parent.

   function Get_Allocation_Y (Widget : access Gtk_Widget_Record) return Gint;
   --  Return the current position of the widget, relative to its parent.

   ------------------
   -- Accelerators --
   ------------------

   procedure Add_Accelerator
     (Widget       : access Gtk_Widget_Record;
      Accel_Signal : in String;
      Accel_Group  : in Gtk.Accel_Group.Gtk_Accel_Group;
      Accel_Key    : in Gdk.Types.Gdk_Key_Type;
      Accel_Mods   : in Gdk.Types.Gdk_Modifier_Type;
      Accel_Flags  : in Gtk.Accel_Group.Gtk_Accel_Flags);
   --  Add a new accelerator for the widget.
   --  The signal Accel_Signal will be sent to Widget when the matching
   --  key is pressed and the widget has the focus.

   procedure Remove_Accelerator
     (Widget       : access Gtk_Widget_Record;
      Accel_Group  : in Gtk.Accel_Group.Gtk_Accel_Group;
      Accel_Key    : in Gdk.Types.Gdk_Key_Type;
      Accel_Mods   : in Gdk.Types.Gdk_Modifier_Type);
   --  Remove an accelerator for the widget.

   procedure Remove_Accelerators
     (Widget       : access Gtk_Widget_Record;
      Accel_Signal : in String;
      Visible_Only : in Boolean := True);
   --  Remove all the accelerators for the widget that emits the Accel_Signal
   --  signal when the key is pressed.
   --  Visible_Only is currently unused in the code of gtk+.

   function Accelerator_Signal
     (Widget       : access Gtk_Widget_Record;
      Accel_Group  : in Gtk.Accel_Group.Gtk_Accel_Group;
      Accel_Key    : in Gdk.Types.Gdk_Key_Type;
      Accel_Mods   : in Gdk.Types.Gdk_Modifier_Type) return Guint;
   --  Return the signal id of the signal emitted when Accel_Key is pressed
   --  inside the widget.

   procedure Lock_Accelerators (Widget : access Gtk_Widget_Record);
   --  Lock the accelerators for the widget.
   --  No new accelerator can be added to Widget (the default behavior is
   --  that the user can dynamically create new accelerators, for instance
   --  by pressing a not-yet assigned key on any menu item.
   --  If you call this function on the menu_item, this behavior will not
   --  longer be activated.

   procedure Unlock_Accelerators (Widget : access Gtk_Widget_Record);
   --  Unlock the accelerators for the widget.
   --  It is now possible to add new accelerators to the widget.

   -------------------------
   --  Events and signals --
   -------------------------

   function Event
     (Widget : access Gtk_Widget_Record'Class;
      Event  : Gdk.Event.Gdk_Event) return Gint;
   --  Emit a signal on the widget.
   --  The exact signal depends on the event type (i.e. if the type is
   --  Gdk_Button_Press, then a "button_press" signal is emitted).

   procedure Activate (Widget : access Gtk_Widget_Record);
   --  Emit an activate signal on the widget.
   --  The exact signal emitted depends on the widget type (i.e. for a
   --  Gtk_Button this emits a "clicked" signal, for a Gtk_Editable this emits
   --  the "activate" signal, ...).

   procedure Grab_Focus (Widget : access Gtk_Widget_Record);
   --  Emit the "grab_focus" signal for the widget.
   --  This is sent when the widget gets the focus. Its visual aspect might
   --  change.
   --  The "Can_Focus" flag must have been set first.

   procedure Set_Events
     (Widget : access Gtk_Widget_Record;
      Events : in     Gdk.Types.Gdk_Event_Mask);
   --  Sets the event mask for the widget.
   --  Widget should not have been realized before, or nothing is done.
   --  This is the only way you can explicitly get mouse or keyboards events on
   --  widgets that do not automatically get them, as for instance in a
   --  Gtk_Drawing_Area.

   function Get_Events
     (Widget : access Gtk_Widget_Record) return Gdk.Types.Gdk_Event_Mask;
   --  Get the event mask for the widget.
   --  This indicates the list of events that the widget receives.

   procedure Add_Events
     (Widget : access Gtk_Widget_Record;
      Events : in     Gdk.Types.Gdk_Event_Mask);
   --  Add some events to the current event mask of the widget.

   procedure Set_Extension_Events
     (Widget : access Gtk_Widget_Record;
      Mode   : in     Gdk.Types.Gdk_Extension_Mode);
   --  Set the extension event mask for the widget.
   --  This is used to activate some special input modes for other devices than
   --  keyboard and mouse.

   function Get_Extension_Events
     (Widget : access Gtk_Widget_Record) return Gdk.Types.Gdk_Extension_Mode;
   --  Return the current extension events mask.

   function Default_Motion_Notify_Event
     (Widget : access Gtk_Widget_Record'Class;
      Event  : Gdk.Event.Gdk_Event) return Gint;
   --  Access to the standard default callback for motion events:
   --  This is mainly used for rulers in Gtk.Ruler (See the example in
   --  testgtk, with create_rulers.adb)

   function Has_Default_Motion_Notify_Handler
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Return True if Widget has a default handler for motion_notify events.
   --  Note that the function Default_Motion_Notify_Event should not be called
   --  if this one returns False, since it would create a segmentation fault.

   --------------------------
   -- Colors and colormaps --
   --------------------------

   function Get_Colormap
     (Widget : access Gtk_Widget_Record) return Gdk.Color.Gdk_Colormap;
   --  Return the colormap used for the widget. This will generally be the
   --  same one for all widgets, but might be different if for instance a
   --  Gtk_Drawing_Area needs to display some different colors on a screen
   --  that only has a limited amount of colors.

   function Get_Visual
     (Widget : access Gtk_Widget_Record) return Gdk.Visual.Gdk_Visual;
   --  Get the visual used for the widget.
   --  I.e. the structure that indicates the depth of the widget (number of
   --  bits per pixel), and some information used internally by GtkAda to
   --  handle colors and colormaps.

   procedure Set_Colormap
     (Widget : access Gtk_Widget_Record;
      Cmap : Gdk.Color.Gdk_Colormap);
   --  Modify the colormap of the widget.
   --  The widget must not have been realized.

   procedure Set_Visual
     (Widget : access Gtk_Widget_Record;
      Visual : Gdk.Visual.Gdk_Visual);
   --  Modify the visual of the widget.
   --  The widget must not have been realized.

   procedure Push_Colormap (Cmap : Gdk.Color.Gdk_Colormap);
   --  Modify temporarily the default colormap set for newly created widgets.
   --  You should use this in pair with Pop_Colormap below (Push the new value,
   --  create the widget, and pop the value).

   procedure Pop_Colormap;
   --  See Push_Colormap for more information.

   procedure Push_Visual (Visual : Gdk.Visual.Gdk_Visual);
   --  Modify temporarily the default visual set for newly created widgets.
   --  You should use this in pair with Pop_Colormap below (Push the new value,
   --  create the widget, and pop the value).

   procedure Pop_Visual;
   --  See Push_Visual for more information.

   function Get_Default_Colormap return Gdk.Color.Gdk_Colormap;
   --  Return the default colormap used when a widget is created.

   procedure Set_Default_Colormap (Cmap : Gdk.Color.Gdk_Colormap);
   --  Modify permanently the default colormap used when a widget is created.
   --  If you only want to modify this colormap temporarily for a few widgets,
   --  you should consider using Push_Colormap and Pop_Colormap instead.

   function Get_Default_Visual return Gdk.Visual.Gdk_Visual;
   --  Return the default visual used when a new widget is created.

   procedure Set_Default_Visual (Visual : Gdk.Visual.Gdk_Visual);
   --  Modify permanently the default visual used when a widget is created.
   --  If you only want to modify this visual temporarily for a few widgets,
   --  you should consider using Push_Visual and Pop_Visual instead.

   ------------
   -- Styles --
   ------------

   procedure Push_Style (Style : Gtk.Style.Gtk_Style);
   --  Change the default values for styles.
   --  This is generally used just before creating a widget. You should use
   --  this procedure in pair with Pop_Style (Push the new value, create the
   --  widget then pop the value)

   procedure Pop_Style;
   --  Restore the default values for styles.
   --  This is generally used just after creating a widget. You should use
   --  this procedure in pair with Push_Style (Push the new value, create the
   --  widget then pop the value)

   procedure Set_Style
     (Widget : access Gtk_Widget_Record;
      Style  : Gtk.Style.Gtk_Style);
   --  Set the style for a given widget.

   function Get_Style (Widget : access Gtk_Widget_Record)
     return Gtk.Style.Gtk_Style;
   --  Return the style of a given widget.

   procedure Modify_Style
     (Widget : access Gtk_Widget_Record;
      Style  : Gtk_Rc_Style);
   --  Modify the default style of a widget.

   procedure Set_Default_Style (Style : Gtk.Style.Gtk_Style);
   --  Set the default global style.

   function Get_Default_Style return Gtk.Style.Gtk_Style;
   --  Get the default global style.

   procedure Set_Rc_Style (Widget : access Gtk_Widget_Record);
   --  Restore the default style of a widget.
   --  The default style is given by the configuration file initially parsed
   --  by GtkAda.

   procedure Ensure_Style (Widget : access Gtk_Widget_Record);
   --  Make sure that the widget has a style associated to it.
   --  Either the default one as set by Set_Rc_Style above or one set by the
   --  user with Set_Style.

   procedure Restore_Default_Style (Widget : access Gtk_Widget_Record);
   --  Restore the default style that was set for the widget.
   --  The default style is the first one that was set either by a call
   --  to Set_Style or Set_Rc_Style.

   procedure Reset_Rc_Styles (Widget : access Gtk_Widget_Record);
   --  Restore the Rc style recursively for widget and its children.

   -------------------
   -- Widgets' tree --
   -------------------

   procedure Set_Name
     (Widget : access Gtk_Widget_Record;
      Name   : in String);
   --  Set the name for the widget.
   --  This name is used purely internally to identify the widget, and does not
   --  give any visual clue.

   function Get_Name (Widget : access Gtk_Widget_Record) return String;
   --  Return the name of the widget if it was set by Set_Name.
   --  Return the name of its class otherwise.

   procedure Set_Parent
     (Widget : access Gtk_Widget_Record;
      Parent : access Gtk_Widget_Record'Class);
   --  Modify the parent for the widget.
   --  This is not the recommended way to do this, you should use
   --  Gtk.Container.Add or Gtk.Box.Pack_Start instead.

   procedure Set_Parent_Window
     (Widget : access Gtk_Widget_Record;
      Window : Gdk.Window.Gdk_Window);
   --  Set the parent window for the actual Gdk_Window of the widget. This sets
   --  up required internal fields, and should be used only when you implement
   --  your own container, as opposed to using one of the standard containers.

   function Get_Parent (Widget : access Gtk_Widget_Record) return Gtk_Widget;
   --  Return the parent of the widget, or null if Widget is a toplevel
   --  widget.

   function Get_Toplevel (Widget : access Gtk_Widget_Record) return Gtk_Widget;
   --  Return the toplevel ancestor of the widget.
   --  This is the window or dialog in which the widget is included.
   --  The widget returned does not have any parent.

   function Get_Ancestor
     (Widget        : access Gtk_Widget_Record;
      Ancestor_Type : in Gtk_Type) return Gtk_Widget;
   --  Return the closest ancestor of Widget which is of type Ancestor_Type.
   --  Return null if there is none.

   function Is_Ancestor
     (Widget   : access Gtk_Widget_Record;
      Ancestor : access Gtk_Widget_Record'Class) return Boolean;
   --  Return True if Ancestor is in the ancestor tree for Widget.
   --  I.e. if Widget is contained within Ancestor.

   procedure Reparent
     (Widget     : access Gtk_Widget_Record;
      New_Parent : access Gtk_Widget_Record'Class);
   --  Change the parent of the widget dynamically.
   --  If both the new parent and the widget are shown, then the widget is
   --  visually redrawn in its new parent.

   --------------------
   -- Misc functions --
   --------------------

   procedure Set_Scroll_Adjustments
     (Widget : access Gtk_Widget_Record;
      Hadj   : Gtk.Adjustment.Gtk_Adjustment;
      Vadj   : Gtk.Adjustment.Gtk_Adjustment);
   --  Emit the "set_scroll_adjustments" signal.
   --  The exact signal emitted depends on the widget type (see
   --  Gtk.Object.Initialize_Class_Record).
   --  The handler creates the adjustments if null is passed as argument, and
   --  makes sure both adjustments are in the correct range.

   procedure Popup (Widget : access Gtk_Widget_Record; X, Y : in Gint);
   --  Realize the widget (see Realize above), moves it to the screen position
   --  (X, Y), and shows the widget.
   --  This should only be used for toplevel windows and dialogs, as you can
   --  no modify the position of a widget that has a parent (the parent is
   --  then responsible for its position).

   function Intersect
     (Widget       : access Gtk_Widget_Record;
      Area         : Gdk.Rectangle.Gdk_Rectangle;
      Intersection : access Gdk.Rectangle.Gdk_Rectangle) return Boolean;
   --  Return True if the widget intersects the screen area Area.
   --  The intersection area is returned in Intersection.

   procedure Grab_Default (Widget : access Gtk_Widget_Record);
   --  The widget becomes the default widget for its parent window or dialog.
   --  All keyboard events will be sent to it if no other widget has the focus.
   --  Note that the "Can_Default" flag must have been set first on WIDGET.

   procedure Set_State
     (Widget : access Gtk_Widget_Record;
      State : in Enums.Gtk_State_Type);
   --  Modify the state of the widget.
   --  This modifies its visual aspect, and thus should be used only if you
   --  change its behavior at the same time, so as not to confuse the user.

   function Get_State
     (Widget : access Gtk_Widget_Record) return Enums.Gtk_State_Type;
   --  Return the state of the widget.

   procedure Set_Sensitive
     (Widget    : access Gtk_Widget_Record;
      Sensitive : in Boolean := True);
   --  Modify the sensitivity of the widget.
   --  An insensitive widget is generally grayed out, and can not be activated.
   --  For instance, an insensitive menu item is grayed, and can never be
   --  selected.

   procedure Set_App_Paintable
     (Widget        : access Gtk_Widget_Record;
      App_Paintable : Boolean);
   --  Modify the "App_Paintable" flag for the widget.

   procedure Get_Pointer
     (Widget : access Gtk_Widget_Record;
      X      : out Gint;
      Y      : out Gint);
   --  Return the coordinates of the pointer (i.e. mouse) relative to Widget.

   procedure Set_Window
     (Widget : access Gtk_Widget_Record;
      Window : in Gdk.Window.Gdk_Window);
   --  Set the Gdk window associated with the widget.

   function Get_Window
     (Widget : access Gtk_Widget_Record) return Gdk.Window.Gdk_Window;
   --  Get the Gdk window associated with the widget.
   --  You can use this window if you need to draw directly on the widget using
   --  the functions found in the Gdk hierarchy.

   procedure Shape_Combine_Mask
     (Widget     : access Gtk_Widget_Record;
      Shape_Mask : Gdk.Bitmap.Gdk_Bitmap;
      Offset_X   : Gint;
      Offset_Y   : Gint);
   --  Modify the shape of the window that contains the widget.
   --  This allows for transparent windows, and requires the Xext library to be
   --  available on your system. If this library is not available, your program
   --  will still work.
   --  See the manual page for XShapeCombineMask(3x) for more information.

   -----------
   -- Flags --
   -----------
   --  Some additional flags are defined for all the visual objects (widgets).
   --  They are defined in addition to the ones defined in Gtk.Object.
   --  These flags are important in that they define exactly the different
   --  states a widget can be in.
   --
   --  - "Toplevel":
   --    Set if the widget is a toplevel widget, ie has no parent. This is
   --    mostly true for windows and dialogs.
   --
   --  - "No_Window":
   --    Set if the widget does not have an associated X11 window, ie can not
   --    receive events directly. For instance, a Gtk_Toolbar does not have
   --    an associated window. These objects are more lightweight, but require
   --    more work from GtkAda. This flag is only set if the widget will never
   --    have a window, even after it is realized.
   --
   --  - "Realized":
   --    Set if the widget has been realized, ie its associated X11 window has
   --    been created (providing the widget excepts a window, see the No_Window
   --    flag
   --
   --  - "Mapped":
   --    Set if the widget is visible on the screen. This is only possible if
   --    the Visible flag is also set.
   --
   --  - "Visible":
   --    Set if the widget will be displayed on the screen when mapped (see the
   --    functions Show and Hide in this package).
   --
   --  - "Sensitive":
   --    Set if the widget is listening to events. See the function
   --    Set_Sensitive in this package. An insensitive widget will generally
   --    have a different visual aspect to clue that it is unavailable (for
   --    instance an insensitive item menu will be grayed)
   --
   --  - "Parent_Sensitive":
   --    Set if the parent is sensitive. A widget is sensitive only if both
   --    the Sensitive and Parent_Sensitive are set.
   --
   --  - "Can_Focus":
   --    Set if the widget can have the focus, ie get keyboard events. Most
   --    widgets can not have the focus.
   --
   --  - "Has_Focus":
   --    Set if the widget currently has the focus. See the function Grab_Focus
   --    in this package.
   --
   --  - "Can_Default":
   --    Set if the widget can be the default widget in a window, ie the one
   --    that will get the keyboard events by default. For instance, the
   --    default button in a dialog is the one that gets clicked on when the
   --    user pressed Enter anywhere in the dialog.
   --
   --  - "Has_Default":
   --    Set if the widget is currently the default widget. See the function
   --    Grab_Default in this package.
   --
   --  - "Has_Grab":
   --    Set if the widget currently grabs all mouse and keyboard events in
   --    the application, even if it does not have the focus. There can be only
   --    such widget per application at any given time.
   --
   --  - "Rc_Style":
   --    Set if the widget's style is either the default style, or in a
   --    customization file. This is unset if the style has been modified by
   --    the user.
   --
   --  - "Composite_Child":
   --    ???
   --
   --  - "No_Reparent":
   --    This flags is never used in gtk+.
   --
   --  - "App_Paintable":
   --    For some containers (including Gtk_Window and Gtk_Layout), this is
   --    unset when the container itself has some special drawing routines.
   --
   --  - "Receives_Default":
   --    Set when the widget receives the default at the time it receives the
   --    focus. This is how the default button in a dialog is automatically
   --    changed when you press another button.

   Toplevel         : constant := 2 ** 4;
   No_Window        : constant := 2 ** 5;
   Realized         : constant := 2 ** 6;
   Mapped           : constant := 2 ** 7;
   Visible          : constant := 2 ** 8;
   Sensitive        : constant := 2 ** 9;
   Parent_Sensitive : constant := 2 ** 10;
   Can_Focus        : constant := 2 ** 11;
   Has_Focus        : constant := 2 ** 12;
   Can_Default      : constant := 2 ** 13;
   Has_Default      : constant := 2 ** 14;
   Has_Grab         : constant := 2 ** 15;
   Rc_Style         : constant := 2 ** 16;
   Composite_Child  : constant := 2 ** 17;
   No_Reparent      : constant := 2 ** 18;
   App_Paintable    : constant := 2 ** 19;
   Receives_Default : constant := 2 ** 20;

   function Toplevel_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the Toplevel flag is set.

   function No_Window_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the No_Window flag is set.

   function Realized_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the Realized flag is set.

   function Mapped_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the Mapped flag is set.

   function Visible_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the Visible flag is set.

   function Drawable_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  True if the widget is both visible and mapped.
   --  In other words, if it does appear on the screen.

   function Is_Sensitive
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the widget is Sensitive.

   function Can_Focus_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the Can_Focus flag is set.

   function Has_Focus_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the Has_Focus flag is set.

   function Has_Default_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the Has_Default flag is set.

   function Has_Grab_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the Has_Grab flag is set.

   function Rc_Style_Is_Set
     (Widget : access Gtk_Widget_Record'Class) return Boolean;
   --  Test whether the Rc_Style flag is set.

   --------------------------------------
   -- Definitions for lists of widgets --
   --------------------------------------

   --  <doc_ignore>

   function Convert (W : in Gtk_Widget) return System.Address;
   function Convert (W : System.Address) return Gtk_Widget;
   package Widget_List is new Glib.Glist.Generic_List (Gtk_Widget);
   package Widget_SList is new Glib.GSlist.Generic_SList (Gtk_Widget);

   --  </doc_ignore>

   -------------
   -- Signals --
   -------------

   --  <signals>
   --  The following new signals are defined for this widget:
   --
   --  - "show"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class);
   --
   --    Emitted when a widget is to be shown (see explanation for the Show
   --    subprogam). This schedules the widget to be displayed on the screen,
   --    and if this is a toplevel widget it actually appears on the screen
   --    and all its children that have been shown.
   --
   --  - "hide"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class);
   --
   --    Emitted when a widget is to be hidden (see explanation for the Hide
   --    subprogram). Hides the widget from the screen, and if its parent is
   --    shown, the widget will not appear on the screen again.
   --
   --  - "map"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class);
   --
   --    Emitted when a widget is mapped on the screen (the default handler
   --    simply emits the "show" signal).
   --
   --  - "unmap"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class);
   --
   --    Emitted when a widget needs to be unmapped on the screen (the default
   --    handler simply emits the "hide" signal).
   --
   --  - "realize"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class);
   --
   --    Emitted when a widget is realized. The default handler creates the
   --    Gdk window associated with the widget, and its ancestors.
   --
   --  - "unrealize"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class);
   --
   --    Emitted when a widget is unrealized. The default handler destroys the
   --    Gdk windows of the widget and all its children.
   --
   --  - "draw"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class;
   --                       Area   : Gdk.Rectangle.Gdk_Rectangle);
   --
   --    Emitted when a widget needs to be drawn. The default handler emits
   --    the "expose" event.
   --
   --  - "draw_focus"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class);
   --
   --    Emitted when a widget needs to be drawn and it has the focus. Some
   --    widgets might want to provide visual clues that they have the focus,
   --    like a black border. This is never called if the widget can not have
   --    the focus (ie the "Can_Focus" flag is unset).
   --
   --  - "draw_default"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class);
   --
   --    Emitted when a widget needs to be drawn and it does not have the
   --    focus. This is never called if the widget can not have the focus
   --    (ie the "Can_Focus" flag is unset).
   --
   --  - "size_request"
   --    procedure Handler (Widget      : access Gtk_Widget_Record'Class;
   --                       Requisition : access Gtk_Requisition);
   --
   --    Should return (in Requisition) the ideal size the widget would like to
   --    have. It is not sure this is the size that will be assigned to it,
   --    since it depends on the size of its parent).
   --
   --  - "size_allocate"
   --    procedure Handler (Widget     : access Gtk_Widget_Record'Class;
   --                       Allocation : Gtk_Allocation);
   --
   --    A size and position were assigned to the widget. This is called every
   --    time the size of the widget changes.
   --    The default handler takes care of resizing and moving the widget.
   --
   --  - "state_changed"
   --    procedure Handler (Widget         : access Gtk_Widget_Record'Class;
   --                       Previous_State : Gtk.Enums.Gtk_State_Type);
   --
   --    The state of the widget has changed.
   --
   --  - "parent_set"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class;
   --                       Previous_Parent : access Gtk_Widget_Record'Class);
   --
   --    A new parent has been set for the widget. The previous parent is
   --    given in arguments (if there was none,
   --    Gdk.Is_Created (Previous_Parent) returns False).
   --
   --  - "style_set"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class);
   --                       Previous_Style : Gtk.Style.Gtk_Style);
   --
   --    The widget's style has been changed (this is not call when some
   --    settings in the style are changed, only when the style itself is
   --    completely changed with a call to Set_Style or Set_Rc_Style).
   --
   --  - "add_accelerator"
   --
   --  ???
   --
   --  - "remove_accelerator"
   --
   --  ???
   --
   --  - "grab_focus"
   --    procedure Handler (Widget : access Gtk_Widget_Record'Class);
   --
   --    The widget has got the focus, ie will now get the keyboard events
   --    sent to a window. This is only called if the "Can_Focus" flag is
   --    set. The "Has_Focus" flag might not be set when this signal is
   --    emitted.
   --
   --  - "event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event)
   --                     return Boolean;
   --
   --    Some event was sent to the widget. This covers all the cases
   --    below, and acts as a general handler. This is called in addition to
   --    the relevant specific handler below.
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "button_press_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Button)
   --                     return Boolean;
   --
   --    A button was pressed while the pointer was inside the widget.
   --    To get this signal, some widgets by have to use the Set_Events
   --    subprogram first to get this event.
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "button_release_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Button)
   --                     return Boolean;
   --
   --    A button was released while the pointer was inside the widget.
   --    Note that in some cases (Gtk_Buttons for instance), another "clicked"
   --    signal could be emitted). This "button_release_event" should mainly
   --    be used for widgets that don't already have specific signals to cover
   --    that case (Gtk_Drawing_Area for instance).
   --
   --    To get this signal, some widgets may have to use the Set_Events
   --    subprogram first to get this event.
   --
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "motion_notify_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Motion)
   --                     return Boolean;
   --
   --    The pointer has moved while remaining inside the widget.
   --    The Set_Events subprogram has to be called first to get this event.
   --
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "delete_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event)
   --                     return Boolean;
   --
   --    The user has clicked on the "close" button in the window's frame
   --    (the button that is automatically set by the window manager). If the
   --    handler returns False, the widget will be destroyed (and the window
   --    closed), but if the handler returns True, nothing will be done.
   --    This is a good way to prevent the user from closing your application's
   --    window if there should be some clean ups first (like saving the
   --    document).
   --
   --  - "destroy_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event)
   --                     return Boolean;
   --
   --    This signal is apparently never emitted by Gtk+. You might want to
   --    use "destroy" instead, which is documented in Gtk.Object.
   --
   --  - "expose_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Expose)
   --                     return Boolean;
   --
   --    The widget needs to be partly redrawn. The exact area to redraw is
   --    found in Event. For some widgets, you should rather connect to the
   --    "draw" signal. However, for instance for Gtk_Drawing_Area widgets,
   --    you have to use this, after setting the correct event mask with
   --    Set_Events.
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "key_press_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Key)
   --                     return Boolean;
   --
   --    A key has been pressed while Widget had the focus. Note that some
   --    widgets like Gtk_Editable provide some higher-level signals to handle
   --    this.
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "key_release_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Key)
   --                     return Boolean;
   --
   --    A key has been released while Widget had the focus.
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "enter_notify_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Crossing)
   --                     return Boolean;
   --
   --    The pointer has just entered the widget. If the "Can_Focus" flag is
   --    set, Widget will gain the focus, and the widget might be drawn
   --    differently.
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "leave_notify_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Crossing)
   --                     return Boolean;
   --
   --    The pointer has just leaved the widget. If the "Can_Focus" flag is
   --    set, Widget will gain the focus, and the widget might be drawn
   --    differently.
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "configure_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Configure)
   --                     return Boolean;
   --
   --    Some configuration of the window has changed (it has been
   --    moved or resized).
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "focus_in_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Focus)
   --                     return Boolean;
   --
   --    The widget has just gained the focus.
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "focus_out_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event_Focus)
   --                     return Boolean;
   --
   --    The widget has just lost the focus.
   --    If the handler returns False, the event might be pass to the parent
   --    of widget (if no other handler of widget has returned True).
   --
   --  - "map_event"
   --    function Handler (Widget : access Gtk_Widget_Record'Class;
   --                      Event  : Gdk.Event.Gdk_Event)
   --