PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_combo_box_entry.e

http://github.com/tybor/Liberty
Specman e | 133 lines | 71 code | 23 blank | 39 comment | 3 complexity | 2174073c74669a9f5f0bc74d61069f9e MD5 | raw file
  1indexing
  2	description: "GtkComboBoxEntry -- A text entry field with a dropdown list."
  3	copyright: "[
  4					Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5					
  6					This library is free software; you can redistribute it and/or
  7					modify it under the terms of the GNU Lesser General Public License
  8					as published by the Free Software Foundation; either version 2.1 of
  9					the License, or (at your option) any later version.
 10					
 11					This library is distributed in the hope that it will be useful, but
 12					WITHOUT ANY WARRANTY; without even the implied warranty of
 13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14					Lesser General Public License for more details.
 15
 16					You should have received a copy of the GNU Lesser General Public
 17					License along with this library; if not, write to the Free Software
 18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 19					02110-1301 USA
 20					]"
 21					
 22class GTK_COMBO_BOX_ENTRY
 23	--A GtkComboBoxEntry is a widget that allows the user to choose
 24	-- from a list of valid choices or enter a different value. It is
 25	-- very similar to a GtkComboBox, but it displays the selected
 26	-- value in an entry to allow modifying it.
 27
 28	-- In contrast to a GtkComboBox, the underlying model of a
 29	-- GtkComboBoxEntry must always have a text column (see
 30	-- `set_text_column'), and the entry will show the content of the
 31	-- text column in the selected row. To get the text from the entry,
 32	-- use `active_text'.
 33
 34	-- The changed signal will be emitted while typing into a
 35	-- GtkComboBoxEntry, as well as when selecting an item from the
 36	-- GtkComboBoxEntry's list. Use `active_row' or `active_iter' to
 37	-- discover whether an item was actually selected from the list.
 38	       
 39	-- Connect to the activate signal of the GtkEntry (use `child') to
 40	-- detect when the user actually finishes entering text.
 41
 42	-- The convenience API to construct simple text-only GtkComboBoxes
 43	-- can also be used with GtkComboBoxEntrys which have been
 44	-- constructed with `with_text_only'.
 45
 46inherit
 47	GTK_COMBO_BOX
 48		rename
 49			with_model as make_combo_box_with_model,
 50			child as entry
 51		export {} make_combo_box_with_model
 52		redefine make, with_text_only, struct_size, entry
 53		end
 54	-- GtkComboBoxEntry implements the same interfaces implemented by
 55	-- GtkComboBox, i.e.: AtkImplementorIface, GtkCellEditable and
 56	-- GtkCellLayout.
 57
 58insert
 59	GTK_COMBO_BOX_ENTRY_EXTERNALS
 60
 61creation make, with_model, with_text_only, from_external_pointer
 62
 63feature {} -- Creation
 64
 65	make is
 66			-- Creates a new GtkComboBoxEntry which has a GtkEntry as
 67			-- child. After construction, you should set a model using
 68			-- `set_model' and a text_column using
 69			-- `set_text_column'.
 70		do
 71			from_external_pointer (gtk_combo_box_entry_new)
 72		end
 73
 74	with_model (a_model: GTK_TREE_MODEL; a_text_column: INTEGER) is
 75			-- Creates a new GtkComboBoxEntry which has a GtkEntry as
 76			-- child and a list of strings as popup. You can get the
 77			-- GtkEntry from a GtkComboBoxEntry using `child'. To add and
 78			-- remove strings from the list, just modify model using its
 79			-- data manipulation API.
 80		do
 81			from_external_pointer (gtk_combo_box_entry_new_with_model (a_model.handle, a_text_column))
 82		end
 83
 84	with_text_only is
 85			-- Convenience function which constructs a new editable text
 86			-- combo box, which is a GtkComboBoxEntry just displaying
 87			-- strings. If you use this function to create a text combo
 88			-- box, you should only manipulate its data source with the
 89			-- following convenience functions: `append_text',
 90			-- `insert_text', `prepend_text' and `remove_text'.
 91		do
 92			from_external_pointer (gtk_combo_box_entry_new_text )
 93			is_text_only:=True
 94		ensure then text_only: is_text_only
 95		end
 96
 97feature
 98	set_text_column (a_column: INTEGER) is
 99			-- Sets the model column which entry box should use to get
100			-- strings from to be `a_column'.
101		require valid_column: a_column >= -1
102		do 
103			gtk_combo_box_entry_set_text_column (handle, a_column)
104		end
105
106	text_column: INTEGER is
107			-- The column which entry box is using to get the strings from.
108		do
109			Result := gtk_combo_box_entry_get_text_column (handle)
110		ensure valid: Result >= -1 
111		end
112
113feature
114
115	entry: GTK_ENTRY is
116		do
117			if hidden_child_wrapper=Void then
118				create hidden_child_wrapper.from_external_pointer (gtk_bin_get_child(handle))
119			end
120			Result := hidden_child_wrapper
121		end
122
123feature {} -- Implementation
124	hidden_child_wrapper: GTK_ENTRY
125
126feature -- size
127
128	struct_size: INTEGER is
129		external "C inline use <gtk/gtk.h>"
130		alias "sizeof(GtkComboBoxEntry)"
131		end
132
133end