From 581cfa4651e114f880ff9c158b5cac374dbaddf0 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Fri, 8 Apr 2005 12:18:03 +0000 Subject: [PATCH] moved coloring callback to widgets module --- .../LiveSupport/Widgets/ZebraTreeView.h | 14 +++++++--- .../modules/widgets/src/ZebraTreeView.cxx | 26 ++++++++++++++++--- .../products/gLiveSupport/src/DjBagWindow.cxx | 19 ++------------ .../products/gLiveSupport/src/DjBagWindow.h | 24 +++++------------ 4 files changed, 41 insertions(+), 42 deletions(-) diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h index ff7b5568d..bc7d3a893 100644 --- a/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h @@ -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 (); }; diff --git a/livesupport/modules/widgets/src/ZebraTreeView.cxx b/livesupport/modules/widgets/src/ZebraTreeView.cxx index 4af11dc9c..60644d8a4 100644 --- a/livesupport/modules/widgets/src/ZebraTreeView.cxx +++ b/livesupport/modules/widgets/src/ZebraTreeView.cxx @@ -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 -#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 columnList = get_columns(); std::list::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; +} + diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx index e09454818..16ba0f144 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx @@ -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::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; -} - - diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.h b/livesupport/products/gLiveSupport/src/DjBagWindow.h index b84d93ca7..e9e47d964 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.h +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.h @@ -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 titleColumn; - /** - * The column for the color of the row. - */ - Gtk::TreeModelColumn colorColumn; - /** * Constructor. */ - ModelColumns(void) throw () + ModelColumns(void) throw () { add(playableColumn); add(typeColumn); add(titleColumn); - add(colorColumn); } };