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-2010 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. --  A scale is a horizontal or vertical widget that a user can slide to choose 
  27. --  a value in a given range. This is a kind of cursor, similar to what one 
  28. --  finds on audio systems to select the volume for instance. 
  29. --  </description> 
  30. --  <c_version>2.16.6</c_version> 
  31. --  <group>Numeric/Text Data Entry</group> 
  32. --  <screenshot>gtk-scale.png</screenshot> 
  33.  
  34. with Glib.Properties; 
  35. with Gtk.Adjustment; 
  36. with Gtk.Enums; use Gtk.Enums; 
  37. with Gtk.GRange; 
  38. with Pango.Layout; 
  39.  
  40. package Gtk.Scale is 
  41.  
  42.    type Gtk_Scale_Record is new Gtk.GRange.Gtk_Range_Record with private; 
  43.    subtype Gtk_Hscale_Record is Gtk_Scale_Record; 
  44.    subtype Gtk_Vscale_Record is Gtk_Scale_Record; 
  45.  
  46.    type Gtk_Scale is access all Gtk_Scale_Record'Class; 
  47.    subtype Gtk_Hscale is Gtk_Scale; 
  48.    subtype Gtk_Vscale is Gtk_Scale; 
  49.  
  50.    procedure Gtk_New_Hscale 
  51.      (Scale      : out Gtk_Scale; 
  52.       Adjustment : Gtk.Adjustment.Gtk_Adjustment); 
  53.    procedure Gtk_New_Hscale 
  54.      (Scale : out Gtk_Scale; 
  55.       Min   : Gdouble; 
  56.       Max   : Gdouble; 
  57.       Step  : Gdouble); 
  58.    --  Create a new horizontal scale widget that lets the user input a number 
  59.    --  between Min and Max with an increment of Step. Step must be non-zero; it 
  60.    --  is the distance the slider moves when using the arrow keys to adjust the 
  61.    --  scale value. An adjustment can be used to specify the range instead. 
  62.  
  63.    procedure Gtk_New_Vscale 
  64.      (Scale      : out Gtk_Scale; 
  65.       Adjustment : Gtk.Adjustment.Gtk_Adjustment); 
  66.    procedure Gtk_New_Vscale 
  67.      (Scale : out Gtk_Scale; 
  68.       Min   : Gdouble; 
  69.       Max   : Gdouble; 
  70.       Step  : Gdouble); 
  71.    --  Create a new vertical scale widget that lets the user input a number 
  72.    --  between Min and Max with an increment of Step. Step must be non-zero; it 
  73.    --  is the distance the slider moves when using the arrow keys to adjust the 
  74.    --  scale value. An adjustment can be used to specify the range instead. 
  75.  
  76.    function Get_Type        return Gtk.Gtk_Type; 
  77.    function Hscale_Get_Type return GType; 
  78.    function Vscale_Get_Type return GType; 
  79.    --  Return the internal value associated with a Gtk_Scale, a 
  80.    --  Gtk_Hscale or a Gtk_Vscale. 
  81.  
  82.    procedure Initialize_Hscale 
  83.      (Scale      : access Gtk_Scale_Record'Class; 
  84.       Adjustment : Gtk.Adjustment.Gtk_Adjustment); 
  85.    procedure Initialize_Hscale 
  86.      (Scale : access Gtk_Scale_Record'Class; 
  87.       Min   : Gdouble; 
  88.       Max   : Gdouble; 
  89.       Step  : Gdouble); 
  90.    --  Internal initialization procedure. 
  91.  
  92.    procedure Initialize_Vscale 
  93.      (Scale      : access Gtk_Scale_Record'Class; 
  94.       Adjustment : Gtk.Adjustment.Gtk_Adjustment); 
  95.    procedure Initialize_Vscale 
  96.      (Scale : access Gtk_Scale_Record'Class; 
  97.       Min   : Gdouble; 
  98.       Max   : Gdouble; 
  99.       Step  : Gdouble); 
  100.    --  Internal initialization procedure. 
  101.  
  102.    procedure Set_Digits 
  103.      (Scale      : access Gtk_Scale_Record; 
  104.       The_Digits : Gint); 
  105.    function Get_Digits (Scale : access Gtk_Scale_Record) return Gint; 
  106.    --  Sets the number of decimal places that are displayed in the value. Also 
  107.    --  causes the value of the adjustment to be rounded off to this number of 
  108.    --  digits, so the retrieved value matches the value the user saw. 
  109.  
  110.    procedure Set_Draw_Value 
  111.      (Scale      : access Gtk_Scale_Record; 
  112.       Draw_Value : Boolean); 
  113.    function Get_Draw_Value (Scale : access Gtk_Scale_Record) return Boolean; 
  114.    --  Specifies whether the current value is displayed as a string next to the 
  115.    --  slider. 
  116.  
  117.    procedure Set_Value_Pos 
  118.      (Scale : access Gtk_Scale_Record; 
  119.       Pos   : Gtk_Position_Type); 
  120.    function Get_Value_Pos 
  121.      (Scale : access Gtk_Scale_Record) return Gtk_Position_Type; 
  122.    --  Sets the position in which the current value is displayed. 
  123.  
  124.    function Get_Layout 
  125.      (Scale : access Gtk_Scale_Record) return Pango.Layout.Pango_Layout; 
  126.    --  Gets the Pango_Layout used to display the scale. The returned object 
  127.    --  is owned by the scale so does not need to be freed by the caller. 
  128.  
  129.    procedure Get_Layout_Offsets 
  130.      (Scale : access Gtk_Scale_Record; 
  131.       X, Y  : out Gint); 
  132.    --  Obtains the coordinates where the scale will draw the Pango_Layout 
  133.    --  representing the text in the scale. Remember 
  134.    --  when using the Pango_Layout functions you need to convert to 
  135.    --  and from pixels using Pango.Enums.To_Pixels 
  136.    --  If the draw_value property is False, the return values are undefined. 
  137.  
  138.    procedure Add_Mark 
  139.      (Scale    : access Gtk_Scale_Record; 
  140.       Value    : Gdouble; 
  141.       Position : Gtk_Position_Type; 
  142.       Markup   : String); 
  143.    --  Adds a mark at Value. 
  144.    -- 
  145.    --  A mark is indicated visually by drawing a tick mark next to the scale, 
  146.    --  and GTK+ makes it easy for the user to position the scale exactly at the 
  147.    --  marks value. For a horizontal scale, Pos_Top is drawn above the scale, 
  148.    --  anything else below. For a vertical scale, Pos_Left is drawn to the left 
  149.    --  of the scale, anything else to the right. 
  150.    -- 
  151.    --  If Markup is not "", text (in Pango Markup format) is shown next to the 
  152.    --  tick mark. 
  153.    -- 
  154.    --  To remove marks from a scale, use Clear_Marks. 
  155.  
  156.    procedure Clear_Marks (Scale : access Gtk_Scale_Record); 
  157.    --  Removes any marks that have been added Add_Mark. 
  158.  
  159.    ---------------- 
  160.    -- Properties -- 
  161.    ---------------- 
  162.    --  The following properties are defined for this widget. See 
  163.    --  Glib.Properties for more information on properties. 
  164.  
  165.    --  <properties> 
  166.    --  Name:  Digits_Property 
  167.    --  Type:  Int 
  168.    --  Descr: The number of decimal places that are displayed in the value 
  169.    -- 
  170.    --  Name:  Draw_Value_Property 
  171.    --  Type:  Boolean 
  172.    --  Descr: Whether the current value is displayed as a string next to the 
  173.    --         slider 
  174.    -- 
  175.    --  Name:  Value_Pos_Property 
  176.    --  Type:  Gtk_Position_Type 
  177.    --  Descr: The position in which the current value is displayed 
  178.    --  </properties> 
  179.  
  180.    Digits_Property     : constant Glib.Properties.Property_Int; 
  181.    Draw_Value_Property : constant Glib.Properties.Property_Boolean; 
  182.    Value_Pos_Property  : constant Gtk.Enums.Property_Gtk_Position_Type; 
  183.  
  184.    ---------------------- 
  185.    -- Style Properties -- 
  186.    ---------------------- 
  187.    --  The following properties can be changed through the gtk theme and 
  188.    --  configuration files, and retrieved through Gtk.Widget.Style_Get_Property 
  189.  
  190.    --  <style_properties> 
  191.    --  Name:  Slider_Length_Property 
  192.    --  Type:  Int 
  193.    --  Descr: Length of scale's slider 
  194.    -- 
  195.    --  Name:  Value_Spacing_Property 
  196.    --  Type:  Int 
  197.    --  Descr: Space between value text and the slider/trough area 
  198.    --  </style_properties> 
  199.  
  200.    Slider_Length_Property : constant Glib.Properties.Property_Int; 
  201.    Value_Spacing_Property : constant Glib.Properties.Property_Int; 
  202.  
  203.    ------------- 
  204.    -- Signals -- 
  205.    ------------- 
  206.  
  207.    --  <signals> 
  208.    --  The following new signals are defined for this widget: 
  209.    -- 
  210.    --  -  "format_value" 
  211.    --     function Handler 
  212.    --        (Scale : access Gtk_Scale_Record'Class; 
  213.    --         Value : Gdouble) return Interfaces.C.Strings.chars_ptr; 
  214.    --     Emitted by the scale to request a formating of its value. The handler 
  215.    --     should return the string representing the value. The returned value 
  216.    --     will be freed by gtk+ 
  217.    -- 
  218.    --  </signals> 
  219.  
  220.    Signal_Format_Value : constant Glib.Signal_Name := "format_value"; 
  221.  
  222. private 
  223.    type Gtk_Scale_Record is new Gtk.GRange.Gtk_Range_Record with null record; 
  224.  
  225.    Digits_Property : constant Glib.Properties.Property_Int := 
  226.      Glib.Properties.Build ("digits"); 
  227.    Draw_Value_Property : constant Glib.Properties.Property_Boolean := 
  228.      Glib.Properties.Build ("draw-value"); 
  229.    Value_Pos_Property  : constant Gtk.Enums.Property_Gtk_Position_Type := 
  230.      Gtk.Enums.Build ("value-pos"); 
  231.  
  232.    Slider_Length_Property : constant Glib.Properties.Property_Int := 
  233.      Glib.Properties.Build ("slider-length"); 
  234.    Value_Spacing_Property : constant Glib.Properties.Property_Int := 
  235.      Glib.Properties.Build ("value-spacing"); 
  236.  
  237.    pragma Import (C, Get_Type,        "gtk_scale_get_type"); 
  238.    pragma Import (C, Hscale_Get_Type, "gtk_hscale_get_type"); 
  239.    pragma Import (C, Vscale_Get_Type, "gtk_vscale_get_type"); 
  240. end Gtk.Scale;