Gtk::TreeViewColumn
class Gtk::TreeViewColumn
The Gtk::TreeViewColumn object is a visible column in a Gtk::TreeView widget. It determines the geometry, type.
Class Methods
Gtk::TreeViewColumn.new(title = nil, cell_renderer = nil, attributes = nil)
-
Creates a new Gtk::TreeViewColumn with a number of default values. This is equivalent to calling Gtk::TreeViewColumn.new, Gtk::TreeViewColumn#title=, Gtk::TreeViewColumn#pack_start, and Gtk::TreeViewColumn#set_attributes on the newly created Gtk::TreeViewColumn.
- title: The title to set the header to.
- cell_renderer: The Gtk::CellRenderer
- attributes: a hash of attributes.
- Returns : A newly created Gtk::TreeViewColumn.
Here's a simple example:
TEXT_COLUMN = 0 COLOR_COLUMN = 1 renderer = Gtk::CellRendererText.new column = Gtk::TreeViewColumn.new("Title", renderer, :text => TEXT_COLUMN, :foreground => COLOR_COLUMN)
Instance Methods
pack_start(cell, expand)
-
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.
- cell: The Gtk::CellRenderer.
- expand: true if cell is to be given extra space allocated to box.
- Returns: self
pack_end(cell, expand)
-
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.
- cell: The Gtk::CellRenderer.
- expand: true if cell is to be given extra space allocated to box.
- Returns: self
clear
-
Unsets all the mappings on all renderers on the Gtk::TreeViewColumn.
- Returns: self
cell_renderers
-
Returns an array of all the cell renderers in the column, in no particular order.
- Returns: An array of Gtk::CellRenderer s
add_attribute(cell_renderer, attribute, column)
-
Adds an attribute mapping to the list in the Gtk::TreeViewColumn. 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.
- cell_renderer: the Gtk::CellRenderer to set attributes on
- attribute: An attribute on the renderer(Symbol or String)
- column: The column position on the model to get the attribute from.
- Returns: self
set_attributes(cell_renderer, attributes)
-
Sets the attributes in the list as the attributes of the Gtk::TreeViewColumn. All existing attributes are removed, and replaced with the new attributes.
You should set cell_renderer to the Gtk::TreeViewColumn before call this method.
- cell_renderer: The Gtk::CellRenderer we're setting the attributes of
- attributes: a hash of attributes. See Gtk::TreeViewColumn.new
set_cell_data_func(cell) {|tvc, cell, model, iter| ... }
-
Sets the block which is used instead of the standard attributes mapping for setting the column value, and should set the value of Gtk::TreeViewColumn's cell renderer as appropriate.
- cell: A Gtk::CellRenderer
- {|tvc, cell, model, iter| ... }: the block
- tvc: the Gtk::TreeViewColumn
- cell: the Gtk::CellRenderer
- model: the Gtk::TreeModel
- iter: the Gtk::TreeIter
- Returns: self
clear_attributes(cell_renderer)
-
Clears all existing attributes previously set with Gtk::TreeViewColumn#add_attribute.
- cell_renderer: a Gtk::CellRenderer to clear the attribute mapping on.
- Returns: self
spacing
-
Returns the spacing of the Gtk::TreeViewColumn.
- Returns : the spacing of the Gtk::TreeViewColumn.
spacing=(spacing)
-
Sets the spacing field of the Gtk::TreeViewColumn, which is the number of pixels to place between cell renderers packed into it.
- spacing: distance between cell renderers in pixels.
- Returns: spacing
set_spacing(spacing)
-
Same as Gtk::TreeViewColumn#spacing=.
- spacing: distance between cell renderers in pixels.
- Returns: self
visible?
-
Returns true if Gtk::TreeViewColumn is visible.
- Returns: whether the column is visible or not. If it is visible, then the tree will show the column.
visible=(visible)
-
Sets the visibility of Gtk::TreeViewColumn.
- visible : true if the Gtk::TreeViewColumn is visible.
- Returns: visible
set_visible(visible)
-
Same as Gtk::TreeViewColumn#visible=.
- Returns: self
resizable?
-
Returns true if the Gtk::TreeViewColumn can be resized by the end user.
- Returns: A Gtk::TreeViewColumn
resizable=(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::TreeViewColumn::AUTOSIZE, then the sizing mode is changed to Gtk::TreeViewColumn::GROW_ONLY.
- resizable: true, if the column can be resized
- Returns: resizable
set_resizable(resizable)
-
Same as Gtk::TreeViewColumn#resizable=.
- resizable: true, if the column can be resized
- Returns: self
sizing
-
Returns the current type of the Gtk::TreeViewColumn.
- Returns: The value of the GtkTreeViewColumnSizing.
sizing=(type)
-
Sets the growth behavior of the Gtk::TreeViewColumn to type.
- type : The GtkTreeViewColumnSizing.
- Returns: type
set_sizing(type)
-
Same as Gtk::TreeViewColumn#sizing=.
- type : The GtkTreeViewColumnSizing.
- Returns: self
width
-
Returns the current size of the Gtk::TreeViewColumn in pixels.
- Returns: The current width of the Gtk::TreeViewColumn.
fixed_width
-
Gets the fixed width of the column. This value is only meaning may not be the actual width of the column on the screen, just what is requested.
- Returns: the fixed width of the column
fixed_width=(fixed_width)
-
Sets the size of the column in pixels. This is meaningful only if the sizing type is Gtk::TreeViewColumn::FIXED. The size of the column is clamped to the min/max width for the column. Please note that the min/max width of the column doesn't actually affect the "fixed_width" property of the widget, just the actual size when displayed.
- fixed_width: The size to set the Gtk::TreeViewColumn to. Must be greater than 0.
- Returns: fixed_width
set_fixed_width
-
Same as Gtk::TreeViewColumn#fixed_width=.
- fixed_width: The size to set the Gtk::TreeViewColumn to. Must be greater than 0.
- Returns: self
min_width
-
Returns the minimum width in pixels of the Gtk::TreeViewColumn, or -1 if no minimum width is set.
- Returns: The minimum width of the Gtk::TreeViewColumn.
min_width=(min_width)
-
Sets the minimum width of the Gtk::TreeViewColumn. If min_width is -1, then the minimum width is unset.
- min_width: The minimum width of the column in pixels, or -1.
- Returns: min_width
set_min_width(min_width)
-
Same as Gtk::TreeViewColumn#min_width=
- min_width: The minimum width of the column in pixels, or -1.
- Returns: self
max_width
- Returns the maximum width in pixels of the Gtk::TreeViewColumn, or -1 if no maximum width is set. * Returns : The maximum width of the Gtk::TreeViewColumn.
max_width=(max_width)
-
Sets the maximum width of the Gtk::TreeViewColumn. 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.
- max_width: The maximum width of the column in pixels, or -1.
- Returns: max_width
set_max_width(max_width)
-
Same as Gtk::TreeViewColumn#max_width=.
- max_width: The maximum width of the column in pixels, or -1.
- Returns: self
clicked
-
Emits the "clicked" signal on the column. This method will only work if the Gtk::TreeViewColumn is clickable.
- Returns: self
title
-
Returns the title of the widget. This value should not be modified.
- Returns : the title of the column.
title=(title)
-
Sets the title of the Gtk::TreeViewColumn. If a custom widget has been set, then this value is ignored.
- title : The title of the Gtk::TreeViewColumn.
- Returns: title
set_title(title)
-
Same as Gtk::TreeViewColumn#title=.
- title : The title of the Gtk::TreeViewColumn.
- Returns: self
clickable?
-
Returns true if the user can click on the header for the column.
- Returns : true if user can click the column header.
clickable=(clickable)
-
Sets the header to be active if active is true. When the header is active, then it can take keyboard focus, and can be clicked.
- clickable: true if the header is active.
- Returns: clickable
set_clickable
-
Same as Gtk::TreeViewColumn#clickable=.
- clickable: true if the header is active.
- Returns: self
widget
-
Returns the Gtk::Widget in the button on the column header. If a custom widget has not been set then nil is returned.
- Returns: The Gtk::Widget in the column header, or nil
widget=(widget)
-
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 the Gtk::TreeViewColumn.
- widget: A child Gtk::Widget, or nil.
- Returns: widget
set_widget(widget)
-
Same as Gtk::TreeViewColumn#widget=.
- Returns: self
alignment
- 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.
alignment=(alignment)
-
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.
- xalign: The alignment, which is between [0.0 and 1.0] inclusive.
- Returns: alignment
set_alignment(alignment)
-
Same as Gtk::TreeViewColumn#alignment=.
- Returns: self
reorderable?
-
Returns true if the Gtk::TreeViewColumn can be reordered by the user.
- Returns : true if the Gtk::TreeViewColumn can be reordered by the user.
reorderable=(reorderable)
-
If reorderable is true, then the column can be reordered by the end user dragging the header.
- reorderable: true, if the column can be reordered.
- Returns: reorderable
set_reorderable(reorderable)
-
Same as Gtk::TreeViewColumn#reorderable=.
- Returns: self
sort_column_id
-
Gets the logical sort_column_id that the model sorts on when this column is selected for sorting. See Gtk::TreeViewColumn#sort_column_id=.
- Returns: the current sort_column_id for this column, or -1 if this column can't be used for sorting.
sort_column_id=(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.
- sort_column_id : The sort_column_id of the model to sort on
- Returns: self
set_sort_column_id(sort_column_id)
-
Same as Gtk::TreeViewColumn#sort_column_id=.
- Returns: self
sort_indicator?
-
Gets the value set by Gtk::TreeViewColumn#sort_indicator=.
- Returns : whether the sort indicator arrow is displayed
sort_indicator=(setting)
-
Call this method with a setting of true to display an arrow in the header button indicating the column is sorted. Call Gtk::TreeViewColumn#sort_order= to change the direction of the arrow.
- setting: true to display an indicator that the column is sorted
- Returns: setting
set_sort_indicator(setting)
-
Same as Gtk::TreeViewColumn#sort_indicator=.
- Returns: self
sort_order
-
Gets the value set by Gtk::TreeViewColumn#sort_order=.
- Returns: the GtkSortType the sort indicator is indicating
sort_order=(order)
-
Changes the appearance of the sort indicator.
This does not actually sort the model. Use Gtk::TreeViewColumn#sort_column_id= if you want automatic sorting support. This method is primarily for custom sorting behavior, and should be used in conjunction with Gtk::TreeSortable#sort_column= 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::TreeViewColumn#sort_indicator=.
- order: GtkSortType that the sort indicator should indicate
- Returns: order
set_sort_order(order)
-
Same as Gtk::TreeViewColumn#sort_order=.
- Returns: self
cell_set_cell_data(model,iter, is_expander, is_expanded)
-
Sets the cell renderer based on the tree_model and iter. That is, for every attribute mapping in the Gtk::TreeViewColumn, 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.
- tree_model: The GtkTreeModel to to get the cell renderers attributes from.
- iter: The Gtk::TreeIter to to get the cell renderer's attributes from.
- is_expander: true, if the row has children
- is_expanded: true, if the row has visible children
- Returns: self
cell_size
-
Obtains the width and height needed to render the column. This is used primarily by the Gtk::TreeView.
- Returns: [cell_area, x_offset, y_offset, width, height]
- cell_area: An Gdk::Rectangle or nil
- x_offset: x offset of cell relative to cell_area, or nil
- y_offset: y offset of cell relative to cell_area, or nil
- width: width needed to render a cell, or nil
- height: height needed to render a cell, or nil
- Returns: [cell_area, x_offset, y_offset, width, height]
cell_is_visible?
-
Returns true if any of the cells packed into the Gtk::TreeViewColumn are visible. For this to be meaningful, you must first initialize the cells with Gtk::TreeViewColumn#cell_set_cell_data.
- Returns: true, if any of the cells packed into the Gtk::TreeViewColumn are currently visible
cell_data_func=
-
not yet
- Returns: self
focus_cell(cell)
-
Sets the current keyboard focus to be at specified cell, if the column contains 2 or more editable and activatable cells. Since 2.2
- cell: the target cell (Gtk::CellRenderer)
- Returns: self
expand
- Return true if the column expands to take any available space. Since 2.4
expand=(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. Since 2.4
- expand: the new value (true or false)
set_expand(expand)
-
Same as Gtk::TreeViewColumn#expand=(expand). Since 2.4
- expand: the new value (true or false)
- Returns: self
queue_resize
-
Flags the column, and the cell renderers added to this column, to have their sizes renegotiated. Since 2.8
- Returns: self
expand?
-
Gets the Column gets share of extra width allocated to the widget.
- Returns: Column gets share of extra width allocated to the widget
reorder
- See Gtk::CellLayout#reorder.
tree_view
-
- Returns: self: FIXME
add_child
- See Gtk::Buildable#add_child.
construct_child
- See Gtk::Buildable#construct_child.
get_internal_child
- See Gtk::Buildable#get_internal_child.
name
- See Gtk::Buildable#name.
name=
- See Gtk::Buildable#name=.
set_buildable_property
- See Gtk::Buildable#set_buildable_property.
set_name
- See Gtk::Buildable#set_name.
builder_name
- See Gtk::Buildable#builder_name.
builder_name=
- See Gtk::Buildable#builder_name=.
set_builder_name
- See Gtk::Buildable#set_builder_name.
Constants
GtkTreeViewColumnSizing
The sizing method the column uses to determine its width. Please note that Gtk::TreeViewColumn::AUTOSIZE are inefficient for large views, and can make columns appear choppy.
Properties
alignment: Float (Read/Write)
- X Alignment of the column header text or widget
clickable: true or false (Read/Write)
- Whether the header can be clicked
fixed-width: Integer (Read/Write)
- Current fixed width of the column
expand: true or false (Read/Write)
- Column gets share of extra width allocated to the widget. Default value: false. Since 2.4
max-width: Integer (Read/Write)
- Maximum allowed width of the column
min-width: Integer (Read/Write)
- Minimum allowed width of the column
reorderable: true or false (Read/Write)
- Whether the column can be reordered around the headers
resizable: true or false (Read/Write)
- Column is user-resizable
sizing: Integer (Read/Write)
- Resize mode of the column
sort-indicator: true or false (Read/Write)
- Whether to show a sort indicator
sort-order: Integer (Read/Write)
- Sort direction the sort indicator should indicate
title: String (Read/Write)
- Title to appear in column header
visible: true or false (Read/Write)
- Whether to display the column
widget: Gtk::Widget (Read/Write)
- Widget to put in column header button instead of column title
width: Integer (Read)
- Current width of the column
spacing: Integer (Read/Write)
- Space which is inserted between cells
sort-column-id: Integer (Read/Write)
- Logical sort column ID this column sorts on when selected for sorting
Keyword(s):
References:[tut-treeview-renderer] [tut-gtk2-treev-trees] [News_20050306_1] [News_20080907_1] [Gtk::CellRendererText] [Gtk::CellRendererPixbuf] [Gtk::CellLayout] [Gtk::TreeViewColumn] [api-gtk-index] [tut-gtk2-treev-addrnhs] [tut-gtk2-treev] [Gtk::CellRendererToggle] [tut-treeview-renderer-attributes] [ruby-gtk-object-hierarchy] [Gtk::TreeSelection] [tut-treeview-components] [Gtk::CellRendererCombo] [tut-treeview-renderer-celldatafunc] [Ruby/GTK] [Gtk::TreeViewColumn::Sizing] [News_20120408_1] [tut-gtk2-treev-cdf] [Gtk::TreeView] [tut-gtk2-treev-parts] [News_20040308_1] [Gtk::TreeSortable] [News_20051016_1] [tut-treeview-renderer-renderer] [index-ruby-gtk2] [News (2017-01-26 No.1)]