public class TreeViewColumn extends Object implements CellLayout
TreeView
Widget. A TreeViewColumn's primary role is to connect one or more
CellRenderers to a vertical position in the tabular layout of a TreeView
and then to assign which attributes of that CellRenderer are powered by
what rows from the data TreeModel that will underlie the TreeView.
You get a TreeViewColumn by calling TreeView's
appendColumn()
.
Modifier and Type | Method and Description |
---|---|
void |
emitClicked()
Activate this column's sorting by sending a click the TreeViewColumn
header.
|
String |
getTitle()
Gets the title of this TreeViewColumn.
|
boolean |
getVisible()
Returns whether the TreeViewColumn is visible or not.
|
Widget |
getWidget()
Returns the Widget in the button on the column header.
|
void |
setAlignment(float xalign)
Set the horizontal alignment of the title (or custom Widget) within the
header of this TreeViewColumn.
|
void |
setClickable(boolean setting)
Set whether the column header allows itself to be clicked.
|
void |
setExpand(boolean setting)
Set whether this TreeViewColumn will share in additional space
available to the parent TreeView.
|
void |
setFixedWidth(int width)
If (and only if) operating with the
FIXED TreeViewSizing mode, this defines the fixed column width in
pixels. |
void |
setMaxWidth(int width)
Sets the maximum width this column can grow.
|
void |
setMinWidth(int width)
Sets the minimal width this column can shrink to.
|
void |
setReorderable(boolean setting)
Permit the user to change the order of the columns in a TreeView by
clicking on one of the column headers and dragging it to a new
position.
|
void |
setResizable(boolean setting)
Permit the user to change the width of the columns in a TreeView by
clicking on the boundary of a column header and dragging it.
|
void |
setSizing(TreeViewColumnSizing type)
Set the mode constant that will be used to determine the width
behaviour of TreeViewColumns when data is changed in the model causing
a CellRenderer to need to redraw a cell.
|
void |
setSortColumn(DataColumn column)
Set the DataColumn that will be used to sort this TreeViewColumn should
sorting be enabled.
|
void |
setTitle(String title)
Set the title to be used for this TreeViewColumn in the TreeView's
header row.
|
void |
setVisible(boolean visible)
Sets the visibility of the TreeViewColumn.
|
void |
setWidget(Widget widget)
Sets the widget in the header to be widget.
|
public void emitClicked()
TreeViewColumn.Clicked
to fire, but more
importantly this causes this vertical to become the active column
dictating the ordering of the TreeView as a whole (assuming the
vertical is setClickable(true)
and
assuming a DataColumn has been set with
setSortColumn()
to indicate the
ordering).public String getTitle()
setTitle()
for further information about
TreeViewColumn titles.public boolean getVisible()
public Widget getWidget()
public void setAlignment(float xalign)
xalign
- As with elsewhere in GTK, a value between 0.0f
for left and 1.0f
for right alignment. The
constants in Alignment
may serve.public void setClickable(boolean setting)
false
, not to be clickable, also meaning that header
won't take the keyboard focus either. Since calling
setSortColumn()
will set
clickable to true
, so you only need this for
the case where you assign a sort order to a column, but don't want
users to be able to change the sorting column or its order.public void setExpand(boolean setting)
true
.
The default for new TreeViewColumns is false
. The last
(right-most) column is treated specially, however. Extra space given to
the TreeView as a whole will automatically go to the last vertical
column (ie, ignoring this being set false
) unless one or
more other columns have had expand set to true
.
public void setFixedWidth(int width)
FIXED
TreeViewSizing mode, this defines the fixed column width in
pixels. If setMinWidth(int)
setMinWidth} or
setMaxWidth(int)
have been called and the fixed width is
outside these bounds Min- or MaxWidth take precedence.
The fixed width can be overridden by the user if
setResizable()
has been set to
true
.
width
- Column width in pixelspublic void setMaxWidth(int width)
TreeViewColumnSizing
variants. If not set, the column growth is
not limited.width
- Column width in pixelspublic void setMinWidth(int width)
TreeViewColumnSizing
variants.width
- Column width in pixelpublic void setReorderable(boolean setting)
Most of the time, however, the order of presentation of the columns is
an integral part of your UI and you don't want the user messing with
it, which is why the default is false
. More than that,
people don't much care for horizontal scrolling; if you are presenting
so much data that reordering the columns would be necessary, perhaps
you should rethink the way you are presenting things.
public void setResizable(boolean setting)
true
will implicitly set
GROW_ONLY
. On the other hand
setting AUTOSIZE
will implicitly
disable resizing.public void setSizing(TreeViewColumnSizing type)
setResizable()
, setMinWidth()
,
setFixedWidth()
, etc and there are quite a
number of permutations available as a result.
GROW_ONLY
is the default.
public void setSortColumn(DataColumn column)
Calling this also makes the TreeViewColumn clickable, but it
does not automatically engage the sorting (maybe you only want sorting
to be optional and only active if the user clicks a header, certainly
if you've set sort information for many columns you will have to
indicate explicitly which one is to be active first, etc). Use
emitClicked()
to activate this column as the one
doing the sorting.
Warning:
This only works if the TreeModel being presented by this TreeView is
sortable, that is, if that model implements TreeSortable.
Since almost everything in GTK does so, you ordinarily don't need to
worry about this. The one that doesn't is TreeModelFilter, so if you're
using a filtered model make sure you wrap it in a TreeModelSort before
adding it to the TreeView.
public void setTitle(String title)
setHeadersClickable(true)
and this TreeViewColumn's
setSortColumn()
, and
that the titles are visible in the first place, ie the header row
hasn't been turned off via TreeView's
setHeadersVisible(false)
].public void setVisible(boolean visible)
public void setWidget(Widget widget)