1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2006-2010 AdaCore                    -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  A Gtk_Combo_Box is a widget that allows the user to choose from a list of 
  26. --  valid choices. The Gtk_Combo_Box displays the selected choice. When 
  27. --  activated, the Gtk_Combo_Box displays a popup which allows the user to make 
  28. --  new choice. The style in which the selected value is displayed, and the 
  29. --  style of the popup is determined by the current theme. It may be similar to 
  30. --  a Gtk_Option_Menu, or similar to a Windows-style combo box. 
  31. -- 
  32. --  Unlike its predecessors Gtk.Combo.Gtk_Combo and 
  33. --  Gtk.Option_Menu.Gtk_Option_Menu, the Gtk_Combo_Box uses the model-view 
  34. --  pattern; the list of valid choices is specified in the form of a tree 
  35. --  model, and the display of the choices can be adapted to the data in the 
  36. --  model by using cell renderers, as you would in a tree view. This is 
  37. --  possible since Gtk_Combo_Box implements the Gtk_Cell_Layout interface. The 
  38. --  tree model holding the valid choices is not restricted to a flat list, it 
  39. --  can be a real tree, and the popup will reflect the tree structure. 
  40. -- 
  41. --  In addition to the model-view API, Gtk_Combo_Box offers a simple API which 
  42. --  is suitable for text-only combo boxes, and hides the complexity of managing 
  43. --  the data in a model. 
  44. --  </description> 
  45. --  <c_version>2.16.6</c_version> 
  46. --  <group>Trees and Lists</group> 
  47. --  <see>Gtk.Combo_Box_Entry</see> 
  48. --  <screenshot>gtk-combo_box</screenshot> 
  49.  
  50. with Glib.Properties; 
  51. with Gtk.Bin; 
  52. with Gtk.Cell_Editable; 
  53. with Gtk.Cell_Layout; 
  54. with Gtk.Enums; 
  55. with Gtk.Tree_Model; 
  56. with Gtk.Tree_View; 
  57. with Glib.Types; 
  58.  
  59. package Gtk.Combo_Box is 
  60.    type Gtk_Combo_Box_Record is new Gtk.Bin.Gtk_Bin_Record with null record; 
  61.    type Gtk_Combo_Box is access all Gtk_Combo_Box_Record'Class; 
  62.  
  63.    procedure Gtk_New    (Combo : out Gtk_Combo_Box); 
  64.    procedure Initialize (Combo : access Gtk_Combo_Box_Record'Class); 
  65.    --  Creates or initializes a new empty combo 
  66.  
  67.    procedure Gtk_New_With_Model 
  68.      (Combo : out Gtk_Combo_Box; 
  69.       Model : access Gtk.Tree_Model.Gtk_Tree_Model_Record'Class); 
  70.    procedure Initialize_With_Model 
  71.      (Combo : access Gtk_Combo_Box_Record'Class; 
  72.       Model : access Gtk.Tree_Model.Gtk_Tree_Model_Record'Class); 
  73.    --  Creates or initializes a new combo initializes to Model. 
  74.  
  75.    function Get_Type return Glib.GType; 
  76.    --  Returns the internal value used for Gtk_Combo_Box widgets 
  77.  
  78.    procedure Set_Model 
  79.      (Combo_Box : access Gtk_Combo_Box_Record; 
  80.       Model     : Gtk.Tree_Model.Gtk_Tree_Model := null); 
  81.    function Get_Model 
  82.      (Combo_Box : access Gtk_Combo_Box_Record) 
  83.       return Gtk.Tree_Model.Gtk_Tree_Model; 
  84.    --  Sets the model used by Combo_Box to be Model. Will unset a previously 
  85.    --  set model (if applicable). If model is null, then it will unset the 
  86.    --  model. Note that this function does not clear the cell renderers, you 
  87.    --  have to call Gtk.Cell_Layout.Clear yourself if you need to set up 
  88.    --  different cell renderers for the new model. 
  89.  
  90.    procedure Set_Active 
  91.      (Combo_Box : access Gtk_Combo_Box_Record; Index : Gint); 
  92.    function Get_Active 
  93.      (Combo_Box : access Gtk_Combo_Box_Record) return Gint; 
  94.    --  Returns the index of the currently active item, or -1 if there's no 
  95.    --  active item. If the model is a non-flat treemodel, and the active item 
  96.    --  is not an immediate child of the root of the tree, this function returns 
  97.    --  Gtk.Tree_Model.Get_Indices (Path)[0], where Path is the Gtk_Tree_Path of 
  98.    --  the active model. 
  99.  
  100.    procedure Set_Active_Iter 
  101.      (Combo_Box : access Gtk_Combo_Box_Record; 
  102.       Iter      : Gtk.Tree_Model.Gtk_Tree_Iter); 
  103.    function Get_Active_Iter 
  104.      (Combo_Box : access Gtk_Combo_Box_Record) 
  105.       return Gtk.Tree_Model.Gtk_Tree_Iter; 
  106.    --  Sets the current active item to be the one referenced by Iter. 
  107.    --  Iter must correspond to a path of depth one. 
  108.  
  109.    procedure Set_Wrap_Width 
  110.      (Combo_Box : access Gtk_Combo_Box_Record; Width : Gint); 
  111.    function Get_Wrap_Width 
  112.      (Combo_Box : access Gtk_Combo_Box_Record) return Gint; 
  113.    --  Returns the wrap width which is used to determine the number 
  114.    --  of columns for the popup menu. If the wrap width is larger than 
  115.    --  1, the combo box is in table mode. This can be used for instance to 
  116.    --  display a matrix of color (a color palette to choose from). 
  117.    --  See also Set_Column_Span_Column 
  118.  
  119.    procedure Set_Add_Tearoffs 
  120.      (Combo_Box : access Gtk_Combo_Box_Record; Add_Tearoffs : Boolean); 
  121.    function Get_Add_Tearoffs 
  122.      (Combo_Box : access Gtk_Combo_Box_Record) return Boolean; 
  123.    --  Sets whether the popup menu should have a tearoff menu item. 
  124.    --  Clicking on this menu will detach the combo into a floating window that 
  125.    --  the user can put anywhere on the screen. 
  126.  
  127.    procedure Set_Button_Sensitivity 
  128.      (Combo_Box   : access Gtk_Combo_Box_Record; 
  129.       Sensitivity : Gtk.Enums.Gtk_Sensitivity_Type); 
  130.    function Get_Button_Sensitivity 
  131.      (Combo_Box : access Gtk_Combo_Box_Record) 
  132.       return Gtk.Enums.Gtk_Sensitivity_Type; 
  133.    --  Sets whether the dropdown button of the combo box should be always 
  134.    --  sensitive (Gtk_Sensitivity_On), never sensitive (Gtk_Sensitivity_Off) 
  135.    --  or only if there is at least one item to display (Gtk_Sensitivity_Auto). 
  136.  
  137.    procedure Set_Column_Span_Column 
  138.      (Combo_Box : access Gtk_Combo_Box_Record; Column_Span : Gint); 
  139.    function Get_Column_Span_Column 
  140.      (Combo_Box : access Gtk_Combo_Box_Record) return Gint; 
  141.    --  Sets the column with column span information for Combo_Box to be 
  142.    --  Column_Span. The column span column contains integers which indicate 
  143.    --  how many columns an item should span. This applies to grid combos, see 
  144.    --  also Set_Wrap_Width. 
  145.  
  146.    procedure Set_Row_Span_Column 
  147.      (Combo_Box : access Gtk_Combo_Box_Record; Row_Span : Gint); 
  148.    function Get_Row_Span_Column 
  149.      (Combo_Box : access Gtk_Combo_Box_Record) return Gint; 
  150.    --  Sets the column with row span information for Combo_Box to be Row_Span. 
  151.    --  The row span column contains integers which indicate how many rows 
  152.    --  an item should span. 
  153.  
  154.    procedure Set_Focus_On_Click 
  155.      (Combo          : access Gtk_Combo_Box_Record; 
  156.       Focus_On_Click : Boolean); 
  157.    function Get_Focus_On_Click 
  158.      (Combo : access Gtk_Combo_Box_Record) return Boolean; 
  159.    --  Sets whether the combo box will grab focus when it is clicked with 
  160.    --  the mouse. Making mouse clicks not grab focus is useful in places 
  161.    --  like toolbars where you don't want the keyboard focus removed from 
  162.    --  the main area of the application. 
  163.  
  164.    procedure Set_Row_Separator_Func 
  165.      (Combo_Box : access Gtk_Combo_Box_Record; 
  166.       Func      : Gtk.Tree_View.Gtk_Tree_View_Row_Separator_Func; 
  167.       Data      : System.Address; 
  168.       Destroy   : Glib.G_Destroy_Notify_Address := null); 
  169.    function Get_Row_Separator_Func 
  170.      (Combo_Box : access Gtk_Combo_Box_Record) 
  171.       return Gtk.Tree_View.Gtk_Tree_View_Row_Separator_Func; 
  172.    --  Sets the row separator function, which is used to determine 
  173.    --  whether a row should be drawn as a separator. If the row separator 
  174.    --  function is null, no separators are drawn. This is the default value. 
  175.  
  176.    procedure Set_Title 
  177.      (Combo_Box : access Gtk_Combo_Box_Record; 
  178.       Title     : String); 
  179.    function Get_Title 
  180.      (Combo_Box : access Gtk_Combo_Box_Record) 
  181.       return String; 
  182.    --  Sets or Gets the menu's title in tearoff mode. 
  183.  
  184.    --------------------------- 
  185.    -- Text-only combo boxes -- 
  186.    --------------------------- 
  187.    --  If your combo box only contains text, you do not necessarily have to go 
  188.    --  through the more complex use of a Gtk_Tree_Model. 
  189.  
  190.    procedure Gtk_New_Text    (Combo : out Gtk_Combo_Box); 
  191.    procedure Initialize_Text (Combo : access Gtk_Combo_Box_Record'Class); 
  192.    --  Convenience function which constructs a new text combo box, which is 
  193.    --  Gtk_Combo_Box just displaying strings. If you use this function to 
  194.    --  create a text combo box, you should only manipulate its data source with 
  195.    --  the following convenience functions: Append_Text, Insert_Text, 
  196.    --  Prepend_Text and Remove_Text 
  197.  
  198.    procedure Append_Text 
  199.      (Combo_Box : access Gtk_Combo_Box_Record; Text : String); 
  200.    procedure Prepend_Text 
  201.      (Combo_Box : access Gtk_Combo_Box_Record; Text : String); 
  202.    procedure Insert_Text 
  203.      (Combo_Box : access Gtk_Combo_Box_Record; 
  204.       Position  : Gint; 
  205.       Text      : String); 
  206.    --  Adds Text to the list of strings stored in Combo_Box. Note that 
  207.    --  you can only use this function with combo boxes constructed with 
  208.    --  Gtk_New_Text. 
  209.  
  210.    procedure Remove_Text 
  211.      (Combo_Box : access Gtk_Combo_Box_Record; Position : Gint); 
  212.    --  Removes the string at Position from Combo_Box. Note that you can only 
  213.    --  use this function with combo boxes constructed with Gtk_New_Text. 
  214.  
  215.    function Get_Active_Text 
  216.      (Combo_Box : access Gtk_Combo_Box_Record) return String; 
  217.    --  Returns the currently active string in Combo_Box or "" if none 
  218.    --  is selected.  Note that you can only use this function with combo 
  219.    --  boxes constructed with Gtk_New_Text. 
  220.  
  221.    -------------------------- 
  222.    -- Programmatic Control -- 
  223.    -------------------------- 
  224.  
  225.    procedure Popdown (Combo_Box : access Gtk_Combo_Box_Record); 
  226.    procedure Popup   (Combo_Box : access Gtk_Combo_Box_Record); 
  227.    --  Hides or pops up the menu or dropdown list of Combo_Box. 
  228.    --  This function is mostly intended for use by accessibility technologies; 
  229.    --  applications should have little use for it. 
  230.  
  231.    ---------------- 
  232.    -- Interfaces -- 
  233.    ---------------- 
  234.    --  This class implements several interfaces. See Glib.Types 
  235.    -- 
  236.    --  - "Gtk_Cell_Layout" 
  237.    --    This interface should be used to add new renderers to the view, to 
  238.    --    render various columns of the model 
  239.    --  - "Gtk_Cell_Editable" 
  240.    --    This interface should be used to edit the contents of a tree model 
  241.    --    cell 
  242.  
  243.    package Implements_Cell_Layout is new Glib.Types.Implements 
  244.      (Gtk.Cell_Layout.Gtk_Cell_Layout, Gtk_Combo_Box_Record, Gtk_Combo_Box); 
  245.    function "+" 
  246.      (Box : access Gtk_Combo_Box_Record'Class) 
  247.       return Gtk.Cell_Layout.Gtk_Cell_Layout 
  248.       renames Implements_Cell_Layout.To_Interface; 
  249.    function "-" 
  250.      (Layout : Gtk.Cell_Layout.Gtk_Cell_Layout) 
  251.       return Gtk_Combo_Box 
  252.       renames Implements_Cell_Layout.To_Object; 
  253.    --  Converts to and from the Gtk_Cell_Layout interface 
  254.  
  255.    package Implements_Cell_Editable is new Glib.Types.Implements 
  256.      (Gtk.Cell_Editable.Gtk_Cell_Editable, 
  257.       Gtk_Combo_Box_Record, Gtk_Combo_Box); 
  258.    function "+" 
  259.      (Box : access Gtk_Combo_Box_Record'Class) 
  260.       return Gtk.Cell_Editable.Gtk_Cell_Editable 
  261.       renames Implements_Cell_Editable.To_Interface; 
  262.    function "-" 
  263.      (Editable : Gtk.Cell_Editable.Gtk_Cell_Editable) 
  264.       return Gtk_Combo_Box 
  265.       renames Implements_Cell_Editable.To_Object; 
  266.    --  Converts to and from the Gtk_Cell_Editable interface 
  267.  
  268.    ---------------- 
  269.    -- Properties -- 
  270.    ---------------- 
  271.    --  The following properties are defined for this widget. See 
  272.    --  Glib.Properties for more information on properties. 
  273.  
  274.    --  <properties> 
  275.    --  Name:  Active_Property 
  276.    --  Type:  Int 
  277.    --  Descr: The item which is currently active 
  278.    -- 
  279.    --  Name:  Add_Tearoffs_Property 
  280.    --  Type:  Boolean 
  281.    --  Descr: Whether dropdowns should have a tearoff menu item 
  282.    -- 
  283.    --  Name:  Button_Sensitivity_Property 
  284.    --  Type:  Enum 
  285.    --  Descr: Whether the dropdown button is sensitive when the model is empty 
  286.    -- 
  287.    --  Name:  Column_Span_Column_Property 
  288.    --  Type:  Int 
  289.    --  Descr: TreeModel column containing the column span values 
  290.    -- 
  291.    --  Name:  Focus_On_Click_Property 
  292.    --  Type:  Boolean 
  293.    --  Descr: Whether the combo box grabs focus when it is clicked with the 
  294.    --         mouse 
  295.    -- 
  296.    --  Name:  Has_Frame_Property 
  297.    --  Type:  Boolean 
  298.    --  Descr: Whether the combo box draws a frame around the child 
  299.    -- 
  300.    --  Name:  Model_Property 
  301.    --  Type:  Object 
  302.    --  Descr: The model for the combo box 
  303.    -- 
  304.    --  Name:  Popup_Shown_Property 
  305.    --  Type:  Boolean 
  306.    --  Descr: Whether the combo's dropdown is shown 
  307.    -- 
  308.    --  Name:  Row_Span_Column_Property 
  309.    --  Type:  Int 
  310.    --  Descr: TreeModel column containing the row span values 
  311.    -- 
  312.    --  Name:  Tearoff_Title_Property 
  313.    --  Type:  String 
  314.    --  Descr: A title that may be displayed by the window manager when the 
  315.    --         popup is torn-off 
  316.    -- 
  317.    --  Name:  Wrap_Width_Property 
  318.    --  Type:  Int 
  319.    --  Descr: Wrap width for layouting the items in a grid 
  320.    --  </properties> 
  321.  
  322.    Active_Property             : constant Glib.Properties.Property_Int; 
  323.    Add_Tearoffs_Property       : constant Glib.Properties.Property_Boolean; 
  324.    Button_Sensitivity_Property : constant Glib.Properties.Property_Enum; 
  325.    Column_Span_Column_Property : constant Glib.Properties.Property_Int; 
  326.    Focus_On_Click_Property     : constant Glib.Properties.Property_Boolean; 
  327.    Has_Frame_Property          : constant Glib.Properties.Property_Boolean; 
  328.    Model_Property              : constant Glib.Properties.Property_Object; 
  329.    Popup_Shown_Property        : constant Glib.Properties.Property_Boolean; 
  330.    Row_Span_Column_Property    : constant Glib.Properties.Property_Int; 
  331.    Tearoff_Title_Property      : constant Glib.Properties.Property_String; 
  332.    Wrap_Width_Property         : constant Glib.Properties.Property_Int; 
  333.  
  334.    ---------------------- 
  335.    -- Style Properties -- 
  336.    ---------------------- 
  337.    --  The following properties can be changed through the gtk theme and 
  338.    --  configuration files, and retrieved through Gtk.Widget.Style_Get_Property 
  339.  
  340.    --  <style_properties> 
  341.    --  Name:  Appears_As_List_Property 
  342.    --  Type:  Boolean 
  343.    --  Descr: Whether dropdowns should look like lists rather than menus 
  344.    -- 
  345.    --  Name:  Arrow_Size_Property 
  346.    --  Type:  Int 
  347.    --  Descr: The minimum size of the arrow in the combo box 
  348.    -- 
  349.    --  Name:  Shadow_Type_Property 
  350.    --  Type:  Enum 
  351.    --  Descr: Which kind of shadow to draw around the combo box 
  352.    --  </style_properties> 
  353.  
  354.    Appears_As_List_Property : constant Glib.Properties.Property_Boolean; 
  355.    Arrow_Size_Property      : constant Glib.Properties.Property_Int; 
  356.    Shadow_Type_Property     : constant Glib.Properties.Property_Enum; 
  357.  
  358.    ------------- 
  359.    -- Signals -- 
  360.    ------------- 
  361.    --  The following new signals are defined for this widget 
  362.  
  363.    --  <signals> 
  364.    --  - "changed" 
  365.    --    procedure Handler (Combo : access Gtk_Combo_Box_Record'Class); 
  366.    --    Emitted when the active item is changed. The can be due to the user 
  367.    --    selecting a different item from the list, or due to a call to 
  368.    --    Set_Active_Iter. It will also be emitted while typing into a 
  369.    --    Gtk_Combo_Box_Entry, as well as when selecting an item from the 
  370.    --    Gtk_Combo_Box_Entry's list. 
  371.    --  </signals> 
  372.  
  373.    Signal_Changed : constant Glib.Signal_Name := "changed"; 
  374.  
  375. private 
  376.    pragma Import (C, Get_Type, "gtk_combo_box_get_type"); 
  377.  
  378.    Active_Property : constant Glib.Properties.Property_Int := 
  379.      Glib.Properties.Build ("active"); 
  380.    Add_Tearoffs_Property : constant Glib.Properties.Property_Boolean := 
  381.      Glib.Properties.Build ("add-tearoffs"); 
  382.    Arrow_Size_Property : constant Glib.Properties.Property_Int := 
  383.      Glib.Properties.Build ("arrow-size"); 
  384.    Button_Sensitivity_Property : constant Glib.Properties.Property_Enum := 
  385.      Glib.Properties.Build ("button-sensitivity"); 
  386.    Column_Span_Column_Property : constant Glib.Properties.Property_Int := 
  387.      Glib.Properties.Build ("column-span-column"); 
  388.    Focus_On_Click_Property : constant Glib.Properties.Property_Boolean := 
  389.      Glib.Properties.Build ("focus-on-click"); 
  390.    Has_Frame_Property : constant Glib.Properties.Property_Boolean := 
  391.      Glib.Properties.Build ("has-frame"); 
  392.    Model_Property : constant Glib.Properties.Property_Object := 
  393.      Glib.Properties.Build ("model"); 
  394.    Popup_Shown_Property : constant Glib.Properties.Property_Boolean := 
  395.      Glib.Properties.Build ("popup-shown"); 
  396.    Row_Span_Column_Property : constant Glib.Properties.Property_Int := 
  397.      Glib.Properties.Build ("row-span-column"); 
  398.    Shadow_Type_Property : constant Glib.Properties.Property_Enum := 
  399.      Glib.Properties.Build ("shadow-type"); 
  400.    Tearoff_Title_Property : constant Glib.Properties.Property_String := 
  401.      Glib.Properties.Build ("tearoff-title"); 
  402.    Wrap_Width_Property : constant Glib.Properties.Property_Int := 
  403.      Glib.Properties.Build ("wrap-width"); 
  404.  
  405.    Appears_As_List_Property : constant Glib.Properties.Property_Boolean := 
  406.      Glib.Properties.Build ("appears-as-list"); 
  407. end Gtk.Combo_Box; 
  408.  
  409. --  No binding: gtk_combo_box_get_popup_accessible