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