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;
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.13 $
Version : $Revision: 1.14 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -126,8 +126,7 @@ DjBagWindow :: DjBagWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
}
// color the columns blue
treeView->setCellDataFunction(
sigc::mem_fun(*this, &DjBagWindow::cellDataFunction));
treeView->setCellDataFunction();
// register the signal handler for treeview entries being clicked
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
@ -645,17 +644,3 @@ DjBagWindow :: onStopButtonClicked(void) throw ()
}
}
/*------------------------------------------------------------------------------
* The callback function.
*----------------------------------------------------------------------------*/
void
DjBagWindow :: cellDataFunction(Gtk::CellRenderer* cell,
const Gtk::TreeModel::iterator& iter)
throw ()
{
Gdk::Color color = Colors::getColor((*iter)[modelColumns.colorColumn]);
cell->property_cell_background_gdk() = color;
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.11 $
Version : $Revision: 1.12 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.h,v $
------------------------------------------------------------------------------*/
@ -50,6 +50,7 @@
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/WhiteWindow.h"
#include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "GLiveSupport.h"
namespace LiveSupport {
@ -71,18 +72,11 @@ using namespace LiveSupport::Widgets;
* playlists.
*
* @author $Author: fgerlits $
* @version $Revision: 1.11 $
* @version $Revision: 1.12 $
*/
class DjBagWindow : public WhiteWindow, public LocalizedObject
{
private:
/**
* The callback function to set the colors of the rows.
*/
void
cellDataFunction(Gtk::CellRenderer* cell,
const Gtk::TreeModel::iterator& iter)
throw ();
protected:
@ -91,9 +85,9 @@ class DjBagWindow : public WhiteWindow, public LocalizedObject
* Lists one clip per row.
*
* @author $Author: fgerlits $
* @version $Revision: 1.11 $
* @version $Revision: 1.12 $
*/
class ModelColumns : public Gtk::TreeModel::ColumnRecord
class ModelColumns : public ZebraTreeModelColumnRecord
{
public:
/**
@ -111,20 +105,14 @@ class DjBagWindow : public WhiteWindow, public LocalizedObject
*/
Gtk::TreeModelColumn<Glib::ustring> titleColumn;
/**
* The column for the color of the row.
*/
Gtk::TreeModelColumn<Colors::ColorName> colorColumn;
/**
* Constructor.
*/
ModelColumns(void) throw ()
ModelColumns(void) throw ()
{
add(playableColumn);
add(typeColumn);
add(titleColumn);
add(colorColumn);
}
};