Main Page Widgets Namespaces Book

# Gtk::CellRenderer Class Reference
[TreeView Classes]

Inheritance diagram for Gtk::CellRenderer:

[legend]
List of all members.

## Detailed Description

CellRenderers are used by Gtk::TreeView columns to render the Gtk::TreeModel column data appropriately.

They display, and allow editing of, the values of their properties. In most cases, Gtk::TreeView::append_column() will automatically choose the appropriate renderer for the mode column's data type, so you will rarely need to worry about these classes.

## Public Member Functions

virtual Glib::ustring | _property_renderable ()
| Returns the property that this CellRenderer renders.
bool | activate (GdkEvent* event, Widget& widget, const Glib::ustring& path, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, CellRendererState flags)
| Passes an activate event to the cell renderer for possible processing.
void | editing_canceled ()
| Causes the cell renderer to emit the "editing-canceled" signal.
void | get_fixed_size (int& width, int& height) const
| Fills in width and height with the appropriate size of cell .
void | get_size (Widget& widget, int& x_offset, int& y_offset, int& width, int& height) const
| Obtains the width and height needed to render the cell.
void | get_size (Widget& widget, 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 cell.
const GtkCellRenderer* | gobj () const
| Provides access to the underlying C GtkObject.
GtkCellRenderer* | gobj ()
| Provides access to the underlying C GtkObject.
void | render (const Glib::RefPtr<Gdk::Window>& window, Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, const Gdk::Rectangle& expose_area, CellRendererState flags)
| Invokes the virtual render function of the Gtk::CellRenderer.
void | set_fixed_size (int width, int height)
| Sets the renderer size to be explicit, independent of the properties set.
Glib::SignalProxy0<void> | signal_editing_canceled ()
| This signal is emitted when the user cancels the process of editing a cell.
Glib::SignalProxy2< void, CellEditable*, const Glib::ustring& > | signal_editing_started ()
| This signal gets emitted when a cell starts to be edited.
CellEditable* | start_editing (GdkEvent* event, Widget& widget, const Glib::ustring& path, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, CellRendererState flags=CellRendererState(0))
| Passes an activate event to the cell renderer for possible processing.
void | stop_editing (bool canceled=false)
| Informs the cell renderer that the editing is stopped.
virtual | ~CellRenderer ()

## Protected Member Functions

| CellRenderer ()
virtual void | on_editing_canceled ()

## Related Functions

(Note that these are not member functions.)
Gtk::CellRenderer* | wrap (GtkCellRenderer* object, bool take_copy=false)

## Constructor & Destructor Documentation

virtual Gtk::CellRenderer::~CellRenderer | ( |  | ) | `[virtual]`

Gtk::CellRenderer::CellRenderer | ( |  | ) | `[protected]`

## Member Function Documentation

virtual Glib::ustring Gtk::CellRenderer::_property_renderable | ( |  | ) | `[virtual]`

| Returns the property that this CellRenderer renders. For instance, property_text for CellRendererText, and property_active for CellRendererToggle Needs to be overridden in derived classes. Reimplemented in Gtk::CellRendererCombo, Gtk::CellRendererPixbuf, Gtk::CellRendererProgress, Gtk::CellRendererText, and Gtk::CellRendererToggle.

bool Gtk::CellRenderer::activate | ( | GdkEvent* | event,
|  | Widget& | widget,
|  | const Glib::ustring& | path,
|  | const Gdk::Rectangle& | background_area,
|  | const Gdk::Rectangle& | cell_area,
|  | CellRendererState | flags
| ) |

Passes an activate event to the cell renderer for possible processing.

Some cell renderers may use events; for example, Gtk::CellRendererToggle toggles when it gets a mouse click.

Parameters:

  | event | A Gdk::Event.
  | widget | Widget that received the event.
  | path | Widget-dependent string representation of the event location; e.g. for Gtk::TreeView, a string representation of Gtk::TreePath.
  | background_area | Background area as passed to gtk_cell_renderer_render .
  | cell_area | Cell area as passed to gtk_cell_renderer_render .
  | flags | Render flags.

Returns:
  `true` if the event was consumed/handled.

void Gtk::CellRenderer::editing_canceled | ( |  | ) |

Causes the cell renderer to emit the "editing-canceled" signal.

This function is for use only by implementations of cell renderers that need to notify the client program that an editing process was canceled and the changes were not committed.

Since gtkmm 2.4:

Deprecated: Use stop_editing() instead

Deprecated:
  Use stop_editing().

void Gtk::CellRenderer::get_fixed_size | ( | int& | width,
|  | int& | height
| ) | const

Fills in width and height with the appropriate size of cell .

Parameters:

  | width | Location to fill in with the fixed width of the widget.
  | height | Location to fill in with the fixed height of the widget.

void Gtk::CellRenderer::get_size | ( | Widget& | widget,
|  | int& | x_offset,
|  | int& | y_offset,
|  | int& | width,
|  | int& | height
| ) | const

Obtains the width and height needed to render the cell.

Used by view widgets to determine the appropriate size for the cell_area passed to render(). Fills in the x and y offsets of the cell relative to this location. Please note that the values set in width and height , as well as those in x_offset and y_offset are inclusive of the xpad and ypad properties.

Parameters:

  | widget | The widget the renderer is rendering to.
  | x_offset | Location to return x offset of cell relative to cell_area.
  | y_offset | Location to return y offset of cell relative to cell_area.
  | width | Location to return width needed to render a cell.
  | height | Location to return height needed to render a cell.

void Gtk::CellRenderer::get_size | ( | Widget& | widget,
|  | 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 cell.

Used by view widgets to determine the appropriate size for the cell_area passed to render(). Fills in the x and y offsets of the cell relative to this location. Please note that the values set in width and height , as well as those in x_offset and y_offset are inclusive of the xpad and ypad properties.

Parameters:

  | widget | The widget the renderer is rendering to.
  | cell_area | The area a cell will be allocated.
  | x_offset | Location to return x offset of cell relative to cell_area .
  | y_offset | Location to return y offset of cell relative to cell_area .
  | width | Location to return width needed to render a cell.
  | height | Location to return height needed to render a cell.

const GtkCellRenderer* Gtk::CellRenderer::gobj | ( |  | ) | const`[inline]`

| Provides access to the underlying C GtkObject. Reimplemented from Gtk::Object. Reimplemented in Gtk::CellRendererAccel, Gtk::CellRendererCombo, Gtk::CellRendererPixbuf, Gtk::CellRendererProgress, Gtk::CellRendererSpin, Gtk::CellRendererText, and Gtk::CellRendererToggle.

GtkCellRenderer* Gtk::CellRenderer::gobj | ( |  | ) | `[inline]`

| Provides access to the underlying C GtkObject. Reimplemented from Gtk::Object. Reimplemented in Gtk::CellRendererAccel, Gtk::CellRendererCombo, Gtk::CellRendererPixbuf, Gtk::CellRendererProgress, Gtk::CellRendererSpin, Gtk::CellRendererText, and Gtk::CellRendererToggle.

virtual void Gtk::CellRenderer::on_editing_canceled | ( |  | ) | `[protected, virtual]`

void Gtk::CellRenderer::render | ( | const Glib::RefPtr<Gdk::Window>& | window,
|  | Widget& | widget,
|  | const Gdk::Rectangle& | background_area,
|  | const Gdk::Rectangle& | cell_area,
|  | const Gdk::Rectangle& | expose_area,
|  | CellRendererState | flags
| ) |

Invokes the virtual render function of the Gtk::CellRenderer.

The three passed-in rectangles are areas of window . Most renderers will draw within cell_area ; the xalign, yalign, xpad, and ypad fields of the Gtk::CellRenderer should be honored with respect to cell_area . background_area includes the blank space around the cell, and also the area containing the tree expander; so the background_area rectangles for all cells tile to cover the entire window . expose_area is a clip rectangle.

Parameters:

  | window | A Gdk::Drawable to draw to.
  | widget | The widget owning window .
  | background_area | Entire cell area (including tree expanders and maybe padding on the sides).
  | cell_area | Area normally rendered by a cell renderer.
  | expose_area | Area that actually needs updating.
  | flags | Flags that affect rendering.

void Gtk::CellRenderer::set_fixed_size | ( | int | width,
|  | int | height
| ) |

Sets the renderer size to be explicit, independent of the properties set.

Parameters:

  | width | The width of the cell renderer, or -1.
  | height | The height of the cell renderer, or -1.

Glib::SignalProxy0<void> Gtk::CellRenderer::signal_editing_canceled | ( |  | ) |

This signal is emitted when the user cancels the process of editing a cell.

For example, an editable cell renderer could be written to cancel editing when the user presses Escape.

See also:
  editing_canceled()

Glib::SignalProxy2<void,CellEditable*,const Glib::ustring&> Gtk::CellRenderer::signal_editing_started | ( |  | ) |

This signal gets emitted when a cell starts to be edited.

The indended use of this signal is to do special setup on editable, e.g. adding an EntryCompletion or setting up additional columns in a ComboBox.

Note that GTK+ doesn't guarantee that cell renderers will continue to use the same kind of widget for editing in future releases, therefore you should check the type of editable before doing any specific setup.

Note that this signal does not work yet in gtkmm. See http://bugzilla.gnome.org/show_bug.cgi?id=301597

Since gtkmm 2.6:

Parameters:

  | editable | the CellEditable.
  | path | the path identifying the edited cell.

CellEditable* Gtk::CellRenderer::start_editing | ( | GdkEvent* | event,
|  | Widget& | widget,
|  | const Glib::ustring& | path,
|  | const Gdk::Rectangle& | background_area,
|  | const Gdk::Rectangle& | cell_area,
|  | CellRendererState | flags = `CellRendererState(0)`
| ) |

Passes an activate event to the cell renderer for possible processing.

Parameters:

  | event | A Gdk::Event.
  | widget | Widget that received the event.
  | path | Widget-dependent string representation of the event location; e.g. for Gtk::TreeView, a string representation of Gtk::TreePath.
  | background_area | Background area as passed to gtk_cell_renderer_render .
  | cell_area | Cell area as passed to gtk_cell_renderer_render .
  | flags | Render flags.

Returns:
  A new Gtk::CellEditable, or `0`.

void Gtk::CellRenderer::stop_editing | ( | bool | canceled = `false` | ) |

Informs the cell renderer that the editing is stopped.

If canceled is `true`, the cell renderer will emit the "editing-canceled" signal. This function should be called by cell renderer implementations in response to the "editing-done" signal of Gtk::CellEditable.

Since gtkmm 2.6:

Parameters:

  | canceled | `true` if the editing has been canceled.

## Friends And Related Function Documentation

Gtk::CellRenderer* wrap | ( | GtkCellRenderer* | object,
|  | bool | take_copy = `false`
| ) | `[related]`

Parameters:

  | object | The C instance
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

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

- cellrenderer.h