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