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. --  Gtk.Scale_Button.Gtk_Scale_Button provides a button which pops up a scale 
  26. --  widget. This kind of widget is commonly used for volume controls in 
  27. --  multimedia applications, and GTK+ provides a 
  28. --  Gtk.Volume_Button.Gtk_Volume_Button subclass that is tailored for this use 
  29. --  case. 
  30. -- 
  31. --  </description> 
  32. pragma Ada_2005; 
  33.  
  34. pragma Warnings (Off, "*is already use-visible*"); 
  35. with GNAT.Strings;    use GNAT.Strings; 
  36. with Glib;            use Glib; 
  37. with Glib.Object;     use Glib.Object; 
  38. with Glib.Properties; use Glib.Properties; 
  39. with Glib.Types;      use Glib.Types; 
  40. with Glib.Variant;    use Glib.Variant; 
  41. with Gtk.Action;      use Gtk.Action; 
  42. with Gtk.Actionable;  use Gtk.Actionable; 
  43. with Gtk.Activatable; use Gtk.Activatable; 
  44. with Gtk.Adjustment;  use Gtk.Adjustment; 
  45. with Gtk.Buildable;   use Gtk.Buildable; 
  46. with Gtk.Button;      use Gtk.Button; 
  47. with Gtk.Enums;       use Gtk.Enums; 
  48. with Gtk.Orientable;  use Gtk.Orientable; 
  49. with Gtk.Widget;      use Gtk.Widget; 
  50.  
  51. package Gtk.Scale_Button is 
  52.  
  53.    type Gtk_Scale_Button_Record is new Gtk_Button_Record with null record; 
  54.    type Gtk_Scale_Button is access all Gtk_Scale_Button_Record'Class; 
  55.  
  56.    ------------------ 
  57.    -- Constructors -- 
  58.    ------------------ 
  59.  
  60.    procedure Gtk_New 
  61.       (Button : out Gtk_Scale_Button; 
  62.        Size   : Gtk.Enums.Gtk_Icon_Size; 
  63.        Min    : Gdouble; 
  64.        Max    : Gdouble; 
  65.        Step   : Gdouble; 
  66.        Icons  : GNAT.Strings.String_List); 
  67.    procedure Initialize 
  68.       (Button : not null access Gtk_Scale_Button_Record'Class; 
  69.        Size   : Gtk.Enums.Gtk_Icon_Size; 
  70.        Min    : Gdouble; 
  71.        Max    : Gdouble; 
  72.        Step   : Gdouble; 
  73.        Icons  : GNAT.Strings.String_List); 
  74.    --  Creates a Gtk.Scale_Button.Gtk_Scale_Button, with a range between Min 
  75.    --  and Max, with a stepping of Step. 
  76.    --  Since: gtk+ 2.12 
  77.    --  "size": a stock icon size 
  78.    --  "min": the minimum value of the scale (usually 0) 
  79.    --  "max": the maximum value of the scale (usually 100) 
  80.    --  "step": the stepping of value when a scroll-wheel event, or up/down 
  81.    --  arrow event occurs (usually 2) 
  82.    --  "icons": a null-terminated array of icon names, or null if you want to 
  83.    --  set the list later with Gtk.Scale_Button.Set_Icons 
  84.  
  85.    function Gtk_Scale_Button_New 
  86.       (Size  : Gtk.Enums.Gtk_Icon_Size; 
  87.        Min   : Gdouble; 
  88.        Max   : Gdouble; 
  89.        Step  : Gdouble; 
  90.        Icons : GNAT.Strings.String_List) return Gtk_Scale_Button; 
  91.    --  Creates a Gtk.Scale_Button.Gtk_Scale_Button, with a range between Min 
  92.    --  and Max, with a stepping of Step. 
  93.    --  Since: gtk+ 2.12 
  94.    --  "size": a stock icon size 
  95.    --  "min": the minimum value of the scale (usually 0) 
  96.    --  "max": the maximum value of the scale (usually 100) 
  97.    --  "step": the stepping of value when a scroll-wheel event, or up/down 
  98.    --  arrow event occurs (usually 2) 
  99.    --  "icons": a null-terminated array of icon names, or null if you want to 
  100.    --  set the list later with Gtk.Scale_Button.Set_Icons 
  101.  
  102.    function Get_Type return Glib.GType; 
  103.    pragma Import (C, Get_Type, "gtk_scale_button_get_type"); 
  104.  
  105.    ------------- 
  106.    -- Methods -- 
  107.    ------------- 
  108.  
  109.    function Get_Adjustment 
  110.       (Button : not null access Gtk_Scale_Button_Record) 
  111.        return Gtk.Adjustment.Gtk_Adjustment; 
  112.    --  Gets the Gtk.Adjustment.Gtk_Adjustment associated with the 
  113.    --  Gtk.Scale_Button.Gtk_Scale_Button's scale. See Gtk.GRange.Get_Adjustment 
  114.    --  for details. 
  115.    --  Since: gtk+ 2.12 
  116.  
  117.    procedure Set_Adjustment 
  118.       (Button     : not null access Gtk_Scale_Button_Record; 
  119.        Adjustment : not null access Gtk.Adjustment.Gtk_Adjustment_Record'Class); 
  120.    --  Sets the Gtk.Adjustment.Gtk_Adjustment to be used as a model for the 
  121.    --  Gtk.Scale_Button.Gtk_Scale_Button's scale. See Gtk.GRange.Set_Adjustment 
  122.    --  for details. 
  123.    --  Since: gtk+ 2.12 
  124.    --  "adjustment": a Gtk.Adjustment.Gtk_Adjustment 
  125.  
  126.    function Get_Minus_Button 
  127.       (Button : not null access Gtk_Scale_Button_Record) 
  128.        return Gtk.Widget.Gtk_Widget; 
  129.    --  Retrieves the minus button of the Gtk.Scale_Button.Gtk_Scale_Button. 
  130.    --  Since: gtk+ 2.14 
  131.  
  132.    function Get_Plus_Button 
  133.       (Button : not null access Gtk_Scale_Button_Record) 
  134.        return Gtk.Widget.Gtk_Widget; 
  135.    --  Retrieves the plus button of the Gtk.Scale_Button.Gtk_Scale_Button. 
  136.    --  Since: gtk+ 2.14 
  137.  
  138.    function Get_Popup 
  139.       (Button : not null access Gtk_Scale_Button_Record) 
  140.        return Gtk.Widget.Gtk_Widget; 
  141.    --  Retrieves the popup of the Gtk.Scale_Button.Gtk_Scale_Button. 
  142.    --  Since: gtk+ 2.14 
  143.  
  144.    function Get_Value 
  145.       (Button : not null access Gtk_Scale_Button_Record) return Gdouble; 
  146.    --  Gets the current value of the scale button. 
  147.    --  Since: gtk+ 2.12 
  148.  
  149.    procedure Set_Value 
  150.       (Button : not null access Gtk_Scale_Button_Record; 
  151.        Value  : Gdouble); 
  152.    --  Sets the current value of the scale; if the value is outside the 
  153.    --  minimum or maximum range values, it will be clamped to fit inside them. 
  154.    --  The scale button emits the 
  155.    --  Gtk.Scale_Button.Gtk_Scale_Button::value-changed signal if the value 
  156.    --  changes. 
  157.    --  Since: gtk+ 2.12 
  158.    --  "value": new value of the scale button 
  159.  
  160.    procedure Set_Icons 
  161.       (Button : not null access Gtk_Scale_Button_Record; 
  162.        Icons  : GNAT.Strings.String_List); 
  163.    --  Sets the icons to be used by the scale button. For details, see the 
  164.    --  Gtk.Scale_Button.Gtk_Scale_Button:icons property. 
  165.    --  Since: gtk+ 2.12 
  166.    --  "icons": a null-terminated array of icon names 
  167.  
  168.    --------------------------------------------- 
  169.    -- Inherited subprograms (from interfaces) -- 
  170.    --------------------------------------------- 
  171.    --  Methods inherited from the Buildable interface are not duplicated here 
  172.    --  since they are meant to be used by tools, mostly. If you need to call 
  173.    --  them, use an explicit cast through the "-" operator below. 
  174.  
  175.    function Get_Action_Name 
  176.       (Self : not null access Gtk_Scale_Button_Record) return UTF8_String; 
  177.  
  178.    procedure Set_Action_Name 
  179.       (Self        : not null access Gtk_Scale_Button_Record; 
  180.        Action_Name : UTF8_String); 
  181.  
  182.    function Get_Action_Target_Value 
  183.       (Self : not null access Gtk_Scale_Button_Record) 
  184.        return Glib.Variant.Gvariant; 
  185.  
  186.    procedure Set_Action_Target_Value 
  187.       (Self         : not null access Gtk_Scale_Button_Record; 
  188.        Target_Value : Glib.Variant.Gvariant); 
  189.  
  190.    procedure Set_Detailed_Action_Name 
  191.       (Self                 : not null access Gtk_Scale_Button_Record; 
  192.        Detailed_Action_Name : UTF8_String); 
  193.  
  194.    procedure Do_Set_Related_Action 
  195.       (Self   : not null access Gtk_Scale_Button_Record; 
  196.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  197.  
  198.    function Get_Related_Action 
  199.       (Self : not null access Gtk_Scale_Button_Record) 
  200.        return Gtk.Action.Gtk_Action; 
  201.  
  202.    procedure Set_Related_Action 
  203.       (Self   : not null access Gtk_Scale_Button_Record; 
  204.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  205.  
  206.    function Get_Use_Action_Appearance 
  207.       (Self : not null access Gtk_Scale_Button_Record) return Boolean; 
  208.  
  209.    procedure Set_Use_Action_Appearance 
  210.       (Self           : not null access Gtk_Scale_Button_Record; 
  211.        Use_Appearance : Boolean); 
  212.  
  213.    procedure Sync_Action_Properties 
  214.       (Self   : not null access Gtk_Scale_Button_Record; 
  215.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  216.  
  217.    function Get_Orientation 
  218.       (Self : not null access Gtk_Scale_Button_Record) 
  219.        return Gtk.Enums.Gtk_Orientation; 
  220.  
  221.    procedure Set_Orientation 
  222.       (Self        : not null access Gtk_Scale_Button_Record; 
  223.        Orientation : Gtk.Enums.Gtk_Orientation); 
  224.  
  225.    ---------------- 
  226.    -- Properties -- 
  227.    ---------------- 
  228.    --  The following properties are defined for this widget. See 
  229.    --  Glib.Properties for more information on properties) 
  230.  
  231.    Icons_Property : constant Glib.Properties.Property_String := 
  232.    Glib.Properties.Build ("icons");--  Unknown type: unspecified 
  233.  
  234.    Adjustment_Property : constant Glib.Properties.Property_Object; 
  235.    --  Type: Gtk.Adjustment.Gtk_Adjustment 
  236.  
  237.    Size_Property : constant Gtk.Enums.Property_Gtk_Icon_Size; 
  238.  
  239.    Value_Property : constant Glib.Properties.Property_Double; 
  240.    --  Type: Gdouble 
  241.  
  242.    ------------- 
  243.    -- Signals -- 
  244.    ------------- 
  245.  
  246.    type Cb_Gtk_Scale_Button_Void is not null access procedure 
  247.      (Self : access Gtk_Scale_Button_Record'Class); 
  248.  
  249.    type Cb_GObject_Void is not null access procedure 
  250.      (Self : access Glib.Object.GObject_Record'Class); 
  251.  
  252.    Signal_Popdown : constant Glib.Signal_Name := "popdown"; 
  253.    procedure On_Popdown 
  254.       (Self  : not null access Gtk_Scale_Button_Record; 
  255.        Call  : Cb_Gtk_Scale_Button_Void; 
  256.        After : Boolean := False); 
  257.    procedure On_Popdown 
  258.       (Self  : not null access Gtk_Scale_Button_Record; 
  259.        Call  : Cb_GObject_Void; 
  260.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  261.        After : Boolean := False); 
  262.    --  The ::popdown signal is a <link linkend="keybinding-signals">keybinding 
  263.    --  signal</link> which gets emitted to popdown the scale widget. 
  264.    -- 
  265.    --  The default binding for this signal is Escape. 
  266.  
  267.    Signal_Popup : constant Glib.Signal_Name := "popup"; 
  268.    procedure On_Popup 
  269.       (Self  : not null access Gtk_Scale_Button_Record; 
  270.        Call  : Cb_Gtk_Scale_Button_Void; 
  271.        After : Boolean := False); 
  272.    procedure On_Popup 
  273.       (Self  : not null access Gtk_Scale_Button_Record; 
  274.        Call  : Cb_GObject_Void; 
  275.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  276.        After : Boolean := False); 
  277.    --  The ::popup signal is a <link linkend="keybinding-signals">keybinding 
  278.    --  signal</link> which gets emitted to popup the scale widget. 
  279.    -- 
  280.    --  The default bindings for this signal are Space, Enter and Return. 
  281.  
  282.    type Cb_Gtk_Scale_Button_Gdouble_Void is not null access procedure 
  283.      (Self  : access Gtk_Scale_Button_Record'Class; 
  284.       Value : Gdouble); 
  285.  
  286.    type Cb_GObject_Gdouble_Void is not null access procedure 
  287.      (Self  : access Glib.Object.GObject_Record'Class; 
  288.       Value : Gdouble); 
  289.  
  290.    Signal_Value_Changed : constant Glib.Signal_Name := "value-changed"; 
  291.    procedure On_Value_Changed 
  292.       (Self  : not null access Gtk_Scale_Button_Record; 
  293.        Call  : Cb_Gtk_Scale_Button_Gdouble_Void; 
  294.        After : Boolean := False); 
  295.    procedure On_Value_Changed 
  296.       (Self  : not null access Gtk_Scale_Button_Record; 
  297.        Call  : Cb_GObject_Gdouble_Void; 
  298.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  299.        After : Boolean := False); 
  300.    --  The ::value-changed signal is emitted when the value field has changed. 
  301.  
  302.    ---------------- 
  303.    -- Interfaces -- 
  304.    ---------------- 
  305.    --  This class implements several interfaces. See Glib.Types 
  306.    -- 
  307.    --  - "Actionable" 
  308.    -- 
  309.    --  - "Activatable" 
  310.    -- 
  311.    --  - "Buildable" 
  312.    -- 
  313.    --  - "Orientable" 
  314.  
  315.    package Implements_Gtk_Actionable is new Glib.Types.Implements 
  316.      (Gtk.Actionable.Gtk_Actionable, Gtk_Scale_Button_Record, Gtk_Scale_Button); 
  317.    function "+" 
  318.      (Widget : access Gtk_Scale_Button_Record'Class) 
  319.    return Gtk.Actionable.Gtk_Actionable 
  320.    renames Implements_Gtk_Actionable.To_Interface; 
  321.    function "-" 
  322.      (Interf : Gtk.Actionable.Gtk_Actionable) 
  323.    return Gtk_Scale_Button 
  324.    renames Implements_Gtk_Actionable.To_Object; 
  325.  
  326.    package Implements_Gtk_Activatable is new Glib.Types.Implements 
  327.      (Gtk.Activatable.Gtk_Activatable, Gtk_Scale_Button_Record, Gtk_Scale_Button); 
  328.    function "+" 
  329.      (Widget : access Gtk_Scale_Button_Record'Class) 
  330.    return Gtk.Activatable.Gtk_Activatable 
  331.    renames Implements_Gtk_Activatable.To_Interface; 
  332.    function "-" 
  333.      (Interf : Gtk.Activatable.Gtk_Activatable) 
  334.    return Gtk_Scale_Button 
  335.    renames Implements_Gtk_Activatable.To_Object; 
  336.  
  337.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  338.      (Gtk.Buildable.Gtk_Buildable, Gtk_Scale_Button_Record, Gtk_Scale_Button); 
  339.    function "+" 
  340.      (Widget : access Gtk_Scale_Button_Record'Class) 
  341.    return Gtk.Buildable.Gtk_Buildable 
  342.    renames Implements_Gtk_Buildable.To_Interface; 
  343.    function "-" 
  344.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  345.    return Gtk_Scale_Button 
  346.    renames Implements_Gtk_Buildable.To_Object; 
  347.  
  348.    package Implements_Gtk_Orientable is new Glib.Types.Implements 
  349.      (Gtk.Orientable.Gtk_Orientable, Gtk_Scale_Button_Record, Gtk_Scale_Button); 
  350.    function "+" 
  351.      (Widget : access Gtk_Scale_Button_Record'Class) 
  352.    return Gtk.Orientable.Gtk_Orientable 
  353.    renames Implements_Gtk_Orientable.To_Interface; 
  354.    function "-" 
  355.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  356.    return Gtk_Scale_Button 
  357.    renames Implements_Gtk_Orientable.To_Object; 
  358.  
  359. private 
  360.    Value_Property : constant Glib.Properties.Property_Double := 
  361.      Glib.Properties.Build ("value"); 
  362.    Size_Property : constant Gtk.Enums.Property_Gtk_Icon_Size := 
  363.      Gtk.Enums.Build ("size"); 
  364.    Adjustment_Property : constant Glib.Properties.Property_Object := 
  365.      Glib.Properties.Build ("adjustment"); 
  366. end Gtk.Scale_Button;