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.Progress_Bar.Gtk_Progress_Bar is typically used to display the 
  26. --  progress of a long running operation. It provides a visual clue that 
  27. --  processing is underway. The Gtk.Progress_Bar.Gtk_Progress_Bar can be used 
  28. --  in two different modes: percentage mode and activity mode. 
  29. -- 
  30. --  When an application can determine how much work needs to take place (e.g. 
  31. --  read a fixed number of bytes from a file) and can monitor its progress, it 
  32. --  can use the Gtk.Progress_Bar.Gtk_Progress_Bar in percentage mode and the 
  33. --  user sees a growing bar indicating the percentage of the work that has been 
  34. --  completed. In this mode, the application is required to call 
  35. --  Gtk.Progress_Bar.Set_Fraction periodically to update the progress bar. 
  36. -- 
  37. --  When an application has no accurate way of knowing the amount of work to 
  38. --  do, it can use the Gtk.Progress_Bar.Gtk_Progress_Bar in activity mode, 
  39. --  which shows activity by a block moving back and forth within the progress 
  40. --  area. In this mode, the application is required to call 
  41. --  Gtk.Progress_Bar.Pulse periodically to update the progress bar. 
  42. -- 
  43. --  There is quite a bit of flexibility provided to control the appearance of 
  44. --  the Gtk.Progress_Bar.Gtk_Progress_Bar. Functions are provided to control 
  45. --  the orientation of the bar, optional text can be displayed along with the 
  46. --  bar, and the step size used in activity mode can be set. 
  47. -- 
  48. --  </description> 
  49. --  <screenshot>gtk-progress_bar</screenshot> 
  50. --  <group>Display widgets</group> 
  51. --  <testgtk>create_progress.adb</testgtk> 
  52. pragma Ada_2005; 
  53.  
  54. pragma Warnings (Off, "*is already use-visible*"); 
  55. with Glib;            use Glib; 
  56. with Glib.Properties; use Glib.Properties; 
  57. with Glib.Types;      use Glib.Types; 
  58. with Gtk.Buildable;   use Gtk.Buildable; 
  59. with Gtk.Enums;       use Gtk.Enums; 
  60. with Gtk.Orientable;  use Gtk.Orientable; 
  61. with Gtk.Widget;      use Gtk.Widget; 
  62. with Pango.Layout;    use Pango.Layout; 
  63.  
  64. package Gtk.Progress_Bar is 
  65.  
  66.    type Gtk_Progress_Bar_Record is new Gtk_Widget_Record with null record; 
  67.    type Gtk_Progress_Bar is access all Gtk_Progress_Bar_Record'Class; 
  68.  
  69.    ------------------ 
  70.    -- Constructors -- 
  71.    ------------------ 
  72.  
  73.    procedure Gtk_New (Progress_Bar : out Gtk_Progress_Bar); 
  74.    procedure Initialize 
  75.       (Progress_Bar : not null access Gtk_Progress_Bar_Record'Class); 
  76.    --  Creates a new Gtk.Progress_Bar.Gtk_Progress_Bar. 
  77.  
  78.    function Gtk_Progress_Bar_New return Gtk_Progress_Bar; 
  79.    --  Creates a new Gtk.Progress_Bar.Gtk_Progress_Bar. 
  80.  
  81.    function Get_Type return Glib.GType; 
  82.    pragma Import (C, Get_Type, "gtk_progress_bar_get_type"); 
  83.  
  84.    ------------- 
  85.    -- Methods -- 
  86.    ------------- 
  87.  
  88.    function Get_Ellipsize 
  89.       (Progress_Bar : not null access Gtk_Progress_Bar_Record) 
  90.        return Pango.Layout.Pango_Ellipsize_Mode; 
  91.    --  Returns the ellipsizing position of the progress bar. See 
  92.    --  Gtk.Progress_Bar.Set_Ellipsize. 
  93.    --  Since: gtk+ 2.6 
  94.  
  95.    procedure Set_Ellipsize 
  96.       (Progress_Bar : not null access Gtk_Progress_Bar_Record; 
  97.        Mode         : Pango.Layout.Pango_Ellipsize_Mode); 
  98.    --  Sets the mode used to ellipsize (add an ellipsis: "...") the text if 
  99.    --  there is not enough space to render the entire string. 
  100.    --  Since: gtk+ 2.6 
  101.    --  "mode": a Pango.Layout.Pango_Ellipsize_Mode 
  102.  
  103.    function Get_Fraction 
  104.       (Progress_Bar : not null access Gtk_Progress_Bar_Record) 
  105.        return Gdouble; 
  106.    --  Returns the current fraction of the task that's been completed. 
  107.  
  108.    procedure Set_Fraction 
  109.       (Progress_Bar : not null access Gtk_Progress_Bar_Record; 
  110.        Fraction     : Gdouble); 
  111.    --  Causes the progress bar to "fill in" the given fraction of the bar. The 
  112.    --  fraction should be between 0.0 and 1.0, inclusive. 
  113.    --  "fraction": fraction of the task that's been completed 
  114.  
  115.    function Get_Inverted 
  116.       (Progress_Bar : not null access Gtk_Progress_Bar_Record) 
  117.        return Boolean; 
  118.    --  Gets the value set by Gtk.Progress_Bar.Set_Inverted. 
  119.  
  120.    procedure Set_Inverted 
  121.       (Progress_Bar : not null access Gtk_Progress_Bar_Record; 
  122.        Inverted     : Boolean); 
  123.    --  Progress bars normally grow from top to bottom or left to right. 
  124.    --  Inverted progress bars grow in the opposite direction. 
  125.    --  "inverted": True to invert the progress bar 
  126.  
  127.    function Get_Pulse_Step 
  128.       (Progress_Bar : not null access Gtk_Progress_Bar_Record) 
  129.        return Gdouble; 
  130.    --  Retrieves the pulse step set with Gtk.Progress_Bar.Set_Pulse_Step. 
  131.  
  132.    procedure Set_Pulse_Step 
  133.       (Progress_Bar : not null access Gtk_Progress_Bar_Record; 
  134.        Fraction     : Gdouble); 
  135.    --  Sets the fraction of total progress bar length to move the bouncing 
  136.    --  block for each call to Gtk.Progress_Bar.Pulse. 
  137.    --  "fraction": fraction between 0.0 and 1.0 
  138.  
  139.    function Get_Show_Text 
  140.       (Progress_Bar : not null access Gtk_Progress_Bar_Record) 
  141.        return Boolean; 
  142.    --  Gets the value of the Gtk.Progress_Bar.Gtk_Progress_Bar:show-text 
  143.    --  property. See Gtk.Progress_Bar.Set_Show_Text. 
  144.    --  Since: gtk+ 3.0 
  145.  
  146.    procedure Set_Show_Text 
  147.       (Progress_Bar : not null access Gtk_Progress_Bar_Record; 
  148.        Show_Text    : Boolean); 
  149.    --  Sets whether the progress bar will show text superimposed over the bar. 
  150.    --  The shown text is either the value of the 
  151.    --  Gtk.Progress_Bar.Gtk_Progress_Bar:text property or, if that is null, the 
  152.    --  Gtk.Progress_Bar.Gtk_Progress_Bar:fraction value, as a percentage. 
  153.    --  To make a progress bar that is styled and sized suitably for containing 
  154.    --  text (even if the actual text is blank), set 
  155.    --  Gtk.Progress_Bar.Gtk_Progress_Bar:show-text to True and 
  156.    --  Gtk.Progress_Bar.Gtk_Progress_Bar:text to the empty string (not null). 
  157.    --  Since: gtk+ 3.0 
  158.    --  "show_text": whether to show superimposed text 
  159.  
  160.    function Get_Text 
  161.       (Progress_Bar : not null access Gtk_Progress_Bar_Record) 
  162.        return UTF8_String; 
  163.    --  Retrieves the text displayed superimposed on the progress bar, if any, 
  164.    --  otherwise null. The return value is a reference to the text, not a copy 
  165.    --  of it, so will become invalid if you change the text in the progress 
  166.    --  bar. 
  167.  
  168.    procedure Set_Text 
  169.       (Progress_Bar : not null access Gtk_Progress_Bar_Record; 
  170.        Text         : UTF8_String := ""); 
  171.    --  Causes the given Text to appear superimposed on the progress bar. 
  172.    --  If Text is null and Gtk.Progress_Bar.Gtk_Progress_Bar:show-text is 
  173.    --  True, the current value of Gtk.Progress_Bar.Gtk_Progress_Bar:fraction 
  174.    --  will be displayed as a percentage. 
  175.    --  If Text is non-null and Gtk.Progress_Bar.Gtk_Progress_Bar:show-text is 
  176.    --  True, the text will be displayed. In this case, it will not display the 
  177.    --  progress percentage. If Text is the empty string, the progress bar will 
  178.    --  still be styled and sized suitably for containing text, as long as 
  179.    --  Gtk.Progress_Bar.Gtk_Progress_Bar:show-text is True. 
  180.    --  "text": a UTF-8 string, or null 
  181.  
  182.    procedure Pulse (Progress_Bar : not null access Gtk_Progress_Bar_Record); 
  183.    --  Indicates that some progress has been made, but you don't know how 
  184.    --  much. Causes the progress bar to enter "activity mode," where a block 
  185.    --  bounces back and forth. Each call to Gtk.Progress_Bar.Pulse causes the 
  186.    --  block to move by a little bit (the amount of movement per pulse is 
  187.    --  determined by Gtk.Progress_Bar.Set_Pulse_Step). 
  188.  
  189.    --------------------------------------------- 
  190.    -- Inherited subprograms (from interfaces) -- 
  191.    --------------------------------------------- 
  192.    --  Methods inherited from the Buildable interface are not duplicated here 
  193.    --  since they are meant to be used by tools, mostly. If you need to call 
  194.    --  them, use an explicit cast through the "-" operator below. 
  195.  
  196.    function Get_Orientation 
  197.       (Self : not null access Gtk_Progress_Bar_Record) 
  198.        return Gtk.Enums.Gtk_Orientation; 
  199.  
  200.    procedure Set_Orientation 
  201.       (Self        : not null access Gtk_Progress_Bar_Record; 
  202.        Orientation : Gtk.Enums.Gtk_Orientation); 
  203.  
  204.    ---------------- 
  205.    -- Properties -- 
  206.    ---------------- 
  207.    --  The following properties are defined for this widget. See 
  208.    --  Glib.Properties for more information on properties) 
  209.  
  210.    Ellipsize_Property : constant Pango.Layout.Property_Pango_Ellipsize_Mode; 
  211.    --  Type: Pango.Layout.Pango_Ellipsize_Mode 
  212.    --  The preferred place to ellipsize the string, if the progress bar does 
  213.    --  not have enough room to display the entire string, specified as a 
  214.    --  Pango.Layout.Pango_Ellipsize_Mode. 
  215.    -- 
  216.    --  Note that setting this property to a value other than 
  217.    --  Pango.Layout.Ellipsize_None has the side-effect that the progress bar 
  218.    --  requests only enough space to display the ellipsis ("..."). Another 
  219.    --  means to set a progress bar's width is Gtk.Widget.Set_Size_Request. 
  220.  
  221.    Fraction_Property : constant Glib.Properties.Property_Double; 
  222.    --  Type: Gdouble 
  223.  
  224.    Inverted_Property : constant Glib.Properties.Property_Boolean; 
  225.  
  226.    Pulse_Step_Property : constant Glib.Properties.Property_Double; 
  227.    --  Type: Gdouble 
  228.  
  229.    Show_Text_Property : constant Glib.Properties.Property_Boolean; 
  230.    --  Sets whether the progress bar will show text superimposed over the bar. 
  231.    --  The shown text is either the value of the 
  232.    --  Gtk.Progress_Bar.Gtk_Progress_Bar:text property or, if that is null, the 
  233.    --  Gtk.Progress_Bar.Gtk_Progress_Bar:fraction value, as a percentage. 
  234.    -- 
  235.    --  To make a progress bar that is styled and sized suitably for containing 
  236.    --  text (even if the actual text is blank), set 
  237.    --  Gtk.Progress_Bar.Gtk_Progress_Bar:show-text to True and 
  238.    --  Gtk.Progress_Bar.Gtk_Progress_Bar:text to the empty string (not null). 
  239.  
  240.    Text_Property : constant Glib.Properties.Property_String; 
  241.  
  242.    ---------------- 
  243.    -- Interfaces -- 
  244.    ---------------- 
  245.    --  This class implements several interfaces. See Glib.Types 
  246.    -- 
  247.    --  - "Buildable" 
  248.    -- 
  249.    --  - "Orientable" 
  250.  
  251.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  252.      (Gtk.Buildable.Gtk_Buildable, Gtk_Progress_Bar_Record, Gtk_Progress_Bar); 
  253.    function "+" 
  254.      (Widget : access Gtk_Progress_Bar_Record'Class) 
  255.    return Gtk.Buildable.Gtk_Buildable 
  256.    renames Implements_Gtk_Buildable.To_Interface; 
  257.    function "-" 
  258.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  259.    return Gtk_Progress_Bar 
  260.    renames Implements_Gtk_Buildable.To_Object; 
  261.  
  262.    package Implements_Gtk_Orientable is new Glib.Types.Implements 
  263.      (Gtk.Orientable.Gtk_Orientable, Gtk_Progress_Bar_Record, Gtk_Progress_Bar); 
  264.    function "+" 
  265.      (Widget : access Gtk_Progress_Bar_Record'Class) 
  266.    return Gtk.Orientable.Gtk_Orientable 
  267.    renames Implements_Gtk_Orientable.To_Interface; 
  268.    function "-" 
  269.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  270.    return Gtk_Progress_Bar 
  271.    renames Implements_Gtk_Orientable.To_Object; 
  272.  
  273. private 
  274.    Text_Property : constant Glib.Properties.Property_String := 
  275.      Glib.Properties.Build ("text"); 
  276.    Show_Text_Property : constant Glib.Properties.Property_Boolean := 
  277.      Glib.Properties.Build ("show-text"); 
  278.    Pulse_Step_Property : constant Glib.Properties.Property_Double := 
  279.      Glib.Properties.Build ("pulse-step"); 
  280.    Inverted_Property : constant Glib.Properties.Property_Boolean := 
  281.      Glib.Properties.Build ("inverted"); 
  282.    Fraction_Property : constant Glib.Properties.Property_Double := 
  283.      Glib.Properties.Build ("fraction"); 
  284.    Ellipsize_Property : constant Pango.Layout.Property_Pango_Ellipsize_Mode := 
  285.      Pango.Layout.Build ("ellipsize"); 
  286. end Gtk.Progress_Bar;