moved row color definitions from ScratchpadWindow to ZebraTreeView class;

added detailed TreeView usage documentation to ZebraTreeView
This commit is contained in:
fgerlits 2005-04-14 11:49:37 +00:00
parent c034ca25e2
commit 49db5f3c53
5 changed files with 84 additions and 23 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeModelColumnRecord.h,v $
------------------------------------------------------------------------------*/
@ -57,7 +57,7 @@ namespace Widgets {
* A basic column record class for tree models with colorable rows.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
class ZebraTreeModelColumnRecord : public Gtk::TreeModelColumnRecord
{
@ -65,14 +65,14 @@ class ZebraTreeModelColumnRecord : public Gtk::TreeModelColumnRecord
/**
* The column for the color of the row.
*/
Gtk::TreeModelColumn<Colors::ColorName> colorColumn;
Gtk::TreeModelColumn<int> rowNumberColumn;
/**
* Constructor.
*/
ZebraTreeModelColumnRecord(void) throw ()
{
add(colorColumn);
add(rowNumberColumn);
}
};

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h,v $
------------------------------------------------------------------------------*/
@ -69,10 +69,29 @@ using namespace LiveSupport::Core;
/* =============================================================== data types */
/**
* A list of items, in rows colored alternately grey and light blue.
* A table of items, in rows colored alternately gray and light blue.
*
* TreeView's contain TreeViewColumns; these contain a title (a text Label)
* and a table column body (a CellRenderer). The CellRenderer needs to be
* connected with a TreeModelColumn using the set_renderer() method of
* TreeViewColumn [which, despite its name, does not set the renderer, just
* connects it with a tree model column].
*
* A single TreeViewColumn may contain several CellRenderer's, i.e.,
* sub-columns.
*
* The standard CellRenderer types (CellRendererText etc) can not be
* instantiated by the user; they can only be created by the shortcut
* TreeViewColumn constructor or the append_column() or insert_column()
* functions in TreeView. These create the appropriate CellRenderer,
* add it the tree view column, and connect it with the tree model column.
*
* A derived CellRenderer sub-type needs to be 1) instantiated;
* 2) added to a TreeViewColumn using a constructor or pack_start() etc;
* 3) connected with a TreeModelColumn using set_renderer().
*
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
* @version $Revision: 1.6 $
*/
class ZebraTreeView : public Gtk::TreeView
{

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraCellRenderer.cxx,v $
------------------------------------------------------------------------------*/
@ -68,7 +68,7 @@ ZebraCellRenderer::ZebraCellRenderer() throw ()
*----------------------------------------------------------------------------*/
ZebraCellRenderer::~ZebraCellRenderer() throw ()
{
std::cerr << "### destructor\n";
// std::cerr << "### destructor\n";
}
@ -82,12 +82,32 @@ ZebraCellRenderer::get_size_vfunc(Gtk::Widget& widget,
int* width, int* height) const
throw ()
{
std::cerr << "### get_size_vfunc()...\n";
// call the parent method
/*
std::cerr << "### get_size_vfunc():"
<< (cell_area ? cell_area->get_x() : -1) << ", "
<< (cell_area ? cell_area->get_y() : -1) << "; "
<< (cell_area ? cell_area->get_width() : -1) << ", "
<< (cell_area ? cell_area->get_height() : -1) << "; "
<< (x_offset ? *x_offset : -1) << ", "
<< (y_offset ? *y_offset : -1) << " --- "
<< (width ? *width : -1) << ", "
<< (height ? *height : -1) << "\n";
*/
// call the parent method
Gtk::CellRendererText::get_size_vfunc(widget, cell_area,
x_offset, y_offset,
width, height);
std::cerr << "... done.\n";
/*
std::cerr << "... done: "
<< (cell_area ? cell_area->get_x() : -1) << ", "
<< (cell_area ? cell_area->get_y() : -1) << "; "
<< (cell_area ? cell_area->get_width() : -1) << ", "
<< (cell_area ? cell_area->get_height() : -1) << "; "
<< (x_offset ? *x_offset : -1) << ", "
<< (y_offset ? *y_offset : -1) << " --- "
<< (width ? *width : -1) << ", "
<< (height ? *height : -1) << "\n";
*/
/*
enum { TOGGLE_WIDTH = 12 };
@ -130,11 +150,26 @@ ZebraCellRenderer::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
Gtk::CellRendererState flags)
throw ()
{
std::cerr << "### render_vfunc()...\n";
/*
std::cerr << "### render_vfunc(): "
<< widget.get_name() << " --- "
<< background_area.get_x() << ", "
<< background_area.get_y() << "; "
<< background_area.get_width() << ", "
<< background_area.get_height() << " -- "
<< cell_area.get_x() << ", "
<< cell_area.get_y() << "; "
<< cell_area.get_width() << ", "
<< cell_area.get_height() << "; "
<< expose_area.get_x() << " -- "
<< expose_area.get_y() << "; "
<< expose_area.get_width() << ", "
<< expose_area.get_height() << " -- "
<< flags << "\n";
*/
// call the parent function
Gtk::CellRendererText::render_vfunc(window, widget, background_area,
cell_area, expose_area, flags);
std::cerr << "... done.\n";
/*
const unsigned int cell_xpad = property_xpad();
const unsigned int cell_ypad = property_ypad();
@ -196,11 +231,18 @@ bool ZebraCellRenderer::activate_vfunc(GdkEvent* event,
Gtk::CellRendererState flags)
throw ()
{
std::cerr << "### activate_vfunc()...\n";
/*
std::cerr << "### activate_vfunc(): "
<< widget.get_name() << ", "
<< path << ", "
// << background_area << ", "
// << cell_area << ", "
<< flags << "\n";
// call the parent function
Gtk::CellRendererText::activate_vfunc(event, widget, path,
background_area, cell_area, flags);
std::cerr << "... done.\n";
*/
/*
if(property_activatable_)
{

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $
------------------------------------------------------------------------------*/
@ -121,8 +121,9 @@ ZebraTreeView :: cellDataFunction(Gtk::CellRenderer* cell,
throw ()
{
ZebraTreeModelColumnRecord model;
Gdk::Color color = Colors::getColor((*iter)[model.colorColumn] );
cell->property_cell_background_gdk() = color;
Colors::ColorName colorName = (*iter)[model.rowNumberColumn] ?
Colors::Gray :
Colors::LightBlue;
cell->property_cell_background_gdk() = Colors::getColor(colorName);
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -264,9 +264,8 @@ ScratchpadWindow :: showContents(void) throw ()
default:
break;
}
row[modelColumns.titleColumn] = *playable->getTitle();
row[modelColumns.colorColumn] = rowNumber % 2 ? Colors::Gray
: Colors::LightBlue;
row[modelColumns.titleColumn] = *playable->getTitle();
row[modelColumns.rowNumberColumn] = rowNumber;
++it;
++rowNumber;