class Gtk::TreeViewColumn

Overview

A visible column in a 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 for an overview of all the objects and data types related to the tree widget and how they work together, and to the Gtk#TreeView documentation for specifics about the CSS node structure for treeviews and their headers.

Included Modules

Defined in:

auto/gtk-4.0/tree_view_column.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Gtk::CellLayout

add_attribute(cell : Gtk::CellRenderer, attribute : String, column : Int32) : Nil add_attribute, area : Gtk::CellArea? area, cells : GLib::List cells, clear : Nil clear, clear_attributes(cell : Gtk::CellRenderer) : Nil clear_attributes, pack_end(cell : Gtk::CellRenderer, expand : Bool) : Nil pack_end, pack_start(cell : Gtk::CellRenderer, expand : Bool) : Nil pack_start, reorder(cell : Gtk::CellRenderer, position : Int32) : Nil reorder, set_cell_data_func(cell : Gtk::CellRenderer, func : Gtk::CellLayoutDataFunc?) : Nil set_cell_data_func, to_unsafe to_unsafe

Instance methods inherited from module Gtk::Buildable

buildable_id : String? buildable_id, to_unsafe to_unsafe

Constructor methods inherited from class GObject::InitiallyUnowned

new new

Class methods inherited from class GObject::InitiallyUnowned

g_type : UInt64 g_type

Instance methods inherited from class GObject::Object

bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void)? qdata, ref_count ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, cast?(obj : GObject::Object) : self? cast?, new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

compat_control(what : UInt64, data : Pointer(Void)?) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Constructor Detail

def self.new #

Creates a new GtkTreeViewColumn.


def self.new(*, alignment : Float32? = nil, cell_area : Gtk::CellArea? = nil, clickable : Bool? = nil, expand : Bool? = nil, fixed_width : Int32? = nil, max_width : Int32? = nil, min_width : Int32? = nil, reorderable : Bool? = nil, resizable : Bool? = nil, sizing : Gtk::TreeViewColumnSizing? = nil, sort_column_id : Int32? = nil, sort_indicator : Bool? = nil, sort_order : Gtk::SortType? = nil, spacing : Int32? = nil, title : String? = nil, visible : Bool? = nil, widget : Gtk::Widget? = nil, width : Int32? = nil, x_offset : Int32? = nil) #

def self.new_with_area(area : Gtk::CellArea) : self #

Creates a new GtkTreeViewColumn using @area to render its cells.


Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def add_attribute(cell_renderer : Gtk::CellRenderer, attribute : String, column : Int32) : Nil #

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.


def alignment : Float32 #

Returns the current x alignment of @tree_column. This value can range between 0.0 and 1.0.


def alignment=(xalign : Float32) : Nil #

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.


def button : Gtk::Widget #

Returns the button used in the treeview column header


def cell_area : Gtk::CellArea? #

def cell_area=(value : Gtk::CellArea?) : Gtk::CellArea? #

def cell_get_position(cell_renderer : Gtk::CellRenderer) : Bool #

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.


def cell_get_size : Nil #

Obtains the width and height needed to render the column. This is used primarily by the GtkTreeView.


def cell_is_visible : Bool #

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()


def cell_set_cell_data(tree_model : Gtk::TreeModel, iter : Gtk::TreeIter, is_expander : Bool, is_expanded : Bool) : Nil #

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.


def clear : Nil #

Unsets all the mappings on all renderers on the @tree_column.


def clear_attributes(cell_renderer : Gtk::CellRenderer) : Nil #

Clears all existing attributes previously set with gtk_tree_view_column_set_attributes().


def clickable : Bool #

Returns %TRUE if the user can click on the header for the column.


def clickable=(clickable : Bool) : Nil #

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.


def clickable? : Bool #

def clicked : Nil #

Emits the “clicked” signal on the column. This function will only work if @tree_column is clickable.


def clicked_signal #

def expand : Bool #

Returns %TRUE if the column expands to fill available space.


def expand=(expand : Bool) : Nil #

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.


def expand? : Bool #

def fixed_width : Int32 #

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().


def fixed_width=(fixed_width : Int32) : Nil #

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.


def focus_cell(cell : Gtk::CellRenderer) : Nil #

Sets the current keyboard focus to be at @cell, if the column contains 2 or more editable and activatable cells.


def max_width : Int32 #

Returns the maximum width in pixels of the @tree_column, or -1 if no maximum width is set.


def max_width=(max_width : Int32) : Nil #

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.


def min_width : Int32 #

Returns the minimum width in pixels of the @tree_column, or -1 if no minimum width is set.


def min_width=(min_width : Int32) : Nil #

Sets the minimum width of the @tree_column. If @min_width is -1, then the minimum width is unset.


def pack_end(cell : Gtk::CellRenderer, expand : Bool) : Nil #

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.


def pack_start(cell : Gtk::CellRenderer, expand : Bool) : Nil #

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.


def queue_resize : Nil #

Flags the column, and the cell renderers added to this column, to have their sizes renegotiated.


def reorderable : Bool #

Returns %TRUE if the @tree_column can be reordered by the user.


def reorderable=(reorderable : Bool) : Nil #

If @reorderable is %TRUE, then the column can be reordered by the end user dragging the header.


def reorderable? : Bool #

def resizable : Bool #

Returns %TRUE if the @tree_column can be resized by the end user.


def resizable=(resizable : Bool) : Nil #

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.


def resizable? : Bool #

def set_cell_data_func(cell_renderer : Gtk::CellRenderer, func : Gtk::TreeCellDataFunc?) : Nil #

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.


Returns the current type of @tree_column.


def sizing=(type : Gtk::TreeViewColumnSizing) : Nil #

Sets the growth behavior of @tree_column to @type.


def sort_column_id : Int32 #

Gets the logical @sort_column_id that the model sorts on when this column is selected for sorting.

See Gtk::TreeViewColumn#sort_column_id=.


def sort_column_id=(sort_column_id : Int32) : Nil #

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.


def sort_indicator : Bool #

Gets the value set by gtk_tree_view_column_set_sort_indicator().


def sort_indicator=(setting : Bool) : Nil #

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.


def sort_indicator? : Bool #

def sort_order : Gtk::SortType #

Gets the value set by gtk_tree_view_column_set_sort_order().


def sort_order=(order : Gtk::SortType) : Nil #

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().


def spacing : Int32 #

Returns the spacing of @tree_column.


def spacing=(spacing : Int32) : Nil #

Sets the spacing field of @tree_column, which is the number of pixels to place between cell renderers packed into it.


def title : String #

Returns the title of the widget.


def title=(title : String) : Nil #

Sets the title of the @tree_column. If a custom widget has been set, then this value is ignored.


def tree_view : Gtk::Widget? #

Returns the GtkTreeView wherein @tree_column has been inserted. If @column is currently not inserted in any tree view, %NULL is returned.


def visible : Bool #

Returns %TRUE if @tree_column is visible.


def visible=(visible : Bool) : Nil #

Sets the visibility of @tree_column.


def visible? : Bool #

def widget : Gtk::Widget? #

Returns the GtkWidget in the button on the column header.

If a custom widget has not been set then %NULL is returned.


def widget=(widget : Gtk::Widget?) : Nil #

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.


def width : Int32 #

Returns the current size of @tree_column in pixels.


def x_offset : Int32 #

Returns the current X offset of @tree_column in pixels.