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-2011, 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 
  37. --  arrow (cursor) keys, though this behaviour can be turned off with 
  38. --  Set_Use_Arrows. 
  39. -- 
  40. --  Normally the arrow keys are only active when the contents of the text 
  41. --  entry field matches one of the items in the list. If the contents of the 
  42. --  entry field do not match any of the list items, then pressing the arrow 
  43. --  keys does nothing. However, by calling Set_Use_Arrows_Always you can 
  44. --  specify that the arrow keys are always active. If the contents of the entry 
  45. --  field does not match any of the items in the list, then pressing the up or 
  46. --  down arrow key will set the entry field to the last or first item in the 
  47. --  list, respectively. 
  48. -- 
  49. --  </description> 
  50. --  <screenshot>gtk-combo</screenshot> 
  51. --  <group>Obsolescent widgets</group> 
  52. --  <see>Gtk.Combo_Box</see> 
  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.Box;         use Gtk.Box; 
  59. with Gtk.Buildable;   use Gtk.Buildable; 
  60. with Gtk.Enums;       use Gtk.Enums; 
  61. with Gtk.Item;        use Gtk.Item; 
  62. with Gtk.Orientable;  use Gtk.Orientable; 
  63. with Gtk.Widget;      use Gtk.Widget; 
  64.  
  65. package Gtk.Combo is 
  66.  
  67.    pragma Obsolescent; 
  68.  
  69.    type Gtk_Combo_Record is new Gtk_Hbox_Record with null record; 
  70.    type Gtk_Combo is access all Gtk_Combo_Record'Class; 
  71.  
  72.    ------------------ 
  73.    -- Constructors -- 
  74.    ------------------ 
  75.  
  76.    procedure Gtk_New (Combo_Box : out Gtk_Combo); 
  77.    procedure Initialize (Combo_Box : access Gtk_Combo_Record'Class); 
  78.  
  79.    function Get_Type return Glib.GType; 
  80.    pragma Import (C, Get_Type, "gtk_combo_get_type"); 
  81.  
  82.    ------------- 
  83.    -- Methods -- 
  84.    ------------- 
  85.  
  86.    procedure Disable_Activate (Combo_Box : access Gtk_Combo_Record); 
  87.    --  Disable the standard handler for the return key in the entry field. The 
  88.    --  default behavior is to popdown the combo box list, so that the user can 
  89.    --  choose from it. However, if you want to add your own callback for the 
  90.    --  return key, you need to call this subprogram, and connect a handler to 
  91.    --  the "activate" signal for the entry. 
  92.  
  93.    procedure Set_Case_Sensitive 
  94.       (Combo_Box : access Gtk_Combo_Record; 
  95.        Val       : Boolean := True); 
  96.    --  Specify whether the text entered into the Gtk_Entry field and the text 
  97.    --  in the list items are case sensitive. This may be useful, for example, 
  98.    --  when you have called Set_Value_In_List to limit the values entered, but 
  99.    --  you are not worried about differences in case. 
  100.  
  101.    procedure Set_Item_String 
  102.       (Combo_Box  : access Gtk_Combo_Record; 
  103.        Item       : access Gtk.Item.Gtk_Item_Record'Class; 
  104.        Item_Value : UTF8_String); 
  105.    --  Set the string to place in the Gtk_Entry field when a particular list 
  106.    --  item is selected. This is needed if the list item is not a simple label. 
  107.  
  108.    procedure Set_Popdown_Strings 
  109.       (Combo_Box : access Gtk_Combo_Record; 
  110.        Strings   : Gtk.Enums.String_List.Glist); 
  111.    --  Set all the items in the popup list. 
  112.  
  113.    procedure Set_Use_Arrows 
  114.       (Combo_Box : access Gtk_Combo_Record; 
  115.        Val       : Boolean := True); 
  116.    --  Specify if the arrow (cursor) keys can be used to step through the 
  117.    --  items in the list. This is on by default. 
  118.  
  119.    procedure Set_Use_Arrows_Always 
  120.       (Combo_Box : access Gtk_Combo_Record; 
  121.        Val       : Boolean := True); 
  122.    --  Specify if the arrow keys will still work even if the current contents 
  123.    --  of the Gtk_Entry field do not match any of the list items. 
  124.  
  125.    procedure Set_Value_In_List 
  126.       (Combo_Box   : access Gtk_Combo_Record; 
  127.        Val         : Boolean := True; 
  128.        Ok_If_Empty : Boolean := False); 
  129.    --  Specify whether the value entered in the text entry field must match 
  130.    --  one of the values in the list. If this is set then the user will not be 
  131.    --  able to perform any other action until a valid value has been entered. 
  132.    --  If an empty field is acceptable, the Ok_If_Empty parameter should be 
  133.    --  True. If the value entered must match one of the values in the list, val 
  134.    --  should be True. 
  135.  
  136.    ------------ 
  137.    -- Fields -- 
  138.    ------------ 
  139.  
  140.    function Get_Entry 
  141.       (Combo_Box : access Gtk_Combo_Record) return Gtk.Widget.Gtk_Widget; 
  142.    procedure Set_Entry 
  143.       (Combo_Box : access Gtk_Combo_Record; 
  144.        Value     : access Gtk.Widget.Gtk_Widget_Record'Class); 
  145.  
  146.    function Get_List 
  147.       (Combo_Box : access Gtk_Combo_Record) return Gtk.Widget.Gtk_Widget; 
  148.  
  149.    --------------------- 
  150.    -- Interfaces_Impl -- 
  151.    --------------------- 
  152.  
  153.    function Get_Orientation 
  154.       (Self : access Gtk_Combo_Record) return Gtk.Enums.Gtk_Orientation; 
  155.    procedure Set_Orientation 
  156.       (Self        : access Gtk_Combo_Record; 
  157.        Orientation : Gtk.Enums.Gtk_Orientation); 
  158.  
  159.    ---------------- 
  160.    -- Interfaces -- 
  161.    ---------------- 
  162.    --  This class implements several interfaces. See Glib.Types 
  163.    -- 
  164.    --  - "Buildable" 
  165.    -- 
  166.    --  - "Orientable" 
  167.  
  168.    package Implements_Buildable is new Glib.Types.Implements 
  169.      (Gtk.Buildable.Gtk_Buildable, Gtk_Combo_Record, Gtk_Combo); 
  170.    function "+" 
  171.      (Widget : access Gtk_Combo_Record'Class) 
  172.    return Gtk.Buildable.Gtk_Buildable 
  173.    renames Implements_Buildable.To_Interface; 
  174.    function "-" 
  175.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  176.    return Gtk_Combo 
  177.    renames Implements_Buildable.To_Object; 
  178.  
  179.    package Implements_Orientable is new Glib.Types.Implements 
  180.      (Gtk.Orientable.Gtk_Orientable, Gtk_Combo_Record, Gtk_Combo); 
  181.    function "+" 
  182.      (Widget : access Gtk_Combo_Record'Class) 
  183.    return Gtk.Orientable.Gtk_Orientable 
  184.    renames Implements_Orientable.To_Interface; 
  185.    function "-" 
  186.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  187.    return Gtk_Combo 
  188.    renames Implements_Orientable.To_Object; 
  189.  
  190.    ---------------- 
  191.    -- Properties -- 
  192.    ---------------- 
  193.    --  The following properties are defined for this widget. See 
  194.    --  Glib.Properties for more information on properties) 
  195.    -- 
  196.    --  Name: Allow_Empty_Property 
  197.    --  Type: Boolean 
  198.    --  Flags: read-write 
  199.    -- 
  200.    --  Name: Case_Sensitive_Property 
  201.    --  Type: Boolean 
  202.    --  Flags: read-write 
  203.    -- 
  204.    --  Name: Enable_Arrow_Keys_Property 
  205.    --  Type: Boolean 
  206.    --  Flags: read-write 
  207.    -- 
  208.    --  Name: Enable_Arrows_Always_Property 
  209.    --  Type: Boolean 
  210.    --  Flags: read-write 
  211.    -- 
  212.    --  Name: Value_In_List_Property 
  213.    --  Type: Boolean 
  214.    --  Flags: read-write 
  215.  
  216.    Allow_Empty_Property : constant Glib.Properties.Property_Boolean; 
  217.    Case_Sensitive_Property : constant Glib.Properties.Property_Boolean; 
  218.    Enable_Arrow_Keys_Property : constant Glib.Properties.Property_Boolean; 
  219.    Enable_Arrows_Always_Property : constant Glib.Properties.Property_Boolean; 
  220.    Value_In_List_Property : constant Glib.Properties.Property_Boolean; 
  221.  
  222. private 
  223.    Allow_Empty_Property : constant Glib.Properties.Property_Boolean := 
  224.      Glib.Properties.Build ("allow-empty"); 
  225.    Case_Sensitive_Property : constant Glib.Properties.Property_Boolean := 
  226.      Glib.Properties.Build ("case-sensitive"); 
  227.    Enable_Arrow_Keys_Property : constant Glib.Properties.Property_Boolean := 
  228.      Glib.Properties.Build ("enable-arrow-keys"); 
  229.    Enable_Arrows_Always_Property : constant Glib.Properties.Property_Boolean := 
  230.      Glib.Properties.Build ("enable-arrows-always"); 
  231.    Value_In_List_Property : constant Glib.Properties.Property_Boolean := 
  232.      Glib.Properties.Build ("value-in-list"); 
  233. end Gtk.Combo;