Class: Gtk::TreeViewColumn
- Inherits:
-
GObject::InitiallyUnowned
- Object
- GObject::InitiallyUnowned
- Gtk::TreeViewColumn
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/gtk3/deprecated.rb,
lib/gtk3/tree-view-column.rb
Overview
A visible column in a [classGtk.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 [classGtk.TreeView] documentation for specifics about the CSS node structure for treeviews and their headers.
Instance Method Summary collapse
-
#add_attribute(renderer, key, value) ⇒ nil
Adds an attribute mapping to the list in tree_column.
-
#add_attribute_raw ⇒ nil
Adds an attribute mapping to the list in tree_column.
-
#alignment ⇒ Gtk::gfloat
Alignment.
- #alignment=(alignment) ⇒ Gtk::gfloat
-
#button ⇒ Gtk::Widget
Returns the button used in the treeview column header.
-
#cell_area ⇒ Gtk::CellArea
The
GtkCellAreaused to layout cell renderers for this column. -
#cell_area=(cell_area) ⇒ Gtk::CellArea
The
GtkCellAreaused to layout cell renderers for this column. -
#cell_get_position(cell_renderer, x_offset, width) ⇒ Boolean
Obtains the horizontal position and size of a cell in a column.
-
#cell_get_size(x_offset, y_offset, width, height) ⇒ nil
Obtains the width and height needed to render the column.
-
#cell_is_visible ⇒ Boolean
Returns true if any of the cells packed into the tree_column are visible.
-
#cell_set_cell_data(tree_model, iter, is_expander, is_expanded) ⇒ nil
Sets the cell renderer based on the tree_model and iter.
-
#clear ⇒ nil
Unsets all the mappings on all renderers on the tree_column.
-
#clear_attributes(cell_renderer) ⇒ nil
Clears all existing attributes previously set with gtk_tree_view_column_set_attributes().
-
#clickable ⇒ Boolean
Returns true if the user can click on the header for the column.
- #clickable=(clickable) ⇒ Boolean
-
#clickable? ⇒ Boolean
Clickable.
-
#clicked ⇒ nil
Emits the “clicked” signal on the column.
-
#expand ⇒ Boolean
Returns true if the column expands to fill available space.
- #expand=(expand) ⇒ Boolean
-
#expand? ⇒ Boolean
Expand.
-
#fixed_width ⇒ Integer
Fixed-width.
- #fixed_width=(fixed_width) ⇒ Integer
-
#focus_cell(cell) ⇒ nil
Sets the current keyboard focus to be at cell, if the column contains 2 or more editable and activatable cells.
-
#initialize(*args) ⇒ Gtk::TreeViewColumn
constructor
Creates a new
GtkTreeViewColumnwith a number of default values. -
#initialize_raw ⇒ Gtk::TreeViewColumn
Creates a new
GtkTreeViewColumnwith a number of default values. -
#max_width ⇒ Integer
Max-width.
- #max_width=(max_width) ⇒ Integer
-
#min_width ⇒ Integer
Min-width.
- #min_width=(min_width) ⇒ Integer
-
#pack_end(cell, expand) ⇒ nil
Adds the cell to end of the column.
-
#pack_start(cell, expand) ⇒ nil
Packs the cell into the beginning of the column.
-
#queue_resize ⇒ nil
Flags the column, and the cell renderers added to this column, to have their sizes renegotiated.
-
#reorderable ⇒ Boolean
Returns true if the tree_column can be reordered by the user.
- #reorderable=(reorderable) ⇒ Boolean
-
#reorderable? ⇒ Boolean
Reorderable.
-
#resizable ⇒ Boolean
Returns true if the tree_column can be resized by the end user.
- #resizable=(resizable) ⇒ Boolean
-
#resizable? ⇒ Boolean
Resizable.
-
#set_attributes(cell_renderer, array) ⇒ nil
Sets the attributes in the list as the attributes of tree_column.
-
#set_cell_data_func(cell_renderer, func, func_data, destroy) ⇒ nil
Sets the
GtkTreeCellDataFuncto use for the column. -
#sizing ⇒ Gtk::TreeViewColumnSizing
Sizing.
- #sizing=(sizing) ⇒ Gtk::TreeViewColumnSizing
-
#sort_column_id ⇒ Integer
Logical sort column ID this column sorts on when selected for sorting.
-
#sort_column_id=(sort_column_id) ⇒ Integer
Logical sort column ID this column sorts on when selected for sorting.
-
#sort_indicator ⇒ Boolean
Gets the value set by gtk_tree_view_column_set_sort_indicator().
- #sort_indicator=(sort_indicator) ⇒ Boolean
-
#sort_indicator? ⇒ Boolean
Sort-indicator.
-
#sort_order ⇒ Gtk::SortType
Sort-order.
- #sort_order=(sort_order) ⇒ Gtk::SortType
-
#spacing ⇒ Integer
Spacing.
- #spacing=(spacing) ⇒ Integer
-
#title ⇒ String
Title.
- #title=(title) ⇒ String
-
#tree_view ⇒ Gtk::Widget
Returns the
GtkTreeViewwherein tree_column has been inserted. -
#visible ⇒ Boolean
Returns true if tree_column is visible.
- #visible=(visible) ⇒ Boolean
-
#visible? ⇒ Boolean
Visible.
-
#widget ⇒ Gtk::Widget
Widget.
- #widget=(widget) ⇒ Gtk::Widget
-
#width ⇒ Integer
Width.
- #width=(width) ⇒ Integer
-
#x_offset ⇒ Integer
X-offset.
- #x_offset=(x_offset) ⇒ Integer
Constructor Details
#initialize(*args) ⇒ Gtk::TreeViewColumn
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:
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);
}
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gtk3/tree-view-column.rb', line 20 def initialize(*args) if args.size == 1 and args[0].is_a?(Hash) = args[0].dup area = .delete(:area) renderer = .delete(:renderer) title = .delete(:title) attributes = .delete(:attributes) unless .empty? names = .keys.inspect available_names = [:area, :renderer, :title, :attributes].inspect = "unknown option(s): #{names}: available options: #{available_names}" raise ArgumentError, end else area = nil title, renderer, attributes = args end attributes ||= {} if area initialize_new_with_area(area) else initialize_raw end set_title(title) if title if renderer pack_start(renderer, true) attributes.each_entry do |key, value| add_attribute(renderer, key, value) end end end |
Instance Method Details
#add_attribute(renderer, key, value) ⇒ 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.
56 57 58 59 |
# File 'lib/gtk3/tree-view-column.rb', line 56 def add_attribute(renderer, key, value) key = key.to_s if key.is_a?(Symbol) add_attribute_raw(renderer, key, value) end |
#add_attribute_raw ⇒ 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.
|
|
# File 'lib/gtk3/tree-view-column.rb', line 55
|
#alignment ⇒ Gtk::gfloat
Returns alignment.
#alignment=(alignment) ⇒ Gtk::gfloat
#button ⇒ Gtk::Widget
Returns the button used in the treeview column header
#cell_area ⇒ Gtk::CellArea
The GtkCellArea used to layout cell renderers for this column.
If no area is specified when creating the tree view column with gtk_tree_view_column_new_with_area()
a horizontally oriented GtkCellAreaBox will be used.
#cell_area=(cell_area) ⇒ Gtk::CellArea
The GtkCellArea used to layout cell renderers for this column.
If no area is specified when creating the tree view column with gtk_tree_view_column_new_with_area()
a horizontally oriented GtkCellAreaBox will be used.
#cell_get_position(cell_renderer, x_offset, width) ⇒ Boolean
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.
#cell_get_size(x_offset, y_offset, width, height) ⇒ nil
Obtains the width and height needed to render the column. This is used
primarily by the GtkTreeView.
#cell_is_visible ⇒ Boolean
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()
#cell_set_cell_data(tree_model, iter, is_expander, is_expanded) ⇒ 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.
#clear ⇒ nil
Unsets all the mappings on all renderers on the tree_column.
#clear_attributes(cell_renderer) ⇒ nil
Clears all existing attributes previously set with gtk_tree_view_column_set_attributes().
#clickable ⇒ Boolean
Returns true if the user can click on the header for the column.
#clickable=(clickable) ⇒ Boolean
#clickable? ⇒ Boolean
Returns clickable.
#clicked ⇒ nil
Emits the “clicked” signal on the column. This function will only work if tree_column is clickable.
#expand ⇒ Boolean
Returns true if the column expands to fill available space.
#expand=(expand) ⇒ Boolean
#expand? ⇒ Boolean
Returns expand.
#fixed_width ⇒ Integer
Returns fixed-width.
#fixed_width=(fixed_width) ⇒ Integer
#focus_cell(cell) ⇒ nil
Sets the current keyboard focus to be at cell, if the column contains 2 or more editable and activatable cells.
#initialize_raw ⇒ Gtk::TreeViewColumn
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:
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);
}
|
|
# File 'lib/gtk3/tree-view-column.rb', line 19
|
#max_width ⇒ Integer
Returns max-width.
#max_width=(max_width) ⇒ Integer
#min_width ⇒ Integer
Returns min-width.
#min_width=(min_width) ⇒ Integer
#pack_end(cell, expand) ⇒ 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.
#pack_start(cell, expand) ⇒ 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.
#queue_resize ⇒ nil
Flags the column, and the cell renderers added to this column, to have their sizes renegotiated.
#reorderable ⇒ Boolean
Returns true if the tree_column can be reordered by the user.
#reorderable=(reorderable) ⇒ Boolean
#reorderable? ⇒ Boolean
Returns reorderable.
#resizable ⇒ Boolean
Returns true if the tree_column can be resized by the end user.
#resizable=(resizable) ⇒ Boolean
#resizable? ⇒ Boolean
Returns resizable.
#set_attributes(cell_renderer, array) ⇒ nil
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.
#set_cell_data_func(cell_renderer, func, func_data, destroy) ⇒ 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 nil to remove an older one.
#sizing ⇒ Gtk::TreeViewColumnSizing
Returns sizing.
#sizing=(sizing) ⇒ Gtk::TreeViewColumnSizing
#sort_column_id ⇒ Integer
Logical sort column ID this column sorts on when selected for sorting. Setting the sort column ID makes the column header clickable. Set to -1 to make the column unsortable.
#sort_column_id=(sort_column_id) ⇒ Integer
Logical sort column ID this column sorts on when selected for sorting. Setting the sort column ID makes the column header clickable. Set to -1 to make the column unsortable.
#sort_indicator ⇒ Boolean
Gets the value set by gtk_tree_view_column_set_sort_indicator().
#sort_indicator=(sort_indicator) ⇒ Boolean
#sort_indicator? ⇒ Boolean
Returns sort-indicator.
#sort_order ⇒ Gtk::SortType
Returns sort-order.
#sort_order=(sort_order) ⇒ Gtk::SortType
#spacing ⇒ Integer
Returns spacing.
#spacing=(spacing) ⇒ Integer
#title ⇒ String
Returns title.
#title=(title) ⇒ String
#tree_view ⇒ Gtk::Widget
Returns the GtkTreeView wherein tree_column has been inserted.
If column is currently not inserted in any tree view, nil is
returned.
#visible ⇒ Boolean
Returns true if tree_column is visible. the tree will show the column.
#visible=(visible) ⇒ Boolean
#visible? ⇒ Boolean
Returns visible.
#widget ⇒ Gtk::Widget
Returns widget.
#widget=(widget) ⇒ Gtk::Widget
#width ⇒ Integer
Returns width.
#width=(width) ⇒ Integer
#x_offset ⇒ Integer
Returns x-offset.