Package ch.bailu.gtk.gtk
Class TreeViewColumn
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gobject.InitiallyUnowned
ch.bailu.gtk.gtk.TreeViewColumn
- All Implemented Interfaces:
PointerInterface
A visible column in a [class@Gtk.TreeView] widget
The `GtkTreeViewColumn` object represents a visible column in a `GtkTreeView` widget.
It allows to set properties of the column header, and functions as a holding pen
for the cell renderers which determine how the data in the column is displayed.
Please refer to the [tree widget conceptual overview](section-tree-widget.html)
for an overview of all the objects and data types related to the tree widget and
how they work together, and to the [class@Gtk.TreeView] documentation for specifics
about the CSS node structure for treeviews and their headers.
The `GtkTreeViewColumn` object represents a visible column in a `GtkTreeView` widget.
It allows to set properties of the column header, and functions as a holding pen
for the cell renderers which determine how the data in the column is displayed.
Please refer to the [tree widget conceptual overview](section-tree-widget.html)
for an overview of all the objects and data types related to the tree widget and
how they work together, and to the [class@Gtk.TreeView] documentation for specifics
about the CSS node structure for treeviews and their headers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interfaceNested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify -
Field Summary
FieldsFields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(CellRenderer cell_renderer, Str attribute, int column) Adds an attribute mapping to the list in @tree_column.voidaddAttribute(CellRenderer cell_renderer, String attribute, int column) Adds an attribute mapping to the list in @tree_column.Implements interfaceBuildable.Implements interfaceCellLayout.booleancellGetPosition(CellRenderer cell_renderer, Int x_offset, Int width) Obtains the horizontal position and size of a cell in a column.voidcellGetSize(Int x_offset, Int y_offset, Int width, Int height) Obtains the width and height needed to render the column.booleanReturns %TRUE if any of the cells packed into the @tree_column are visible.voidcellSetCellData(TreeModel tree_model, TreeIter iter, boolean is_expander, boolean is_expanded) Sets the cell renderer based on the @tree_model and @iter.voidclear()Unsets all the mappings on all renderers on the @tree_column.voidclearAttributes(CellRenderer cell_renderer) Clears all existing attributes previously set with
gtk_tree_view_column_set_attributes().voidclicked()Emits the “clicked” signal on the column.voidfocusCell(CellRenderer cell) Sets the current keyboard focus to be at @cell, if the column contains
2 or more editable and activatable cells.floatReturns the current x alignment of @tree_column.Returns the button used in the treeview column headerstatic ClassHandlerbooleanReturns %TRUE if the user can click on the header for the column.booleanReturns %TRUE if the column expands to fill available space.intGets the fixed width of the column.static intintReturns the maximum width in pixels of the @tree_column, or -1 if no maximum
width is set.intReturns the minimum width in pixels of the @tree_column, or -1 if no minimum
width is set.static longstatic TypeSystem.TypeSizebooleanReturns %TRUE if the @tree_column can be reordered by the user.booleanReturns %TRUE if the @tree_column can be resized by the end user.intReturns the current type of @tree_column.intGets the logical @sort_column_id that the model sorts on
when this column is selected for sorting.booleanGets the value set by gtk_tree_view_column_set_sort_indicator().intGets the value set by gtk_tree_view_column_set_sort_order().intReturns the spacing of @tree_column.getTitle()Returns the title of the widget.Returns the `GtkTreeView` wherein @tree_column has been inserted.static longstatic TypeSystem.TypeSizebooleanReturns %TRUE if @tree_column is visible.Returns the `GtkWidget` in the button on the column header.intgetWidth()Returns the current size of @tree_column in pixels.intReturns the current X offset of @tree_column in pixels.static TreeViewColumnCreates a new `GtkTreeViewColumn` using @area to render its cells.static TreeViewColumnnewWithAttributesTreeViewColumn(Str title, CellRenderer cell, Object... _elipse) Creates a new `GtkTreeViewColumn` with a number of default values.static TreeViewColumnnewWithAttributesTreeViewColumn(String title, CellRenderer cell, Object... _elipse) Creates a new `GtkTreeViewColumn` with a number of default values.onClicked(TreeViewColumn.OnClicked signal) Connect to signal "clicked".voidpackEnd(CellRenderer cell, boolean expand) Adds the @cell to end of the column.voidpackStart(CellRenderer cell, boolean expand) Packs the @cell into the beginning of the column.voidFlags the column, and the cell renderers added to this column, to have
their sizes renegotiated.voidsetAlignment(float xalign) Sets the alignment of the title or custom widget inside the column header.voidsetAttributes(CellRenderer cell_renderer, Object... _elipse) Sets the attributes in the list as the attributes of @tree_column.voidsetCellDataFunc(CellRenderer cell_renderer, TreeViewColumn.OnTreeCellDataFunc func, Pointer func_data, TreeViewColumn.OnDestroyNotify destroy) Sets the `GtkTreeCellDataFunc` to use for the column.voidsetClickable(boolean clickable) Sets the header to be active if @clickable is %TRUE.voidsetExpand(boolean expand) Sets the column to take available extra space.voidsetFixedWidth(int fixed_width) If @fixed_width is not -1, sets the fixed width of @tree_column; otherwise
unsets it.voidsetMaxWidth(int max_width) Sets the maximum width of the @tree_column.voidsetMinWidth(int min_width) Sets the minimum width of the @tree_column.voidsetReorderable(boolean reorderable) If @reorderable is %TRUE, then the column can be reordered by the end user
dragging the header.voidsetResizable(boolean resizable) If @resizable is %TRUE, then the user can explicitly resize the column by
grabbing the outer edge of the column button.voidsetSizing(int type) Sets the growth behavior of @tree_column to @type.voidsetSortColumnId(int sort_column_id) Sets the logical @sort_column_id that this column sorts on when this column
is selected for sorting.voidsetSortIndicator(boolean setting) Call this function with a @setting of %TRUE to display an arrow in
the header button indicating the column is sorted.voidsetSortOrder(int order) Changes the appearance of the sort indicator.voidsetSpacing(int spacing) Sets the spacing field of @tree_column, which is the number of pixels to
place between cell renderers packed into it.voidSets the title of the @tree_column.voidSets the title of the @tree_column.voidsetVisible(boolean visible) Sets the visibility of @tree_column.voidSets the widget in the header to be @widget.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnrefMethods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacksMethods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNullMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_CLICKED
- See Also:
-
-
Constructor Details
-
TreeViewColumn
-
TreeViewColumn
public TreeViewColumn()Creates a new `GtkTreeViewColumn`.
-
-
Method Details
-
getClassHandler
-
newWithAreaTreeViewColumn
Creates a new `GtkTreeViewColumn` using @area to render its cells.- Parameters:
area- the `GtkCellArea` that the newly created column should use to layout cells.- Returns:
- A newly created `GtkTreeViewColumn`.
-
newWithAttributesTreeViewColumn
public static TreeViewColumn newWithAttributesTreeViewColumn(@Nonnull Str title, @Nonnull CellRenderer cell, Object... _elipse) Creates a new `GtkTreeViewColumn` with a number of default values.
This is equivalent to calling gtk_tree_view_column_set_title(),
gtk_tree_view_column_pack_start(), and
gtk_tree_view_column_set_attributes() on the newly created `GtkTreeViewColumn`.
Here’s a simple example:<!-- language="C" --> enum { TEXT_COLUMN, COLOR_COLUMN, N_COLUMNS }; // ... { GtkTreeViewColumn *column; GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Title", renderer, "text", TEXT_COLUMN, "foreground", COLOR_COLUMN, NULL); }- Parameters:
title- The title to set the header tocell- The `GtkCellRenderer`_elipse- A %NULL-terminated list of attributes- Returns:
- A newly created `GtkTreeViewColumn`.
-
newWithAttributesTreeViewColumn
public static TreeViewColumn newWithAttributesTreeViewColumn(String title, @Nonnull CellRenderer cell, Object... _elipse) Creates a new `GtkTreeViewColumn` with a number of default values.
This is equivalent to calling gtk_tree_view_column_set_title(),
gtk_tree_view_column_pack_start(), and
gtk_tree_view_column_set_attributes() on the newly created `GtkTreeViewColumn`.
Here’s a simple example:<!-- language="C" --> enum { TEXT_COLUMN, COLOR_COLUMN, N_COLUMNS }; // ... { GtkTreeViewColumn *column; GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Title", renderer, "text", TEXT_COLUMN, "foreground", COLOR_COLUMN, NULL); }- Parameters:
title- The title to set the header tocell- The `GtkCellRenderer`_elipse- A %NULL-terminated list of attributes- Returns:
- A newly created `GtkTreeViewColumn`.
-
addAttribute
Adds an attribute mapping to the list in @tree_column.
The @column is the
column of the model to get a value from, and the @attribute is the
parameter on @cell_renderer to be set from the value. So for example
if column 2 of the model contains strings, you could have the
“text” attribute of a `GtkCellRendererText` get its values from
column 2.- Parameters:
cell_renderer- the `GtkCellRenderer` to set attributes onattribute- An attribute on the renderercolumn- The column position on the model to get the attribute from.
-
addAttribute
Adds an attribute mapping to the list in @tree_column.
The @column is the
column of the model to get a value from, and the @attribute is the
parameter on @cell_renderer to be set from the value. So for example
if column 2 of the model contains strings, you could have the
“text” attribute of a `GtkCellRendererText` get its values from
column 2.- Parameters:
cell_renderer- the `GtkCellRenderer` to set attributes onattribute- An attribute on the renderercolumn- The column position on the model to get the attribute from.
-
cellGetPosition
public boolean cellGetPosition(@Nonnull CellRenderer cell_renderer, @Nullable Int x_offset, @Nullable Int width) Obtains the horizontal position and size of a cell in a column.
If the cell is not found in the column, @start_pos and @width
are not changed and %FALSE is returned.- Parameters:
cell_renderer- a `GtkCellRenderer`x_offset- return location for the horizontal position of @cell within @tree_columnwidth- return location for the width of @cell- Returns:
- %TRUE if @cell belongs to @tree_column
-
cellGetSize
public void cellGetSize(@Nullable Int x_offset, @Nullable Int y_offset, @Nullable Int width, @Nullable Int height) Obtains the width and height needed to render the column. This is used
primarily by the `GtkTreeView`.- Parameters:
x_offset- location to return x offset of a cell relative to @cell_areay_offset- location to return y offset of a cell relative to @cell_areawidth- location to return width needed to render a cellheight- location to return height needed to render a cell
-
cellIsVisible
public boolean cellIsVisible()Returns %TRUE if any of the cells packed into the @tree_column are visible.
For this to be meaningful, you must first initialize the cells with
gtk_tree_view_column_cell_set_cell_data()- Returns:
- %TRUE, if any of the cells packed into the @tree_column are currently visible
-
cellSetCellData
public void cellSetCellData(@Nonnull TreeModel tree_model, @Nonnull TreeIter iter, boolean is_expander, boolean is_expanded) Sets the cell renderer based on the @tree_model and @iter. That is, for
every attribute mapping in @tree_column, it will get a value from the set
column on the @iter, and use that value to set the attribute on the cell
renderer. This is used primarily by the `GtkTreeView`.- Parameters:
tree_model- The `GtkTreeModel` to get the cell renderers attributes from.iter- The `GtkTreeIter` to get the cell renderer’s attributes from.is_expander- %TRUE, if the row has childrenis_expanded- %TRUE, if the row has visible children
-
clear
public void clear()Unsets all the mappings on all renderers on the @tree_column. -
clearAttributes
Clears all existing attributes previously set with
gtk_tree_view_column_set_attributes().- Parameters:
cell_renderer- a `GtkCellRenderer` to clear the attribute mapping on.
-
clicked
public void clicked()Emits the “clicked” signal on the column. This function will only work if
@tree_column is clickable. -
focusCell
Sets the current keyboard focus to be at @cell, if the column contains
2 or more editable and activatable cells.- Parameters:
cell- A `GtkCellRenderer`
-
getAlignment
public float getAlignment()Returns the current x alignment of @tree_column. This value can range
between 0.0 and 1.0.- Returns:
- The current alignent of @tree_column.
-
getButton
Returns the button used in the treeview column header- Returns:
- The button for the column header.
-
getClickable
public boolean getClickable()Returns %TRUE if the user can click on the header for the column.- Returns:
- %TRUE if user can click the column header.
-
getExpand
public boolean getExpand()Returns %TRUE if the column expands to fill available space.- Returns:
- %TRUE if the column expands to fill available space.
-
getFixedWidth
public int getFixedWidth()Gets the fixed width of the column. This may not be the actual displayed
width of the column; for that, use gtk_tree_view_column_get_width().- Returns:
- The fixed width of the column.
-
getMaxWidth
public int getMaxWidth()Returns the maximum width in pixels of the @tree_column, or -1 if no maximum
width is set.- Returns:
- The maximum width of the @tree_column.
-
getMinWidth
public int getMinWidth()Returns the minimum width in pixels of the @tree_column, or -1 if no minimum
width is set.- Returns:
- The minimum width of the @tree_column.
-
getReorderable
public boolean getReorderable()Returns %TRUE if the @tree_column can be reordered by the user.- Returns:
- %TRUE if the @tree_column can be reordered by the user.
-
getResizable
public boolean getResizable()Returns %TRUE if the @tree_column can be resized by the end user.- Returns:
- %TRUE, if the @tree_column can be resized.
-
getSizing
public int getSizing()Returns the current type of @tree_column.- Returns:
- The type of @tree_column.
-
getSortColumnId
public int getSortColumnId()Gets the logical @sort_column_id that the model sorts on
when this column is selected for sorting.
See [method@Gtk.TreeViewColumn.set_sort_column_id].- Returns:
- the current @sort_column_id for this column, or -1 if this column can’t be used for sorting
-
getSortIndicator
public boolean getSortIndicator()Gets the value set by gtk_tree_view_column_set_sort_indicator().- Returns:
- whether the sort indicator arrow is displayed
-
getSortOrder
public int getSortOrder()Gets the value set by gtk_tree_view_column_set_sort_order().- Returns:
- the sort order the sort indicator is indicating
-
getSpacing
public int getSpacing()Returns the spacing of @tree_column.- Returns:
- the spacing of @tree_column.
-
getTitle
Returns the title of the widget.- Returns:
- the title of the column. This string should not be modified or freed.
-
getTreeView
Returns the `GtkTreeView` wherein @tree_column has been inserted.
If @column is currently not inserted in any tree view, %NULL is
returned.- Returns:
- The tree view wherein @column has been inserted
-
getVisible
public boolean getVisible()Returns %TRUE if @tree_column is visible.- Returns:
- whether the column is visible or not. If it is visible, then the tree will show the column.
-
getWidget
Returns the `GtkWidget` in the button on the column header.
If a custom widget has not been set then %NULL is returned.- Returns:
- The `GtkWidget` in the column header
-
getWidth
public int getWidth()Returns the current size of @tree_column in pixels.- Returns:
- The current width of @tree_column.
-
getXOffset
public int getXOffset()Returns the current X offset of @tree_column in pixels.- Returns:
- The current X offset of @tree_column.
-
packEnd
Adds the @cell to end of the column. If @expand is %FALSE, then the @cell
is allocated no more space than it needs. Any unused space is divided
evenly between cells for which @expand is %TRUE.- Parameters:
cell- The `GtkCellRenderer`expand- %TRUE if @cell is to be given extra space allocated to @tree_column.
-
packStart
Packs the @cell into the beginning of the column. If @expand is %FALSE, then
the @cell is allocated no more space than it needs. Any unused space is divided
evenly between cells for which @expand is %TRUE.- Parameters:
cell- The `GtkCellRenderer`expand- %TRUE if @cell is to be given extra space allocated to @tree_column.
-
queueResize
public void queueResize()Flags the column, and the cell renderers added to this column, to have
their sizes renegotiated. -
setAlignment
public void setAlignment(float xalign) Sets the alignment of the title or custom widget inside the column header.
The alignment determines its location inside the button -- 0.0 for left, 0.5
for center, 1.0 for right.- Parameters:
xalign- The alignment, which is between [0.0 and 1.0] inclusive.
-
setAttributes
Sets the attributes in the list as the attributes of @tree_column.
The attributes should be in attribute/column order, as in
gtk_tree_view_column_add_attribute(). All existing attributes
are removed, and replaced with the new attributes.- Parameters:
cell_renderer- the `GtkCellRenderer` we’re setting the attributes of_elipse- A %NULL-terminated list of attributes
-
setCellDataFunc
public void setCellDataFunc(@Nonnull CellRenderer cell_renderer, TreeViewColumn.OnTreeCellDataFunc func, @Nullable Pointer func_data, TreeViewColumn.OnDestroyNotify destroy) Sets the `GtkTreeCellDataFunc` to use for the column.
This
function is used instead of the standard attributes mapping for
setting the column value, and should set the value of @tree_column's
cell renderer as appropriate. @func may be %NULL to remove an
older one.- Parameters:
cell_renderer- A `GtkCellRenderer`func- The `GtkTreeCellDataFunc` to use.func_data- The user data for @func.destroy- The destroy notification for @func_data
-
setClickable
public void setClickable(boolean clickable) Sets the header to be active if @clickable is %TRUE. When the header is
active, then it can take keyboard focus, and can be clicked.- Parameters:
clickable- %TRUE if the header is active.
-
setExpand
public void setExpand(boolean expand) Sets the column to take available extra space. This space is shared equally
amongst all columns that have the expand set to %TRUE. If no column has this
option set, then the last column gets all extra space. By default, every
column is created with this %FALSE.
Along with “fixed-width”, the “expand” property changes when the column is
resized by the user.- Parameters:
expand- %TRUE if the column should expand to fill available space.
-
setFixedWidth
public void setFixedWidth(int fixed_width) If @fixed_width is not -1, sets the fixed width of @tree_column; otherwise
unsets it. The effective value of @fixed_width is clamped between the
minimum and maximum width of the column; however, the value stored in the
“fixed-width” property is not clamped. If the column sizing is
%GTK_TREE_VIEW_COLUMN_GROW_ONLY or %GTK_TREE_VIEW_COLUMN_AUTOSIZE, setting
a fixed width overrides the automatically calculated width. Note that
@fixed_width is only a hint to GTK; the width actually allocated to the
column may be greater or less than requested.
Along with “expand”, the “fixed-width” property changes when the column is
resized by the user.- Parameters:
fixed_width- The new fixed width, in pixels, or -1.
-
setMaxWidth
public void setMaxWidth(int max_width) Sets the maximum width of the @tree_column. If @max_width is -1, then the
maximum width is unset. Note, the column can actually be wider than max
width if it’s the last column in a view. In this case, the column expands to
fill any extra space.- Parameters:
max_width- The maximum width of the column in pixels, or -1.
-
setMinWidth
public void setMinWidth(int min_width) Sets the minimum width of the @tree_column. If @min_width is -1, then the
minimum width is unset.- Parameters:
min_width- The minimum width of the column in pixels, or -1.
-
setReorderable
public void setReorderable(boolean reorderable) If @reorderable is %TRUE, then the column can be reordered by the end user
dragging the header.- Parameters:
reorderable- %TRUE, if the column can be reordered.
-
setResizable
public void setResizable(boolean resizable) If @resizable is %TRUE, then the user can explicitly resize the column by
grabbing the outer edge of the column button.
If resizable is %TRUE and
sizing mode of the column is %GTK_TREE_VIEW_COLUMN_AUTOSIZE, then the sizing
mode is changed to %GTK_TREE_VIEW_COLUMN_GROW_ONLY.- Parameters:
resizable- %TRUE, if the column can be resized
-
setSizing
public void setSizing(int type) Sets the growth behavior of @tree_column to @type.- Parameters:
type- The `GtkTreeViewColumn`Sizing.
-
setSortColumnId
public void setSortColumnId(int sort_column_id) Sets the logical @sort_column_id that this column sorts on when this column
is selected for sorting. Doing so makes the column header clickable.- Parameters:
sort_column_id- The @sort_column_id of the model to sort on.
-
setSortIndicator
public void setSortIndicator(boolean setting) Call this function with a @setting of %TRUE to display an arrow in
the header button indicating the column is sorted. Call
gtk_tree_view_column_set_sort_order() to change the direction of
the arrow.- Parameters:
setting- %TRUE to display an indicator that the column is sorted
-
setSortOrder
public void setSortOrder(int order) Changes the appearance of the sort indicator.
This does not actually sort the model. Use
gtk_tree_view_column_set_sort_column_id() if you want automatic sorting
support. This function is primarily for custom sorting behavior, and should
be used in conjunction with gtk_tree_sortable_set_sort_column_id() to do
that. For custom models, the mechanism will vary.
The sort indicator changes direction to indicate normal sort or reverse sort.
Note that you must have the sort indicator enabled to see anything when
calling this function; see gtk_tree_view_column_set_sort_indicator().- Parameters:
order- sort order that the sort indicator should indicate
-
setSpacing
public void setSpacing(int spacing) Sets the spacing field of @tree_column, which is the number of pixels to
place between cell renderers packed into it.- Parameters:
spacing- distance between cell renderers in pixels.
-
setTitle
Sets the title of the @tree_column. If a custom widget has been set, then
this value is ignored.- Parameters:
title- The title of the @tree_column.
-
setTitle
Sets the title of the @tree_column. If a custom widget has been set, then
this value is ignored.- Parameters:
title- The title of the @tree_column.
-
setVisible
public void setVisible(boolean visible) Sets the visibility of @tree_column.- Parameters:
visible- %TRUE if the @tree_column is visible.
-
setWidget
Sets the widget in the header to be @widget. If widget is %NULL, then the
header button is set with a `GtkLabel` set to the title of @tree_column.- Parameters:
widget- A child `GtkWidget`
-
onClicked
Connect to signal "clicked".
SeeTreeViewColumn.OnClicked.onClicked()for signal description.
FieldSIGNAL_ON_CLICKEDcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
asBuildable
Implements interfaceBuildable. Call this to get access to interface functions.- Returns:
Buildable
-
asCellLayout
Implements interfaceCellLayout. Call this to get access to interface functions.- Returns:
CellLayout
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-