org.gnome.gtk

## Class CellRendererText

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

- Direct Known Subclasses:
    CellRendererAccel, CellRendererCombo, CellRendererSpin

      public class CellRendererText
      extends CellRenderer

  Render textual data into a TreeViewColumn. This is the most commonly used CellRenderer, used to present Strings. The fundamental mapping method is `setText()` which you use to indicate the particular DataColumnString from the underlying TreeModel which will provide the Strings.

  CellRendererTexts are also frequently used to present numerical data when it is desired to apply formatting to that data (converting it to a String in the process) before rendering it. If you do that, you'll probably want to use a second (numerically typed) DataColumn to indicate the appropriate sorting order to be applied if that TreeViewColumn is clicked and sorting is turned on for it; see `setSortColumn()`.

  Since:
    4.0.5
  Author:
    Andrew Cowie

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `CellRendererText.Edited` Event generated after user activated a cell, changed its content and pressed Return.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CellRendererText(CellLayout vertical)` Construct a new CellRendererText.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `connect(CellRendererText.Edited handler)` Hook up a handler to receive "edited" events on this CellRenderer.
    `EllipsizeMode` | `getEllipsizeMode()` Get the current ellipsization used.
    `void` | `setAlignment(Alignment align)` Set the Alignment used when multiple lines of text appear within the cell.
    `void` | `setEditable(boolean editable)` Indicate if the contents rendered by this CellRenderer should be editable.
    `void` | `setEditable(DataColumnBoolean column)` Indicate the DataColumn containing the information whether the cell should be editable or not.
    `void` | `setEllipsize(EllipsizeMode setting)` Set the `ellipsization mode` to use to make the text fits the cell width.
    `void` | `setForeground(DataColumnString column)` Indicate the DataColumn containing the name of the foreground colour to used when rendering text.
    `void` | `setMarkup(DataColumnString column)` Indicate the DataColumn containing Pango markup to render as text.
    `void` | `setText(DataColumnString column)` Indicate the DataColumn containing the plain text to render.

    - ### Methods inherited from class org.gnome.gtk.CellRenderer

      `setAlignment, setBackground, setBackground, setVisible, setWidth`

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

      `toString`

    - ### Methods inherited from class Object

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

- - ### Constructor Detail

    - #### CellRendererText

          public CellRendererText(CellLayout vertical)

      Construct a new CellRendererText. Specify the TreeViewColumn it will belong to and from whose parent TreeView has the TreeModel where the columns of data will come from.
      Since:
        4.0.5

  - ### Method Detail

    - #### connect

          public void connect(CellRendererText.Edited handler)

      Hook up a handler to receive "edited" events on this CellRenderer. A typical example of how this is used is as follows:

           final DataColumnString column;
           final TreeView view;
           final ListStore store;
           final TreeViewColumn visibleColumn

           store = new ListStore(new DataColumn[]{
                    column = new DataColumnString()
           });

           view = new TreeView(store);
           visibleColumn = view.appendColumn();
           CellRendererText renderer = new CellRendererText(visibleColumn);
           renderer.setText(column);
           renderer.setEditable(true);
           renderer.connect(new CellRendererText.Edited(){
                public void onEdited(CellRendererText source, TreePath path, String text) {
                    System.out.println("New value for path " + path + " is " + text);
                    TreeIter row = store.getIter(path);
                    store.setValue(row, column, text);
                }});

      Since:
        4.0.8

    - #### getEllipsizeMode

          public EllipsizeMode getEllipsizeMode()

      Get the current ellipsization used.
      Since:
        4.0.17

    - #### setAlignment

          public void setAlignment(Alignment align)

      Set the Alignment used when multiple lines of text appear within the cell. This is specific to CellRendererText; for the position of any CellRenderer within its enclosing TreeViewColumn, see CellRenderer's `setAlignment()`.
      Since:
        4.0.20

    - #### setEditable

          public void setEditable(boolean editable)

      Indicate if the contents rendered by this CellRenderer should be editable. This affects all rows rendered by this CellRenderer.
      Since:
        4.0.8

    - #### setEditable

          public void setEditable(DataColumnBoolean column)

      Indicate the DataColumn containing the information whether the cell should be editable or not.
      Since:
        4.0.9

    - #### setEllipsize

          public void setEllipsize(EllipsizeMode setting)

      Set the `ellipsization mode` to use to make the text fits the cell width.
      Since:
        4.0.17

    - #### setForeground

          public void setForeground(DataColumnString column)

      Indicate the DataColumn containing the name of the foreground colour to used when rendering text.
      Since:
        4.0.5

    - #### setMarkup

          public void setMarkup(DataColumnString column)

      Indicate the DataColumn containing Pango markup to render as text.

      The String in the DataColumn being rendered will be interpreted as containing markup in Pango's text markup language. Using this allows you to make very expressive presentations within TreeView cells.

      Using this (instead of `setText()`) has the same effect as using a Label with `setUseMarkup(true)` in normal layouts.

      Since:
        4.0.5

    - #### setText

          public void setText(DataColumnString column)

      Indicate the DataColumn containing the plain text to render. This will map the DataColumn that will be used to provide the text to be rendered in the TreeViewColumn this CellRenderer is packed into. This is by far and away the most commonly used mapping in the entire TreeView API.

      If you want to use Pango markup to format the text being rendered, call `setMarkup()` instead.

      Since:
        4.0.5