Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Public Member Functions | Static Protected Attributes
Xfc::Gtk::TreeViewColumn Class Reference

A GtkTreeViewColumn C++ wrapper class. More...

#include <xfc/gtk/treeviewcolumn.hh>

Inheritance diagram for Xfc::Gtk::TreeViewColumn:
Xfc::Gtk::Object Xfc::Gtk::CellLayout Xfc::G::Object Xfc::G::TypeInterface Xfc::G::TypeInstance Xfc::G::TypeInstance Xfc::Trackable Xfc::Trackable

List of all members.

Public Member Functions

Static Protected Attributes

Constructors


Detailed Description

A GtkTreeViewColumn C++ wrapper class.

A TreeViewColumn is the object that TreeView uses to organize the vertical columns in the tree view. It needs to know the name of the column to label for the user, what type of cell renderer to use, and which piece of data to retrieve from the model for a given row.

See also: the TreeView Widget HOWTO and example.


Constructor & Destructor Documentation

Xfc::Gtk::TreeViewColumn::TreeViewColumn ( GtkTreeViewColumn *  tree_column,
bool  owns_reference = false 
) [explicit, protected]

Construct a new TreeViewColumn from an existing GtkTreeViewColumn.

Parameters:
tree_columnA pointer to a GtkTreeViewColumn.
owns_referenceSet false if the initial reference count is floating, set true if it's not.

The tree_column can be a newly created GtkTreeViewColumn or an existing GtkTreeViewColumn (see G::Object::Object).

Xfc::Gtk::TreeViewColumn::TreeViewColumn ( const String title)

Construct a new tree column and sets the title.

Parameters:
titleThe title to set the header to.
Xfc::Gtk::TreeViewColumn::TreeViewColumn ( const String title,
CellRenderer cell,
const String attribute,
int  column 
)

Construct a new tree column with a number of default values (see add_attribute()).

Parameters:
titleThe title to set the header to.
cellThe CellRenderer.
attributeAn attribute on the renderer.
columnThe column position on the model to get the attribute from.

This is equivalent constructing an empty column and calling set_title(), pack_start(), and add_attributes().

Here's a simple example:

< enum { TEXT_COLUMN, N_COLUMNS };
< ...
< Gtk::CellRendererText  *cell = new Gtk::CellRendererText();
< Gtk::TreeViewColumn *column = new Gtk::TreeViewColumn("Title", cell, "text", TEXT_COLUMN);
<
Xfc::Gtk::TreeViewColumn::TreeViewColumn ( const String title,
CellRenderer cell,
const CellColumnAttributes attributes 
)

Construct a new tree column with a number of default values.

Parameters:
titleThe title to set the header to.
cellThe CellRenderer.
attributesThe tree column attributes to set.

This is equivalent constructing an empty column and calling set_title(), pack_start(), and add_attributes().

Here's a simple example:

< enum { TEXT_COLUMN, COLOR_COLUMN, N_COLUMNS };
< ...
< Gtk::CellRendererText  *cell = new Gtk::CellRendererText();
<
< CellColumnAttributes attributes;
< attributes.add("text", TEXT_COLUMN);
< attributes.add("foreground", COLOR_COLUMN);
< Gtk::TreeViewColumn *column = new Gtk::TreeViewColumn("Title", cell, attributes);
<

Member Function Documentation

void Xfc::Gtk::TreeViewColumn::add_attribute ( CellRenderer cell,
const String attribute,
int  column 
)

Adds an attribute mapping to the list in the tree column.

Parameters:
cellThe CellRenderer to set attributes on.
attributeAn attribute on the renderer.
columnThe column position on the model to get the attribute from.

The column is the column of the model to get a value from, and the attribute is the parameter on cell 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 CellRendererText get its values from column 2.

Reimplemented from Xfc::Gtk::CellLayout.

void Xfc::Gtk::TreeViewColumn::cell_get_size ( const Gdk::Rectangle cell_area,
int *  x_offset,
int *  y_offset,
int *  width,
int *  height 
) const

Obtains the width and height needed to render the column.

Parameters:
cell_areaThe area a cell in the column will be allocated, or null.
x_offsetThe location to return X offset of a cell relative to cell_area, or null.
y_offsetThe location to return Y offset of a cell relative to cell_area, or null.
widthThe location to return width needed to render a cell, or null.
heightThe location to return height needed to render a cell, or null.

This is used primarily by the Gtk::TreeView.

Returns true if any of the cells packed into the tree column are visible.

Returns:
true if any of the cells packed into the tree_column are currently visible.

For this to be meaningful, you must first initialize the cells with cell_set_cell_data().

void Xfc::Gtk::TreeViewColumn::cell_set_cell_data ( const TreeModel model,
const TreeIter iter,
bool  is_expander,
bool  is_expanded 
)

Sets the cell renderer based on the tree model and iter.

Parameters:
modelThe TreeModel to to get the cell renderers attributes from.
iterThe TreeIter to to get the cell renderer's attributes from.
is_expanderSet true if the row has children.
is_expandedSet true if the row has visible children.

That is, for every attribute mapping in the 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.

Clears all existing attributes previously set with set_attributes().

Parameters:
cellA CellRenderer to clear the attribute mapping on.

Reimplemented from Xfc::Gtk::CellLayout.

Emits the "clicked" signal on the column.

This method will only work if the tree column is clickable.

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

Parameters:
cellA CellRenderer.
bool Xfc::Gtk::TreeViewColumn::get_cell_renderers ( std::vector< CellRenderer * > &  cell_list) const

Gets a list of all the cell renderers in the column, in no particular order.

Parameters:
cell_listA reference to a vector of CellRenderer* to hold the list of cell renderers.
Returns:
true if cell_list is not empty.

Determines whether the column expands to take any of the available space.

Returns:
true if the column expands.

Gets the fixed width of the column.

This value may not be the actual width of the column on the screen, just what is requested.

Gets the logical sort_column_id that the model sorts on when this column is selected for sorting (see set_sort_column_id()).

Returns:
The current sort_column_id for this column, or -1 if this column can't be used for sorting.

Gets the value set by set_sort_indicator().

Returns:
Whether the sort indicator arrow is displayed.

Gets the value set by set_sort_order().

Returns:
The sort order the sort indicator is indicating.

Returns true if the tree column is visible.

Returns:
Whether the column is visible or not.

If the tree column is visible, then the tree will show the column.

Returns the Widget in the button on the column header.

Returns:
The Widget in the column header, or null.

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

void Xfc::Gtk::TreeViewColumn::pack_end ( CellRenderer cell,
bool  expand = true 
)

Adds the cell to end of the column.

Parameters:
cellThe CellRenderer.
expandtrue if cell is to be given extra space allocated to box.

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.

Reimplemented from Xfc::Gtk::CellLayout.

void Xfc::Gtk::TreeViewColumn::pack_start ( CellRenderer cell,
bool  expand = true 
)

Packs the cell into the beginning of the column.

Parameters:
cellThe CellRenderer.
expandtrue if cell is to be given extra space allocated to box.

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.

Reimplemented from Xfc::Gtk::CellLayout.

Removes the current CellDataSlot used for the column.

Parameters:
cellA CellRenderer.

Reimplemented from Xfc::Gtk::CellLayout.

Sets the alignment of the title or custom widget inside the column header.

Parameters:
xalignThe alignment, which is between [0.0 and 1.0] inclusive.

The alignment determines its location inside the button - 0.0 for left, 0.5 for center, 1.0 for right.

Sets the attributes in the list as the attributes of the tree column.

Parameters:
cellThe CellRenderer.
attributesThe tree column attributes to set.

Reimplemented from Xfc::Gtk::CellLayout.

Sets the CellDataSlot to use for the column.

Parameters:
cellA CellRenderer.
slotThe CellDataSlot to use.

The CellDataSlot is used instead of the standard attributes mapping for setting the column value, and should set the value of the tree column's cell renderer as appropriate. slot may be null to remove an older one.

Reimplemented from Xfc::Gtk::CellLayout.

Sets the header to be active if active is true.

Parameters:
activetrue if the header is active.

When the header is active, then it can take keyboard focus, and can be clicked.

void Xfc::Gtk::TreeViewColumn::set_expand ( bool  expand)

Sets the column to take available extra space.

Parameters:
expandSet true if the column should expand.

This space is shared equally amongst all columns that have 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.

void Xfc::Gtk::TreeViewColumn::set_fixed_width ( int  fixed_width)

Sets the size of the column in pixels.

Parameters:
fixed_widthThe size to set tree_column to. Must be greater than 0.

This is only meaningful if the sizing type is TREE_VIEW_COLUMN_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.

void Xfc::Gtk::TreeViewColumn::set_max_width ( int  max_width)

Sets the maximum width of the tree column.

Parameters:
max_widthThe maximum width of the column in pixels, or -1.

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.

void Xfc::Gtk::TreeViewColumn::set_min_width ( int  min_width)

Sets the minimum width of the tree column.

Parameters:
min_widthThe minimum width of the column in pixels, or -1.

If min_width is -1, then the minimum width is unset.

void Xfc::Gtk::TreeViewColumn::set_reorderable ( bool  reorderable)

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

Parameters:
reorderabletrue if the column can be reordered.
void Xfc::Gtk::TreeViewColumn::set_resizable ( bool  resizable)

If resizable is true, then the user can explicitly resize the column by grabbing the outer edge of the column button.

Parameters:
resizabletrue if the column can be resized.

If resizable is true and sizing mode of the column is TREE_VIEW_COLUMN_AUTOSIZE, then the sizing mode is changed to TREE_VIEW_COLUMN_GROW_ONLY.

Sets the growth behavior of the tree column to type.

Parameters:
typeThe TreeViewColumnSizing.
void Xfc::Gtk::TreeViewColumn::set_sort_column_id ( int  sort_column_id)

Sets the logical sort_column_id that this column sorts on when this column is selected for sorting.

Parameters:
sort_column_idThe sort_column_id of the model to sort on.

Setting the logical sort_column_id makes the column header clickable. You probably only want to use set_sort_column_id(). The other sorting methods exist to allow for custom sorting.

Call this method with a setting of true to display an arrow in the header button indicating the column is sorted.

Parameters:
settingtrue to display an indicator that the column is sorted.

Call set_sort_order() to change the direction of the arrow.

Changes the appearance of the sort indicator.

Parameters:
orderThe sort order that the sort indicator should indicate.

This does not actually sort the model. Use set_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::set_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 method; see set_sort_indicator().

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

Parameters:
spacingThe distance between cell renderers in pixels.
void Xfc::Gtk::TreeViewColumn::set_title ( const String title)

Sets the title of the tree column.

Parameters:
titleThe title of the tree column.

If a custom widget has been set, then this value is ignored.

void Xfc::Gtk::TreeViewColumn::set_visible ( bool  visible)

Sets the visibility of the tree column.

Parameters:
visibletrue if the tree column is visible.

Sets the widget in the header to be widget.

Parameters:
widgetA child Widget, or null.

If widget is null, then the header button is set with a Label set to the title of tree_column.


Member Data Documentation

Clicked signal (see signal_clicked()).

Calls a slot with the signature:

< void function();
<

The documentation for this class was generated from the following file:
Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC