/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

  1. indexing
  2. description: "GTK_RADIO_BUTTON -- A choice from multiple check buttons."
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. date: "$Date:$"
  19. revision: "$Revision:$"
  20. class GTK_RADIO_BUTTON
  21. -- A single radio button performs the same basic function as a
  22. -- GtkCheckButton, as its position in the object hierarchy
  23. -- reflects. It is only when multiple radio buttons are grouped
  24. -- together that they become a different user interface component
  25. -- in their own right.
  26. -- Every radio button is a member of some group of radio
  27. -- buttons. When one is selected, all other radio buttons in the
  28. -- same group are deselected. A GtkRadioButton is one way of giving
  29. -- the user a choice from many options.
  30. -- Create the first radio button of a group with `in_a_new_group',
  31. -- then add further buttons with the other cration procedures
  32. -- (i.e.: `from_group', `from_widget' and so on)
  33. -- Retrieve the group a GtkRadioButton is assigned to use gtk_radio_button_get_group().
  34. -- To remove a GtkRadioButton from one group and make it part of a new one, use gtk_radio_button_set_group().
  35. -- The group list does not need to be freed, as each GtkRadioButton will remove itself and its list item when it is destroyed.
  36. -- Example 1. How to create a group of two radio buttons.
  37. -- void create_radio_buttons (void) {
  38. -- GtkWidget *window, *radio1, *radio2, *box, *entry;
  39. -- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  40. -- box = gtk_vbox_new (TRUE, 2);
  41. -- /* Create a radio button with a GtkEntry widget */
  42. -- radio1 = gtk_radio_button_new (NULL);
  43. -- entry = gtk_entry_new ();
  44. -- gtk_container_add (GTK_CONTAINER (radio1), entry);
  45. -- /* Create a radio button with a label */
  46. -- radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1),
  47. -- "I'm the second radio button.");
  48. -- /* Pack them into a box, then show all the widgets */
  49. -- gtk_box_pack_start (GTK_BOX (box), radio1, TRUE, TRUE, 2);
  50. -- gtk_box_pack_start (GTK_BOX (box), radio2, TRUE, TRUE, 2);
  51. -- gtk_container_add (GTK_CONTAINER (window), box);
  52. -- gtk_widget_show_all (window);
  53. -- return;
  54. -- }
  55. -- 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.
  56. inherit
  57. GTK_CHECK_BUTTON
  58. rename
  59. with_label as make_check_with_label,
  60. with_mnemonic as make_check_with_mnemonic
  61. export {} make_check_with_label, make_check_with_mnemonic
  62. -- Instead of undefining, which would turn this class into a
  63. -- deferred one.
  64. end
  65. insert
  66. GTK_RADIO_BUTTON_EXTERNALS
  67. -- GtkRadioButton implements AtkImplementorIface.
  68. creation
  69. in_a_new_group,
  70. from_group,
  71. from_widget,
  72. with_label,
  73. with_label_from_widget,
  74. with_mnemonic,
  75. with_mnemonic_from_widget,
  76. from_external_pointer
  77. feature {} -- Creation
  78. in_a_new_group is
  79. -- Creates a new GTK_RADIO_BUTTON in a new group.
  80. do
  81. from_external_pointer (gtk_radio_button_new (default_pointer))
  82. end
  83. from_group (a_group: G_SLIST[GTK_RADIO_BUTTON]) is
  84. -- Creates a new GTK_RADIO_BUTTON. To be of any practical
  85. -- value, a widget should then be packed into the radio
  86. -- button. `a_group': an existing radio button group, or Void
  87. -- if you are creating a new group.
  88. require
  89. gtk_initialized: gtk.is_initialized
  90. group_not_void: a_group/=Void
  91. do
  92. from_external_pointer (gtk_radio_button_new (a_group.handle))
  93. end
  94. from_widget (a_widget: GTK_RADIO_BUTTON) is
  95. -- Creates a new GtkRadioButton, adding it to the same group
  96. -- of `a_widget'. As with `make', a widget should be packed
  97. -- into the radio button.
  98. require
  99. gtk_initialized: gtk.is_initialized
  100. widget_not_void: a_widget /= Void
  101. do
  102. from_external_pointer (gtk_radio_button_new_from_widget (a_widget.handle))
  103. end
  104. with_label (a_group: G_SLIST[GTK_RADIO_BUTTON]; a_label: STRING) is
  105. -- Creates a new GTK_RADIO_BUTTON with `a_label' displayed
  106. -- next to the radio button; `a_group' is an existing radio
  107. -- button group, or Void if you are creating a new group.
  108. require
  109. gtk_initialized: gtk.is_initialized
  110. group_not_void: a_group/=Void implies not a_group.is_empty
  111. label_not_void: a_label /= Void
  112. local ptr: POINTER
  113. do
  114. if a_group/=Void then ptr:=a_group.handle end
  115. from_external_pointer (gtk_radio_button_new_with_label (ptr, a_label.to_external))
  116. end
  117. with_label_from_widget (a_widget: GTK_RADIO_BUTTON; a_label: STRING) is
  118. -- Creates a new GtkRadioButton, adding it to the same group
  119. -- of `a_widget'; `a_label' displayed next to the radio
  120. -- button.
  121. require
  122. gtk_initialized: gtk.is_initialized
  123. widget_not_void: a_widget /= Void
  124. label_not_void: a_label /= Void
  125. do
  126. from_external_pointer(gtk_radio_button_new_with_label_from_widget
  127. (a_widget.handle, a_label.to_external))
  128. end
  129. with_mnemonic (a_group: G_SLIST[GTK_RADIO_BUTTON]; a_label: STRING) is
  130. -- Creates a new GtkRadioButton containing `a_label', adding
  131. -- it to `a_group'. The label will be created using
  132. -- GTK_LABEL.with_mnemonic, so underscores in label indicate
  133. -- the mnemonic for the button.
  134. require
  135. gtk_initialized: gtk.is_initialized
  136. group_not_void: a_group/=Void implies not a_group.is_empty
  137. label_not_void: a_label /= Void
  138. do
  139. from_external_pointer (gtk_radio_button_new_with_mnemonic (a_group.handle, a_label.to_external))
  140. end
  141. with_mnemonic_from_widget (a_widget: GTK_RADIO_BUTTON; a_label: STRING) is
  142. -- Creates a new GTK_RADIO_BUTTON containing `a_label' to the
  143. -- same group of `a_widget'. The label will be created using
  144. -- GTK_LABEL.with_mnemonic, so underscores in label indicate
  145. -- the mnemonic for the button.
  146. require
  147. gtk_initialized: gtk.is_initialized
  148. widget_not_void: a_widget /= Void
  149. label_not_void: a_label /= Void
  150. do
  151. from_external_pointer (gtk_radio_button_new_with_mnemonic_from_widget
  152. (a_widget.handle, a_label.to_external))
  153. end
  154. feature -- group
  155. set_group (a_group: G_SLIST[GTK_RADIO_BUTTON]) is
  156. -- Sets a Current's group to `a_group'. It should be noted
  157. -- that this does not change the layout of your interface in
  158. -- any way, so if you are changing the group, it is likely
  159. -- you will need to re-arrange the user interface to reflect
  160. -- these changes. See also `set_group_from'
  161. do
  162. gtk_radio_button_set_group (handle,a_group.handle)
  163. end
  164. set_group_from (another: GTK_RADIO_BUTTON) is
  165. -- Makes Current belong to the same group of `another'. The
  166. -- implementation is (slightly) faster than
  167. -- a_radio_button.set_group (another.group)
  168. do
  169. gtk_radio_button_set_group (handle,
  170. gtk_radio_button_get_group(another.handle))
  171. end
  172. group: G_SLIST[GTK_RADIO_BUTTON] is
  173. -- the group assigned to a radio button.
  174. do
  175. create {G_OBJECT_SLIST[GTK_RADIO_BUTTON]} Result.from_external_pointer (gtk_radio_button_get_group(handle))
  176. end
  177. feature -- Property Details TODO
  178. -- The "group" property
  179. -- "group" GtkRadioButton : Write
  180. -- Sets a new group for a radio button.
  181. feature -- Signal Details TODO
  182. -- The "group-changed" signal
  183. -- void user_function (GtkRadioButton *style,
  184. -- gpointer user_data) : Run first
  185. -- 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.
  186. -- style : the object which received the signal
  187. -- user_data : user data set when the signal handler was connected.
  188. -- Since 2.4
  189. -- See Also
  190. -- GtkOptionMenu
  191. -- Another way of offering the user a single choice from many.
  192. end