class Gtk::TreeViewColumn

Overview

A visible column in a Gtk::TreeView widget

The Gtk::TreeViewColumn object represents a visible column in a Gtk::TreeView 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:

lib/gi-crystal/src/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 | Nil 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) : Nil set_cell_data_func, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::CellLayout

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::CellLayout

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String | Nil buildable_id, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Buildable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Buildable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class GObject::InitiallyUnowned

==(other : self) ==, hash(hasher) hash

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

==(other : self) ==, 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) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, 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) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil 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, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : 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

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new : self #

Creates a new Gtk::TreeViewColumn.


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

[View source]
def self.new_with_area(area : Gtk::CellArea) : self #

Creates a new Gtk::TreeViewColumn using area to render its cells.


[View source]

Class Method Detail

def self.g_type : UInt64 #

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


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


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 Gtk::CellRendererText get its values from column 2.


[View source]
def alignment : Float32 #

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


[View source]
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.


[View source]
def button : Gtk::Widget #

Returns the button used in the treeview column header


[View source]
def cell_area : Gtk::CellArea | Nil #

[View source]
def cell_area=(value : Gtk::CellArea | Nil) : Gtk::CellArea | Nil #

[View source]
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.


[View source]
def cell_get_size : Nil #

Obtains the width and height needed to render the column. This is used primarily by the Gtk::TreeView.


[View source]
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()


[View source]
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 Gtk::TreeView.


[View source]
def clear : Nil #

Unsets all the mappings on all renderers on the tree_column.


[View source]
def clear_attributes(cell_renderer : Gtk::CellRenderer) : Nil #

Clears all existing attributes previously set with gtk_tree_view_column_set_attributes().


[View source]
def clickable : Bool #

Returns true if the user can click on the header for the column.


[View source]
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.


[View source]
def clickable? : Bool #

[View source]
def clicked : Nil #

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


[View source]
def clicked_signal #

[View source]
def expand : Bool #

Returns true if the column expands to fill available space.


[View source]
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.


[View source]
def expand? : Bool #

[View source]
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().


[View source]
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.


[View source]
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.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def max_width : Int32 #

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


[View source]
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.


[View source]
def min_width : Int32 #

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


[View source]
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.


[View source]
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.


[View source]
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.


[View source]
def queue_resize : Nil #

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


[View source]
def reorderable : Bool #

Returns true if the tree_column can be reordered by the user.


[View source]
def reorderable=(reorderable : Bool) : Nil #

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


[View source]
def reorderable? : Bool #

[View source]
def resizable : Bool #

Returns true if the tree_column can be resized by the end user.


[View source]
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.


[View source]
def resizable? : Bool #

[View source]
def set_cell_data_func(cell_renderer : Gtk::CellRenderer, func : Gtk::TreeCellDataFunc | Nil) : Nil #

Sets the Gtk::TreeCellDataFunc 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 nil to remove an older one.


[View source]

Returns the current type of tree_column.


[View source]
def sizing=(type : Gtk::TreeViewColumnSizing) : Nil #

Sets the growth behavior of tree_column to type.


[View source]
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=.


[View source]
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.


[View source]
def sort_indicator : Bool #

Gets the value set by gtk_tree_view_column_set_sort_indicator().


[View source]
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.


[View source]
def sort_indicator? : Bool #

[View source]
def sort_order : Gtk::SortType #

Gets the value set by gtk_tree_view_column_set_sort_order().


[View source]
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().


[View source]
def spacing : Int32 #

Returns the spacing of tree_column.


[View source]
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.


[View source]
def title : String #

Returns the title of the widget.


[View source]
def title=(title : String) : Nil #

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


[View source]
def tree_view : Gtk::Widget | Nil #

Returns the Gtk::TreeView wherein tree_column has been inserted. If column is currently not inserted in any tree view, nil is returned.


[View source]
def visible : Bool #

Returns true if tree_column is visible.


[View source]
def visible=(visible : Bool) : Nil #

Sets the visibility of tree_column.


[View source]
def visible? : Bool #

[View source]
def widget : Gtk::Widget | Nil #

Returns the Gtk::Widget in the button on the column header.

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


[View source]
def widget=(widget : Gtk::Widget | Nil) : Nil #

Sets the widget in the header to be widget. If widget is nil, then the header button is set with a Gtk::Label set to the title of tree_column.


[View source]
def width : Int32 #

Returns the current size of tree_column in pixels.


[View source]
def x_offset : Int32 #

Returns the current X offset of tree_column in pixels.


[View source]