Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gtk::CellLayout Class Reference

A GtkCellLayout C++ wrapper class. More...

`#include <xfc/gtk/celllayout.hh>`

Inheritance diagram for Xfc::Gtk::CellLayout:

List of all members.

## Public Types

- typedef sigc::slot< void,
  CellRenderer &, const TreeModel &,
  const TreeIter & > CellDataSlot
    Signature of the callback slot to be called to set the attributes of a cell's cell renderers, instead of just using the straight mapping between the cell and the model.

## Public Member Functions

Accessors

- GtkCellLayout * gtk_cell_layout () const
    Get a pointer to the GtkCellLayout structure.
- operator GtkCellLayout * () const
    Conversion operator; safely converts a CellLayout to a GtkCellLayout pointer.

Methods

- void pack_start (CellRenderer &cell, bool expand=true)
    Packs the cell into the beginning of the cell layout.
- void pack_end (CellRenderer &cell, bool expand=true)
    Adds the cell to the end of the cell layout.
- void add_attribute (CellRenderer &cell, const String &attribute, int column)
    Adds an attribute mapping to the list in the cell layout.
- void set_attributes (CellRenderer &cell, const CellColumnAttributes &attributes)
    Sets the attributes in the CellColumnAttributes object as the attributes of the cell layout.
- void set_cell_data_func (CellRenderer &cell, const CellDataSlot &slot)
    Sets the CellDataSlot to use for the cell layout.
- void remove_cell_data_func (CellRenderer &cell)
    Removes the current CellDataSlot used for the cell layout.
- void reorder (CellRenderer &cell, int position)
    Re-inserts cell at position.
- void clear_attributes (CellRenderer &cell)
    Clears all existing attributes previously set with set_attributes().
- void clear ()
    Unsets all the mappings on all renderers on the cell layout.

## Protected Member Functions

Constructors

- CellLayout ()
    Constructs a new CellLayout object.
- virtual ~CellLayout ()=0
    Destructor.

## Detailed Description

A GtkCellLayout C++ wrapper class.

CellLayout is an interface that can be implemented by an object that wants to provide a Gtk::TreeViewColumn-like API for packing cells, setting attributes and data funcs.

CellLayout is implemented by Gtk::EntryCompletion, Gtk::TreeViewColumn, Gtk::ComboBox and Gtk::ComboBoxEntry.

## Member Typedef Documentation

typedef sigc::slot<void, CellRenderer&, const TreeModel&, const TreeIter&> Xfc::Gtk::CellLayout::CellDataSlot

Signature of the callback slot to be called to set the attributes of a cell's cell renderers, instead of just using the straight mapping between the cell and the model.

Example: Method signature for CellDataSlot.

                 void method(CellRenderer& cell, const TreeModel& tree_model, const TreeIter& iter);
                 // cell: The cell renderer whose value is to be set.
                 // tree_model: The TreeModel being rendered.
                 // iter: A TreeIter indicating the row to set the value for.

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

## Member Function Documentation

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

Adds an attribute mapping to the list in the cell layout.

Parameters:

  | cell | A Gtk::CellRenderer.
  | attribute | An attribute on the renderer.
  | column | The column position in 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 Gtk::CellRendererText get its values from column 2.

Reimplemented in Xfc::Gtk::TreeViewColumn.

void Xfc::Gtk::CellLayout::clear_attributes | ( | CellRenderer & | cell | ) |

Clears all existing attributes previously set with set_attributes().

Parameters:

  | cell | A Gtk::CellRenderer to clear the attribute mapping on.

Reimplemented in Xfc::Gtk::TreeViewColumn.

void Xfc::Gtk::CellLayout::pack_end | ( | CellRenderer & | cell,
|  | bool | expand = `true`
| ) |

Adds the cell to the end of the cell layout.

Parameters:

  | cell | A Gtk::CellRenderer.
  | expand | Set true if cell is to be given extra space allocated to cell_layout.

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 in Xfc::Gtk::TreeViewColumn.

void Xfc::Gtk::CellLayout::pack_start | ( | CellRenderer & | cell,
|  | bool | expand = `true`
| ) |

Packs the cell into the beginning of the cell layout.

Parameters:

  | cell | A Gtk::CellRenderer.
  | expand | Set true if cell is to be given extra space allocated to cell_layout.

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 in Xfc::Gtk::TreeViewColumn.

void Xfc::Gtk::CellLayout::remove_cell_data_func | ( | CellRenderer & | cell | ) |

Removes the current CellDataSlot used for the cell layout.

Parameters:

  | cell | A Gtk::CellRenderer.

Reimplemented in Xfc::Gtk::TreeViewColumn.

void Xfc::Gtk::CellLayout::reorder | ( | CellRenderer & | cell,
|  | int | position
| ) |

Re-inserts cell at position.

Parameters:

  | cell | A GtkCellRenderer to reorder.
  | position | The new position to insert cell at.

Note that cell must already be packed into the cell layout for this method to function properly.

void Xfc::Gtk::CellLayout::set_attributes | ( | CellRenderer & | cell,
|  | const CellColumnAttributes & | attributes
| ) |

Sets the attributes in the CellColumnAttributes object as the attributes of the cell layout.

Parameters:

  | cell | The CellRenderer.
  | attributes | The attributes to set on the column of cells.

All existing attributes are removed, and replaced with the new attributes.

Here's a simple TreeViewColumn 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);

Reimplemented in Xfc::Gtk::TreeViewColumn.

void Xfc::Gtk::CellLayout::set_cell_data_func | ( | CellRenderer & | cell,
|  | const CellDataSlot & | slot
| ) |

Sets the CellDataSlot to use for the cell layout.

Parameters:

  | cell | A Gtk::CellRenderer.
  | slot | The CellDataSlot to use.

The CellDataSlot is used instead of the standard attributes mapping for setting the column value, and should set the value of cell_layout's cell renderer(s) as appropriate.

Reimplemented in Xfc::Gtk::TreeViewColumn.

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

- celllayout.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3