PageRenderTime 31ms CodeModel.GetById 18ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_radio_button.e

http://github.com/tybor/Liberty
Specman e | 233 lines | 110 code | 41 blank | 82 comment | 3 complexity | c8f6bd51ded59917506d816c4d754bb6 MD5 | raw file
  1indexing
  2	description: "GTK_RADIO_BUTTON -- A choice from multiple check buttons."
  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	date: "$Date:$"
 22	revision: "$Revision:$"
 23
 24class GTK_RADIO_BUTTON
 25	-- A single radio button performs the same basic function as a
 26	-- GtkCheckButton, as its position in the object hierarchy
 27	-- reflects. It is only when multiple radio buttons are grouped
 28	-- together that they become a different user interface component
 29	-- in their own right.
 30
 31	-- Every radio button is a member of some group of radio
 32	-- buttons. When one is selected, all other radio buttons in the
 33	-- same group are deselected. A GtkRadioButton is one way of giving
 34	-- the user a choice from many options.
 35
 36	-- Create the first radio button of a group with `in_a_new_group',
 37	-- then add further buttons with the other cration procedures
 38	-- (i.e.: `from_group', `from_widget' and so on)
 39
 40	-- Retrieve the group a GtkRadioButton is assigned to use gtk_radio_button_get_group().
 41
 42-- To remove a GtkRadioButton from one group and make it part of a new one, use gtk_radio_button_set_group().
 43
 44-- The group list does not need to be freed, as each GtkRadioButton will remove itself and its list item when it is destroyed.
 45
 46	-- Example 1. How to create a group of two radio buttons.
 47
 48-- void create_radio_buttons (void) {
 49
 50--    GtkWidget *window, *radio1, *radio2, *box, *entry;
 51--    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 52--    box = gtk_vbox_new (TRUE, 2);
 53	
 54--    /* Create a radio button with a GtkEntry widget */
 55--    radio1 = gtk_radio_button_new (NULL);
 56--    entry = gtk_entry_new ();
 57--    gtk_container_add (GTK_CONTAINER (radio1), entry);
 58	
 59	
 60--    /* Create a radio button with a label */
 61--    radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1),
 62-- 							"I'm the second radio button.");
 63	
 64--    /* Pack them into a box, then show all the widgets */
 65--    gtk_box_pack_start (GTK_BOX (box), radio1, TRUE, TRUE, 2);
 66--    gtk_box_pack_start (GTK_BOX (box), radio2, TRUE, TRUE, 2);
 67--    gtk_container_add (GTK_CONTAINER (window), box);
 68--    gtk_widget_show_all (window);
 69--    return;
 70-- }
 71
 72
 73-- When an unselected button in the group is clicked the clicked button receives the "toggled" signal, as does the previously selected button. Inside the "toggled" handler, gtk_toggle_button_get_active() can be used to determine if the button has been selected or deselected.
 74
 75inherit
 76	GTK_CHECK_BUTTON
 77		rename
 78			with_label as make_check_with_label,
 79			with_mnemonic as make_check_with_mnemonic
 80		export {} make_check_with_label, make_check_with_mnemonic
 81			-- Instead of undefining, which would turn this class into a 
 82			-- deferred one.
 83		end
 84
 85insert
 86	GTK_RADIO_BUTTON_EXTERNALS
 87		-- GtkRadioButton implements AtkImplementorIface.	
 88
 89creation
 90	in_a_new_group,
 91	from_group,
 92	from_widget,
 93	with_label,
 94	with_label_from_widget,
 95	with_mnemonic,
 96	with_mnemonic_from_widget,
 97	from_external_pointer
 98
 99feature {} -- Creation
100	in_a_new_group is
101			-- Creates a new GTK_RADIO_BUTTON in a new group.
102		do
103			from_external_pointer (gtk_radio_button_new (default_pointer))
104		end
105	
106	from_group (a_group: G_SLIST[GTK_RADIO_BUTTON]) is
107			-- Creates a new GTK_RADIO_BUTTON. To be of any practical
108			-- value, a widget should then be packed into the radio
109			-- button. `a_group': an existing radio button group, or Void
110			-- if you are creating a new group.
111		require
112			gtk_initialized: gtk.is_initialized
113			group_not_void: a_group/=Void
114		do
115			from_external_pointer (gtk_radio_button_new (a_group.handle))
116		end
117	
118	from_widget (a_widget: GTK_RADIO_BUTTON) is
119			-- Creates a new GtkRadioButton, adding it to the same group
120			-- of `a_widget'. As with `make', a widget should be packed
121			-- into the radio button.
122		require
123			gtk_initialized: gtk.is_initialized
124			widget_not_void: a_widget /= Void
125		do
126			from_external_pointer (gtk_radio_button_new_from_widget (a_widget.handle))
127		end
128
129	with_label (a_group: G_SLIST[GTK_RADIO_BUTTON]; a_label: STRING) is
130			-- Creates a new GTK_RADIO_BUTTON with `a_label' displayed
131			-- next to the radio button; `a_group' is an existing radio
132			-- button group, or Void if you are creating a new group.
133		require
134			gtk_initialized: gtk.is_initialized
135			group_not_void: a_group/=Void implies not a_group.is_empty
136			label_not_void: a_label /= Void
137		local ptr: POINTER
138		do
139			if a_group/=Void then ptr:=a_group.handle end
140			from_external_pointer (gtk_radio_button_new_with_label (ptr, a_label.to_external))
141		end
142
143	with_label_from_widget (a_widget: GTK_RADIO_BUTTON; a_label: STRING) is
144			-- Creates a new GtkRadioButton, adding it to the same group
145			-- of `a_widget'; `a_label' displayed next to the radio
146			-- button.
147		require
148			gtk_initialized: gtk.is_initialized
149			widget_not_void: a_widget /= Void
150			label_not_void: a_label /= Void
151		do
152			from_external_pointer(gtk_radio_button_new_with_label_from_widget
153										 (a_widget.handle, a_label.to_external))
154		end
155
156
157	with_mnemonic (a_group: G_SLIST[GTK_RADIO_BUTTON]; a_label: STRING) is
158			-- Creates a new GtkRadioButton containing `a_label', adding
159			-- it to `a_group'. The label will be created using
160			-- GTK_LABEL.with_mnemonic, so underscores in label indicate
161			-- the mnemonic for the button.
162		require
163			gtk_initialized: gtk.is_initialized
164			group_not_void: a_group/=Void implies not a_group.is_empty	
165			label_not_void: a_label /= Void
166		do
167			from_external_pointer (gtk_radio_button_new_with_mnemonic (a_group.handle, a_label.to_external))
168		end
169
170	with_mnemonic_from_widget (a_widget: GTK_RADIO_BUTTON; a_label: STRING) is
171			-- Creates a new GTK_RADIO_BUTTON containing `a_label' to the
172			-- same group of `a_widget'. The label will be created using
173			-- GTK_LABEL.with_mnemonic, so underscores in label indicate
174			-- the mnemonic for the button.
175		require
176			gtk_initialized: gtk.is_initialized
177			widget_not_void: a_widget /= Void
178			label_not_void: a_label /= Void
179		do
180			from_external_pointer (gtk_radio_button_new_with_mnemonic_from_widget
181										  (a_widget.handle, a_label.to_external))
182		end
183
184feature -- group
185	set_group (a_group: G_SLIST[GTK_RADIO_BUTTON]) is
186			-- Sets a Current's group to `a_group'. It should be noted
187			-- that this does not change the layout of your interface in
188			-- any way, so if you are changing the group, it is likely
189			-- you will need to re-arrange the user interface to reflect
190			-- these changes. See also `set_group_from'
191		do
192			gtk_radio_button_set_group (handle,a_group.handle)
193		end
194
195	set_group_from (another: GTK_RADIO_BUTTON) is
196			-- Makes Current belong to the same group of `another'. The
197			-- implementation is (slightly) faster than
198			-- a_radio_button.set_group (another.group)
199		do
200			gtk_radio_button_set_group (handle,
201												 gtk_radio_button_get_group(another.handle))
202		end
203
204	group: G_SLIST[GTK_RADIO_BUTTON] is
205			-- the group assigned to a radio button.
206		do
207			create {G_OBJECT_SLIST[GTK_RADIO_BUTTON]} Result.from_external_pointer (gtk_radio_button_get_group(handle))
208		end
209
210feature -- Property Details TODO
211-- The "group" property
212
213--   "group"                GtkRadioButton        : Write
214
215-- Sets a new group for a radio button.
216feature -- Signal Details TODO
217-- The "group-changed" signal
218
219-- void        user_function                  (GtkRadioButton *style,
220--                                             gpointer        user_data)      : Run first
221
222-- Emitted when the group of radio buttons that a radio button belongs to changes. This is emitted when a radio button switches from being alone to being part of a group of 2 or more buttons, or vice-versa, and when a buttton is moved from one group of 2 or more buttons to a different one, but not when the composition of the group that a button belongs to changes.
223
224-- style : 	the object which received the signal
225-- user_data : 	user data set when the signal handler was connected.
226
227-- Since 2.4
228-- See Also
229
230-- GtkOptionMenu 	
231
232-- Another way of offering the user a single choice from many.
233end