/src/wrappers/gtk/library/gtk_cell_renderer.e

http://github.com/tybor/Liberty · Specman e · 388 lines · 94 code · 87 blank · 207 comment · 3 complexity · 250b3434ec6a3da4a48e32ec5c340135 MD5 · raw file

  1. indexing
  2. description: "GtkCellRenderer An object for rendering a single cell on a GdkDrawable."
  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. deferred class GTK_CELL_RENDERER
  19. -- The GtkCellRenderer is a base class of a set of objects used for
  20. -- rendering a cell to a GdkDrawable. These objects are used
  21. -- primarily by the GtkTreeView widget, though they aren't tied to
  22. -- them in any specific way. It is worth noting that
  23. -- GtkCellRenderer is not a GtkWidget and cannot be treated as
  24. -- such.
  25. -- The primary use of a GtkCellRenderer is for drawing a certain
  26. -- graphical elements on a GdkDrawable. Typically, one cell
  27. -- renderer is used to draw many cells on the screen. To this
  28. -- extent, it isn't expected that a CellRenderer keep any permanent
  29. -- state around. Instead, any state is set just prior to use using
  30. -- GObjects property system. Then, the cell is measured using
  31. -- `size'. Finally, the cell is rendered in the correct location
  32. -- using `render'.
  33. -- There are a number of rules that must be followed when
  34. -- writing a new GtkCellRenderer. First and formost, it's
  35. -- important that a certain set of properties will always
  36. -- yield a cell renderer of the same size, barring a GtkStyle
  37. -- change. The GtkCellRenderer also has a number of generic
  38. -- properties that are expected to be honored by all
  39. -- children.
  40. -- Beyond merely rendering a cell, cell renderers can optionally
  41. -- provide active user interface elements. A cell renderer can be
  42. -- activatable like GtkCellRendererToggle, which toggles when it
  43. -- gets activated by a mouse click, or it can be editable like
  44. -- GtkCellRendererText, which allows the user to edit the text
  45. -- using a GtkEntry. To make a cell renderer activatable or
  46. -- editable, you have to implement the activate or start_editing
  47. -- virtual functions, respectively.
  48. inherit
  49. GTK_OBJECT
  50. insert
  51. GTK_CELL_RENDERER_EXTERNALS
  52. feature
  53. size (a_widget: GTK_WIDGET): TUPLE[INTEGER,INTEGER,INTEGER,INTEGER,GDK_RECTANGLE] is
  54. -- The x and y offset width and height needed to render the
  55. -- cell. Used by view widgets to determine the appropriate
  56. -- size for the cell_area passed to `render'. x and y offsets
  57. -- are relative to the GDK_RECTANGLE. Please note that the
  58. -- values set in width and height, as well as those in
  59. -- x_offset and y_offset are inclusive of the xpad and ypad
  60. -- properties.
  61. require
  62. widget_not_void: a_widget/=Void
  63. local
  64. an_x_offset, an_y_offset, a_width, an_height: INTEGER
  65. a_rectangle: GDK_RECTANGLE
  66. do
  67. create a_rectangle.make
  68. -- cell : a GtkCellRenderer
  69. -- widget : the widget the renderer is rendering to
  70. -- cell_area : The area a cell will be allocated, or NULL
  71. -- x_offset : location to return x offset of cell relative to cell_area, or NULL
  72. -- y_offset : location to return y offset of cell relative to cell_area, or NULL
  73. -- width : location to return width needed to render a cell, or NULL
  74. -- height : location to return height needed to render a cell, or NULL
  75. gtk_cell_renderer_get_size (handle, a_widget.handle,
  76. a_rectangle.handle, $an_x_offset, $an_y_offset,
  77. $a_width, $an_height)
  78. create Result.make_5(an_x_offset, an_y_offset, a_width, an_height, a_rectangle)
  79. ensure
  80. not_void: Result/=Void
  81. rectangle_not_void: Result.item_5 /= Void
  82. end
  83. -- render (a_window: GTK_WINDOW; a_widget: GTK_WIDGET)
  84. -- void gtk_cell_renderer_render (GtkCellRenderer *cell,
  85. -- GdkWindow *window,
  86. -- GtkWidget *widget,
  87. -- GdkRectangle *background_area,
  88. -- GdkRectangle *cell_area,
  89. -- GdkRectangle *expose_area,
  90. -- GtkCellRendererState flags);
  91. -- Invokes the virtual render function of the GtkCellRenderer. The
  92. -- three passed-in rectangles are areas of window. Most renderers
  93. -- will draw within cell_area; the xalign, yalign, xpad, and ypad
  94. -- fields of the GtkCellRenderer should be honored with respect to
  95. -- cell_area. background_area includes the blank space around the
  96. -- cell, and also the area containing the tree expander; so the
  97. -- background_area rectangles for all cells tile to cover the
  98. -- entire window. expose_area is a clip rectangle.
  99. -- cell : a GtkCellRenderer
  100. -- window : a GdkDrawable to draw to
  101. -- widget : the widget owning window
  102. -- background_area : entire cell area (including tree expanders and maybe padding on the sides)
  103. -- cell_area : area normally rendered by a cell renderer
  104. -- expose_area : area that actually needs updating
  105. -- flags : flags that affect rendering
  106. -- gtk_cell_renderer_activate ()
  107. -- gboolean gtk_cell_renderer_activate (GtkCellRenderer *cell,
  108. -- GdkEvent *event,
  109. -- GtkWidget *widget,
  110. -- const gchar *path,
  111. -- GdkRectangle *background_area,
  112. -- GdkRectangle *cell_area,
  113. -- GtkCellRendererState flags);
  114. -- Passes an activate event to the cell renderer for possible processing. Some cell renderers may use events; for example, GtkCellRendererToggle toggles when it gets a mouse click.
  115. -- cell : a GtkCellRenderer
  116. -- event : a GdkEvent
  117. -- widget : widget that received the event
  118. -- path : widget-dependent string representation of the event location; e.g. for GtkTreeView, a string representation of GtkTreePath
  119. -- background_area : background area as passed to gtk_cell_renderer_render
  120. -- cell_area : cell area as passed to gtk_cell_renderer_render
  121. -- flags : render flags
  122. -- Returns : TRUE if the event was consumed/handled
  123. -- gtk_cell_renderer_start_editing ()
  124. -- GtkCellEditable* gtk_cell_renderer_start_editing
  125. -- (GtkCellRenderer *cell,
  126. -- GdkEvent *event,
  127. -- GtkWidget *widget,
  128. -- const gchar *path,
  129. -- GdkRectangle *background_area,
  130. -- GdkRectangle *cell_area,
  131. -- GtkCellRendererState flags);
  132. -- Passes an activate event to the cell renderer for possible processing.
  133. -- cell : a GtkCellRenderer
  134. -- event : a GdkEvent
  135. -- widget : widget that received the event
  136. -- path : widget-dependent string representation of the event location; e.g. for GtkTreeView, a string representation of GtkTreePath
  137. -- background_area : background area as passed to gtk_cell_renderer_render
  138. -- cell_area : cell area as passed to gtk_cell_renderer_render
  139. -- flags : render flags
  140. -- Returns : A new GtkCellEditable, or NULL
  141. stop_editing (emit_editing_canceled_signal: BOOLEAN) is
  142. -- Informs the cell renderer that the editing is stopped. If
  143. -- `emit_editing_canceled_signal' is True, the cell renderer
  144. -- will emit the "editing-canceled" signal. This function
  145. -- should be called by cell renderer implementations in
  146. -- response to the "editing-done" signal of GtkCellEditable.
  147. do
  148. gtk_cell_renderer_stop_editing (handle, emit_editing_canceled_signal.to_integer)
  149. end
  150. fixed_size: TUPLE[INTEGER,INTEGER] is
  151. -- the fixed width and height of the widget
  152. local a_width, an_height: INTEGER
  153. do
  154. gtk_cell_renderer_get_fixed_size (handle, $a_width, $an_height)
  155. create Result.make_2 (a_width, an_height)
  156. end
  157. set_fixed_size (a_width, an_height: INTEGER) is
  158. -- Sets the renderer size to be explicit, independent of the
  159. -- properties set. `a_width': the width of the cell renderer,
  160. -- or -1; `an_height': the height of the cell renderer, or -1
  161. do
  162. gtk_cell_renderer_set_fixed_size (handle, a_width, an_height)
  163. end
  164. feature -- Property Details
  165. -- The "cell-background" property
  166. -- "cell-background" gchararray : Write
  167. -- Cell background color as a string.
  168. -- Default value: NULL
  169. -- The "cell-background-gdk" property
  170. -- "cell-background-gdk" GdkColor : Read / Write
  171. -- Cell background color as a GdkColor.
  172. -- The "cell-background-set" property
  173. -- "cell-background-set" gboolean : Read / Write
  174. -- Whether this tag affects the cell background color.
  175. -- Default value: FALSE
  176. -- The "height" property
  177. -- "height" gint : Read / Write
  178. -- The fixed height.
  179. -- Allowed values: >= -1
  180. -- Default value: -1
  181. -- The "is-expanded" property
  182. -- "is-expanded" gboolean : Read / Write
  183. -- Row is an expander row, and is expanded.
  184. -- Default value: FALSE
  185. -- The "is-expander" property
  186. -- "is-expander" gboolean : Read / Write
  187. -- Row has children.
  188. -- Default value: FALSE
  189. -- The "mode" property
  190. -- "mode" GtkCellRendererMode : Read / Write
  191. -- Editable mode of the CellRenderer.
  192. -- Default value: GTK_CELL_RENDERER_MODE_INERT
  193. -- The "sensitive" property
  194. -- "sensitive" gboolean : Read / Write
  195. -- Display the cell sensitive.
  196. -- Default value: TRUE
  197. -- The "visible" property
  198. -- "visible" gboolean : Read / Write
  199. -- Display the cell.
  200. -- Default value: TRUE
  201. -- The "width" property
  202. -- "width" gint : Read / Write
  203. -- The fixed width.
  204. -- Allowed values: >= -1
  205. -- Default value: -1
  206. -- The "xalign" property
  207. -- "xalign" gfloat : Read / Write
  208. -- The x-align.
  209. -- Allowed values: [0,1]
  210. -- Default value: 0.5
  211. -- The "xpad" property
  212. -- "xpad" guint : Read / Write
  213. -- The xpad.
  214. -- Default value: 0
  215. -- The "yalign" property
  216. -- "yalign" gfloat : Read / Write
  217. -- The y-align.
  218. -- Allowed values: [0,1]
  219. -- Default value: 0.5
  220. -- The "ypad" property
  221. -- "ypad" guint : Read / Write
  222. -- The ypad.
  223. -- Default value: 0
  224. feature -- "editing-canceled"
  225. editing_canceled_signal_name: STRING is "editing-canceled"
  226. -- "editing-canceled"
  227. -- void user_function (GtkCellRenderer *renderer,
  228. -- gpointer user_data);
  229. enable_on_editing_canceled is
  230. -- Connects "editing-canceled" signal to `on_editing_canceled' feature.
  231. do
  232. connect (Current, editing_canceled_signal_name, $on_editing_canceled)
  233. end
  234. on_editing_canceled: INTEGER is
  235. -- This signal gets emitted when the user cancels the process of
  236. -- editing a cell. For example, an editable cell renderer could be
  237. -- written to cancel editing when the user presses Escape.
  238. do
  239. end
  240. connect_agent_to_editing_canceled_signal (a_procedure: PROCEDURE[ANY, TUPLE [GTK_CELL_RENDERER]]) is
  241. -- renderer : the object which received the signal
  242. require
  243. valid_procedure: a_procedure /= Void
  244. wrapper_is_stored: is_eiffel_wrapper_stored
  245. local
  246. editing_canceled_callback: EDITING_CANCELED_CALLBACK
  247. do
  248. create editing_canceled_callback.make
  249. editing_canceled_callback.connect (Current, a_procedure)
  250. end
  251. feature -- "editing-started"
  252. editing_started_signal_name: STRING is "editing-started"
  253. -- "editing-started"
  254. -- void user_function (GtkCellRenderer *renderer,
  255. -- GtkCellEditable *editable,
  256. -- gchar *path,
  257. -- gpointer user_data);
  258. enable_on_editing_started is
  259. -- Connects "editing-started" signal to `on_editing_started' feature.
  260. do
  261. connect (Current, editing_started_signal_name, $on_editing_started)
  262. end
  263. on_editing_started: INTEGER is
  264. -- This signal gets emitted when a cell starts to be edited. The
  265. -- indended use of this signal is to do special setup on editable, e.g.
  266. -- adding a GtkEntryCompletion or setting up additional columns in a
  267. -- GtkComboBox.
  268. -- Note that GTK+ doesn't guarantee that cell renderers will
  269. -- continue to use the same kind of widget for editing in future
  270. -- releases, therefore you should check the type of editable before
  271. -- doing any specific setup, as in the following example:
  272. -- static void
  273. -- text_editing_started (GtkCellRenderer *cell,
  274. -- GtkCellEditable *editable,
  275. -- const gchar *path,
  276. -- gpointer data)
  277. -- {
  278. -- if (GTK_IS_ENTRY (editable))
  279. -- {
  280. -- GtkEntry *entry = GTK_ENTRY (editable);
  281. -- /* ... create a GtkEntryCompletion */
  282. -- gtk_entry_set_completion (entry, completion);
  283. -- }
  284. -- }
  285. do
  286. end
  287. connect_agent_to_editing_started_signal (a_procedure: PROCEDURE[ANY, TUPLE [GTK_CELL_EDITABLE,
  288. STRING, GTK_CELL_RENDERER]]) is
  289. -- renderer : the object which received the signal
  290. -- editable : the GtkCellEditable
  291. -- path : the path identifying the edited cell
  292. require
  293. valid_procedure: a_procedure /= Void
  294. wrapper_is_stored: is_eiffel_wrapper_stored
  295. local
  296. editing_started_callback: EDITING_STARTED_CALLBACK
  297. do
  298. create editing_started_callback.make
  299. editing_started_callback.connect (Current, a_procedure)
  300. end
  301. end -- class GTK_CELL_RENDERER