org.gnome.gtk

## Class CellRenderer

- Object
- - org.freedesktop.bindings.Pointer
  - - org.freedesktop.bindings.Proxy
    - - org.gnome.glib.Object
      - - org.gnome.gtk.CellRenderer

- Direct Known Subclasses:
    CellRendererPixbuf, CellRendererProgress, CellRendererSpinner, CellRendererText, CellRendererToggle

      public abstract class CellRenderer
      extends Object

  Present data in CellLayouts (ie, the TreeViewColumns of TreeView, and ComboBox).

  Note that there is not one CellRenderer per individual cell in the table-like presentation of a TreeView! Instead, a CellRenderer is an engine called upon to draw many cells. The Widget employing them will, by turn, set various properties (the actual data for the current cell in question would be what changes, though most of the rest of the properties would likely remain constant) and then ask the CellRenderer to return the rendered result.

  You will see two types of setters in CellRenderers. The most important ones are those that take a DataColumn for an argument, and will adjust that property of the CellRenderer for each row of the model based on the value of the specified column.

  While the whole point of the CellRenderers is to present the data from a given column of your data model, CellRenderers also offer a considerable number of properties that you don't need to vary row by row but want to set for the TreeViewColumn as a whole. For these you will notice a a setter which takes a conventional type as its argument; setting this property will set it for all rows in that column. (Occasionally you will see the setter for a property overloaded to offer you both a DataColumn driven mode and a fixed value mode for the rare occasions where both styles are useful, but in general it's fairly obvious that you use a property one way or the other).

  It's easy to be tempted into thinking that CellRenderers are Widgets, especially as they get `pack()`ed into TreeViewColumns on their way to being used in TreeViews. They are, however, merely utility elements that are used to facilitate drawing, and not full power Widgets.

  Do not try to reuse a CellRenderer between different TreeViewColumns.

  Since:
    4.0.5
  Author:
    Andrew Cowie, Stefan Prelle

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `setAlignment(float xalign, float yalign)` Set the alignment of this CellRenderer in the TreeViewColumn.
    `void` | `setBackground(DataColumnString column)` Indicate the DataColumn containing the name of the colour to use as background for this CellRenderer.
    `void` | `setBackground(String colour)` Set the background colour to be used by this CellRenderer for all the rows it draws.
    `void` | `setVisible(DataColumnBoolean column)` Indicate if the CellRenderer should be visible, depending on the content of a DataColumnBoolean.
    `void` | `setWidth(int width)` Fix the width of this CellRenderer, specified in pixels.

    - ### Methods inherited from class org.freedesktop.bindings.Pointer

      `toString`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Method Detail

    - #### setAlignment

          public void setAlignment(float xalign,
                          float yalign)

      Set the alignment of this CellRenderer in the TreeViewColumn.

    - #### setBackground

          public void setBackground(DataColumnString column)

      Indicate the DataColumn containing the name of the colour to use as background for this CellRenderer. You can set the background dynamically with TreeModel data via this method, or set it statically once via the other `setBackground()` overload.

    - #### setBackground

          public void setBackground(String colour)

      Set the background colour to be used by this CellRenderer for all the rows it draws.

    - #### setVisible

          public void setVisible(DataColumnBoolean column)

      Indicate if the CellRenderer should be visible, depending on the content of a DataColumnBoolean. For example, you could set use this property to control whether or not a `CellRendererToggle` was visible in a TreeView where you want each of the leaf rows to have such a Button but you do not want the parent node rows to have one.
      Since:
        4.0.9

    - #### setWidth

          public void setWidth(int width)

      Fix the width of this CellRenderer, specified in pixels.
      Since:
        4.0.20