1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  The Gtk.Level_Bar.Gtk_Level_Bar is a bar widget that can be used as a 
  26. --  level indicator. Typical use cases are displaying the strength of a 
  27. --  password, or showing the charge level of a battery. 
  28. -- 
  29. --  Use Gtk.Level_Bar.Set_Value to set the current value, and 
  30. --  Gtk.Level_Bar.Add_Offset_Value to set the value offsets at which the bar 
  31. --  will be considered in a different state. GTK will add two offsets by 
  32. --  default on the level bar: GTK_LEVEL_BAR_OFFSET_LOW and 
  33. --  GTK_LEVEL_BAR_OFFSET_HIGH, with values 0.25 and 0.75 respectively. 
  34. -- 
  35. --  == Adding a custom offset on the bar == 
  36. -- 
  37. --    static GtkWidget * 
  38. --    create_level_bar (void) 
  39. --    { 
  40. --       GtkWidget *level_bar; 
  41. --       level_bar = gtk_level_bar_new (); 
  42. --       /<!---->* This changes the value of the default low offset *<!---->/ 
  43. --       gtk_level_bar_add_offset_value (GTK_LEVEL_BAR (level_bar), 
  44. --          GTK_LEVEL_BAR_OFFSET_LOW, 0.10); 
  45. --       /<!---->* This adds a new offset to the bar; the application will 
  46. --       * be able to change its color by using the following selector, 
  47. --       * either by adding it to its CSS file or using 
  48. --       * Gtk.Css_Provider.Load_From_Data and Gtk.Style_Context.Add_Provider 
  49. --       * 
  50. --       * .level-bar.fill-block.level-my-offset { 
  51. --          *   background-color: green; 
  52. --          *   border-style: solid; 
  53. --          *   border-color: black; 
  54. --          *   border-style: 1px; 
  55. --          * } 
  56. --          *<!---->/ 
  57. --          gtk_level_bar_add_offset_value (GTK_LEVEL_BAR (level_bar), 
  58. --             "my-offset", 0.60); 
  59. --          return level_bar; 
  60. --       } 
  61. -- 
  62. --  The default interval of values is between zero and one, but it's possible 
  63. --  to modify the interval using Gtk.Level_Bar.Set_Min_Value and 
  64. --  Gtk.Level_Bar.Set_Max_Value. The value will be always drawn in proportion 
  65. --  to the admissible interval, i.e. a value of 15 with a specified interval 
  66. --  between 10 and 20 is equivalent to a value of 0.5 with an interval between 
  67. --  0 and 1. When GTK_LEVEL_BAR_MODE_DISCRETE is used, the bar level is 
  68. --  rendered as a finite and number of separated blocks instead of a single 
  69. --  one. The number of blocks that will be rendered is equal to the number of 
  70. --  units specified by the admissible interval. For instance, to build a bar 
  71. --  rendered with five blocks, it's sufficient to set the minimum value to 0 
  72. --  and the maximum value to 5 after changing the indicator mode to discrete. 
  73. -- 
  74. --  </description> 
  75. pragma Ada_2005; 
  76.  
  77. pragma Warnings (Off, "*is already use-visible*"); 
  78. with Glib;            use Glib; 
  79. with Glib.Object;     use Glib.Object; 
  80. with Glib.Properties; use Glib.Properties; 
  81. with Glib.Types;      use Glib.Types; 
  82. with Gtk.Buildable;   use Gtk.Buildable; 
  83. with Gtk.Enums;       use Gtk.Enums; 
  84. with Gtk.Orientable;  use Gtk.Orientable; 
  85. with Gtk.Widget;      use Gtk.Widget; 
  86.  
  87. package Gtk.Level_Bar is 
  88.  
  89.    type Gtk_Level_Bar_Record is new Gtk_Widget_Record with null record; 
  90.    type Gtk_Level_Bar is access all Gtk_Level_Bar_Record'Class; 
  91.  
  92.    ------------------ 
  93.    -- Constructors -- 
  94.    ------------------ 
  95.  
  96.    procedure Gtk_New (Self : out Gtk_Level_Bar); 
  97.    procedure Initialize (Self : not null access Gtk_Level_Bar_Record'Class); 
  98.    --  Creates a new Gtk.Level_Bar.Gtk_Level_Bar. 
  99.    --  Since: gtk+ 3.6 
  100.  
  101.    function Gtk_Level_Bar_New return Gtk_Level_Bar; 
  102.    --  Creates a new Gtk.Level_Bar.Gtk_Level_Bar. 
  103.    --  Since: gtk+ 3.6 
  104.  
  105.    procedure Gtk_New_For_Interval 
  106.       (Self      : out Gtk_Level_Bar; 
  107.        Min_Value : Gdouble; 
  108.        Max_Value : Gdouble); 
  109.    procedure Initialize_For_Interval 
  110.       (Self      : not null access Gtk_Level_Bar_Record'Class; 
  111.        Min_Value : Gdouble; 
  112.        Max_Value : Gdouble); 
  113.    --  Utility constructor that creates a new Gtk.Level_Bar.Gtk_Level_Bar for 
  114.    --  the specified interval. 
  115.    --  Since: gtk+ 3.6 
  116.    --  "min_value": a positive value 
  117.    --  "max_value": a positive value 
  118.  
  119.    function Gtk_Level_Bar_New_For_Interval 
  120.       (Min_Value : Gdouble; 
  121.        Max_Value : Gdouble) return Gtk_Level_Bar; 
  122.    --  Utility constructor that creates a new Gtk.Level_Bar.Gtk_Level_Bar for 
  123.    --  the specified interval. 
  124.    --  Since: gtk+ 3.6 
  125.    --  "min_value": a positive value 
  126.    --  "max_value": a positive value 
  127.  
  128.    function Get_Type return Glib.GType; 
  129.    pragma Import (C, Get_Type, "gtk_level_bar_get_type"); 
  130.  
  131.    ------------- 
  132.    -- Methods -- 
  133.    ------------- 
  134.  
  135.    procedure Add_Offset_Value 
  136.       (Self  : not null access Gtk_Level_Bar_Record; 
  137.        Name  : UTF8_String; 
  138.        Value : Gdouble); 
  139.    --  Adds a new offset marker on Self at the position specified by Value. 
  140.    --  When the bar value is in the interval topped by Value (or between Value 
  141.    --  and Gtk.Level_Bar.Gtk_Level_Bar:max-value in case the offset is the last 
  142.    --  one on the bar) a style class named 'level-'Name will be applied when 
  143.    --  rendering the level bar fill. If another offset marker named Name 
  144.    --  exists, its value will be replaced by Value. 
  145.    --  Since: gtk+ 3.6 
  146.    --  "name": the name of the new offset 
  147.    --  "value": the value for the new offset 
  148.  
  149.    function Get_Inverted 
  150.       (Self : not null access Gtk_Level_Bar_Record) return Boolean; 
  151.    --  Return the value of the Gtk.Level_Bar.Gtk_Level_Bar:inverted property. 
  152.    --  Since: gtk+ 3.8 
  153.  
  154.    procedure Set_Inverted 
  155.       (Self     : not null access Gtk_Level_Bar_Record; 
  156.        Inverted : Boolean); 
  157.    --  Sets the value of the Gtk.Level_Bar.Gtk_Level_Bar:inverted property. 
  158.    --  Since: gtk+ 3.8 
  159.    --  "inverted": True to invert the level bar 
  160.  
  161.    function Get_Max_Value 
  162.       (Self : not null access Gtk_Level_Bar_Record) return Gdouble; 
  163.    --  Returns the value of the Gtk.Level_Bar.Gtk_Level_Bar:max-value 
  164.    --  property. 
  165.    --  Since: gtk+ 3.6 
  166.  
  167.    procedure Set_Max_Value 
  168.       (Self  : not null access Gtk_Level_Bar_Record; 
  169.        Value : Gdouble); 
  170.    --  Sets the value of the Gtk.Level_Bar.Gtk_Level_Bar:max-value property. 
  171.    --  Since: gtk+ 3.6 
  172.    --  "value": a positive value 
  173.  
  174.    function Get_Min_Value 
  175.       (Self : not null access Gtk_Level_Bar_Record) return Gdouble; 
  176.    --  Returns the value of the Gtk.Level_Bar.Gtk_Level_Bar:min-value 
  177.    --  property. 
  178.    --  Since: gtk+ 3.6 
  179.  
  180.    procedure Set_Min_Value 
  181.       (Self  : not null access Gtk_Level_Bar_Record; 
  182.        Value : Gdouble); 
  183.    --  Sets the value of the Gtk.Level_Bar.Gtk_Level_Bar:min-value property. 
  184.    --  Since: gtk+ 3.6 
  185.    --  "value": a positive value 
  186.  
  187.    function Get_Mode 
  188.       (Self : not null access Gtk_Level_Bar_Record) 
  189.        return Gtk.Enums.Gtk_Level_Bar_Mode; 
  190.    --  Returns the value of the Gtk.Level_Bar.Gtk_Level_Bar:mode property. 
  191.    --  Since: gtk+ 3.6 
  192.  
  193.    procedure Set_Mode 
  194.       (Self : not null access Gtk_Level_Bar_Record; 
  195.        Mode : Gtk.Enums.Gtk_Level_Bar_Mode); 
  196.    --  Sets the value of the Gtk.Level_Bar.Gtk_Level_Bar:mode property. 
  197.    --  Since: gtk+ 3.6 
  198.    --  "mode": a Gtk.Enums.Gtk_Level_Bar_Mode 
  199.  
  200.    function Get_Offset_Value 
  201.       (Self  : not null access Gtk_Level_Bar_Record; 
  202.        Name  : UTF8_String := ""; 
  203.        Value : access Gdouble) return Boolean; 
  204.    --  Fetches the value specified for the offset marker Name in Self, 
  205.    --  returning True in case an offset named Name was found. 
  206.    --  Since: gtk+ 3.6 
  207.    --  "name": the name of an offset in the bar 
  208.    --  "value": location where to store the value 
  209.  
  210.    function Get_Value 
  211.       (Self : not null access Gtk_Level_Bar_Record) return Gdouble; 
  212.    --  Returns the value of the Gtk.Level_Bar.Gtk_Level_Bar:value property. 
  213.    --  Since: gtk+ 3.6 
  214.  
  215.    procedure Set_Value 
  216.       (Self  : not null access Gtk_Level_Bar_Record; 
  217.        Value : Gdouble); 
  218.    --  Sets the value of the Gtk.Level_Bar.Gtk_Level_Bar:value property. 
  219.    --  Since: gtk+ 3.6 
  220.    --  "value": a value in the interval between 
  221.    --  Gtk.Level_Bar.Gtk_Level_Bar:min-value and 
  222.    --  Gtk.Level_Bar.Gtk_Level_Bar:max-value 
  223.  
  224.    procedure Remove_Offset_Value 
  225.       (Self : not null access Gtk_Level_Bar_Record; 
  226.        Name : UTF8_String := ""); 
  227.    --  Removes an offset marker previously added with 
  228.    --  Gtk.Level_Bar.Add_Offset_Value. 
  229.    --  Since: gtk+ 3.6 
  230.    --  "name": the name of an offset in the bar 
  231.  
  232.    --------------------------------------------- 
  233.    -- Inherited subprograms (from interfaces) -- 
  234.    --------------------------------------------- 
  235.    --  Methods inherited from the Buildable interface are not duplicated here 
  236.    --  since they are meant to be used by tools, mostly. If you need to call 
  237.    --  them, use an explicit cast through the "-" operator below. 
  238.  
  239.    function Get_Orientation 
  240.       (Self : not null access Gtk_Level_Bar_Record) 
  241.        return Gtk.Enums.Gtk_Orientation; 
  242.  
  243.    procedure Set_Orientation 
  244.       (Self        : not null access Gtk_Level_Bar_Record; 
  245.        Orientation : Gtk.Enums.Gtk_Orientation); 
  246.  
  247.    ---------------- 
  248.    -- Properties -- 
  249.    ---------------- 
  250.    --  The following properties are defined for this widget. See 
  251.    --  Glib.Properties for more information on properties) 
  252.  
  253.    Inverted_Property : constant Glib.Properties.Property_Boolean; 
  254.    --  Level bars normally grow from top to bottom or left to right. Inverted 
  255.    --  level bars grow in the opposite direction. 
  256.  
  257.    Max_Value_Property : constant Glib.Properties.Property_Double; 
  258.    --  Type: Gdouble 
  259.    --  The Gtk.Level_Bar.Gtk_Level_Bar:max-value property determaxes the 
  260.    --  maximum value of the interval that can be displayed by the bar. 
  261.  
  262.    Min_Value_Property : constant Glib.Properties.Property_Double; 
  263.    --  Type: Gdouble 
  264.    --  The Gtk.Level_Bar.Gtk_Level_Bar:min-value property determines the 
  265.    --  minimum value of the interval that can be displayed by the bar. 
  266.  
  267.    Mode_Property : constant Gtk.Enums.Property_Gtk_Level_Bar_Mode; 
  268.    --  The Gtk.Level_Bar.Gtk_Level_Bar:bar-mode property determines the way 
  269.    --  Gtk.Level_Bar.Gtk_Level_Bar interprets the value properties to draw the 
  270.    --  level fill area. Specifically, when the value is 
  271.    --  GTK_LEVEL_BAR_MODE_CONTINUOUS, Gtk.Level_Bar.Gtk_Level_Bar will draw a 
  272.    --  single block representing the current value in that area; when the value 
  273.    --  is GTK_LEVEL_BAR_MODE_DISCRETE, the widget will draw a succession of 
  274.    --  separate blocks filling the draw area, with the number of blocks being 
  275.    --  equal to the units separating the integral roundings of 
  276.    --  Gtk.Level_Bar.Gtk_Level_Bar:min-value and 
  277.    --  Gtk.Level_Bar.Gtk_Level_Bar:max-value. 
  278.  
  279.    Value_Property : constant Glib.Properties.Property_Double; 
  280.    --  Type: Gdouble 
  281.    --  The Gtk.Level_Bar.Gtk_Level_Bar:value property determines the currently 
  282.    --  filled value of the level bar. 
  283.  
  284.    ------------- 
  285.    -- Signals -- 
  286.    ------------- 
  287.  
  288.    type Cb_Gtk_Level_Bar_UTF8_String_Void is not null access procedure 
  289.      (Self : access Gtk_Level_Bar_Record'Class; 
  290.       Name : UTF8_String); 
  291.  
  292.    type Cb_GObject_UTF8_String_Void is not null access procedure 
  293.      (Self : access Glib.Object.GObject_Record'Class; 
  294.       Name : UTF8_String); 
  295.  
  296.    Signal_Offset_Changed : constant Glib.Signal_Name := "offset-changed"; 
  297.    procedure On_Offset_Changed 
  298.       (Self  : not null access Gtk_Level_Bar_Record; 
  299.        Call  : Cb_Gtk_Level_Bar_UTF8_String_Void; 
  300.        After : Boolean := False); 
  301.    procedure On_Offset_Changed 
  302.       (Self  : not null access Gtk_Level_Bar_Record; 
  303.        Call  : Cb_GObject_UTF8_String_Void; 
  304.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  305.        After : Boolean := False); 
  306.    --  Emitted when an offset specified on the bar changes value as an effect 
  307.    --  to Gtk.Level_Bar.Add_Offset_Value being called. 
  308.    -- 
  309.    --  The signal supports detailed connections; you can connect to the 
  310.    --  detailed signal "changed::x" in order to only receive callbacks when the 
  311.    --  value of offset "x" changes. 
  312.  
  313.    ---------------- 
  314.    -- Interfaces -- 
  315.    ---------------- 
  316.    --  This class implements several interfaces. See Glib.Types 
  317.    -- 
  318.    --  - "Buildable" 
  319.    -- 
  320.    --  - "Orientable" 
  321.  
  322.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  323.      (Gtk.Buildable.Gtk_Buildable, Gtk_Level_Bar_Record, Gtk_Level_Bar); 
  324.    function "+" 
  325.      (Widget : access Gtk_Level_Bar_Record'Class) 
  326.    return Gtk.Buildable.Gtk_Buildable 
  327.    renames Implements_Gtk_Buildable.To_Interface; 
  328.    function "-" 
  329.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  330.    return Gtk_Level_Bar 
  331.    renames Implements_Gtk_Buildable.To_Object; 
  332.  
  333.    package Implements_Gtk_Orientable is new Glib.Types.Implements 
  334.      (Gtk.Orientable.Gtk_Orientable, Gtk_Level_Bar_Record, Gtk_Level_Bar); 
  335.    function "+" 
  336.      (Widget : access Gtk_Level_Bar_Record'Class) 
  337.    return Gtk.Orientable.Gtk_Orientable 
  338.    renames Implements_Gtk_Orientable.To_Interface; 
  339.    function "-" 
  340.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  341.    return Gtk_Level_Bar 
  342.    renames Implements_Gtk_Orientable.To_Object; 
  343.  
  344. private 
  345.    Value_Property : constant Glib.Properties.Property_Double := 
  346.      Glib.Properties.Build ("value"); 
  347.    Mode_Property : constant Gtk.Enums.Property_Gtk_Level_Bar_Mode := 
  348.      Gtk.Enums.Build ("mode"); 
  349.    Min_Value_Property : constant Glib.Properties.Property_Double := 
  350.      Glib.Properties.Build ("min-value"); 
  351.    Max_Value_Property : constant Glib.Properties.Property_Double := 
  352.      Glib.Properties.Build ("max-value"); 
  353.    Inverted_Property : constant Glib.Properties.Property_Boolean := 
  354.      Glib.Properties.Build ("inverted"); 
  355. end Gtk.Level_Bar;