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-2006 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. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  The Gtk_Combo widget consists of a single-line text entry field and a 
  27. --  drop-down list. The drop-down list is displayed when the user clicks on a 
  28. --  small arrow button to the right of the entry field. 
  29. -- 
  30. --  The drop-down list is a Gtk_List widget and can be accessed using the list 
  31. --  member of the Gtk_Combo. List elements can contain arbitrary widgets, but 
  32. --  if an element is not a plain label, then you must use the 
  33. --  Gtk_List.Set_Item_String function. This sets the string which will be 
  34. --  placed in the text entry field when the item is selected. 
  35. -- 
  36. --  By default, the user can step through the items in the list using the arrow 
  37. --  (cursor) keys, though this behaviour can be turned off with Set_Use_Arrows. 
  38. -- 
  39. --  Normally the arrow keys are only active when the contents of the text entry 
  40. --  field matches one of the items in the list. If the contents of the entry 
  41. --  field do not match any of the list items, then pressing the arrow keys does 
  42. --  nothing. However, by calling Set_Use_Arrows_Always you can specify that the 
  43. --  arrow keys are always active. If the contents of the entry field does not 
  44. --  match any of the items in the list, then pressing the up or down arrow key 
  45. --  will set the entry field to the last or first item in the list, 
  46. --  respectively. 
  47. --  </description> 
  48. --  <c_version>2.8.17</c_version> 
  49. --  <group>Obsolescent widgets</group> 
  50. --  <screenshot>gtk-combo</screenshot> 
  51. --  <see>Gtk.Combo_Box</see> 
  52.  
  53. with Glib.Properties; 
  54. with Gtk.GEntry; 
  55. pragma Warnings (Off);  --  Gtk.List is obsolescent 
  56. with Gtk.List; 
  57. pragma Warnings (On); 
  58. with Gtk.Box; 
  59. with Gtk.Item; 
  60. with Gtk.Window; 
  61. with Gtk.Enums; use Gtk.Enums; 
  62.  
  63. package Gtk.Combo is 
  64.    pragma Obsolescent; 
  65.  
  66.    type Gtk_Combo_Record is new Gtk.Box.Gtk_Box_Record with private; 
  67.    type Gtk_Combo is access all Gtk_Combo_Record'Class; 
  68.  
  69.    procedure Gtk_New (Combo_Box : out Gtk_Combo); 
  70.    --  Create a new Gtk_Combo. 
  71.  
  72.    procedure Initialize (Combo_Box : access Gtk_Combo_Record'Class); 
  73.    --  Internal initialization function. 
  74.    --  See the section "Creating your own widgets" in the documentation. 
  75.  
  76.    function Get_Type return Gtk.Gtk_Type; 
  77.    --  Return the internal value associated with a Gtk_Combo. 
  78.  
  79.    procedure Set_Value_In_List 
  80.      (Combo_Box   : access Gtk_Combo_Record; 
  81.       Val         : Boolean := True; 
  82.       Ok_If_Empty : Boolean := False); 
  83.    --  Specify whether the value entered in the text entry field must match one 
  84.    --  of the values in the list. If this is set then the user will not be able 
  85.    --  to perform any other action until a valid value has been entered. 
  86.    --  If an empty field is acceptable, the Ok_If_Empty parameter should be 
  87.    --  True. 
  88.    --  If the value entered must match one of the values in the list, val 
  89.    --  should be True. 
  90.  
  91.    procedure Set_Use_Arrows 
  92.      (Combo_Box : access Gtk_Combo_Record; Val : Boolean := True); 
  93.    --  Specify if the arrow (cursor) keys can be used to step through the 
  94.    --  items in the list. This is on by default. 
  95.  
  96.    procedure Set_Use_Arrows_Always 
  97.      (Combo_Box : access Gtk_Combo_Record; Val : Boolean := True); 
  98.    --  Specify if the arrow keys will still work even if the current contents 
  99.    --  of the Gtk_Entry field do not match any of the list items. 
  100.  
  101.    procedure Set_Case_Sensitive 
  102.      (Combo_Box : access Gtk_Combo_Record; Val : Boolean := True); 
  103.    --  Specify whether the text entered into the Gtk_Entry field and the text 
  104.    --  in the list items are case sensitive. 
  105.    --  This may be useful, for example, when you have called Set_Value_In_List 
  106.    --  to limit the values entered, but you are not worried about differences 
  107.    --  in case. 
  108.  
  109.    procedure Set_Item_String 
  110.      (Combo_Box  : access Gtk_Combo_Record; 
  111.       Item       : Gtk.Item.Gtk_Item; 
  112.       Item_Value : UTF8_String); 
  113.    --  Set the string to place in the Gtk_Entry field when a particular list 
  114.    --  item is selected. This is needed if the list item is not a simple label. 
  115.  
  116.    procedure Set_Popdown_Strings 
  117.      (Combo_Box : access Gtk_Combo_Record; 
  118.       Strings   : String_List.Glist); 
  119.    --  Set all the items in the popup list. 
  120.  
  121.    procedure Disable_Activate (Combo_Box : access Gtk_Combo_Record); 
  122.    --  Disable the standard handler for the <return> key in the entry field. 
  123.    --  The default behavior is to popdown the combo box list, so that the user 
  124.    --  can choose from it. However, if you want to add your own callback 
  125.    --  for the return key, you need to call this subprogram, and connect 
  126.    --  a handler to the "activate" signal for the entry. 
  127.  
  128.    procedure Set_Entry 
  129.      (Combo_Box : access Gtk_Combo_Record; 
  130.       GEntry    : Gtk.GEntry.Gtk_Entry); 
  131.    function Get_Entry 
  132.      (Combo_Box : access Gtk_Combo_Record) return Gtk.GEntry.Gtk_Entry; 
  133.    --  Set the entry field for the combo box. 
  134.  
  135.    pragma Warnings (Off); --  Gtk_List is obsolescent 
  136.    function Get_List 
  137.      (Combo_Box : access Gtk_Combo_Record) return Gtk.List.Gtk_List; 
  138.    --  Return the list of items associated with a Combo_Box. 
  139.    --  Add (Gtk.Container.Add) Gtk_List_Items to this list to insert new 
  140.    --  entries in the popdown menu. 
  141.    pragma Warnings (On); 
  142.  
  143.    function Get_Popup_Window 
  144.      (Combo_Box : access Gtk_Combo_Record) return Gtk.Window.Gtk_Window; 
  145.    --  Return the popup window associated with a Combo_Box. 
  146.  
  147.    ---------------- 
  148.    -- Properties -- 
  149.    ---------------- 
  150.  
  151.    --  <properties> 
  152.    --  The following properties are defined for this widget. See 
  153.    --  Glib.Properties for more information on properties. 
  154.    -- 
  155.    --  Name:  Enable_Arrow_Keys_Property 
  156.    --  Type:  Boolean 
  157.    --  Flags: read-write 
  158.    --  Descr: Whether the arrow keys move through the list of items 
  159.    --  See also:  Set_Use_Arrows 
  160.    -- 
  161.    --  Name:  Enable_Arrow_Always_Property 
  162.    --  Type:  Boolean 
  163.    --  Flags: read-write 
  164.    --  Descr: Whether the arrow keys work, even if the entry contents are 
  165.    --         not in the list 
  166.    --  See also:  Set_Use_Arrows_Always 
  167.    -- 
  168.    --  Name:  Case_Sensitive_Property 
  169.    --  Type:  Boolean 
  170.    --  Flags: read-write 
  171.    --  Descr: Whether list item matching is case sensitive 
  172.    --  See also:  Set_Case_Sensitive 
  173.    -- 
  174.    --  Name:  Allow_Empty_Property 
  175.    --  Type:  Boolean 
  176.    --  Descr: Whether an empty value may be entered in this field 
  177.    -- 
  178.    --  Name:  Enable_Arrows_Always_Property 
  179.    --  Type:  Boolean 
  180.    --  Descr: Obsolete property, ignored 
  181.    -- 
  182.    --  Name:  Value_In_List_Property 
  183.    --  Type:  Boolean 
  184.    --  Descr: Whether entered values must already be present in the list 
  185.    -- 
  186.    --  </properties> 
  187.  
  188.    Enable_Arrow_Keys_Property    : constant Glib.Properties.Property_Boolean; 
  189.    Enable_Arrow_Always_Property  : constant Glib.Properties.Property_Boolean; 
  190.    Case_Sensitive_Property       : constant Glib.Properties.Property_Boolean; 
  191.    Allow_Empty_Property          : constant Glib.Properties.Property_Boolean; 
  192.    Enable_Arrows_Always_Property : constant Glib.Properties.Property_Boolean; 
  193.    Value_In_List_Property        : constant Glib.Properties.Property_Boolean; 
  194.  
  195.    ------------- 
  196.    -- Signals -- 
  197.    ------------- 
  198.  
  199.    --  <signals> 
  200.    --  The following new signals are defined for this widget: 
  201.    --  </signals> 
  202.  
  203. private 
  204.    type Gtk_Combo_Record is new Gtk.Box.Gtk_Box_Record with null record; 
  205.  
  206.    Enable_Arrow_Keys_Property   : constant Glib.Properties.Property_Boolean := 
  207.      Glib.Properties.Build ("enable_arrow_keys"); 
  208.    Enable_Arrow_Always_Property : constant Glib.Properties.Property_Boolean := 
  209.      Glib.Properties.Build ("enable_arrow_always"); 
  210.    Case_Sensitive_Property      : constant Glib.Properties.Property_Boolean := 
  211.      Glib.Properties.Build ("case_sensitive"); 
  212.    Allow_Empty_Property : constant Glib.Properties.Property_Boolean := 
  213.      Glib.Properties.Build ("allow-empty"); 
  214.    Enable_Arrows_Always_Property : constant Glib.Properties.Property_Boolean := 
  215.      Glib.Properties.Build ("enable-arrows-always"); 
  216.    Value_In_List_Property : constant Glib.Properties.Property_Boolean := 
  217.      Glib.Properties.Build ("value-in-list"); 
  218.  
  219.    pragma Import (C, Get_Type, "gtk_combo_get_type"); 
  220. end Gtk.Combo; 
  221.  
  222. --  <example> 
  223. --  Creating a Gtk_Combo widget with simple text items. 
  224. -- 
  225. --    Combo : Gtk_Combo; 
  226. --    Items : String_List.Glist; 
  227. -- 
  228. --    String_List.Append (Items, "First Item"); 
  229. --    String_List.Append (Items, "Second Item"); 
  230. --    String_List.Append (Items, "Third Item"); 
  231. --    String_List.Append (Items, "Fourth Item"); 
  232. --    String_List.Append (Items, "Fifth Item"); 
  233. -- 
  234. --    Gtk_New (Combo); 
  235. --    Set_Popdown_Strings (Combo, Items); 
  236. --    Free (Items); 
  237. --  </example>