public class CellRendererText extends CellRenderer
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()
.
Modifier and Type | Class and Description |
---|---|
static interface |
CellRendererText.Edited
Event generated after user activated a cell, changed its content and
pressed Return.
|
Constructor and Description |
---|
CellRendererText(CellLayout vertical)
Construct a new CellRendererText.
|
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.
|
setAlignment, setBackground, setBackground, setVisible, setWidth
public CellRendererText(CellLayout vertical)
public void connect(CellRendererText.Edited handler)
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); }});
public EllipsizeMode getEllipsizeMode()
public void setAlignment(Alignment align)
setAlignment()
.public void setEditable(boolean editable)
public void setEditable(DataColumnBoolean column)
public void setEllipsize(EllipsizeMode setting)
ellipsization mode
to use to make the
text fits the cell width.public void setForeground(DataColumnString column)
public void setMarkup(DataColumnString column)
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.
public void setText(DataColumnString column)
If you want to use Pango markup to format the text being rendered, call
setMarkup()
instead.