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