added ZebraTreeView to widgets, and to WidgetFactory;

modified DJBagWindow (Scratchpad) to use the widget factory for this widget
This commit is contained in:
fgerlits 2005-03-29 16:08:39 +00:00
parent 9206d822ed
commit 0cb4f64754
7 changed files with 250 additions and 39 deletions

View file

@ -20,8 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Author : $Author: maroy $
# Version : $Revision: 1.9 $
# Author : $Author: fgerlits $
# Version : $Revision: 1.10 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/etc/Makefile.in,v $
#
# @configure_input@
@ -116,7 +116,8 @@ WIDGETS_LIB_OBJS = ${TMP_DIR}/ImageButton.o \
${TMP_DIR}/ButtonImages.o \
${TMP_DIR}/ComboBoxText.o \
${TMP_DIR}/Notebook.o \
${TMP_DIR}/WidgetFactory.o
${TMP_DIR}/WidgetFactory.o \
${TMP_DIR}/ZebraTreeView.o
TEST_EXE_OBJS = ${TMP_DIR}/TestWindow.o \
${TMP_DIR}/main.o

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $
------------------------------------------------------------------------------*/
@ -52,6 +52,7 @@
#include "LiveSupport/Widgets/ComboBoxText.h"
#include "LiveSupport/Widgets/BlueBin.h"
#include "LiveSupport/Widgets/EntryBin.h"
#include "LiveSupport/Widgets/ZebraTreeView.h"
namespace LiveSupport {
@ -86,7 +87,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.9 $
* @version $Revision: 1.10 $
*/
class WidgetFactory :
virtual public Configurable
@ -318,6 +319,17 @@ class WidgetFactory :
*/
Gtk::Image *
createResizeImage(void) throw ();
/**
* Create and return a ZebraTreeView instance.
* It is the reponsibility of the caller to dispose of the created
* object properly.
*
* @return the ZebraTreeView object.
*/
ZebraTreeView *
createTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
throw ();
};

View file

@ -0,0 +1,116 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h,v $
------------------------------------------------------------------------------*/
#ifndef LiveSupport_Widgets_ZebraTreeView_h
#define LiveSupport_Widgets_ZebraTreeView_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <gtkmm/treemodel.h>
#include <gtkmm/treeview.h>
#include <gtkmm/label.h>
#include <gtkmm/table.h>
#include <gtkmm/alignment.h>
#include <gtkmm/eventbox.h>
#include <gtkmm/image.h>
#include <gtkmm/window.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Widgets/CornerImages.h"
#include "LiveSupport/Widgets/ImageButton.h"
#include "LiveSupport/Widgets/BlueBin.h"
namespace LiveSupport {
namespace Widgets {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* A list of items, in rows colored alternately grey and light blue.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
*/
class ZebraTreeView : public Gtk::TreeView
{
private:
/**
* Default constructor.
*/
ZebraTreeView(void) throw ()
{
}
protected:
public:
/**
* Constructor.
*
* @param treeModel the data the treeView will show.
*/
ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
throw ();
/**
* A virtual destructor.
*/
virtual
~ZebraTreeView(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Widgets
} // namespace LiveSupport
#endif // LiveSupport_Widgets_ZebraTreeView_h

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.10 $
Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $
------------------------------------------------------------------------------*/
@ -346,3 +346,14 @@ WidgetFactory :: createResizeImage(void) throw ()
return new Gtk::Image(resizeImage);
}
/*------------------------------------------------------------------------------
* Create a ZebraTreeView table
*----------------------------------------------------------------------------*/
ZebraTreeView *
WidgetFactory :: createTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
throw ()
{
return new ZebraTreeView(treeModel);
}

View file

@ -0,0 +1,72 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <iostream>
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/ZebraTreeView.h"
using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
ZebraTreeView :: ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
throw ()
: Gtk::TreeView(treeModel)
{
}
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
ZebraTreeView :: ~ZebraTreeView(void) throw ()
{
}

View file

@ -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.cxx,v $
------------------------------------------------------------------------------*/
@ -111,8 +111,26 @@ DjBagWindow :: DjBagWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
add(vBox);
// Create the Tree model:
treeModel = Gtk::ListStore::create(modelColumns);
treeView = Gtk::manage(widgetFactory->createTreeView(treeModel));
// Add the TreeView's view columns:
try {
treeView->append_column(*getResourceUstring("typeColumnLabel"),
modelColumns.typeColumn);
treeView->append_column(*getResourceUstring("titleColumnLabel"),
modelColumns.titleColumn);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
}
// register the signal handler for treeview entries being clicked
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
&DjBagWindow::onEntryClicked));
// Add the TreeView, inside a ScrolledWindow, with the button underneath:
scrolledWindow.add(treeView);
scrolledWindow.add(*treeView);
// Only show the scrollbars when they are necessary:
scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
@ -133,25 +151,6 @@ DjBagWindow :: DjBagWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
bottomButtonBox.pack_start(*clearListButton, Gtk::PACK_SHRINK);
bottomButtonBox.pack_start(*removeButton, Gtk::PACK_SHRINK);
// Create the Tree model:
treeModel = Gtk::ListStore::create(modelColumns);
treeView.set_model(treeModel);
// Add the TreeView's view columns:
try {
treeView.append_column(*getResourceUstring("typeColumnLabel"),
modelColumns.typeColumn);
treeView.append_column(*getResourceUstring("titleColumnLabel"),
modelColumns.titleColumn);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
}
// register the signal handler for treeview entries being clicked
treeView.signal_button_press_event().connect_notify(sigc::mem_fun(*this,
&DjBagWindow::onEntryClicked));
// create the right-click entry context menu for audio clips
audioClipMenu = Gtk::manage(new Gtk::Menu());
Gtk::Menu::MenuList& audioClipMenuList = audioClipMenu->items();
@ -298,7 +297,7 @@ DjBagWindow :: onEntryClicked (GdkEventButton * event) throw ()
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
// only show the context menu, if something is already selected
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
treeView.get_selection();
treeView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
if (iter) {
@ -330,7 +329,7 @@ void
DjBagWindow :: onRemoveItem(void) throw ()
{
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
treeView.get_selection();
treeView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
@ -351,7 +350,7 @@ void
DjBagWindow :: onUpItem(void) throw ()
{
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
treeView.get_selection();
treeView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
@ -396,7 +395,7 @@ void
DjBagWindow :: onDownItem(void) throw ()
{
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
treeView.get_selection();
treeView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
@ -444,7 +443,7 @@ void
DjBagWindow :: onDeleteItem(void) throw ()
{
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
treeView.get_selection();
treeView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
@ -508,7 +507,7 @@ void
DjBagWindow :: onAddToPlaylist(void) throw ()
{
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
treeView.get_selection();
treeView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
@ -529,7 +528,7 @@ void
DjBagWindow :: onSchedulePlaylist(void) throw ()
{
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
treeView.get_selection();
treeView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
@ -574,7 +573,7 @@ void
DjBagWindow :: onPlayItem(void) throw ()
{
Glib::RefPtr<Gtk::TreeView::Selection> refSelection =
treeView.get_selection();
treeView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.8 $
Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.h,v $
------------------------------------------------------------------------------*/
@ -71,7 +71,7 @@ using namespace LiveSupport::Widgets;
* playlists.
*
* @author $Author: fgerlits $
* @version $Revision: 1.8 $
* @version $Revision: 1.9 $
*/
class DjBagWindow : public WhiteWindow, public LocalizedObject
{
@ -83,7 +83,7 @@ class DjBagWindow : public WhiteWindow, public LocalizedObject
* Lists one clip per row.
*
* @author $Author: fgerlits $
* @version $Revision: 1.8 $
* @version $Revision: 1.9 $
*/
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
@ -138,7 +138,7 @@ class DjBagWindow : public WhiteWindow, public LocalizedObject
/**
* The tree view, now only showing rows.
*/
Gtk::TreeView treeView;
Gtk::TreeView * treeView;
/**
* The tree model, as a GTK reference.