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