/src/wrappers/gtk/library/gtk_expander.e

http://github.com/tybor/Liberty · Specman e · 365 lines · 167 code · 92 blank · 106 comment · 3 complexity · 56af825173728e72ebe3f3847af4b23a MD5 · raw file

  1. indexing
  2. description: "GtkExpander -- A container which can hide its child."
  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_EXPANDER
  21. -- A GtkExpander allows the user to hide or show its child by clicking on an
  22. -- expander triangle similar to the triangles used in a GtkTreeView.
  23. -- Normally you use an expander as you would use any other descendant of
  24. -- GtkBin; you create the child widget and use gtk_container_add() to add it
  25. -- to the expander. When the expander is toggled, it will take care of
  26. -- showing and hiding the child automatically.
  27. -- Special Usage: There are situations in which you may prefer to show and
  28. -- hide the expanded widget yourself, such as when you want to actually
  29. -- create the widget at expansion time. In this case, create a GtkExpander
  30. -- but do not add a child to it. The expander widget has an expanded property
  31. -- which can be used to monitor its expansion state. You should watch this
  32. -- property with a signal connection as follows:
  33. -- expander = gtk_expander_new_with_mnemonic ("_More Options");
  34. -- g_signal_connect (expander, "notify::expanded", G_CALLBACK
  35. -- (expander_callback), NULL);
  36. -- ...
  37. -- static void -- expander_callback (GObject *object, GParamSpec *param_spec,
  38. -- gpointer user_data) -- { -- GtkExpander *expander;
  39. -- expander = GTK_EXPANDER (object);
  40. -- if (gtk_expander_get_expanded (expander)) { /* Show or create widgets */ }
  41. -- else { /* Hide or destroy widgets */ } -- }
  42. inherit
  43. GTK_BIN -- rename make as make_bin end
  44. -- Implemented Interfaces: GtkExpander implements AtkImplementorIface.
  45. insert G_OBJECT_FACTORY [GTK_WIDGET]
  46. creation make, make_with_mnemonic, from_external_pointer
  47. feature {} -- Creation
  48. make (a_label: STRING) is
  49. -- Creates a new expander using 'a_label' as the text of the
  50. -- label.
  51. -- Note: better make as in Eiffel tradition or new as in GTK
  52. -- API? Paolo 2006-04-27
  53. require valid_label: a_label /= Void
  54. do
  55. from_external_pointer(gtk_expander_new(a_label.to_external))
  56. end
  57. make_with_mnemonic (a_label: STRING) is
  58. -- Creates a new expander using label as the text of the
  59. -- label. If characters in label are preceded by an
  60. -- underscore, they are underlined. If you need a literal
  61. -- underscore character in a label, use '__' (two
  62. -- underscores). The first underlined character represents a
  63. -- keyboard accelerator called a mnemonic. Pressing Alt and
  64. -- that key activates the button.
  65. -- Note: better make_with_mnemonic as in Eiffel tradition or
  66. -- new_with_mnemonic as in GTK API? Paolo 2006-04-27
  67. require valid_label: a_label /= Void
  68. do
  69. from_external_pointer(gtk_expander_new_with_mnemonic(a_label.to_external))
  70. end
  71. feature
  72. set_expanded is
  73. -- Reveales the child widget to be revealed
  74. do
  75. gtk_expander_set_expanded (handle, 1)
  76. ensure is_expanded: is_expanded
  77. end
  78. unset_expanded is
  79. -- Hides the child widget.
  80. do
  81. gtk_expander_set_expanded (handle, 0)
  82. ensure unexpanded: not is_expanded
  83. end
  84. is_expanded: BOOLEAN is
  85. -- IS the child widget shown to the user?
  86. do
  87. Result:=gtk_expander_get_expanded(handle).to_boolean
  88. end
  89. set_spacing (a_spacing: INTEGER) is
  90. -- Sets the spacing field of expander, wbhich is the number of
  91. -- pixels to place between expander and the child.
  92. do
  93. gtk_expander_set_spacing (handle, a_spacing)
  94. end
  95. spacing: INTEGER is
  96. -- the spacing field of expander, wbhich is the number of
  97. -- pixels to place between expander and the child.
  98. do
  99. Result:=gtk_expander_get_spacing(handle)
  100. end
  101. set_label (a_label: STRING) is
  102. -- Sets the text of the label of the expander to `a_label'.
  103. -- This will also clear any previously set labels.
  104. require valid_label: a_label /= Void
  105. do
  106. gtk_expander_set_label (handle, a_label.to_external)
  107. end
  108. label: STRING is
  109. -- The text from the label of the expander, as set by --
  110. -- `set_label'. If the label text has not been set the return
  111. -- value will be Void. This will be the case if you create an
  112. -- empty button with make to use as a container.
  113. local ptr: POINTER
  114. do
  115. ptr:=gtk_expander_get_label(handle)
  116. -- Note: gtk_expander_get_label returns a pointer owned by
  117. -- the widget and must not be modified or freed.
  118. if ptr.is_not_null then
  119. create Result.from_external_copy (ptr)
  120. end
  121. end
  122. set_use_underline is
  123. -- Put an underline in the text of the expander label
  124. -- indicating the character used for the mnemonic accelerator
  125. -- key.
  126. do
  127. gtk_expander_set_use_underline (handle, 1)
  128. ensure set: is_underline_used
  129. end
  130. unset_use_underline is
  131. -- Remove the underline under the mnemonic accelerator key
  132. do
  133. gtk_expander_set_use_underline (handle, 0)
  134. ensure unset: not is_underline_used
  135. end
  136. is_underline_used: BOOLEAN is
  137. -- Does an embedded underline in the expander label indicates
  138. -- a mnemonic? See `set_use_underline'.
  139. do
  140. Result:=gtk_expander_get_use_underline(handle).to_boolean
  141. end
  142. set_use_markup is
  143. -- Sets whether the text of the label contains markup in
  144. -- Pango's text markup language. See `set_markup'.
  145. do
  146. gtk_expander_set_use_markup (handle, 1)
  147. ensure set: is_markup_used
  148. end
  149. unset_use_markup is
  150. -- Do not use Pango markups in the label
  151. do
  152. gtk_expander_set_use_markup (handle, 0)
  153. ensure unset: not is_markup_used
  154. end
  155. is_markup_used: BOOLEAN is
  156. -- Is the label's text interpreted as marked up with the
  157. -- Pango text markup language? See `set_use_markup'.
  158. do
  159. Result:=(gtk_expander_get_use_markup(handle).to_boolean)
  160. end
  161. set_label_widget (a_widget: GTK_WIDGET) is
  162. -- Set the label widget for the expander. This is the widget
  163. -- that will appear emCbedded alongside the expander arrow.
  164. require valid_widget: a_widget /= Void
  165. do
  166. gtk_expander_set_label_widget (handle, a_widget.handle)
  167. end
  168. label_widget: GTK_WIDGET is
  169. -- The label widget for the frame. 'set_label_widget'. Can
  170. -- be Void
  171. do
  172. Result := wrapper (gtk_expander_get_label_widget (handle))
  173. end
  174. -- Since 2.4
  175. feature -- Properties
  176. -- "expanded" gboolean : Read / Write / Construct
  177. -- "label" gchararray : Read / Write / Construct
  178. -- "label-widget" GtkWidget : Read / Write
  179. -- "spacing" gint : Read / Write
  180. -- "use-markup" gboolean : Read / Write / Construct
  181. -- "use-underline" gboolean : Read / Write / Construct
  182. -- Style Properties
  183. -- "expander-size" gint : Read
  184. -- "expander-spacing" gint : Read
  185. -- "activate" void user_function (GtkExpander *expander,
  186. -- gpointer user_data) : Run last / Action
  187. -- The "spacing" property
  188. -- "spacing" gint : Read / Write
  189. -- Space to put between the label and the child.
  190. -- Allowed values: >= 0
  191. -- Default value: 0
  192. -- -----------------------------------------------------------------------
  193. -- The "use-markup" property
  194. -- "use-markup" gboolean : Read / Write / Construct
  195. -- The text of the label includes XML markup. See pango_parse_markup().
  196. -- Default value: FALSE
  197. -- -----------------------------------------------------------------------
  198. -- The "use-underline" property
  199. -- "use-underline" gboolean : Read / Write / Construct
  200. -- If set, an underline in the text indicates the next character should be
  201. -- used for the mnemonic accelerator key.
  202. -- Default value: FALSE
  203. -- Style Property Details
  204. -- The "expander-size" style property
  205. -- "expander-size" gint : Read
  206. -- Size of the expander arrow.
  207. -- Allowed values: >= 0
  208. -- Default value: 10
  209. -- -----------------------------------------------------------------------
  210. -- The "expander-spacing" style property
  211. -- "expander-spacing" gint : Read
  212. -- Spacing around expander arrow.
  213. -- Allowed values: >= 0
  214. -- Default value: 2
  215. feature -- The "activate" signal
  216. activate_signal_name: STRING is "activate"
  217. on_activate is
  218. do
  219. -- Empty by default
  220. end
  221. enable_on_activate is
  222. do
  223. connect (Current, activate_signal_name, $on_activate)
  224. end
  225. feature {} -- size
  226. struct_size: INTEGER is
  227. external "C inline use <gtk/gtk.h>"
  228. alias "sizeof(GtkExpander)"
  229. end
  230. feature {} -- External calls
  231. gtk_expander_new (a_label: POINTER): POINTER is -- GtkWidget*
  232. external "C use <gtk/gtk.h>"
  233. end
  234. gtk_expander_new_with_mnemonic (a_label: POINTER): POINTER is -- GtkWidget*
  235. external "C use <gtk/gtk.h>"
  236. end
  237. gtk_expander_set_expanded (an_expander: POINTER; an_expanded: INTEGER) is
  238. external "C use <gtk/gtk.h>"
  239. end
  240. gtk_expander_get_expanded (an_expander: POINTER): INTEGER is
  241. external "C use <gtk/gtk.h>"
  242. end
  243. gtk_expander_set_spacing (an_expander: POINTER; a_spacing: INTEGER) is
  244. external "C use <gtk/gtk.h>"
  245. end
  246. gtk_expander_get_spacing (an_expander: POINTER): INTEGER is
  247. external "C use <gtk/gtk.h>"
  248. end
  249. gtk_expander_set_label (an_expander, a_label: POINTER) is
  250. external "C use <gtk/gtk.h>"
  251. end
  252. gtk_expander_get_label (an_expander: POINTER): POINTER is -- const gchar*
  253. external "C use <gtk/gtk.h>"
  254. end
  255. gtk_expander_set_use_underline (an_expander: POINTER; a_use_underline: INTEGER) is
  256. external "C use <gtk/gtk.h>"
  257. end
  258. gtk_expander_get_use_underline (an_expander: POINTER): INTEGER is
  259. external "C use <gtk/gtk.h>"
  260. end
  261. gtk_expander_set_use_markup (an_expander: POINTER; a_use_markup: INTEGER) is
  262. external "C use <gtk/gtk.h>"
  263. end
  264. gtk_expander_get_use_markup (an_expander: POINTER): INTEGER is
  265. external "C use <gtk/gtk.h>"
  266. end
  267. gtk_expander_set_label_widget (an_expander, a_label_widget: POINTER) is
  268. external "C use <gtk/gtk.h>"
  269. end
  270. gtk_expander_get_label_widget (an_expander: POINTER): POINTER is -- GtkWidget*
  271. external "C use <gtk/gtk.h>"
  272. end
  273. end