/src/wrappers/gtk/library/gtk_cell_view.e

http://github.com/tybor/Liberty · Specman e · 218 lines · 134 code · 39 blank · 45 comment · 3 complexity · f82b57f523d6cad4daad79b05263a1a9 MD5 · raw file

  1. indexing
  2. description: "GtkCellView, a widget displaying a single row of a GtkTreeModel."
  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. class GTK_CELL_VIEW
  19. -- A GtkCellView displays a single row of a GtkTreeModel, using
  20. -- cell renderers just like GtkTreeView. GtkCellView doesn't
  21. -- support some of the more complex features of GtkTreeView, like
  22. -- cell editing and drag and drop.
  23. inherit
  24. GTK_WIDGET
  25. GTK_CELL_LAYOUT
  26. undefine
  27. store_eiffel_wrapper
  28. end
  29. -- GtkCellView also implements AtkImplementorIface.
  30. creation make, from_external_pointer
  31. feature {} -- Creation
  32. make is
  33. -- Creates a new GtkCellView widget.
  34. do
  35. from_external_pointer (gtk_cell_view_new)
  36. end
  37. make_with_text (a_text: STRING) is
  38. -- Creates a new GtkCellView widget, adds a
  39. -- GtkCellRendererText to it, and makes its show `a_text'.
  40. require valide_text: a_text /= Void
  41. do
  42. handle:=gtk_cell_view_new_with_text (a_text.to_external)
  43. store_eiffel_wrapper
  44. end
  45. new_with_markup (a_markup: STRING) is
  46. -- Creates a new GtkCellView widget, adds a
  47. -- GtkCellRendererText to it, and makes its show
  48. -- `a_markup'. The text can be marked up with the Pango text
  49. -- markup language.
  50. require valid_text: a_markup /= Void
  51. do
  52. from_external_pointer (gtk_cell_view_new_with_markup (a_markup.to_external))
  53. end
  54. make_with_pixbuf (a_pixbuf: GDK_PIXBUF) is
  55. -- Creates a new GtkCellView widget, adds a
  56. -- GtkCellRendererPixbuf to it, and makes its show `a_pixbuf'.
  57. do
  58. handle:=gtk_cell_view_new_with_pixbuf (a_pixbuf.handle)
  59. store_eiffel_wrapper
  60. end
  61. feature
  62. set_model (a_model: GTK_TREE_MODEL) is
  63. -- Sets the model for cell_view. If Current already has a
  64. -- model set, it will remove it before setting the new model.
  65. require valid_model: a_model /= Void
  66. do
  67. gtk_cell_view_set_model (handle, a_model.handle)
  68. end
  69. unset_model is
  70. -- Unset the old model.
  71. do
  72. gtk_cell_view_set_model (handle, default_pointer)
  73. end
  74. set_displayed_row (a_path: GTK_TREE_PATH) is
  75. -- Sets the row of the model that is currently displayed by
  76. -- the GtkCellView. If the `a_path' is unset, then the
  77. -- contents of the cellview "stick" at their last value; this
  78. -- is not normally a desired result, but may be a needed
  79. -- intermediate state if say, the model for the GtkCellView
  80. -- becomes temporarily empty.
  81. require valid_path: a_path /= Void
  82. do
  83. gtk_cell_view_set_displayed_row (handle, a_path.handle)
  84. end
  85. unset_displayed_row is
  86. -- Unset the displayed row; it is not normally a desired
  87. -- result, but may be a needed intermediate state if say, the
  88. -- model for the GtkCellView becomes temporarily empty.
  89. do
  90. gtk_cell_view_set_displayed_row (handle, default_pointer)
  91. end
  92. displayed_row: GTK_TREE_PATH is
  93. -- A GtkTreePath referring to the currently displayed row. It
  94. -- is Void ff no row is currently displayed.
  95. local
  96. ptr: POINTER
  97. do
  98. ptr := gtk_cell_view_get_displayed_row (handle)
  99. if ptr.is_not_null then create Result.from_external_pointer (ptr) end
  100. end
  101. size_of_row (a_path: GTK_TREE_PATH): GTK_REQUISITION is
  102. -- the size needed by Current to display the model row pointed to by `a_path'.
  103. require valid_path: a_path /= Void
  104. local shall_be_true: INTEGER
  105. do
  106. create Result.make
  107. shall_be_true:=gtk_cell_view_get_size_of_row (handle, a_path.handle,
  108. Result.handle)
  109. end
  110. set_background_color (a_color: GDK_COLOR) is
  111. -- Sets the background color of view.
  112. do
  113. gtk_cell_view_set_background_color (handle, a_color.handle)
  114. end
  115. cell_renderers: G_LIST [GTK_CELL_RENDERER] is
  116. -- the cell renderers which have been added to Current
  117. -- cell_view.
  118. do
  119. create {G_OBJECT_LIST[GTK_CELL_RENDERER]}
  120. Result.from_external_pointer (gtk_cell_view_get_cell_renderers (handle))
  121. debug print (once "Warning! Possible memory problems in GTK_CELL_VIEW.cell_renderers%N") end
  122. -- TODO: The returned list, but not the renderers has been newly
  123. -- allocated and should be freed with g_list_free() when no
  124. -- longer needed.
  125. end
  126. feature -- The "background" property
  127. set_backgroud_color_name (a_color_name: STRING) is
  128. do
  129. set_string_property (background_property_name, a_color_name)
  130. end
  131. -- "background" gchararray : Write
  132. -- Background color as a string.
  133. -- Default value: NULL
  134. -- The "background-gdk" property
  135. -- "background-gdk" GdkColor : Read / Write
  136. -- Background color as a GdkColor.
  137. -- The "background-set" property
  138. -- "background-set" gboolean : Read / Write
  139. -- Whether this tag affects the background color.
  140. -- Default value: FALSE
  141. feature -- size
  142. struct_size: INTEGER is
  143. external "C inline use <gtk/gtk.h>"
  144. alias "sizeof(GtkCellView)"
  145. end
  146. feature {} -- Properties string-names
  147. background_property_name: STRING is "background"
  148. feature {} -- External calls
  149. gtk_cell_view_new: POINTER is
  150. external "C use <gtk/gtk.h>"
  151. end
  152. gtk_cell_view_new_with_text (a_text: POINTER): POINTER is
  153. external "C use <gtk/gtk.h>"
  154. end
  155. gtk_cell_view_new_with_markup (a_markup: POINTER): POINTER is
  156. external "C use <gtk/gtk.h>"
  157. end
  158. gtk_cell_view_new_with_pixbuf (a_pixbuf: POINTER): POINTER is
  159. external "C use <gtk/gtk.h>"
  160. end
  161. gtk_cell_view_set_model (a_cell_view, a_model: POINTER) is
  162. external "C use <gtk/gtk.h>"
  163. end
  164. gtk_cell_view_set_displayed_row (a_cell_view, a_path: POINTER) is
  165. external "C use <gtk/gtk.h>"
  166. end
  167. gtk_cell_view_get_displayed_row (a_cell_view: POINTER): POINTER is
  168. external "C use <gtk/gtk.h>"
  169. end
  170. gtk_cell_view_get_size_of_row (a_cell_view, a_path, a_gtk_requisiton: POINTER): INTEGER is -- gboolean
  171. external "C use <gtk/gtk.h>"
  172. end
  173. gtk_cell_view_set_background_color (a_cell_view a_gdk_color: POINTER) is
  174. external "C use <gtk/gtk.h>"
  175. end
  176. gtk_cell_view_get_cell_renderers (a_cell_view: POINTER): POINTER is -- GList*
  177. external "C use <gtk/gtk.h>"
  178. end
  179. end