moved coloring callback to widgets module

This commit is contained in:
fgerlits 2005-04-08 12:18:03 +00:00
parent a574e393c7
commit 581cfa4651
4 changed files with 41 additions and 42 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h,v $
------------------------------------------------------------------------------*/
@ -72,7 +72,7 @@ using namespace LiveSupport::Core;
* A list of items, in rows colored alternately grey and light blue.
*
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
*/
class ZebraTreeView : public Gtk::TreeView
{
@ -84,6 +84,14 @@ class ZebraTreeView : public Gtk::TreeView
{
}
/**
* The callback function to set the colors of the rows.
*/
void
cellDataFunction(Gtk::CellRenderer* cell,
const Gtk::TreeModel::iterator& iter)
throw ();
protected:
public:
@ -105,7 +113,7 @@ class ZebraTreeView : public Gtk::TreeView
* Set the callback function for every column.
*/
void
setCellDataFunction(const Column::SlotCellData& callback)
setCellDataFunction(void)
throw ();
};

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $
------------------------------------------------------------------------------*/
@ -35,7 +35,8 @@
#include <iostream>
#include "LiveSupport/Widgets/WidgetFactory.h" Gdk::Color blueColor = Colors::getColor(Colors::LightBlue);
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "LiveSupport/Widgets/ZebraTreeView.h"
@ -76,15 +77,32 @@ ZebraTreeView :: ~ZebraTreeView(void) throw ()
* Set the callback function for every column.
*----------------------------------------------------------------------------*/
void
ZebraTreeView :: setCellDataFunction(const Column::SlotCellData& callback) throw ()
ZebraTreeView :: setCellDataFunction(void) throw ()
{
std::list<Column*> columnList = get_columns();
std::list<Column*>::iterator it;
for (it = columnList.begin(); it != columnList.end(); ++it) {
(*it)->set_cell_data_func(*(*it)->get_first_cell_renderer(), callback);
(*it)->set_cell_data_func(
*(*it)->get_first_cell_renderer(),
sigc::mem_fun(*this, &ZebraTreeView::cellDataFunction) );
}
// set_rules_hint(); // suggest coloring with alternate colors
}
/*------------------------------------------------------------------------------
* The callback function.
*----------------------------------------------------------------------------*/
void
ZebraTreeView :: cellDataFunction(Gtk::CellRenderer* cell,
const Gtk::TreeModel::iterator& iter)
throw ()
{
ZebraTreeModelColumnRecord model;
Gdk::Color color = Colors::getColor((*iter)[model.colorColumn] );
cell->property_cell_background_gdk() = color;
}