1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2011, AdaCore                   -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  This widget is generally put on the sides of a drawing area to help the 
  27. --  user measure distances. It indicates the current position of the mouse 
  28. --  cursor within the drawing area, and can be graduated in multiple units. 
  29. -- 
  30. --  </description> 
  31. --  <screenshot>gtk-rulers</screenshot> 
  32. --  <group>Drawing</group> 
  33. --  <testgtk>create_rulers.adb</testgtk> 
  34.  
  35. pragma Warnings (Off, "*is already use-visible*"); 
  36. with Glib;            use Glib; 
  37. with Glib.Properties; use Glib.Properties; 
  38. with Glib.Types;      use Glib.Types; 
  39. with Gtk.Buildable;   use Gtk.Buildable; 
  40. with Gtk.Enums;       use Gtk.Enums; 
  41. with Gtk.Orientable;  use Gtk.Orientable; 
  42. with Gtk.Widget;      use Gtk.Widget; 
  43.  
  44. package Gtk.Ruler is 
  45.  
  46.    type Gtk_Ruler_Record is new Gtk_Widget_Record with null record; 
  47.    type Gtk_Ruler is access all Gtk_Ruler_Record'Class; 
  48.  
  49.    subtype Gtk_Vruler_Record is Gtk_Ruler_Record; 
  50.    subtype Gtk_Vruler is Gtk_Ruler; 
  51.  
  52.    subtype Gtk_Hruler_Record is Gtk_Ruler_Record; 
  53.    subtype Gtk_Hruler is Gtk_Ruler; 
  54.  
  55.    ------------------ 
  56.    -- Constructors -- 
  57.    ------------------ 
  58.  
  59.    function Get_Type return Glib.GType; 
  60.    pragma Import (C, Get_Type, "gtk_ruler_get_type"); 
  61.  
  62.    procedure Gtk_New_Vruler (Ruler : out Gtk_Vruler); 
  63.    procedure Initialize_Vruler (Ruler : access Gtk_Vruler_Record'Class); 
  64.    --  Creates a new vertical ruler unmaintained and too specialized. There is 
  65.    --  no replacement. 
  66.  
  67.    function Vruler_Get_Type return Glib.GType; 
  68.    pragma Import (C, Vruler_Get_Type, "gtk_vruler_get_type"); 
  69.  
  70.    procedure Gtk_New_Hruler (Ruler : out Gtk_Hruler); 
  71.    procedure Initialize_Hruler (Ruler : access Gtk_Hruler_Record'Class); 
  72.  
  73.    function Hruler_Get_Type return Glib.GType; 
  74.    pragma Import (C, Hruler_Get_Type, "gtk_hruler_get_type"); 
  75.  
  76.    ------------- 
  77.    -- Methods -- 
  78.    ------------- 
  79.  
  80.    procedure Draw_Pos (Ruler : access Gtk_Ruler_Record); 
  81.  
  82.    procedure Draw_Ticks (Ruler : access Gtk_Ruler_Record); 
  83.  
  84.    function Get_Metric 
  85.       (Ruler : access Gtk_Ruler_Record) return Gtk.Enums.Gtk_Metric_Type; 
  86.    procedure Set_Metric 
  87.       (Ruler  : access Gtk_Ruler_Record; 
  88.        Metric : Gtk.Enums.Gtk_Metric_Type); 
  89.    --  Set or get the units used for a Gtk_Ruler. See Set_Metric 
  90.  
  91.    procedure Get_Range 
  92.       (Ruler    : access Gtk_Ruler_Record; 
  93.        Lower    : out Gdouble; 
  94.        Upper    : out Gdouble; 
  95.        Position : out Gdouble; 
  96.        Max_Size : out Gdouble); 
  97.    procedure Set_Range 
  98.       (Ruler    : access Gtk_Ruler_Record; 
  99.        Lower    : Gdouble; 
  100.        Upper    : Gdouble; 
  101.        Position : Gdouble; 
  102.        Max_Size : Gdouble); 
  103.    --  This sets the range of the ruler. unmaintained and too specialized. 
  104.    --  There is no replacement. 
  105.    --  "lower": the lower limit of the ruler 
  106.    --  "upper": the upper limit of the ruler 
  107.    --  "position": the mark on the ruler 
  108.    --  "max_size": the maximum size of the ruler used when calculating the 
  109.    --  space to leave for the text 
  110.  
  111.    --------------------- 
  112.    -- Interfaces_Impl -- 
  113.    --------------------- 
  114.  
  115.    function Get_Orientation 
  116.       (Self : access Gtk_Ruler_Record) return Gtk.Enums.Gtk_Orientation; 
  117.    procedure Set_Orientation 
  118.       (Self        : access Gtk_Ruler_Record; 
  119.        Orientation : Gtk.Enums.Gtk_Orientation); 
  120.  
  121.    ---------------- 
  122.    -- Interfaces -- 
  123.    ---------------- 
  124.    --  This class implements several interfaces. See Glib.Types 
  125.    -- 
  126.    --  - "Buildable" 
  127.    -- 
  128.    --  - "Orientable" 
  129.  
  130.    package Implements_Buildable is new Glib.Types.Implements 
  131.      (Gtk.Buildable.Gtk_Buildable, Gtk_Ruler_Record, Gtk_Ruler); 
  132.    function "+" 
  133.      (Widget : access Gtk_Ruler_Record'Class) 
  134.    return Gtk.Buildable.Gtk_Buildable 
  135.    renames Implements_Buildable.To_Interface; 
  136.    function "-" 
  137.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  138.    return Gtk_Ruler 
  139.    renames Implements_Buildable.To_Object; 
  140.  
  141.    package Implements_Orientable is new Glib.Types.Implements 
  142.      (Gtk.Orientable.Gtk_Orientable, Gtk_Ruler_Record, Gtk_Ruler); 
  143.    function "+" 
  144.      (Widget : access Gtk_Ruler_Record'Class) 
  145.    return Gtk.Orientable.Gtk_Orientable 
  146.    renames Implements_Orientable.To_Interface; 
  147.    function "-" 
  148.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  149.    return Gtk_Ruler 
  150.    renames Implements_Orientable.To_Object; 
  151.  
  152.    ---------------- 
  153.    -- Properties -- 
  154.    ---------------- 
  155.    --  The following properties are defined for this widget. See 
  156.    --  Glib.Properties for more information on properties) 
  157.    -- 
  158.    --  Name: Lower_Property 
  159.    --  Type: Gdouble 
  160.    --  Flags: read-write 
  161.    -- 
  162.    --  Name: Max_Size_Property 
  163.    --  Type: Gdouble 
  164.    --  Flags: read-write 
  165.    -- 
  166.    --  Name: Metric_Property 
  167.    --  Type: Gtk.Enums.Gtk_Metric_Type 
  168.    --  Flags: read-write 
  169.    --  The metric used for the ruler. 
  170.    -- 
  171.    --  Name: Position_Property 
  172.    --  Type: Gdouble 
  173.    --  Flags: read-write 
  174.    -- 
  175.    --  Name: Upper_Property 
  176.    --  Type: Gdouble 
  177.    --  Flags: read-write 
  178.    --  The following properties are defined for this widget. See 
  179.    --  Glib.Properties for more information on properties) 
  180.    --  The following properties are defined for this widget. See 
  181.    --  Glib.Properties for more information on properties) 
  182.  
  183.    Lower_Property : constant Glib.Properties.Property_Double; 
  184.    Max_Size_Property : constant Glib.Properties.Property_Double; 
  185.    Metric_Property : constant Gtk.Enums.Property_Metric_Type; 
  186.    Position_Property : constant Glib.Properties.Property_Double; 
  187.    Upper_Property : constant Glib.Properties.Property_Double; 
  188.  
  189. private 
  190.    Lower_Property : constant Glib.Properties.Property_Double := 
  191.      Glib.Properties.Build ("lower"); 
  192.    Max_Size_Property : constant Glib.Properties.Property_Double := 
  193.      Glib.Properties.Build ("max-size"); 
  194.    Metric_Property : constant Gtk.Enums.Property_Metric_Type := 
  195.      Gtk.Enums.Build ("metric"); 
  196.    Position_Property : constant Glib.Properties.Property_Double := 
  197.      Glib.Properties.Build ("position"); 
  198.    Upper_Property : constant Glib.Properties.Property_Double := 
  199.      Glib.Properties.Build ("upper"); 
  200. end Gtk.Ruler;