1Gtk2::CellRenderer(3) User Contributed Perl DocumentationGtk2::CellRenderer(3)
2
3
4

NAME

6       Gtk2::CellRenderer - An object that renders a single cell onto a
7       Gtk2::Gdk::Drawable
8

DESCRIPTION

10       The Gtk2::CellRenderer is the base class for objects which render cells
11       onto drawables.  These objects are used primarily by the
12       Gtk2::TreeView, though they aren't tied to them in any specific way.
13
14       Typically, one cell renderer is used to draw many cells onto the
15       screen.  Thus, the cell renderer doesn't keep state; instead, any state
16       is set immediately prior to use through the object property system.
17       The cell is measured with "get_size", and then renderered with
18       "render".
19

HIERARCHY

21         Glib::Object
22         +----Glib::InitiallyUnowned
23              +----Gtk2::Object
24                   +----Gtk2::CellRenderer
25

METHODS

27   boolean = $cell->activate ($event, $widget, $path, $background_area,
28       $cell_area, $flags)
29       ·   $event (Gtk2::Gdk::Event)
30
31       ·   $widget (Gtk2::Widget)
32
33       ·   $path (string)
34
35       ·   $background_area (Gtk2::Gdk::Rectangle)
36
37       ·   $cell_area (Gtk2::Gdk::Rectangle)
38
39       ·   $flags (Gtk2::CellRendererState)
40
41   (xalign, yalign) = $cell->get_alignment
42       Since: gtk+ 2.18
43
44   $cell->set_alignment ($xalign, $yalign)
45       ·   $xalign (double)
46
47       ·   $yalign (double)
48
49       Since: gtk+ 2.18
50
51   $cell->editing_canceled
52       Since: gtk+ 2.4
53
54   (width, height) = $cell->get_fixed_size
55       Fetch the fixed size if $cell.  Values of -1 mean "this dimension is
56       not fixed."
57
58   $cell->set_fixed_size ($width, $height)
59       ·   $width (integer)
60
61       ·   $height (integer)
62
63       Set the renderer's size explicitly, independent of object properties.
64       A value of -1 means "don't use a fixed size for this dimension."
65
66   (xpad, ypad) = $cell->get_padding
67       Since: gtk+ 2.18
68
69   $cell->set_padding ($xpad, $ypad)
70       ·   $xpad (integer)
71
72       ·   $ypad (integer)
73
74       Since: gtk+ 2.18
75
76   $cell->render ($drawable, $widget, $background_area, $cell_area,
77       $expose_area, $flags)
78       ·   $drawable (Gtk2::Gdk::Drawable)
79
80       ·   $widget (Gtk2::Widget)
81
82       ·   $background_area (Gtk2::Gdk::Rectangle)
83
84       ·   $cell_area (Gtk2::Gdk::Rectangle)
85
86       ·   $expose_area (Gtk2::Gdk::Rectangle)
87
88       ·   $flags (Gtk2::CellRendererState)
89
90   boolean = $cell->get_sensitive
91       Since: gtk+ 2.18
92
93   $cell->set_sensitive ($sensitive)
94       ·   $sensitive (boolean)
95
96       Since: gtk+ 2.18
97
98   (x_offset, y_offset, width, height) = $cell->get_size ($widget, $cell_area)
99       ·   $widget (Gtk2::Widget)
100
101       ·   $cell_area (Gtk2::Gdk::Rectangle or undef)
102
103   celleditable or undef = $cell->start_editing ($event, $widget, $path,
104       $background_area, $cell_area, $flags)
105       ·   $event (Gtk2::Gdk::Event)
106
107       ·   $widget (Gtk2::Widget)
108
109       ·   $path (string)
110
111       ·   $background_area (Gtk2::Gdk::Rectangle)
112
113       ·   $cell_area (Gtk2::Gdk::Rectangle)
114
115       ·   $flags (Gtk2::CellRendererState)
116
117   $cell->stop_editing ($canceled)
118       ·   $canceled (boolean)
119
120       Since: gtk+ 2.6
121
122   boolean = $cell->get_visible
123       Since: gtk+ 2.18
124
125   $cell->set_visible ($visible)
126       ·   $visible (boolean)
127
128       Since: gtk+ 2.18
129

PROPERTIES

131       'cell-background' (string : default undef : writable / private)
132           Cell background color as a string
133
134       'cell-background-gdk' (Gtk2::Gdk::Color : default undef : readable /
135       writable / private)
136           Cell background color as a GdkColor
137
138       'cell-background-set' (boolean : default false : readable / writable /
139       private)
140           Whether this tag affects the cell background color
141
142       'editing' (boolean : default false : readable / private)
143           Whether the cell renderer is currently in editing mode
144
145       'height' (integer : default -1 : readable / writable / private)
146           The fixed height
147
148       'is-expanded' (boolean : default false : readable / writable / private)
149           Row is an expander row, and is expanded
150
151       'is-expander' (boolean : default false : readable / writable / private)
152           Row has children
153
154       'mode' (Gtk2::CellRendererMode : default "inert" : readable / writable
155       / private)
156           Editable mode of the CellRenderer
157
158       'sensitive' (boolean : default true : readable / writable / private)
159           Display the cell sensitive
160
161       'visible' (boolean : default true : readable / writable / private)
162           Display the cell
163
164       'width' (integer : default -1 : readable / writable / private)
165           The fixed width
166
167       'xalign' (float : default 0.5 : readable / writable / private)
168           The x-align
169
170       'xpad' (Glib::UInt : default 0 : readable / writable / private)
171           The xpad
172
173       'yalign' (float : default 0.5 : readable / writable / private)
174           The y-align
175
176       'ypad' (Glib::UInt : default 0 : readable / writable / private)
177           The ypad
178

SIGNALS

180       editing-canceled (Gtk2::CellRenderer)
181       editing-started (Gtk2::CellRenderer, Gtk2::CellEditable, string)
182

ENUMS AND FLAGS

184   enum Gtk2::CellRendererMode
185       ·   'inert' / 'GTK_CELL_RENDERER_MODE_INERT'
186
187       ·   'activatable' / 'GTK_CELL_RENDERER_MODE_ACTIVATABLE'
188
189       ·   'editable' / 'GTK_CELL_RENDERER_MODE_EDITABLE'
190
191   flags Gtk2::CellRendererState
192       ·   'selected' / 'GTK_CELL_RENDERER_SELECTED'
193
194       ·   'prelit' / 'GTK_CELL_RENDERER_PRELIT'
195
196       ·   'insensitive' / 'GTK_CELL_RENDERER_INSENSITIVE'
197
198       ·   'sorted' / 'GTK_CELL_RENDERER_SORTED'
199
200       ·   'focused' / 'GTK_CELL_RENDERER_FOCUSED'
201

DERIVING NEW CELL RENDERERS

203       Gtk+ provides three cell renderers: Gtk2::CellRendererText,
204       Gtk2::CellRendererToggle, and Gtk2::CellRendererPixbuf.  You may derive
205       a new renderer from any of these, or directly from Gtk2::CellRenderer
206       itself.
207
208       There are a number of rules that must be followed when writing a new
209       cell renderer.  First and foremost, it's important that a certain set
210       of properties always yields a cell of the same size, barring a
211       Gtk2::Style change.  The cell renderer also has a number of generic
212       properties that are expected to be honored by all children.
213
214       The new renderer must be a GObject, so you must follow the normal
215       procedure for creating a new Glib::Object (i.e., either
216       Glib::Object::Subclass or Glib::Type::register_object).  The new
217       subclass can customize the object's behavior by providing new
218       implementations of these four methods:
219
220       (x_offset, y_offset, width, height) = GET_SIZE ($cell, $widget,
221       $cell_area)
222           o $cell (Gtk2::CellRenderer)
223           o $widget (Gtk2::Widget) widget to which $cell is rendering
224           o $cell_area (Gtk2::Gdk::Rectangle or undef) The area a cell will
225           be allocated, or undef.
226
227           Return Values:
228
229           - x_offset - x offset of cell relative to $cell_area
230           - y_offset - y offset of cell relative to $cell_area
231           - width - width needed to render cell
232           - height - height needed to render cell
233
234           This is called to calculate the size of the cell for display,
235           taking into account the padding and alignment properties of the
236           parent.  This one will be called very often.  If you need to know
237           your cell's data, then get it from the appropriate object
238           properties, which will be set accordingly before this method is
239           called.
240
241       RENDER ($cell, $drawable, $widget, $background_area, $cell_area,
242       $expose_area, $flags)
243           o $cell (Gtk2::CellRenderer)
244           o $drawable (Gtk2::Gdk::Drawable) window on which to draw
245           o $widget (Gtk2::Widget) widget owning $drawable
246           o $background_area (Gtk2::Gdk::Rectangle) entire cell area
247           (including tree expanders and maybe padding on the sides)
248           o $cell_area (Gtk2::Gdk::Rectangle) area normally rendered by a
249           cell renderer
250           o $expose_area (Gtk2::Gdk::Rectangle) area that actually needs
251           updating
252           o $flags (Gtk2::CellRendererState) flags that affect rendering
253
254           This is called to render the cell onto the screen.  As with
255           GET_SIZE, the data for the cell comes from object properties.  In
256           general, you'll want to make use of Gtk2::Style methods for drawing
257           anything fancy.
258
259           The three passed-in rectangles are areas of $drawable.  Most
260           renderers draw within $cell_area; the xalign, yalign, xpad, and
261           ypad fields of the cell renderer should be honored with respect to
262           $cell_area.  $background_area includes the blank space around the
263           cell, and also the area containing the tree expander; so the
264           $background_area rectangles for all cells cover the entire
265           $drawable.  $expose_area is a clip rectangle.
266
267       boolean = ACTIVATE ($cell, $event, $widget, $path, $background_area,
268       $cell_area, $flags)
269           o $cell (Gtk2::CellRenderer)
270           o $event (Gtk2::Gdk::Event)
271           o $widget (Gtk2::Widget) widget that received the event
272           o $path (string) widget-dependent string representation of the
273           event location; e.g. for a Gtk2::TreeView, a string representation
274           of a Gtk2::TreePath.
275           o $background_area (Gtk2::Gdk::Rectangle) background area as passed
276           to "RENDER".
277           o $cell_area (Gtk2::Gdk::Rectangle) cell area as passed to
278           "RENDER".
279           o $flags (Gtk2::CellRendererState) render flags
280
281           This method is called when an event occurs on a cell.  Implementing
282           it is not mandatory.  The return value should be TRUE if the event
283           was consumed/handled.
284
285       celleditable or undef = START_EDITING ($cell, $event, $widget, $path,
286       $background_area, $cell_area, $flags)
287           o $cell (Gtk2::CellRenderer)
288           o $event (Gtk2::Gdk::Event)
289           o $widget (Gtk2::Widget) widget that received the event
290           o $path (string) widget-dependent string representation of the
291           event location; e.g. for a Gtk2::TreeView, a string representation
292           of a Gtk2::TreePath.
293           o $background_area (Gtk2::Gdk::Rectangle) background area as passed
294           to "RENDER".
295           o $cell_area (Gtk2::Gdk::Rectangle) cell area as passed to
296           "RENDER".
297           o $flags (Gtk2::CellRendererState) render flags
298
299           For cells that are editable, this is called to put the cell into
300           editing mode.  If the return value is an object is a
301           Gtk2::CellEditable, that widget will be used to edit the value; the
302           calling code takes care of sizing, placing, and showing the
303           editable, you just need to return it.  If the return value is
304           undef, the editing is aborted.
305
306       Note: for backward compatibility, the bizarre and non-standard scheme
307       used for this in 1.02x is still supported, but is deprecated and should
308       not be used in new code, and since i don't want people to use it any
309       more i will not document it here.
310

SEE ALSO

312       Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object
313
315       Copyright (C) 2003-2011 by the gtk2-perl team.
316
317       This software is licensed under the LGPL.  See Gtk2 for a full notice.
318
319
320
321perl v5.28.0                      2018-07-18             Gtk2::CellRenderer(3)
Impressum