added first zebra stripes to ZebraTreeView
This commit is contained in:
parent
10fded16ce
commit
7b09d7d251
4 changed files with 61 additions and 23 deletions
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h,v $
|
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.
|
* A list of items, in rows colored alternately grey and light blue.
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.2 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
class ZebraTreeView : public Gtk::TreeView
|
class ZebraTreeView : public Gtk::TreeView
|
||||||
{
|
{
|
||||||
|
@ -102,10 +102,11 @@ class ZebraTreeView : public Gtk::TreeView
|
||||||
~ZebraTreeView(void) throw ();
|
~ZebraTreeView(void) throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color the columns blue.
|
* Set the callback function for every column.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
colorBlue(void) throw ();
|
setCellDataFunction(const Column::SlotCellData& callback)
|
||||||
|
throw ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -35,7 +35,8 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
#include "LiveSupport/Widgets/WidgetFactory.h" Gdk::Color blueColor = Colors::getColor(Colors::LightBlue);
|
||||||
|
|
||||||
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ using namespace LiveSupport::Widgets;
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
ZebraTreeView :: ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
|
ZebraTreeView :: ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
|
||||||
throw ()
|
throw ()
|
||||||
: Gtk::TreeView(treeModel)
|
: Gtk::TreeView(treeModel)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -66,22 +67,24 @@ ZebraTreeView :: ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
ZebraTreeView :: ~ZebraTreeView(void) throw ()
|
ZebraTreeView :: ~ZebraTreeView(void) throw ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Color the table blue.
|
* Set the callback function for every column.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
ZebraTreeView :: colorBlue(void) throw ()
|
ZebraTreeView :: setCellDataFunction(const Column::SlotCellData& callback) throw ()
|
||||||
{
|
{
|
||||||
Gdk::Color bgColor = Colors::getColor(Colors::LightBlue);
|
std::list<Column*> columnList = get_columns();
|
||||||
|
std::list<Column*>::iterator it;
|
||||||
for (int i = 0; i < get_columns().size(); i++) {
|
|
||||||
Gtk::CellRenderer* renderer = get_column_cell_renderer(i);
|
for (it = columnList.begin(); it != columnList.end(); ++it) {
|
||||||
renderer->property_cell_background_gdk() = bgColor;
|
(*it)->set_cell_data_func(*(*it)->get_first_cell_renderer(), callback);
|
||||||
// renderer->property_cell_background_set() = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set_rules_hint(); // suggest coloring with alternate colors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.12 $
|
Version : $Revision: 1.13 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -126,7 +126,8 @@ DjBagWindow :: DjBagWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||||
}
|
}
|
||||||
|
|
||||||
// color the columns blue
|
// color the columns blue
|
||||||
treeView->colorBlue();
|
treeView->setCellDataFunction(
|
||||||
|
sigc::mem_fun(*this, &DjBagWindow::cellDataFunction));
|
||||||
|
|
||||||
// register the signal handler for treeview entries being clicked
|
// register the signal handler for treeview entries being clicked
|
||||||
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
|
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
|
||||||
|
@ -246,6 +247,8 @@ DjBagWindow :: showContents(void) throw ()
|
||||||
it = djBagContents->begin();
|
it = djBagContents->begin();
|
||||||
end = djBagContents->end();
|
end = djBagContents->end();
|
||||||
treeModel->clear();
|
treeModel->clear();
|
||||||
|
int rowNumber = 0;
|
||||||
|
|
||||||
while (it != end) {
|
while (it != end) {
|
||||||
playable = *it;
|
playable = *it;
|
||||||
row = *(treeModel->append());
|
row = *(treeModel->append());
|
||||||
|
@ -264,8 +267,11 @@ DjBagWindow :: showContents(void) throw ()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
row[modelColumns.titleColumn] = *playable->getTitle();
|
row[modelColumns.titleColumn] = *playable->getTitle();
|
||||||
|
row[modelColumns.colorColumn] = rowNumber % 2 ? Colors::Gray
|
||||||
|
: Colors::LightBlue;
|
||||||
|
|
||||||
it++;
|
++it;
|
||||||
|
++rowNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,3 +645,17 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.10 $
|
Version : $Revision: 1.11 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -71,10 +71,18 @@ using namespace LiveSupport::Widgets;
|
||||||
* playlists.
|
* playlists.
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.10 $
|
* @version $Revision: 1.11 $
|
||||||
*/
|
*/
|
||||||
class DjBagWindow : public WhiteWindow, public LocalizedObject
|
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:
|
protected:
|
||||||
|
|
||||||
|
@ -83,7 +91,7 @@ class DjBagWindow : public WhiteWindow, public LocalizedObject
|
||||||
* Lists one clip per row.
|
* Lists one clip per row.
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.10 $
|
* @version $Revision: 1.11 $
|
||||||
*/
|
*/
|
||||||
class ModelColumns : public Gtk::TreeModel::ColumnRecord
|
class ModelColumns : public Gtk::TreeModel::ColumnRecord
|
||||||
{
|
{
|
||||||
|
@ -103,6 +111,11 @@ class DjBagWindow : public WhiteWindow, public LocalizedObject
|
||||||
*/
|
*/
|
||||||
Gtk::TreeModelColumn<Glib::ustring> titleColumn;
|
Gtk::TreeModelColumn<Glib::ustring> titleColumn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column for the color of the row.
|
||||||
|
*/
|
||||||
|
Gtk::TreeModelColumn<Colors::ColorName> colorColumn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -111,6 +124,7 @@ class DjBagWindow : public WhiteWindow, public LocalizedObject
|
||||||
add(playableColumn);
|
add(playableColumn);
|
||||||
add(typeColumn);
|
add(typeColumn);
|
||||||
add(titleColumn);
|
add(titleColumn);
|
||||||
|
add(colorColumn);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue