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 $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
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.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class ZebraTreeView : public Gtk::TreeView
|
||||
{
|
||||
|
@ -102,10 +102,11 @@ class ZebraTreeView : public Gtk::TreeView
|
|||
~ZebraTreeView(void) throw ();
|
||||
|
||||
/**
|
||||
* Color the columns blue.
|
||||
* Set the callback function for every column.
|
||||
*/
|
||||
void
|
||||
colorBlue(void) throw ();
|
||||
setCellDataFunction(const Column::SlotCellData& callback)
|
||||
throw ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
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 $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -35,7 +35,8 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h"
|
||||
#include "LiveSupport/Widgets/WidgetFactory.h" Gdk::Color blueColor = Colors::getColor(Colors::LightBlue);
|
||||
|
||||
#include "LiveSupport/Widgets/ZebraTreeView.h"
|
||||
|
||||
|
||||
|
@ -72,16 +73,18 @@ ZebraTreeView :: ~ZebraTreeView(void) throw ()
|
|||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Color the table blue.
|
||||
* Set the callback function for every column.
|
||||
*----------------------------------------------------------------------------*/
|
||||
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);
|
||||
renderer->property_cell_background_gdk() = bgColor;
|
||||
// renderer->property_cell_background_set() = false;
|
||||
for (it = columnList.begin(); it != columnList.end(); ++it) {
|
||||
(*it)->set_cell_data_func(*(*it)->get_first_cell_renderer(), callback);
|
||||
}
|
||||
|
||||
// set_rules_hint(); // suggest coloring with alternate colors
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
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 $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -126,7 +126,8 @@ DjBagWindow :: DjBagWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
|||
}
|
||||
|
||||
// color the columns blue
|
||||
treeView->colorBlue();
|
||||
treeView->setCellDataFunction(
|
||||
sigc::mem_fun(*this, &DjBagWindow::cellDataFunction));
|
||||
|
||||
// register the signal handler for treeview entries being clicked
|
||||
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
|
||||
|
@ -246,6 +247,8 @@ DjBagWindow :: showContents(void) throw ()
|
|||
it = djBagContents->begin();
|
||||
end = djBagContents->end();
|
||||
treeModel->clear();
|
||||
int rowNumber = 0;
|
||||
|
||||
while (it != end) {
|
||||
playable = *it;
|
||||
row = *(treeModel->append());
|
||||
|
@ -264,8 +267,11 @@ DjBagWindow :: showContents(void) throw ()
|
|||
break;
|
||||
}
|
||||
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 $
|
||||
Version : $Revision: 1.10 $
|
||||
Version : $Revision: 1.11 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -71,10 +71,18 @@ using namespace LiveSupport::Widgets;
|
|||
* playlists.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.10 $
|
||||
* @version $Revision: 1.11 $
|
||||
*/
|
||||
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:
|
||||
|
||||
|
@ -83,7 +91,7 @@ class DjBagWindow : public WhiteWindow, public LocalizedObject
|
|||
* Lists one clip per row.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.10 $
|
||||
* @version $Revision: 1.11 $
|
||||
*/
|
||||
class ModelColumns : public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
|
@ -103,6 +111,11 @@ 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.
|
||||
*/
|
||||
|
@ -111,6 +124,7 @@ class DjBagWindow : public WhiteWindow, public LocalizedObject
|
|||
add(playableColumn);
|
||||
add(typeColumn);
|
||||
add(titleColumn);
|
||||
add(colorColumn);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue