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-2013, 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. -- As a special exception, if other files instantiate generics from  -- 
  23. -- this unit, or you link this unit with other files to produce an   -- 
  24. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  25. -- executable to be covered by the GNU General Public License. This  -- 
  26. -- exception does not however invalidate any other reasons why the   -- 
  27. -- executable file  might be covered by the  GNU Public License.     -- 
  28. ----------------------------------------------------------------------- 
  29.  
  30. --  <description> 
  31. --  This widget is generally put on the sides of a drawing area to help the 
  32. --  user measure distances. It indicates the current position of the mouse 
  33. --  cursor within the drawing area, and can be graduated in multiple units. 
  34. -- 
  35. --  </description> 
  36. --  <screenshot>gtk-rulers</screenshot> 
  37. --  <group>Drawing</group> 
  38. --  <testgtk>create_rulers.adb</testgtk> 
  39.  
  40. pragma Warnings (Off, "*is already use-visible*"); 
  41. with Glib;            use Glib; 
  42. with Glib.Properties; use Glib.Properties; 
  43. with Glib.Types;      use Glib.Types; 
  44. with Gtk.Buildable;   use Gtk.Buildable; 
  45. with Gtk.Enums;       use Gtk.Enums; 
  46. with Gtk.Orientable;  use Gtk.Orientable; 
  47. with Gtk.Widget;      use Gtk.Widget; 
  48.  
  49. package Gtk.Ruler is 
  50.  
  51.    type Gtk_Ruler_Record is new Gtk_Widget_Record with null record; 
  52.    type Gtk_Ruler is access all Gtk_Ruler_Record'Class; 
  53.  
  54.    subtype Gtk_Vruler_Record is Gtk_Ruler_Record; 
  55.    subtype Gtk_Vruler is Gtk_Ruler; 
  56.  
  57.    subtype Gtk_Hruler_Record is Gtk_Ruler_Record; 
  58.    subtype Gtk_Hruler is Gtk_Ruler; 
  59.  
  60.    ------------------ 
  61.    -- Constructors -- 
  62.    ------------------ 
  63.  
  64.    function Get_Type return Glib.GType; 
  65.    pragma Import (C, Get_Type, "gtk_ruler_get_type"); 
  66.  
  67.    procedure Gtk_New_Vruler (Ruler : out Gtk_Vruler); 
  68.    procedure Initialize_Vruler (Ruler : access Gtk_Vruler_Record'Class); 
  69.    --  Creates a new vertical ruler unmaintained and too specialized. There is 
  70.    --  no replacement. 
  71.  
  72.    function Vruler_Get_Type return Glib.GType; 
  73.    pragma Import (C, Vruler_Get_Type, "gtk_vruler_get_type"); 
  74.  
  75.    procedure Gtk_New_Hruler (Ruler : out Gtk_Hruler); 
  76.    procedure Initialize_Hruler (Ruler : access Gtk_Hruler_Record'Class); 
  77.  
  78.    function Hruler_Get_Type return Glib.GType; 
  79.    pragma Import (C, Hruler_Get_Type, "gtk_hruler_get_type"); 
  80.  
  81.    ------------- 
  82.    -- Methods -- 
  83.    ------------- 
  84.  
  85.    procedure Draw_Pos (Ruler : access Gtk_Ruler_Record); 
  86.  
  87.    procedure Draw_Ticks (Ruler : access Gtk_Ruler_Record); 
  88.  
  89.    function Get_Metric 
  90.       (Ruler : access Gtk_Ruler_Record) return Gtk.Enums.Gtk_Metric_Type; 
  91.    procedure Set_Metric 
  92.       (Ruler  : access Gtk_Ruler_Record; 
  93.        Metric : Gtk.Enums.Gtk_Metric_Type); 
  94.    --  Set or get the units used for a Gtk_Ruler. See Set_Metric 
  95.  
  96.    procedure Get_Range 
  97.       (Ruler    : access Gtk_Ruler_Record; 
  98.        Lower    : out Gdouble; 
  99.        Upper    : out Gdouble; 
  100.        Position : out Gdouble; 
  101.        Max_Size : out Gdouble); 
  102.    procedure Set_Range 
  103.       (Ruler    : access Gtk_Ruler_Record; 
  104.        Lower    : Gdouble; 
  105.        Upper    : Gdouble; 
  106.        Position : Gdouble; 
  107.        Max_Size : Gdouble); 
  108.    --  This sets the range of the ruler. unmaintained and too specialized. 
  109.    --  There is no replacement. 
  110.    --  "lower": the lower limit of the ruler 
  111.    --  "upper": the upper limit of the ruler 
  112.    --  "position": the mark on the ruler 
  113.    --  "max_size": the maximum size of the ruler used when calculating the 
  114.    --  space to leave for the text 
  115.  
  116.    --------------------- 
  117.    -- Interfaces_Impl -- 
  118.    --------------------- 
  119.  
  120.    function Get_Orientation 
  121.       (Self : access Gtk_Ruler_Record) return Gtk.Enums.Gtk_Orientation; 
  122.    procedure Set_Orientation 
  123.       (Self        : access Gtk_Ruler_Record; 
  124.        Orientation : Gtk.Enums.Gtk_Orientation); 
  125.  
  126.    ---------------- 
  127.    -- Interfaces -- 
  128.    ---------------- 
  129.    --  This class implements several interfaces. See Glib.Types 
  130.    -- 
  131.    --  - "Buildable" 
  132.    -- 
  133.    --  - "Orientable" 
  134.  
  135.    package Implements_Buildable is new Glib.Types.Implements 
  136.      (Gtk.Buildable.Gtk_Buildable, Gtk_Ruler_Record, Gtk_Ruler); 
  137.    function "+" 
  138.      (Widget : access Gtk_Ruler_Record'Class) 
  139.    return Gtk.Buildable.Gtk_Buildable 
  140.    renames Implements_Buildable.To_Interface; 
  141.    function "-" 
  142.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  143.    return Gtk_Ruler 
  144.    renames Implements_Buildable.To_Object; 
  145.  
  146.    package Implements_Orientable is new Glib.Types.Implements 
  147.      (Gtk.Orientable.Gtk_Orientable, Gtk_Ruler_Record, Gtk_Ruler); 
  148.    function "+" 
  149.      (Widget : access Gtk_Ruler_Record'Class) 
  150.    return Gtk.Orientable.Gtk_Orientable 
  151.    renames Implements_Orientable.To_Interface; 
  152.    function "-" 
  153.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  154.    return Gtk_Ruler 
  155.    renames Implements_Orientable.To_Object; 
  156.  
  157.    ---------------- 
  158.    -- Properties -- 
  159.    ---------------- 
  160.    --  The following properties are defined for this widget. See 
  161.    --  Glib.Properties for more information on properties) 
  162.    -- 
  163.    --  Name: Lower_Property 
  164.    --  Type: Gdouble 
  165.    --  Flags: read-write 
  166.    -- 
  167.    --  Name: Max_Size_Property 
  168.    --  Type: Gdouble 
  169.    --  Flags: read-write 
  170.    -- 
  171.    --  Name: Metric_Property 
  172.    --  Type: Gtk.Enums.Gtk_Metric_Type 
  173.    --  Flags: read-write 
  174.    --  The metric used for the ruler. 
  175.    -- 
  176.    --  Name: Position_Property 
  177.    --  Type: Gdouble 
  178.    --  Flags: read-write 
  179.    -- 
  180.    --  Name: Upper_Property 
  181.    --  Type: Gdouble 
  182.    --  Flags: read-write 
  183.    --  The following properties are defined for this widget. See 
  184.    --  Glib.Properties for more information on properties) 
  185.    --  The following properties are defined for this widget. See 
  186.    --  Glib.Properties for more information on properties) 
  187.  
  188.    Lower_Property : constant Glib.Properties.Property_Double; 
  189.    Max_Size_Property : constant Glib.Properties.Property_Double; 
  190.    Metric_Property : constant Gtk.Enums.Property_Metric_Type; 
  191.    Position_Property : constant Glib.Properties.Property_Double; 
  192.    Upper_Property : constant Glib.Properties.Property_Double; 
  193.  
  194. private 
  195.    Lower_Property : constant Glib.Properties.Property_Double := 
  196.      Glib.Properties.Build ("lower"); 
  197.    Max_Size_Property : constant Glib.Properties.Property_Double := 
  198.      Glib.Properties.Build ("max-size"); 
  199.    Metric_Property : constant Gtk.Enums.Property_Metric_Type := 
  200.      Gtk.Enums.Build ("metric"); 
  201.    Position_Property : constant Glib.Properties.Property_Double := 
  202.      Glib.Properties.Build ("position"); 
  203.    Upper_Property : constant Glib.Properties.Property_Double := 
  204.      Glib.Properties.Build ("upper"); 
  205. end Gtk.Ruler;