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 provides a low level graphical representation of a range of 
  27. --  values. It is used by other widgets such as Gtk_Scale and Gtk_Scrollbar. 
  28. -- 
  29. --  </description> 
  30. --  <screenshot>gtk-range</screenshot> 
  31. --  <testgtk>create_range.adb</testgtk> 
  32.  
  33. pragma Warnings (Off, "*is already use-visible*"); 
  34. with Gdk.Rectangle;   use Gdk.Rectangle; 
  35. with Glib;            use Glib; 
  36. with Glib.Properties; use Glib.Properties; 
  37. with Glib.Types;      use Glib.Types; 
  38. with Gtk.Adjustment;  use Gtk.Adjustment; 
  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.GRange is 
  45.  
  46.    type Gtk_Range_Record is new Gtk_Widget_Record with null record; 
  47.    type Gtk_Range is access all Gtk_Range_Record'Class; 
  48.  
  49.    ------------------ 
  50.    -- Constructors -- 
  51.    ------------------ 
  52.  
  53.    function Get_Type return Glib.GType; 
  54.    pragma Import (C, Get_Type, "gtk_range_get_type"); 
  55.  
  56.    ------------- 
  57.    -- Methods -- 
  58.    ------------- 
  59.  
  60.    function Get_Adjustment 
  61.       (The_Range : access Gtk_Range_Record) 
  62.        return Gtk.Adjustment.Gtk_Adjustment; 
  63.    procedure Set_Adjustment 
  64.       (The_Range  : access Gtk_Range_Record; 
  65.        Adjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class); 
  66.    --  Sets the adjustment to be used as the "model" object for this range 
  67.    --  widget. The adjustment indicates the current range value, the minimum 
  68.    --  and maximum range values, the step/page increments used for keybindings 
  69.    --  and scrolling, and the page size. The page size is normally 0 for 
  70.    --  Gtk.Scale.Gtk_Scale and nonzero for Gtk.Scrollbar.Gtk_Scrollbar, and 
  71.    --  indicates the size of the visible area of the widget being scrolled. The 
  72.    --  page size affects the size of the scrollbar slider. 
  73.    --  "adjustment": a Gtk.Adjustment.Gtk_Adjustment 
  74.  
  75.    function Get_Fill_Level 
  76.       (The_Range : access Gtk_Range_Record) return Gdouble; 
  77.    procedure Set_Fill_Level 
  78.       (The_Range  : access Gtk_Range_Record; 
  79.        Fill_Level : Gdouble); 
  80.    --  Set the new position of the fill level indicator. The "fill level" is 
  81.    --  probably best described by its most prominent use case, which is an 
  82.    --  indicator for the amount of pre-buffering in a streaming media player. 
  83.    --  In that use case, the value of the range would indicate the current play 
  84.    --  position, and the fill level would be the position up to which the 
  85.    --  file/stream has been downloaded. This amount of prebuffering can be 
  86.    --  displayed on the range's trough and is themeable separately from the 
  87.    --  trough. To enable fill level display, use 
  88.    --  Gtk.GRange.Set_Show_Fill_Level. The range defaults to not showing the 
  89.    --  fill level. Additionally, it's possible to restrict the range's slider 
  90.    --  position to values which are smaller than the fill level. This is 
  91.    --  controller by Gtk.GRange.Set_Restrict_To_Fill_Level and is by default 
  92.    --  enabled. 
  93.    --  Since: gtk+ 2.12 
  94.    --  "fill_level": the new position of the fill level indicator 
  95.  
  96.    function Get_Flippable 
  97.       (The_Range : access Gtk_Range_Record) return Boolean; 
  98.    procedure Set_Flippable 
  99.       (The_Range : access Gtk_Range_Record; 
  100.        Flippable : Boolean); 
  101.    --  If a range is flippable, it will switch its direction if it is 
  102.    --  horizontal and its direction is %GTK_TEXT_DIR_RTL. See 
  103.    --  Gtk.Widget.Get_Direction. 
  104.    --  Since: gtk+ 2.18 
  105.    --  "flippable": True to make the range flippable 
  106.  
  107.    function Get_Inverted 
  108.       (The_Range : access Gtk_Range_Record) return Boolean; 
  109.    procedure Set_Inverted 
  110.       (The_Range : access Gtk_Range_Record; 
  111.        Setting   : Boolean); 
  112.    --  Ranges normally move from lower to higher values as the slider moves 
  113.    --  from top to bottom or left to right. Inverted ranges have higher values 
  114.    --  at the top or on the right rather than on the bottom or left. 
  115.    --  "setting": True to invert the range 
  116.  
  117.    function Get_Lower_Stepper_Sensitivity 
  118.       (The_Range : access Gtk_Range_Record) 
  119.        return Gtk.Enums.Gtk_Sensitivity_Type; 
  120.    procedure Set_Lower_Stepper_Sensitivity 
  121.       (The_Range   : access Gtk_Range_Record; 
  122.        Sensitivity : Gtk.Enums.Gtk_Sensitivity_Type); 
  123.    --  Sets the sensitivity policy for the stepper that points to the 'lower' 
  124.    --  end of the GtkRange's adjustment. 
  125.    --  Since: gtk+ 2.10 
  126.    --  "sensitivity": the lower stepper's sensitivity policy. 
  127.  
  128.    function Get_Min_Slider_Size 
  129.       (The_Range : access Gtk_Range_Record) return Gint; 
  130.    procedure Set_Min_Slider_Size 
  131.       (The_Range : access Gtk_Range_Record; 
  132.        Min_Size  : Boolean); 
  133.    --  Sets the minimum size of the range's slider. This function is useful 
  134.    --  mainly for Gtk.GRange.Gtk_Range subclasses. 
  135.    --  Since: gtk+ 2.20 
  136.    --  "min_size": The slider's minimum size 
  137.  
  138.    procedure Get_Range_Rect 
  139.       (The_Range  : access Gtk_Range_Record; 
  140.        Range_Rect : out Gdk.Rectangle.Gdk_Rectangle); 
  141.    --  This function returns the area that contains the range's trough and its 
  142.    --  steppers, in widget->window coordinates. This function is useful mainly 
  143.    --  for Gtk.GRange.Gtk_Range subclasses. 
  144.    --  Since: gtk+ 2.20 
  145.    --  "range_rect": return location for the range rectangle 
  146.  
  147.    function Get_Restrict_To_Fill_Level 
  148.       (The_Range : access Gtk_Range_Record) return Boolean; 
  149.    procedure Set_Restrict_To_Fill_Level 
  150.       (The_Range              : access Gtk_Range_Record; 
  151.        Restrict_To_Fill_Level : Boolean); 
  152.    --  Sets whether the slider is restricted to the fill level. See 
  153.    --  Gtk.GRange.Set_Fill_Level for a general description of the fill level 
  154.    --  concept. 
  155.    --  Since: gtk+ 2.12 
  156.    --  "restrict_to_fill_level": Whether the fill level restricts slider 
  157.    --  movement. 
  158.  
  159.    function Get_Round_Digits 
  160.       (The_Range : access Gtk_Range_Record) return Gint; 
  161.    procedure Set_Round_Digits 
  162.       (The_Range    : access Gtk_Range_Record; 
  163.        Round_Digits : Gint); 
  164.    --  Sets the number of digits to round the value to when it changes. See 
  165.    --  Gtk.GRange.Gtk_Range::change-value. 
  166.    --  Since: gtk+ 2.24 
  167.    --  "round_digits": the precision in digits, or -1 
  168.  
  169.    function Get_Show_Fill_Level 
  170.       (The_Range : access Gtk_Range_Record) return Boolean; 
  171.    procedure Set_Show_Fill_Level 
  172.       (The_Range       : access Gtk_Range_Record; 
  173.        Show_Fill_Level : Boolean); 
  174.    --  Sets whether a graphical fill level is show on the trough. See 
  175.    --  Gtk.GRange.Set_Fill_Level for a general description of the fill level 
  176.    --  concept. 
  177.    --  Since: gtk+ 2.12 
  178.    --  "show_fill_level": Whether a fill level indicator graphics is shown. 
  179.  
  180.    procedure Get_Slider_Range 
  181.       (The_Range    : access Gtk_Range_Record; 
  182.        Slider_Start : out Gint; 
  183.        Slider_End   : out Gint); 
  184.    --  This function returns sliders range along the long dimension, in 
  185.    --  widget->window coordinates. This function is useful mainly for 
  186.    --  Gtk.GRange.Gtk_Range subclasses. 
  187.    --  Since: gtk+ 2.20 
  188.    --  "slider_start": return location for the slider's start, or null 
  189.    --  "slider_end": return location for the slider's end, or null 
  190.  
  191.    function Get_Slider_Size_Fixed 
  192.       (The_Range : access Gtk_Range_Record) return Boolean; 
  193.    procedure Set_Slider_Size_Fixed 
  194.       (The_Range  : access Gtk_Range_Record; 
  195.        Size_Fixed : Boolean); 
  196.    --  Sets whether the range's slider has a fixed size, or a size that 
  197.    --  depends on it's adjustment's page size. This function is useful mainly 
  198.    --  for Gtk.GRange.Gtk_Range subclasses. 
  199.    --  Since: gtk+ 2.20 
  200.    --  "size_fixed": True to make the slider size constant 
  201.  
  202.    function Get_Update_Policy 
  203.       (The_Range : access Gtk_Range_Record) return Gtk.Enums.Gtk_Update_Type; 
  204.    pragma Obsolescent (Get_Update_Policy); 
  205.    procedure Set_Update_Policy 
  206.       (The_Range : access Gtk_Range_Record; 
  207.        Policy    : Gtk.Enums.Gtk_Update_Type); 
  208.    pragma Obsolescent (Set_Update_Policy); 
  209.    --  Sets the update policy for the range. GTK_UPDATE_CONTINUOUS means that 
  210.    --  anytime the range slider is moved, the range value will change and the 
  211.    --  value_changed signal will be emitted. GTK_UPDATE_DELAYED means that the 
  212.    --  value will be updated after a brief timeout where no slider motion 
  213.    --  occurs, so updates are spaced by a short time rather than continuous. 
  214.    --  GTK_UPDATE_DISCONTINUOUS means that the value will only be updated when 
  215.    --  the user releases the button and ends the slider drag operation. 
  216.    --  updates, you need to code it yourself. 
  217.    --  Deprecated since 2.24, There is no replacement. If you require delayed 
  218.    --  "policy": update policy 
  219.  
  220.    function Get_Upper_Stepper_Sensitivity 
  221.       (The_Range : access Gtk_Range_Record) 
  222.        return Gtk.Enums.Gtk_Sensitivity_Type; 
  223.    procedure Set_Upper_Stepper_Sensitivity 
  224.       (The_Range   : access Gtk_Range_Record; 
  225.        Sensitivity : Gtk.Enums.Gtk_Sensitivity_Type); 
  226.    --  Sets the sensitivity policy for the stepper that points to the 'upper' 
  227.    --  end of the GtkRange's adjustment. 
  228.    --  Since: gtk+ 2.10 
  229.    --  "sensitivity": the upper stepper's sensitivity policy. 
  230.  
  231.    function Get_Value (The_Range : access Gtk_Range_Record) return Gdouble; 
  232.    procedure Set_Value 
  233.       (The_Range : access Gtk_Range_Record; 
  234.        Value     : Gdouble); 
  235.    --  Sets the current value of the range; if the value is outside the 
  236.    --  minimum or maximum range values, it will be clamped to fit inside them. 
  237.    --  The range emits the Gtk.GRange.Gtk_Range::value-changed signal if the 
  238.    --  value changes. 
  239.    --  "value": new value of the range 
  240.  
  241.    procedure Set_Increments 
  242.       (The_Range : access Gtk_Range_Record; 
  243.        Step      : Gdouble; 
  244.        Page      : Gdouble); 
  245.    --  Sets the step and page sizes for the range. The step size is used when 
  246.    --  the user clicks the Gtk.Scrollbar.Gtk_Scrollbar arrows or moves 
  247.    --  Gtk.Scale.Gtk_Scale via arrow keys. The page size is used for example 
  248.    --  when moving via Page Up or Page Down keys. 
  249.    --  "step": step size 
  250.    --  "page": page size 
  251.  
  252.    procedure Set_Range 
  253.       (The_Range : access Gtk_Range_Record; 
  254.        Min       : Gdouble; 
  255.        Max       : Gdouble); 
  256.    --  Sets the allowable values in the Gtk.GRange.Gtk_Range, and clamps the 
  257.    --  range value to be between Min and Max. (If the range has a non-zero page 
  258.    --  size, it is clamped between Min and Max - page-size.) 
  259.    --  "min": minimum range value 
  260.    --  "max": maximum range value 
  261.  
  262.    --------------------- 
  263.    -- Interfaces_Impl -- 
  264.    --------------------- 
  265.  
  266.    function Get_Orientation 
  267.       (Self : access Gtk_Range_Record) return Gtk.Enums.Gtk_Orientation; 
  268.    procedure Set_Orientation 
  269.       (Self        : access Gtk_Range_Record; 
  270.        Orientation : Gtk.Enums.Gtk_Orientation); 
  271.  
  272.    ---------------- 
  273.    -- Interfaces -- 
  274.    ---------------- 
  275.    --  This class implements several interfaces. See Glib.Types 
  276.    -- 
  277.    --  - "Buildable" 
  278.    -- 
  279.    --  - "Orientable" 
  280.  
  281.    package Implements_Buildable is new Glib.Types.Implements 
  282.      (Gtk.Buildable.Gtk_Buildable, Gtk_Range_Record, Gtk_Range); 
  283.    function "+" 
  284.      (Widget : access Gtk_Range_Record'Class) 
  285.    return Gtk.Buildable.Gtk_Buildable 
  286.    renames Implements_Buildable.To_Interface; 
  287.    function "-" 
  288.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  289.    return Gtk_Range 
  290.    renames Implements_Buildable.To_Object; 
  291.  
  292.    package Implements_Orientable is new Glib.Types.Implements 
  293.      (Gtk.Orientable.Gtk_Orientable, Gtk_Range_Record, Gtk_Range); 
  294.    function "+" 
  295.      (Widget : access Gtk_Range_Record'Class) 
  296.    return Gtk.Orientable.Gtk_Orientable 
  297.    renames Implements_Orientable.To_Interface; 
  298.    function "-" 
  299.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  300.    return Gtk_Range 
  301.    renames Implements_Orientable.To_Object; 
  302.  
  303.    ---------------- 
  304.    -- Properties -- 
  305.    ---------------- 
  306.    --  The following properties are defined for this widget. See 
  307.    --  Glib.Properties for more information on properties) 
  308.    -- 
  309.    --  Name: Adjustment_Property 
  310.    --  Type: Gtk.Adjustment.Gtk_Adjustment 
  311.    --  Flags: read-write 
  312.    -- 
  313.    --  Name: Fill_Level_Property 
  314.    --  Type: Gdouble 
  315.    --  Flags: read-write 
  316.    --  The fill level (e.g. prebuffering of a network stream). See 
  317.    --  Gtk.GRange.Set_Fill_Level. 
  318.    -- 
  319.    --  Name: Inverted_Property 
  320.    --  Type: Boolean 
  321.    --  Flags: read-write 
  322.    -- 
  323.    --  Name: Lower_Stepper_Sensitivity_Property 
  324.    --  Type: Gtk.Enums.Gtk_Sensitivity_Type 
  325.    --  Flags: read-write 
  326.    -- 
  327.    --  Name: Restrict_To_Fill_Level_Property 
  328.    --  Type: Boolean 
  329.    --  Flags: read-write 
  330.    --  The restrict-to-fill-level property controls whether slider movement is 
  331.    --  restricted to an upper boundary set by the fill level. See 
  332.    --  Gtk.GRange.Set_Restrict_To_Fill_Level. 
  333.    -- 
  334.    --  Name: Round_Digits_Property 
  335.    --  Type: Gint 
  336.    --  Flags: read-write 
  337.    --  The number of digits to round the value to when it changes, or -1. See 
  338.    --  Gtk.GRange.Gtk_Range::change-value. 
  339.    -- 
  340.    --  Name: Show_Fill_Level_Property 
  341.    --  Type: Boolean 
  342.    --  Flags: read-write 
  343.    --  The show-fill-level property controls whether fill level indicator 
  344.    --  graphics are displayed on the trough. See 
  345.    --  Gtk.GRange.Set_Show_Fill_Level. 
  346.    -- 
  347.    --  Name: Update_Policy_Property 
  348.    --  Type: Gtk.Enums.Gtk_Update_Type 
  349.    --  Flags: read-write 
  350.    -- 
  351.    --  Name: Upper_Stepper_Sensitivity_Property 
  352.    --  Type: Gtk.Enums.Gtk_Sensitivity_Type 
  353.    --  Flags: read-write 
  354.  
  355.    Adjustment_Property : constant Glib.Properties.Property_Object; 
  356.    Fill_Level_Property : constant Glib.Properties.Property_Double; 
  357.    Inverted_Property : constant Glib.Properties.Property_Boolean; 
  358.    Lower_Stepper_Sensitivity_Property : constant Gtk.Enums.Property_Gtk_Sensitivity_Type; 
  359.    Restrict_To_Fill_Level_Property : constant Glib.Properties.Property_Boolean; 
  360.    Round_Digits_Property : constant Glib.Properties.Property_Int; 
  361.    Show_Fill_Level_Property : constant Glib.Properties.Property_Boolean; 
  362.    Update_Policy_Property : constant Gtk.Enums.Property_Gtk_Update_Type; 
  363.    Upper_Stepper_Sensitivity_Property : constant Gtk.Enums.Property_Gtk_Sensitivity_Type; 
  364.  
  365.    ------------- 
  366.    -- Signals -- 
  367.    ------------- 
  368.    --  The following new signals are defined for this widget: 
  369.    -- 
  370.    --  "adjust-bounds" 
  371.    --     procedure Handler 
  372.    --       (Self   : access Gtk_Range_Record'Class; 
  373.    --        Object : Gdouble); 
  374.    -- 
  375.    --  "change-value" 
  376.    --     function Handler 
  377.    --       (Self   : access Gtk_Range_Record'Class; 
  378.    --        Scroll : Gtk.Enums.Gtk_Scroll_Type; 
  379.    --        Value  : Gdouble) return Boolean; 
  380.    --    --  "scroll": the type of scroll action that was performed 
  381.    --    --  "value": the new value resulting from the scroll action 
  382.    --  The ::change-value signal is emitted when a scroll action is performed 
  383.    --  on a range. It allows an application to determine the type of scroll 
  384.    --  event that occurred and the resultant new value. The application can 
  385.    --  handle the event itself and return True to prevent further processing. 
  386.    --  Or, by returning False, it can pass the event to other handlers until 
  387.    --  the default GTK+ handler is reached. The value parameter is unrounded. 
  388.    --  An application that overrides the ::change-value signal is responsible 
  389.    --  for clamping the value to the desired number of decimal digits; the 
  390.    --  default GTK+ handler clamps the value based on 
  391.    --  Gtk.GRange.Gtk_Range:round_digits. It is not possible to use delayed 
  392.    --  update policies in an overridden ::change-value handler. 
  393.    --  Returns True to prevent other handlers from being invoked for the 
  394.    --  signal, False to propagate the signal further 
  395.    -- 
  396.    --  "move-slider" 
  397.    --     procedure Handler 
  398.    --       (Self : access Gtk_Range_Record'Class; 
  399.    --        Step : Gtk.Enums.Gtk_Scroll_Type); 
  400.    --    --  "step": how to move the slider 
  401.    --  Virtual function that moves the slider. Used for keybindings. 
  402.    -- 
  403.    --  "value-changed" 
  404.    --     procedure Handler (Self : access Gtk_Range_Record'Class); 
  405.    --  Emitted when the range value changes. 
  406.  
  407.    Signal_Adjust_Bounds : constant Glib.Signal_Name := "adjust-bounds"; 
  408.    Signal_Change_Value : constant Glib.Signal_Name := "change-value"; 
  409.    Signal_Move_Slider : constant Glib.Signal_Name := "move-slider"; 
  410.    Signal_Value_Changed : constant Glib.Signal_Name := "value-changed"; 
  411.  
  412. private 
  413.    Adjustment_Property : constant Glib.Properties.Property_Object := 
  414.      Glib.Properties.Build ("adjustment"); 
  415.    Fill_Level_Property : constant Glib.Properties.Property_Double := 
  416.      Glib.Properties.Build ("fill-level"); 
  417.    Inverted_Property : constant Glib.Properties.Property_Boolean := 
  418.      Glib.Properties.Build ("inverted"); 
  419.    Lower_Stepper_Sensitivity_Property : constant Gtk.Enums.Property_Gtk_Sensitivity_Type := 
  420.      Gtk.Enums.Build ("lower-stepper-sensitivity"); 
  421.    Restrict_To_Fill_Level_Property : constant Glib.Properties.Property_Boolean := 
  422.      Glib.Properties.Build ("restrict-to-fill-level"); 
  423.    Round_Digits_Property : constant Glib.Properties.Property_Int := 
  424.      Glib.Properties.Build ("round-digits"); 
  425.    Show_Fill_Level_Property : constant Glib.Properties.Property_Boolean := 
  426.      Glib.Properties.Build ("show-fill-level"); 
  427.    Update_Policy_Property : constant Gtk.Enums.Property_Gtk_Update_Type := 
  428.      Gtk.Enums.Build ("update-policy"); 
  429.    Upper_Stepper_Sensitivity_Property : constant Gtk.Enums.Property_Gtk_Sensitivity_Type := 
  430.      Gtk.Enums.Build ("upper-stepper-sensitivity"); 
  431. end Gtk.GRange;