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. --  A Gtk.Expander.Gtk_Expander allows the user to hide or show its child by 
  26. --  clicking on an expander triangle similar to the triangles used in a 
  27. --  Gtk.Tree_View.Gtk_Tree_View. 
  28. -- 
  29. --  Normally you use an expander as you would use any other descendant of 
  30. --  Gtk.Bin.Gtk_Bin; you create the child widget and use Gtk.Container.Add to 
  31. --  add it to the expander. When the expander is toggled, it will take care of 
  32. --  showing and hiding the child automatically. 
  33. -- 
  34. --  == Special Usage == 
  35. -- 
  36. --  There are situations in which you may prefer to show and hide the expanded 
  37. --  widget yourself, such as when you want to actually create the widget at 
  38. --  expansion time. In this case, create a Gtk.Expander.Gtk_Expander but do not 
  39. --  add a child to it. The expander widget has an 
  40. --  Gtk.Expander.Gtk_Expander:expanded property which can be used to monitor 
  41. --  its expansion state. You should watch this property with a signal 
  42. --  connection as follows: 
  43. -- 
  44. --  <programlisting id="expander-callback-example"> expander = 
  45. --  gtk_expander_new_with_mnemonic ("_More Options"); g_signal_connect 
  46. --  (expander, "notify::expanded", G_CALLBACK (expander_callback), NULL); 
  47. --  ... 
  48. -- 
  49. --  static void expander_callback (GObject *object, GParamSpec *param_spec, 
  50. --  gpointer user_data) { GtkExpander *expander; 
  51. -- 
  52. --  expander = GTK_EXPANDER (object); 
  53. -- 
  54. --  if (gtk_expander_get_expanded (expander)) { /* Show or create widgets */ } 
  55. --  else { /* Hide or destroy widgets */ } } </programlisting> 
  56. -- 
  57. --  == GtkExpander as GtkBuildable == 
  58. -- 
  59. --  The GtkExpander implementation of the GtkBuildable interface supports 
  60. --  placing a child in the label position by specifying "label" as the "type" 
  61. --  attribute of a <child> element. A normal content child can be specified 
  62. --  without specifying a <child> type attribute. 
  63. -- 
  64. --  == A UI definition fragment with GtkExpander == 
  65. -- 
  66. --    <object class="GtkExpander"> 
  67. --    <child type="label"> 
  68. --    <object class="GtkLabel" id="expander-label"/> 
  69. --    </child> 
  70. --    <child> 
  71. --    <object class="GtkEntry" id="expander-content"/> 
  72. --    </child> 
  73. --    </object> 
  74. --  </description> 
  75. --  <screenshot>gtk-expanded</screenshot> 
  76. --  <group>Layout containers</group> 
  77. pragma Ada_2005; 
  78.  
  79. pragma Warnings (Off, "*is already use-visible*"); 
  80. with Glib;            use Glib; 
  81. with Glib.Object;     use Glib.Object; 
  82. with Glib.Properties; use Glib.Properties; 
  83. with Glib.Types;      use Glib.Types; 
  84. with Gtk.Bin;         use Gtk.Bin; 
  85. with Gtk.Buildable;   use Gtk.Buildable; 
  86. with Gtk.Widget;      use Gtk.Widget; 
  87.  
  88. package Gtk.Expander is 
  89.  
  90.    type Gtk_Expander_Record is new Gtk_Bin_Record with null record; 
  91.    type Gtk_Expander is access all Gtk_Expander_Record'Class; 
  92.  
  93.    ------------------ 
  94.    -- Constructors -- 
  95.    ------------------ 
  96.  
  97.    procedure Gtk_New (Expander : out Gtk_Expander; Label : UTF8_String); 
  98.    procedure Initialize 
  99.       (Expander : not null access Gtk_Expander_Record'Class; 
  100.        Label    : UTF8_String); 
  101.    --  Creates a new expander using Label as the text of the label. 
  102.    --  Since: gtk+ 2.4 
  103.    --  "label": the text of the label 
  104.  
  105.    function Gtk_Expander_New (Label : UTF8_String) return Gtk_Expander; 
  106.    --  Creates a new expander using Label as the text of the label. 
  107.    --  Since: gtk+ 2.4 
  108.    --  "label": the text of the label 
  109.  
  110.    procedure Gtk_New_With_Mnemonic 
  111.       (Expander : out Gtk_Expander; 
  112.        Label    : UTF8_String := ""); 
  113.    procedure Initialize_With_Mnemonic 
  114.       (Expander : not null access Gtk_Expander_Record'Class; 
  115.        Label    : UTF8_String := ""); 
  116.    --  Creates a new expander using Label as the text of the label. If 
  117.    --  characters in Label are preceded by an underscore, they are underlined. 
  118.    --  If you need a literal underscore character in a label, use '__' (two 
  119.    --  underscores). The first underlined character represents a keyboard 
  120.    --  accelerator called a mnemonic. Pressing Alt and that key activates the 
  121.    --  button. 
  122.    --  Since: gtk+ 2.4 
  123.    --  "label": the text of the label with an underscore in front of the 
  124.    --  mnemonic character 
  125.  
  126.    function Gtk_Expander_New_With_Mnemonic 
  127.       (Label : UTF8_String := "") return Gtk_Expander; 
  128.    --  Creates a new expander using Label as the text of the label. If 
  129.    --  characters in Label are preceded by an underscore, they are underlined. 
  130.    --  If you need a literal underscore character in a label, use '__' (two 
  131.    --  underscores). The first underlined character represents a keyboard 
  132.    --  accelerator called a mnemonic. Pressing Alt and that key activates the 
  133.    --  button. 
  134.    --  Since: gtk+ 2.4 
  135.    --  "label": the text of the label with an underscore in front of the 
  136.    --  mnemonic character 
  137.  
  138.    function Get_Type return Glib.GType; 
  139.    pragma Import (C, Get_Type, "gtk_expander_get_type"); 
  140.  
  141.    ------------- 
  142.    -- Methods -- 
  143.    ------------- 
  144.  
  145.    function Get_Expanded 
  146.       (Expander : not null access Gtk_Expander_Record) return Boolean; 
  147.    --  Queries a Gtk.Expander.Gtk_Expander and returns its current state. 
  148.    --  Returns True if the child widget is revealed. 
  149.    --  See Gtk.Expander.Set_Expanded. 
  150.    --  Since: gtk+ 2.4 
  151.  
  152.    procedure Set_Expanded 
  153.       (Expander : not null access Gtk_Expander_Record; 
  154.        Expanded : Boolean); 
  155.    --  Sets the state of the expander. Set to True, if you want the child 
  156.    --  widget to be revealed, and False if you want the child widget to be 
  157.    --  hidden. 
  158.    --  Since: gtk+ 2.4 
  159.    --  "expanded": whether the child widget is revealed 
  160.  
  161.    function Get_Label 
  162.       (Expander : not null access Gtk_Expander_Record) return UTF8_String; 
  163.    --  Fetches the text from a label widget including any embedded underlines 
  164.    --  indicating mnemonics and Pango markup, as set by Gtk.Expander.Set_Label. 
  165.    --  If the label text has not been set the return value will be null. This 
  166.    --  will be the case if you create an empty button with gtk_button_new to 
  167.    --  use as a container. 
  168.    --  Note that this function behaved differently in versions prior to 2.14 
  169.    --  and used to return the label text stripped of embedded underlines 
  170.    --  indicating mnemonics and Pango markup. This problem can be avoided by 
  171.    --  fetching the label text directly from the label widget. 
  172.    --  Since: gtk+ 2.4 
  173.  
  174.    procedure Set_Label 
  175.       (Expander : not null access Gtk_Expander_Record; 
  176.        Label    : UTF8_String := ""); 
  177.    --  Sets the text of the label of the expander to Label. 
  178.    --  This will also clear any previously set labels. 
  179.    --  Since: gtk+ 2.4 
  180.    --  "label": a string 
  181.  
  182.    function Get_Label_Fill 
  183.       (Expander : not null access Gtk_Expander_Record) return Boolean; 
  184.    --  Returns whether the label widget will fill all available horizontal 
  185.    --  space allocated to Expander. 
  186.    --  Since: gtk+ 2.22 
  187.  
  188.    procedure Set_Label_Fill 
  189.       (Expander   : not null access Gtk_Expander_Record; 
  190.        Label_Fill : Boolean); 
  191.    --  Sets whether the label widget should fill all available horizontal 
  192.    --  space allocated to Expander. 
  193.    --  Since: gtk+ 2.22 
  194.    --  "label_fill": True if the label should should fill all available 
  195.    --  horizontal space 
  196.  
  197.    function Get_Label_Widget 
  198.       (Expander : not null access Gtk_Expander_Record) 
  199.        return Gtk.Widget.Gtk_Widget; 
  200.    --  Retrieves the label widget for the frame. See 
  201.    --  Gtk.Expander.Set_Label_Widget. 
  202.    --  Since: gtk+ 2.4 
  203.  
  204.    procedure Set_Label_Widget 
  205.       (Expander     : not null access Gtk_Expander_Record; 
  206.        Label_Widget : access Gtk.Widget.Gtk_Widget_Record'Class); 
  207.    --  Set the label widget for the expander. This is the widget that will 
  208.    --  appear embedded alongside the expander arrow. 
  209.    --  Since: gtk+ 2.4 
  210.    --  "label_widget": the new label widget 
  211.  
  212.    function Get_Resize_Toplevel 
  213.       (Expander : not null access Gtk_Expander_Record) return Boolean; 
  214.    --  Returns whether the expander will resize the toplevel widget containing 
  215.    --  the expander upon resizing and collpasing. 
  216.    --  Since: gtk+ 3.2 
  217.  
  218.    procedure Set_Resize_Toplevel 
  219.       (Expander        : not null access Gtk_Expander_Record; 
  220.        Resize_Toplevel : Boolean); 
  221.    --  Sets whether the expander will resize the toplevel widget containing 
  222.    --  the expander upon resizing and collpasing. 
  223.    --  Since: gtk+ 3.2 
  224.    --  "resize_toplevel": whether to resize the toplevel 
  225.  
  226.    function Get_Spacing 
  227.       (Expander : not null access Gtk_Expander_Record) return Gint; 
  228.    --  Gets the value set by Gtk.Expander.Set_Spacing. 
  229.    --  Since: gtk+ 2.4 
  230.  
  231.    procedure Set_Spacing 
  232.       (Expander : not null access Gtk_Expander_Record; 
  233.        Spacing  : Gint); 
  234.    --  Sets the spacing field of Expander, which is the number of pixels to 
  235.    --  place between expander and the child. 
  236.    --  Since: gtk+ 2.4 
  237.    --  "spacing": distance between the expander and child in pixels 
  238.  
  239.    function Get_Use_Markup 
  240.       (Expander : not null access Gtk_Expander_Record) return Boolean; 
  241.    --  Returns whether the label's text is interpreted as marked up with the 
  242.    --  <link linkend="PangoMarkupFormat">Pango text markup language</link>. See 
  243.    --  Gtk.Expander.Set_Use_Markup. 
  244.    --  Since: gtk+ 2.4 
  245.  
  246.    procedure Set_Use_Markup 
  247.       (Expander   : not null access Gtk_Expander_Record; 
  248.        Use_Markup : Boolean); 
  249.    --  Sets whether the text of the label contains markup in <link 
  250.    --  linkend="PangoMarkupFormat">Pango's text markup language</link>. See 
  251.    --  Gtk.Label.Set_Markup. 
  252.    --  Since: gtk+ 2.4 
  253.    --  "use_markup": True if the label's text should be parsed for markup 
  254.  
  255.    function Get_Use_Underline 
  256.       (Expander : not null access Gtk_Expander_Record) return Boolean; 
  257.    --  Returns whether an embedded underline in the expander label indicates a 
  258.    --  mnemonic. See Gtk.Expander.Set_Use_Underline. 
  259.    --  Since: gtk+ 2.4 
  260.  
  261.    procedure Set_Use_Underline 
  262.       (Expander      : not null access Gtk_Expander_Record; 
  263.        Use_Underline : Boolean); 
  264.    --  If true, an underline in the text of the expander label indicates the 
  265.    --  next character should be used for the mnemonic accelerator key. 
  266.    --  Since: gtk+ 2.4 
  267.    --  "use_underline": True if underlines in the text indicate mnemonics 
  268.  
  269.    ---------------- 
  270.    -- Properties -- 
  271.    ---------------- 
  272.    --  The following properties are defined for this widget. See 
  273.    --  Glib.Properties for more information on properties) 
  274.  
  275.    Expanded_Property : constant Glib.Properties.Property_Boolean; 
  276.  
  277.    Label_Property : constant Glib.Properties.Property_String; 
  278.  
  279.    Label_Fill_Property : constant Glib.Properties.Property_Boolean; 
  280.  
  281.    Label_Widget_Property : constant Glib.Properties.Property_Object; 
  282.    --  Type: Gtk.Widget.Gtk_Widget 
  283.  
  284.    Resize_Toplevel_Property : constant Glib.Properties.Property_Boolean; 
  285.    --  When this property is True, the expander will resize the toplevel 
  286.    --  widget containing the expander upon expanding and collapsing. 
  287.  
  288.    Spacing_Property : constant Glib.Properties.Property_Int; 
  289.  
  290.    Use_Markup_Property : constant Glib.Properties.Property_Boolean; 
  291.  
  292.    Use_Underline_Property : constant Glib.Properties.Property_Boolean; 
  293.  
  294.    ------------- 
  295.    -- Signals -- 
  296.    ------------- 
  297.  
  298.    type Cb_Gtk_Expander_Void is not null access procedure (Self : access Gtk_Expander_Record'Class); 
  299.  
  300.    type Cb_GObject_Void is not null access procedure 
  301.      (Self : access Glib.Object.GObject_Record'Class); 
  302.  
  303.    Signal_Activate : constant Glib.Signal_Name := "activate"; 
  304.    procedure On_Activate 
  305.       (Self  : not null access Gtk_Expander_Record; 
  306.        Call  : Cb_Gtk_Expander_Void; 
  307.        After : Boolean := False); 
  308.    procedure On_Activate 
  309.       (Self  : not null access Gtk_Expander_Record; 
  310.        Call  : Cb_GObject_Void; 
  311.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  312.        After : Boolean := False); 
  313.  
  314.    ---------------- 
  315.    -- Interfaces -- 
  316.    ---------------- 
  317.    --  This class implements several interfaces. See Glib.Types 
  318.    -- 
  319.    --  - "Buildable" 
  320.  
  321.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  322.      (Gtk.Buildable.Gtk_Buildable, Gtk_Expander_Record, Gtk_Expander); 
  323.    function "+" 
  324.      (Widget : access Gtk_Expander_Record'Class) 
  325.    return Gtk.Buildable.Gtk_Buildable 
  326.    renames Implements_Gtk_Buildable.To_Interface; 
  327.    function "-" 
  328.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  329.    return Gtk_Expander 
  330.    renames Implements_Gtk_Buildable.To_Object; 
  331.  
  332. private 
  333.    Use_Underline_Property : constant Glib.Properties.Property_Boolean := 
  334.      Glib.Properties.Build ("use-underline"); 
  335.    Use_Markup_Property : constant Glib.Properties.Property_Boolean := 
  336.      Glib.Properties.Build ("use-markup"); 
  337.    Spacing_Property : constant Glib.Properties.Property_Int := 
  338.      Glib.Properties.Build ("spacing"); 
  339.    Resize_Toplevel_Property : constant Glib.Properties.Property_Boolean := 
  340.      Glib.Properties.Build ("resize-toplevel"); 
  341.    Label_Widget_Property : constant Glib.Properties.Property_Object := 
  342.      Glib.Properties.Build ("label-widget"); 
  343.    Label_Fill_Property : constant Glib.Properties.Property_Boolean := 
  344.      Glib.Properties.Build ("label-fill"); 
  345.    Label_Property : constant Glib.Properties.Property_String := 
  346.      Glib.Properties.Build ("label"); 
  347.    Expanded_Property : constant Glib.Properties.Property_Boolean := 
  348.      Glib.Properties.Build ("expanded"); 
  349. end Gtk.Expander;