Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Gtk::TreeViewColumn Class Reference

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

`#include <inti/gtk/treeviewcolumn.h>`

Inheritance diagram for Inti::Gtk::TreeViewColumn:

List of all members.

## Public Types

- typedef Slot3< void, CellRenderer &,
  TreeModel *, const TreeIter & > CellDataSlot
    Signature of the callback slot to be called to set the properties of a cell instead of just using the straight mapping between the cell and the model.

## Public Member Functions

Constructors

- TreeViewColumn ()
    Construct a new tree view column.
- TreeViewColumn (const String &title, CellRenderer *cell,...)
    Construct a new tree column with a number of default values.
- TreeViewColumn (const String &title, CellRenderer &cell, const std::map< int, String > &attributes)
    Construct a new tree column with a number of default values.
- virtual ~TreeViewColumn ()
    Destructor.

Accessors

- GtkTreeViewColumn * gtk_tree_view_column () const
    Get a pointer to the GtkTreeViewColumn structure.
- GtkTreeViewColumnClass * gtk_tree_view_column_class () const
    Get a pointer to the GtkTreeViewColumnClass structure.
- operator GtkTreeViewColumn * () const
    Conversion operator; safely converts a TreeViewColumn to a GtkTreeViewColumn pointer.
- int get_spacing () const
    Returns the spacing of the tree column, in pixels.
- bool get_visible () const
    Returns true if the tree column is visible.
- bool get_resizable () const
    Returns true if the tree column can be resized by the end user.
- TreeViewColumnSizing get_sizing () const
    Returns the current sizing method of the tree_column.
- int get_width () const
    Returns the current size of the tree column in pixels.
- int get_fixed_width () const
    Gets the fixed width of the column.
- int get_min_width () const
    Returns the minimum width in pixels of the tree column, or -1 if no minimum width is set.
- int get_max_width () const
    Returns the maximum width in pixels of the tree column, or -1 if no maximum width is set.
- String get_title () const
    Returns the title of the tree column.
- bool get_clickable () const
    Returns true if the user can click on the header for the column.
- Widget * get_widget () const
    Returns the Widget in the button on the column header.
- float get_alignment () const
    Returns the current x alignment of the tree column. This value can range between 0.0 and 1.0.
- bool get_reorderable () const
    Returns true if the tree column can be reordered by the user.
- int get_sort_column_id () const
    Gets the logical sort_column_id that the model sorts on when this column is selected for sorting (see set_sort_column_id()).
- bool get_sort_indicator () const
    Gets the value set by set_sort_indicator().
- SortType get_sort_order () const
    Gets the value set by set_sort_order().
- bool get_cell_renderers (std::vector< CellRenderer * > &cell_list) const
    Gets a list of all the cell renderers in the column, in no particular order.
- void 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.
- bool cell_is_visible () const
    Returns true if any of the cells packed into the tree column are visible.

Methods

- void pack_start (CellRenderer &cell, bool expand=true)
    Packs the cell into the beginning of the column.
- void pack_end (CellRenderer &cell, bool expand=true)
    Adds the cell to end of the column.
- void clear ()
    Unsets all the mappings on all renderers on the tree column.
- void add_attribute (CellRenderer &cell, const String &attribute, int column)
    Adds an attribute mapping to the list in the tree column.
- void set_attributes (CellRenderer *cell,...)
    Sets the attributes in the list as the attributes of the tree column.
- void set_attributes (CellRenderer &cell, const std::map< int, String > &attributes)
    Sets the attributes in the list as the attributes of the tree column.
- void set_cell_data_slot (CellRenderer &cell, const CellDataSlot *slot)
    Sets the CellDataSlot to use for the column.
- void clear_attributes (CellRenderer &cell)
    Clears all existing attributes previously set with set_attributes().
- void set_spacing (int spacing)
    Sets the spacing field of the tree column, which is the number of pixels to place between cell renderers packed into it.
- void set_visible (bool visible)
    Sets the visibility of the tree column.
- void 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.
- void set_sizing (TreeViewColumnSizing type)
    Sets the growth behavior of the tree column to type.
- void set_fixed_width (int fixed_width)
    Sets the size of the column in pixels.
- void set_min_width (int min_width)
    Sets the minimum width of the tree column.
- void set_max_width (int max_width)
    Sets the maximum width of the tree column.
- void set_title (const String &title)
    Sets the title of the tree column.
- void clicked ()
    Emits the "clicked" signal on the column.
- void set_clickable (bool active)
    Sets the header to be active if active is true.
- void set_widget (Widget *widget)
    Sets the widget in the header to be widget.
- void set_alignment (float xalign)
    Sets the alignment of the title or custom widget inside the column header.
- void set_reorderable (bool reorderable)
    If reorderable is true, then the column can be reordered by the end user dragging the header.
- void 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.
- void set_sort_indicator (bool setting)
    Call this method with a setting of true to display an arrow in the header button indicating the column is sorted.
- void set_sort_order (SortType order)
    Changes the appearance of the sort indicator.
- void 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.
- void focus_cell (CellRenderer &cell)
    Sets the current keyboard focus to be at cell, if the column contains 2 or more editable and activatable cells.

Property Proxies

- const VisiblePropertyProxy prop_visible ()
    Whether to display the column (bool : Read / Write).
- const ResizablePropertyProxy prop_resizable ()
    Column is user-resizable (bool : Read / Write).
- const WidthPropertyProxy prop_width ()
    Current width of the column (int : Read).
- const SizingPropertyProxy prop_sizing ()
    Resize mode of the column (TreeViewColumnSizing : Read / Write).
- const FixedWidthPropertyProxy prop_fixed_width ()
    Current fixed width of the column (int : Read / Write).
- const MinWidthPropertyProxy prop_min_width ()
    Minimum allowed width of the column (int : Read / Write).
- const MaxWidthPropertyProxy prop_max_width ()
    Maximum allowed width of the column (int : Read / Write).
- const TitlePropertyProxy prop_title ()
    Title to appear in column header (String : Read / Write).
- const ClickablePropertyProxy prop_clickable ()
    Whether the header can be clicked (bool : Read / Write).
- const WidgetPropertyProxy prop_widget ()
    Widget to put in column header button instead of column title (Widget* : Read / Write).
- const AlignmentPropertyProxy prop_alignment ()
    X Alignment of the column header text or widget (float : Read / Write).
- const ReorderablePropertyProxy prop_reorderable ()
    Whether the column can be reordered around the headers (bool : Read / Write).
- const SortIndicatorPropertyProxy prop_sort_indicator ()
    Whether to show a sort indicator (bool : Read / Write).
- const SortOrderPropertyProxy prop_sort_order ()
    Sort direction the sort indicator should indicate (SortType : Read / Write).

Signal Proxies

- const ClickedSignalProxy sig_clicked ()
    Connect to the clicked_signal; emitted when the user clicks on the header for the column.

## Protected Member Functions

Constructors

- TreeViewColumn (GtkTreeViewColumn *tree_column, bool reference=false)
    Construct a new TreeViewColumn from an existing GtkTreeViewColumn.

Signal Handlers

- virtual void on_clicked ()
    Called when the user clicks on the header for the column.

## 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.

## Member Typedef Documentation

typedef Slot3<void, CellRenderer&, TreeModel*, const TreeIter&> Inti::Gtk::TreeViewColumn::CellDataSlot

| Signature of the callback slot to be called to set the properties of a cell instead of just using the straight mapping between the cell and the model. Example: Method signature for CellDataSlot.
                 void method(CellRenderer& cell, TreeModel* tree_model, const TreeIter& iter);

                 // cell: The CellRenderer that is being rendered by tree_column.
                 // tree_model: The TreeModel being rendered.
                 // iter: A TreeIter of the current row rendered.
This is useful for customizing the cell renderer. For example, a function might get an integer from the tree_model, and render it to the "text" attribute of "cell" by converting it to its written equivilent. This is set by calling set_cell_data_func().

## Constructor & Destructor Documentation

Inti::Gtk::TreeViewColumn::TreeViewColumn | ( | GtkTreeViewColumn * | tree_column,
|  | bool | reference = false
| ) | `[explicit, protected]`

  | Construct a new TreeViewColumn from an existing GtkTreeViewColumn. Parameters:
  tree_column | A pointer to a GtkTreeViewColumn.
  reference | Set 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).

Inti::Gtk::TreeViewColumn::TreeViewColumn | ( | const String & | title,
|  | CellRenderer * | cell,
|  | ... |
| ) |

  | Construct a new tree column with a number of default values. Parameters:
  title | The title to set the header to.
  cell | The CellRenderer.
  ... | A null-terminated list of attribute/column pairs.
This is equivalent to calling set_title(), pack_start(), and set_attributes() on the newly created column. Here's a simple example:
                 enum { TEXT_COLUMN, COLOR_COLUMN, N_COLUMNS };
                 ...
                 Gtk::CellRendererText  *cell = new Gtk::CellRendererText();
                 Gtk::TreeViewColumn *column = new Gtk::TreeViewColumn("Title", cell,
                                                                       "text", TEXT_COLUMN,
                                                                       "foreground", COLOR_COLUMN, 0);

Inti::Gtk::TreeViewColumn::TreeViewColumn | ( | const String & | title,
|  | CellRenderer & | cell,
|  | const std::map< int, String > & | attributes
| ) |

  | Construct a new tree column with a number of default values. Parameters:
  title | The title to set the header to.
  cell | The CellRenderer.
  attributes | A reference to a map of column/attribute pairs.
This is equivalent to calling set_title(), pack_start(), and set_attributes() on the newly created column. Here's a simple example:
                 enum { TEXT_COLUMN, COLOR_COLUMN, N_COLUMNS };
                 ...
                 Gtk::CellRendererText  *cell = new Gtk::CellRendererText();

                 typedef std::map<int, String> attributes;
                 Attributes attributes;
                 attributes.insert(Attributes::value_type(TEXT_COLUMN, "text"));
                 attributes.insert(Attributes::value_type(COLOR_COLUMN, "foreground"));

                 Gtk::TreeViewColumn *column = new Gtk::TreeViewColumn("Title", cell, attributes);

## Member Function Documentation

void Inti::Gtk::TreeViewColumn::add_attribute | ( | CellRenderer & | cell,
|  | const String & | attribute,
|  | int | column
| ) |

  | Adds an attribute mapping to the list in the tree column. Parameters:
  cell | The CellRenderer to set attributes on.
  attribute | An attribute on the renderer.
  column | The 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.

void Inti::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_area | The area a cell in the column will be allocated, or null.
  x_offset | The location to return X offset of a cell relative to cell_area, or null.
  y_offset | The location to return Y offset of a cell relative to cell_area, or null.
  width | The location to return width needed to render a cell, or null.
  height | The location to return height needed to render a cell, or null.
This is used primarily by the Gtk::TreeView.

bool Inti::Gtk::TreeViewColumn::cell_is_visible | ( |  | ) | const

| 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 Inti::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:
  model | The TreeModel to to get the cell renderers attributes from.
  iter | The TreeIter to to get the cell renderer's attributes from.
  is_expander | Set true if the row has children.
  is_expanded | Set 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.

void Inti::Gtk::TreeViewColumn::clear_attributes | ( | CellRenderer & | cell | ) |

  | Clears all existing attributes previously set with set_attributes(). Parameters:
  cell | A CellRenderer to clear the attribute mapping on.

void Inti::Gtk::TreeViewColumn::clicked | ( |  | ) |

| Emits the "clicked" signal on the column. This method will only work if the tree column is clickable.

void Inti::Gtk::TreeViewColumn::focus_cell | ( | CellRenderer & | cell | ) |

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

bool Inti::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_list | A reference to a vector of CellRenderer* to hold the list of cell renderers.
Returns: true if cell_list is not empty.

int Inti::Gtk::TreeViewColumn::get_fixed_width | ( |  | ) | const

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

int Inti::Gtk::TreeViewColumn::get_sort_column_id | ( |  | ) | const

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

bool Inti::Gtk::TreeViewColumn::get_sort_indicator | ( |  | ) | const

| Gets the value set by set_sort_indicator(). Returns: Whether the sort indicator arrow is displayed.

SortType Inti::Gtk::TreeViewColumn::get_sort_order | ( |  | ) | const

| Gets the value set by set_sort_order(). Returns: The sort order the sort indicator is indicating.

bool Inti::Gtk::TreeViewColumn::get_visible | ( |  | ) | const

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

Widget* Inti::Gtk::TreeViewColumn::get_widget | ( |  | ) | const

| 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 Inti::Gtk::TreeViewColumn::pack_end | ( | CellRenderer & | cell,
|  | bool | expand = true
| ) |

  | Adds the cell to end of the column. Parameters:
  cell | The CellRenderer.
  expand | true 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.

void Inti::Gtk::TreeViewColumn::pack_start | ( | CellRenderer & | cell,
|  | bool | expand = true
| ) |

  | Packs the cell into the beginning of the column. Parameters:
  cell | The CellRenderer.
  expand | true 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.

void Inti::Gtk::TreeViewColumn::set_alignment | ( | float | xalign | ) |

  | Sets the alignment of the title or custom widget inside the column header. Parameters:
  xalign | The 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.

void Inti::Gtk::TreeViewColumn::set_attributes | ( | CellRenderer & | cell,
|  | const std::map< int, String > & | attributes
| ) |

  | Sets the attributes in the list as the attributes of the tree column. Parameters:
  cell | The CellRenderer.
  attributes | A reference to a map of column/attribute pairs.
The declaration order is reversed in the map, i.e. column/attribute, because maps require the unique key value (column) to come first.

void Inti::Gtk::TreeViewColumn::set_attributes | ( | CellRenderer * | cell,
|  | ... |
| ) |

  | Sets the attributes in the list as the attributes of the tree column. Parameters:
  cell | The CellRenderer.
  ... | A null-terminated list of attribute/column pairs.
The attributes should be in attribute/column order, as in add_attribute(). All existing attributes are removed, and replaced with the new attributes.

void Inti::Gtk::TreeViewColumn::set_cell_data_slot | ( | CellRenderer & | cell,
|  | const CellDataSlot * | slot
| ) |

  | Sets the CellDataSlot to use for the column. Parameters:
  cell | A CellRenderer.
  slot | The CellDataSlot to use.
This method 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.

void Inti::Gtk::TreeViewColumn::set_clickable | ( | bool | active | ) |

  | Sets the header to be active if active is true. Parameters:
  active | true if the header is active.
When the header is active, then it can take keyboard focus, and can be clicked.

void Inti::Gtk::TreeViewColumn::set_fixed_width | ( | int | fixed_width | ) |

  | Sets the size of the column in pixels. Parameters:
  fixed_width | The 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 Inti::Gtk::TreeViewColumn::set_max_width | ( | int | max_width | ) |

  | Sets the maximum width of the tree column. Parameters:
  max_width | The 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 Inti::Gtk::TreeViewColumn::set_min_width | ( | int | min_width | ) |

  | Sets the minimum width of the tree column. Parameters:
  min_width | The minimum width of the column in pixels, or -1.
If min_width is -1, then the minimum width is unset.

void Inti::Gtk::TreeViewColumn::set_reorderable | ( | bool | reorderable | ) |

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

void Inti::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:
  resizable | true 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.

void Inti::Gtk::TreeViewColumn::set_sizing | ( | TreeViewColumnSizing | type | ) |

  | Sets the growth behavior of the tree column to type. Parameters:
  type | The TreeViewColumnSizing.

void Inti::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_id | The 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.

void Inti::Gtk::TreeViewColumn::set_sort_indicator | ( | bool | setting | ) |

  | Call this method with a setting of true to display an arrow in the header button indicating the column is sorted. Parameters:
  setting | true to display an indicator that the column is sorted.
Call set_sort_order() to change the direction of the arrow.

void Inti::Gtk::TreeViewColumn::set_sort_order | ( | SortType | order | ) |

  | Changes the appearance of the sort indicator. Parameters:
  order | The 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().

void Inti::Gtk::TreeViewColumn::set_spacing | ( | int | spacing | ) |

  | Sets the spacing field of the tree column, which is the number of pixels to place between cell renderers packed into it. Parameters:
  spacing | The distance between cell renderers in pixels.

void Inti::Gtk::TreeViewColumn::set_title | ( | const String & | title | ) |

  | Sets the title of the tree column. Parameters:
  title | The title of the tree column.
If a custom widget has been set, then this value is ignored.

void Inti::Gtk::TreeViewColumn::set_visible | ( | bool | visible | ) |

  | Sets the visibility of the tree column. Parameters:
  visible | true if the tree column is visible.

void Inti::Gtk::TreeViewColumn::set_widget | ( | Widget * | widget | ) |

  | Sets the widget in the header to be widget. Parameters:
  widget | A child Widget, or null.
If widget is null, then the header button is set with a Label set to the title of tree_column.

The documentation for this class was generated from the following file:

- treeviewcolumn.h

Main Page - Footer