CellRenderer

An object for rendering a single cell

The gtk.cell_renderer.CellRenderer is a base class of a set of objects used for rendering a cell to a cairo.context.Context. These objects are used primarily by the gtk.tree_view.TreeView widget, though they aren’t tied to them in any specific way. It is worth noting that gtk.cell_renderer.CellRenderer is not a gtk.widget.Widget and cannot be treated as such.

The primary use of a gtk.cell_renderer.CellRenderer is for drawing a certain graphical elements on a cairo.context.Context. Typically, one cell renderer is used to draw many cells on the screen. To this extent, it isn’t expected that a CellRenderer keep any permanent state around. Instead, any state is set just prior to use using gobject.object.ObjectGs property system. Then, the cell is measured using gtk.cell_renderer.CellRenderer.getPreferredSize. Finally, the cell is rendered in the correct location using gtk.cell_renderer.CellRenderer.snapshot.

There are a number of rules that must be followed when writing a new gtk.cell_renderer.CellRenderer. First and foremost, it’s important that a certain set of properties will always yield a cell renderer of the same size, barring a style change. The gtk.cell_renderer.CellRenderer also has a number of generic properties that are expected to be honored by all children.

Beyond merely rendering a cell, cell renderers can optionally provide active user interface elements. A cell renderer can be “activatable” like gtk.cell_renderer.CellRendererToggle, which toggles when it gets activated by a mouse click, or it can be “editable” like gtk.cell_renderer.CellRendererText, which allows the user to edit the text using a widget implementing the gtk.cell_editable.CellEditable interface, e.g. gtk.entry.Entry. To make a cell renderer activatable or editable, you have to implement the gtk.cell_renderer.CellRendererClass.activate or gtk.cell_renderer.CellRendererClass.start_editing virtual functions, respectively.

Many properties of gtk.cell_renderer.CellRenderer and its subclasses have a corresponding “set” property, e.g. “cell-background-set” corresponds to “cell-background”. These “set” properties reflect whether a property has been set or not. You should not set them independently.

More...
class CellRenderer : InitiallyUnowned {}

Members

Functions

activate
bool activate(gdk.event.Event event, gtk.widget.Widget widget, string path, gdk.rectangle.Rectangle backgroundArea, gdk.rectangle.Rectangle cellArea, gtk.types.CellRendererState flags)

Passes an activate event to the cell renderer for possible processing. Some cell renderers may use events; for example, gtk.cell_renderer_toggle.CellRendererToggle toggles when it gets a mouse click.

connectEditingCanceled
ulong connectEditingCanceled(T callback, Flag!"After" after)

Connect to EditingCanceled signal.

connectEditingStarted
ulong connectEditingStarted(T callback, Flag!"After" after)

Connect to EditingStarted signal.

getAlignedArea
void getAlignedArea(gtk.widget.Widget widget, gtk.types.CellRendererState flags, gdk.rectangle.Rectangle cellArea, gdk.rectangle.Rectangle alignedArea)

Gets the aligned area used by cell inside cell_area. Used for finding the appropriate edit and focus rectangle.

getAlignment
void getAlignment(float xalign, float yalign)

Fills in xalign and yalign with the appropriate values of cell.

getFixedSize
void getFixedSize(int width, int height)

Fills in width and height with the appropriate size of cell.

getIsExpanded
bool getIsExpanded()

Checks whether the given gtk.cell_renderer.CellRenderer is expanded.

getIsExpander
bool getIsExpander()

Checks whether the given gtk.cell_renderer.CellRenderer is an expander.

getPadding
void getPadding(int xpad, int ypad)

Fills in xpad and ypad with the appropriate values of cell.

getPreferredHeight
void getPreferredHeight(gtk.widget.Widget widget, int minimumSize, int naturalSize)

Retrieves a renderer’s natural size when rendered to widget.

getPreferredHeightForWidth
void getPreferredHeightForWidth(gtk.widget.Widget widget, int width, int minimumHeight, int naturalHeight)

Retrieves a cell renderers’s minimum and natural height if it were rendered to widget with the specified width.

getPreferredSize
void getPreferredSize(gtk.widget.Widget widget, gtk.requisition.Requisition minimumSize, gtk.requisition.Requisition naturalSize)

Retrieves the minimum and natural size of a cell taking into account the widget’s preference for height-for-width management.

getPreferredWidth
void getPreferredWidth(gtk.widget.Widget widget, int minimumSize, int naturalSize)

Retrieves a renderer’s natural size when rendered to widget.

getPreferredWidthForHeight
void getPreferredWidthForHeight(gtk.widget.Widget widget, int height, int minimumWidth, int naturalWidth)

Retrieves a cell renderers’s minimum and natural width if it were rendered to widget with the specified height.

getRequestMode
gtk.types.SizeRequestMode getRequestMode()

Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.

getSensitive
bool getSensitive()

Returns the cell renderer’s sensitivity.

getState
gtk.types.StateFlags getState(gtk.widget.Widget widget, gtk.types.CellRendererState cellState)

Translates the cell renderer state to gtk.types.StateFlags, based on the cell renderer and widget sensitivity, and the given gtk.cell_renderer.CellRendererState.

getVisible
bool getVisible()

Returns the cell renderer’s visibility.

isActivatable
bool isActivatable()

Checks whether the cell renderer can do something when activated.

setAlignment
void setAlignment(float xalign, float yalign)

Sets the renderer’s alignment within its available space.

setFixedSize
void setFixedSize(int width, int height)

Sets the renderer size to be explicit, independent of the properties set.

setIsExpanded
void setIsExpanded(bool isExpanded)

Sets whether the given gtk.cell_renderer.CellRenderer is expanded.

setIsExpander
void setIsExpander(bool isExpander)

Sets whether the given gtk.cell_renderer.CellRenderer is an expander.

setPadding
void setPadding(int xpad, int ypad)

Sets the renderer’s padding.

setSensitive
void setSensitive(bool sensitive)

Sets the cell renderer’s sensitivity.

setVisible
void setVisible(bool visible)

Sets the cell renderer’s visibility.

snapshot
void snapshot(gtk.snapshot.Snapshot snapshot, gtk.widget.Widget widget, gdk.rectangle.Rectangle backgroundArea, gdk.rectangle.Rectangle cellArea, gtk.types.CellRendererState flags)

Invokes the virtual render function of the gtk.cell_renderer.CellRenderer. The three passed-in rectangles are areas in cr. Most renderers will draw within cell_area; the xalign, yalign, xpad, and ypad fields of the gtk.cell_renderer.CellRenderer should be honored with respect to cell_area. background_area includes the blank space around the cell, and also the area containing the tree expander; so the background_area rectangles for all cells tile to cover the entire window.

startEditing
gtk.cell_editable.CellEditable startEditing(gdk.event.Event event, gtk.widget.Widget widget, string path, gdk.rectangle.Rectangle backgroundArea, gdk.rectangle.Rectangle cellArea, gtk.types.CellRendererState flags)

Starts editing the contents of this cell, through a new gtk.cell_editable.CellEditable widget created by the gtk.cell_renderer.CellRendererClass.start_editing virtual function.

stopEditing
void stopEditing(bool canceled)

Informs the cell renderer that the editing is stopped. If canceled is true, the cell renderer will emit the gtk.cell_renderer.CellRenderer::editing-canceled signal.

Detailed Description

Deprecated: List views use widgets for displaying their contents