added widgets module

This commit is contained in:
maroy 2005-01-25 20:27:15 +00:00
parent 0a318234f9
commit b75da7e43f
13 changed files with 1299 additions and 0 deletions

View File

@ -0,0 +1,95 @@
#!/bin/sh
#-------------------------------------------------------------------------------
# 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: maroy $
# Version : $Revision: 1.1 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/bin/autogen.sh,v $
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Run this to set up the build system: configure, makefiles, etc.
# (based on the version in enlightenment's cvs)
#-------------------------------------------------------------------------------
package="Widgets"
# assume we're in $basedir/bin
reldir=`dirname $0`/..
basedir=`cd $reldir; pwd;`
test -z "$basedir" && basedir=.
usrdir=`cd $basedir/../../usr; pwd;`
bindir=$basedir/bin
etcdir=$basedir/etc
tmpdir=$basedir/tmp
cd "$tmpdir"
DIE=0
(autoheader --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile $package."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile $package."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
if test "$DIE" -eq 1; then
exit 1
fi
if test -z "$*"; then
echo "I am going to run ./configure with no arguments - if you wish "
echo "to pass any to it, please specify them on the $0 command line."
fi
echo "Generating configuration files for $package, please wait...."
configure_ac=${etcdir}/configure.ac
configure=${tmpdir}/configure
aclocal_m4=${tmpdir}/aclocal.m4
# run aclocal in etc, as it's blind, only sees files in the current directory
ACLOCAL_FLAGS="--output=${aclocal_m4}"
echo " aclocal $ACLOCAL_FLAGS"
cd ${etcdir} && aclocal $ACLOCAL_FLAGS ; cd ${tmpdir}
echo " autoheader ${configure_ac}"
autoheader ${configure_ac}
echo " autoconf -I ${tmpdir} -o ${configure} ${configure_ac}"
autoconf -I ${tmpdir} -o ${configure} ${configure_ac}
export CPPFLAGS="-I$usrdir/include"
export LDFLAGS="-L$usrdir/lib"
export PKG_CONFIG_PATH="$usrdir/lib/pkgconfig"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$usrdir/lib"
${configure} "$@" && echo

View File

@ -0,0 +1 @@
keep me

View File

@ -0,0 +1,173 @@
#-------------------------------------------------------------------------------
# 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: maroy $
# Version : $Revision: 1.1 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/etc/Makefile.in,v $
#
# @configure_input@
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# General command definitions
#-------------------------------------------------------------------------------
MKDIR = mkdir -p
RM = rm -f
RMDIR = rm -rf
DOXYGEN = doxygen
#-------------------------------------------------------------------------------
# Basic directory and file definitions
#-------------------------------------------------------------------------------
BASE_DIR = @builddir@
DOC_DIR = ${BASE_DIR}/doc
DOXYGEN_DIR = ${DOC_DIR}/doxygen
COVERAGE_DIR = ${DOC_DIR}/coverage
ETC_DIR = ${BASE_DIR}/etc
INCLUDE_DIR = ${BASE_DIR}/include
LIB_DIR = ${BASE_DIR}/lib
SRC_DIR = ${BASE_DIR}/src
TMP_DIR = ${BASE_DIR}/tmp
USR_DIR = ${BASE_DIR}/../../usr
USR_INCLUDE_DIR = ${USR_DIR}/include
USR_LIB_DIR = ${USR_DIR}/lib
BOOST_INCLUDE_DIR = ${USR_INCLUDE_DIR}/boost-1_31
MODULES_DIR = ${BASE_DIR}/..
CORE_DIR = ${MODULES_DIR}/core
CORE_INCLUDE_DIR = ${CORE_DIR}/include
CORE_LIB_DIR = ${CORE_DIR}/lib
CORE_LIB = livesupport_core
CORE_LIB_FILE = ${CORE_LIB_DIR}/lib${CORE_LIB}.a
VPATH = ${SRC_DIR}
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
GTKMM_CFLAGS=@GTKMM_CFLAGS@
GTKMM_LIBS=@GTKMM_LIBS@
TEST_RESULTS = ${DOC_DIR}/testResults.xml
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
TEST_XSLT = ../etc/testResultToHtml.xsl
WIDGETS_LIB = livesupport_widgets
WIDGETS_LIB_FILE = ${LIB_DIR}/lib${WIDGETS_LIB}.a
TEST_EXE = ${TMP_DIR}/test
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
export LD_LIBRARY_PATH:=${LD_LIBRARY_PATH}:${USR_LIB_DIR}
#-------------------------------------------------------------------------------
# Configuration parameters
#-------------------------------------------------------------------------------
CPPFLAGS = @CPPFLAGS@
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
-pedantic -Wall -Wno-long-long \
${LIBXMLPP_CFLAGS} \
${GTKMM_CFLAGS} \
-I${USR_INCLUDE_DIR} \
-I${BOOST_INCLUDE_DIR} \
-I${CORE_INCLUDE_DIR} \
-I${INCLUDE_DIR} -I${TMP_DIR}
LDFLAGS = @LDFLAGS@ -pthread \
${LIBXMLPP_LIBS} \
${GTKMM_LIBS} \
-L${USR_LIB_DIR} \
-L${CORE_LIB_DIR} \
-L${LIB_DIR}
#-------------------------------------------------------------------------------
# Dependencies
#-------------------------------------------------------------------------------
WIDGETS_LIB_OBJS = ${TMP_DIR}/ImageButton.o
TEST_EXE_OBJS = ${TMP_DIR}/TestWindow.o \
${TMP_DIR}/main.o
TEST_EXE_LIBS = -l${CORE_LIB} \
-lboost_date_time-gcc \
-lxmlrpc++ -lssl
#-------------------------------------------------------------------------------
# Targets
#-------------------------------------------------------------------------------
.PHONY: all dir_setup doc clean docclean depclean distclean
all: dir_setup ${WIDGETS_LIB_FILE}
dir_setup: ${TMP_DIR} ${DOXYGEN_DIR}
doc:
${DOXYGEN} ${DOXYGEN_CONFIG}
clean:
${RM} ${WIDGETS_LIB_OBJS} ${WIDGETS_LIB_FILE}
${RM} ${TEST_EXE_OBJS} ${TEST_EXE}
${RM} ${TMP_DIR}/*.bb ${TMP_DIR}/*.bbg ${TMP_DIR}/*.da ${TMP_DIR}/*.info
docclean:
${RMDIR} ${DOXYGEN_DIR}/html
${RMDIR} ${COVERAGE_DIR}/*
${RM} ${TEST_RESULTS}
depclean: clean
distclean: clean docclean
${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te*
run: all ${TEST_EXE}
${TEST_EXE}
#-------------------------------------------------------------------------------
# Specific targets
#-------------------------------------------------------------------------------
${WIDGETS_LIB_FILE}: ${WIDGETS_LIB_OBJS}
${AR} crus $@ $^
${TMP_DIR}:
${MKDIR} ${TMP_DIR}
${DOXYGEN_DIR}:
${MKDIR} ${DOXYGEN_DIR}
${TEST_EXE}: ${CORE_LIB_FILE} ${TEST_EXE_OBJS} ${WIDGETS_LIB_FILE}
${CXX} ${LDFLAGS} -o $@ ${TEST_EXE_OBJS} ${TEST_EXE_LIBS} \
${WIDGETS_LIB_FILE}
${CORE_LIB_FILE}:
${MAKE} -C ${CORE_DIR}
#-------------------------------------------------------------------------------
# Pattern rules
#-------------------------------------------------------------------------------
${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx
${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $<

View File

@ -0,0 +1,74 @@
dnl-----------------------------------------------------------------------------
dnl Copyright (c) 2004 Media Development Loan Fund
dnl
dnl This file is part of the LiveSupport project.
dnl http://livesupport.campware.org/
dnl To report bugs, send an e-mail to bugs@campware.org
dnl
dnl LiveSupport is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl LiveSupport is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with LiveSupport; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
dnl
dnl
dnl Author : $Author: maroy $
dnl Version : $Revision: 1.1 $
dnl Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/etc/configure.ac,v $
dnl-----------------------------------------------------------------------------
dnl-----------------------------------------------------------------------------
dnl NOTE: Run all configure related scripts from the tmp directory of the
dnl project.
dnl This is due to the fact that configure spreads a lot of trash around,
dnl like atom4te cache directories, config.* files, etc. into the directory
dnl it is being run from. We clearly don't want these in our base directory.
dnl-----------------------------------------------------------------------------
AC_INIT(Widgets, 1.0, bugs@campware.org)
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (c) 2004 Media Development Loan Fund under the GNU GPL])
AC_REVISION($Revision: 1.1 $)
AC_CONFIG_SRCDIR(../include/LiveSupport/Widgets/ImageButton.h)
AC_CONFIG_HEADERS(configure.h)
AC_PROG_CXX()
AC_CHECK_HEADERS(getopt.h)
PKG_CHECK_MODULES(LIBXMLPP,[libxml++-2.6 >= 2.6.0])
AC_SUBST(LIBXMLPP_CFLAGS)
AC_SUBST(LIBXMLPP_LIBS)
PKG_CHECK_MODULES(GTKMM,[gtkmm-2.4 >= 2.4.0])
AC_SUBST(GTKMM_CFLAGS)
AC_SUBST(GTKMM_LIBS)
dnl-----------------------------------------------------------------------------
dnl enable compilaton for code coverage data
dnl-----------------------------------------------------------------------------
AC_SUBST(COVERAGE_CXXFLAGS)
AC_ARG_ENABLE( coverage,
[ --enable-coverage enable code coverage data generaton (no) ],
ENABLE_COVERAGE=${enableval}, ENABLE_COVERAGE="no" )
if test "x${ENABLE_COVERAGE}" == "xyes" ; then
COVERAGE_CXXFLAGS="-fprofile-arcs -ftest-coverage"
AC_MSG_RESULT([compiling in code coverage mode])
else
AC_MSG_RESULT([not compiling in code coverage mode])
fi
AC_CONFIG_FILES(../Makefile:../etc/Makefile.in)
AC_OUTPUT()

View File

@ -0,0 +1,247 @@
/*------------------------------------------------------------------------------
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: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ImageButton.h,v $
------------------------------------------------------------------------------*/
#ifndef LiveSupport_Widgets_ImageButton_h
#define LiveSupport_Widgets_ImageButton_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <gtkmm/button.h>
namespace LiveSupport {
namespace Widgets {
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* A button that is represented by a bitmap totally.
* The button is fixed in size, which is determined by the images used
* to represent it.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
*/
class ImageButton : public Gtk::Button
{
private:
/**
* The possible states of the button.
*/
typedef enum { passiveState, rollState, selectedState } State;
/**
* The Gdk::Window object, used to draw inside this button.
*/
Glib::RefPtr<Gdk::Window> gdkWindow;
/**
* The Graphics Context, used to draw.
*/
Glib::RefPtr<Gdk::GC> gc;
/**
* The state of the button.
*/
State state;
/**
* The image of the button itself, in passive state
*/
Glib::RefPtr<Gdk::Pixbuf> passiveImage;
/**
* The image of the button, when the mouse hovers above it.
*/
Glib::RefPtr<Gdk::Pixbuf> rollImage;
/**
* Default constructor.
*/
ImageButton(void) throw ()
{
}
protected:
/**
* Handle the size request event.
*
* @param requisition the size request, also being the ouptut
* parameter.
*/
virtual void
on_size_request(Gtk::Requisition* requisition)
throw ();
/**
* Handle the size allocate event.
*
* @param allocation the allocated size.
*/
virtual void
on_size_allocate(Gtk::Allocation& allocation)
throw ();
/**
* Handle the map event.
*/
virtual void
on_map() throw ();
/**
* Handle the unmap event.
*/
virtual void
on_unmap() throw ();
/**
* Handle the realize event.
*/
virtual void
on_realize() throw ();
/**
* Handle the unrealize event.
*/
virtual void
on_unrealize() throw ();
/**
* Handle the expose event.
*
* @param event the actual expose event recieved.
* @return true if something was drawn (?)
*/
virtual bool
on_expose_event(GdkEventExpose* event) throw ();
/**
* Execute a function on all children of this container.
*
* @param includeInternals true if the callback function should
* also be called on the internals, false otherwise.
* @param callback the callback function to execute on the children.
* @param callbackData the data passed to the callback function.
*/
virtual void
forall_vfunc(gboolean includeInternals,
GtkCallback callback,
gpointer callbackData)
throw ();
/**
* Handle the add event.
*
* @param child the child being added to the widget.
*/
virtual void
on_add(Gtk::Widget* child) throw ();
/**
* Handle the remove event.
*
* @param child the child to remove from the widget.
*/
virtual void
on_remove(Gtk::Widget* child) throw ();
/**
* Tell what kind of children this container accepts.
*
* @return the type of children this container accepts.
*/
virtual GtkType
child_type_vfunc() const throw ();
/**
* Handle the event when the mouse enters the button area.
*/
virtual void
on_enter(void) throw ();
/**
* Handle the event when the mouse leaves the button area.
*/
virtual void
on_leave(void) throw ();
public:
/**
* Constructor, with only one image.
*
* @param image the image of the button.
*/
ImageButton(Glib::RefPtr<Gdk::Pixbuf> image) throw ();
/**
* Constructor, with a passive and a rollover image.
* The two images are assumed to be of the same size.
*
* @param passiveImage the passive image of the button.
* @param rollImage the image of the button when the mouse rolls
* over it.
*/
ImageButton(Glib::RefPtr<Gdk::Pixbuf> passiveImage,
Glib::RefPtr<Gdk::Pixbuf> rollImage) throw ();
/**
* A virtual destructor.
*/
virtual
~ImageButton(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Widgets
} // namespace LiveSupport
#endif // LiveSupport_Widgets_ImageButton_h

View File

@ -0,0 +1 @@
keep me

View File

@ -0,0 +1,306 @@
/*------------------------------------------------------------------------------
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: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ImageButton.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "LiveSupport/Widgets/ImageButton.h"
using namespace LiveSupport::Widgets;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
ImageButton :: ImageButton(Glib::RefPtr<Gdk::Pixbuf> image)
throw ()
{
set_flags(Gtk::NO_WINDOW);
state = passiveState;
this->passiveImage = image;
this->rollImage.clear();
}
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
ImageButton :: ImageButton(Glib::RefPtr<Gdk::Pixbuf> passiveImage,
Glib::RefPtr<Gdk::Pixbuf> rollImage)
throw ()
{
set_flags(Gtk::NO_WINDOW);
state = passiveState;
this->passiveImage = passiveImage;
this->rollImage = rollImage;
}
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
ImageButton :: ~ImageButton(void) throw ()
{
}
/*------------------------------------------------------------------------------
* Handle the size request event.
*----------------------------------------------------------------------------*/
void
ImageButton :: on_size_request(Gtk::Requisition* requisition) throw ()
{
*requisition = Gtk::Requisition();
requisition->width = passiveImage->get_width();
requisition->height = passiveImage->get_height();
}
/*------------------------------------------------------------------------------
* Handle the size allocate event.
* We will not be given heights or widths less than we have requested,
* though we might get more.
*----------------------------------------------------------------------------*/
void
ImageButton :: on_size_allocate(Gtk::Allocation& allocation) throw ()
{
set_allocation(allocation);
if (gdkWindow) {
gdkWindow->move_resize( allocation.get_x(),
allocation.get_y(),
allocation.get_width(),
allocation.get_height() );
}
}
/*------------------------------------------------------------------------------
* Execute a function on all the children.
* As this widget has no children, don't do anything.
*----------------------------------------------------------------------------*/
void
ImageButton :: forall_vfunc(gboolean includeInternals,
GtkCallback callback,
gpointer callbackData) throw ()
{
}
/*------------------------------------------------------------------------------
* Handle the add child widget event.
* As this widget has no children, don't do anything.
*----------------------------------------------------------------------------*/
void
ImageButton :: on_add(Gtk::Widget* child) throw ()
{
}
/*------------------------------------------------------------------------------
* Handle the remove child widget event.
* As this widget has no children, don't do anything.
*----------------------------------------------------------------------------*/
void
ImageButton :: on_remove(Gtk::Widget* child) throw ()
{
}
/*------------------------------------------------------------------------------
* Return what kind of widgets can be added to this container.
* As this widget has no children, return G_TYPE_NONE always.
*----------------------------------------------------------------------------*/
GtkType
ImageButton :: child_type_vfunc() const throw ()
{
return G_TYPE_NONE;
}
/*------------------------------------------------------------------------------
* Handle the map event.
*----------------------------------------------------------------------------*/
void
ImageButton :: on_map() throw ()
{
Gtk::Button::on_map();
}
/*------------------------------------------------------------------------------
* Handle the unmap event.
*----------------------------------------------------------------------------*/
void
ImageButton :: on_unmap() throw ()
{
Gtk::Button::on_unmap();
}
/*------------------------------------------------------------------------------
* Handle the realize event.
*----------------------------------------------------------------------------*/
void
ImageButton :: on_realize() throw ()
{
Gtk::Button::on_realize();
if (!gdkWindow) {
// create the Gdk::Window, if it didn't exist before
GdkWindowAttr attributes;
memset(&attributes, 0, sizeof(attributes));
Gtk::Allocation allocation = get_allocation();
// set initial position and size of the Gdk::Window
attributes.x = allocation.get_x();
attributes.y = allocation.get_y();
attributes.width = allocation.get_width();
attributes.height = allocation.get_height();
attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
gdkWindow = Gdk::Window::create(get_window(),
&attributes,
GDK_WA_X | GDK_WA_Y);
unset_flags(Gtk::NO_WINDOW);
set_window(gdkWindow);
// make the widget receive expose events
gdkWindow->set_user_data(gobj());
// allocate a GC for use in on_expose_event()
gc = Gdk::GC::create(gdkWindow);
}
}
/*------------------------------------------------------------------------------
* Handle the unrealize event.
*----------------------------------------------------------------------------*/
void
ImageButton :: on_unrealize() throw ()
{
gdkWindow.clear();
gc.clear();
Gtk::Button::on_unrealize();
}
/*------------------------------------------------------------------------------
* Handle the expose event.
*----------------------------------------------------------------------------*/
bool
ImageButton :: on_expose_event(GdkEventExpose* event) throw ()
{
if (event->count > 0) {
return false;
}
if (gdkWindow) {
gdkWindow->clear();
Glib::RefPtr<Gdk::Pixbuf> image;
switch (state) {
case passiveState:
default:
image = passiveImage;
break;
case rollState:
image = rollImage ? rollImage : passiveImage;
break;
}
// just draw the button image at the centre of the available space
int x = (get_width() - image->get_width()) / 2;
int y = (get_height() - image->get_height()) / 2;
image->render_to_drawable(gdkWindow,
get_style()->get_black_gc(),
0, 0,
x,
y,
image->get_width(),
image->get_height(),
Gdk::RGB_DITHER_NONE,
0, 0);
}
return false;
}
/*------------------------------------------------------------------------------
* Handle the mouse enter event.
*----------------------------------------------------------------------------*/
void
ImageButton :: on_enter(void) throw ()
{
state = rollState;
Gtk::Button::on_enter();
}
/*------------------------------------------------------------------------------
* Handle the mouse leave event.
*----------------------------------------------------------------------------*/
void
ImageButton :: on_leave(void) throw ()
{
state = passiveState;
Gtk::Button::on_leave();
}

View File

@ -0,0 +1,81 @@
/*------------------------------------------------------------------------------
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: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "TestWindow.h"
using namespace LiveSupport::Widgets;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
TestWindow :: TestWindow (void)
throw ()
{
Glib::RefPtr<Gdk::Pixbuf> passiveImage;
Glib::RefPtr<Gdk::Pixbuf> rollImage;
passiveImage = Gdk::Pixbuf::create_from_file("var/delete.png");
rollImage = Gdk::Pixbuf::create_from_file("var/delete_roll.png");
imageButton.reset(new ImageButton(passiveImage, rollImage));
layout.reset(new Gtk::Table());
layout->attach(*imageButton, 0, 1, 0, 1);
add(*layout);
show_all();
}
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
TestWindow :: ~TestWindow (void) throw ()
{
}

View File

@ -0,0 +1,108 @@
/*------------------------------------------------------------------------------
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: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.h,v $
------------------------------------------------------------------------------*/
#ifndef TestWindow_h
#define TestWindow_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <gtkmm/window.h>
#include <gtkmm/table.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Widgets/ImageButton.h"
namespace LiveSupport {
namespace Widgets {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* A window, enabling interactive testing of UI components.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
*/
class TestWindow : public Gtk::Window
{
protected:
/**
* The layout used in the window.
*/
Ptr<Gtk::Table>::Ref layout;
/**
* An image button.
*/
Ptr<ImageButton>::Ref imageButton;
public:
/**
* Constructor.
*/
TestWindow(void) throw ();
/**
* Virtual destructor.
*/
virtual
~TestWindow(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Widgets
} // namespace LiveSupport
#endif // TestWindow_h

View File

@ -0,0 +1,212 @@
/*------------------------------------------------------------------------------
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: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/main.cxx,v $
------------------------------------------------------------------------------*/
/** @file
* This file contains the main entry point to the Scheduler daemon.
*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_GETOPT_H
#include <getopt.h>
#else
#error "Need getopt.h"
#endif
#include <iostream>
#include <libxml++/libxml++.h>
#include <gtkmm/main.h>
#include "LiveSupport/Core/Ptr.h"
#include "TestWindow.h"
using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/**
* Our copyright notice, should be at most 80 columns
*/
static const char copyrightNotice[] =
"Copyright (c) 2004 Media Development Loan Fund under the GNU GPL";
/**
* String describing the short options.
*/
static const char options[] = "c:hv";
/**
* Structure describing the long options
*/
static const struct option longOptions[] = {
{ "config", required_argument, 0, 'c' },
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'v' },
{ 0, 0, 0, 0 }
};
/* =============================================== local function prototypes */
/**
* Print program version.
*
* @param os the std::ostream to print to.
*/
static void
printVersion ( std::ostream & os );
/**
* Print program usage information.
*
* @param invocation the command line command used to invoke this program.
* @param os the std::ostream to print to.
*/
static void
printUsage ( const char invocation[],
std::ostream & os );
/* ============================================================= module code */
/**
* Program entry point.
*
* @param argc the number of command line arguments passed by the user.
* @param argv the command line arguments passed by the user.
* @return 0 on success, non-0 on failure.
*/
int main ( int argc,
char * argv[] )
{
// initialize the Gtk library, with the Gtk options first
Gtk::Main kit(argc, argv);
// take a look at our options
int i;
std::string configFileName;
while ((i = getopt_long(argc, argv, options, longOptions, 0)) != -1) {
switch (i) {
case 'c':
configFileName = optarg;
break;
case 'h':
printUsage(argv[0], std::cout);
exit(EXIT_SUCCESS);
case 'v':
printVersion(std::cout);
exit(EXIT_SUCCESS);
default:
printUsage(argv[0], std::cout);
exit(EXIT_FAILURE);
}
}
if (optind != argc) {
printUsage(argv[0], std::cout);
exit(EXIT_FAILURE);
}
std::cerr << "using config file '" << configFileName << '\'' << std::endl;
TestWindow testWindow;
Gtk::Main::run(testWindow);
/*
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref
gLiveSupport(new LiveSupport::GLiveSupport::GLiveSupport());
try {
std::auto_ptr<xmlpp::DomParser>
parser(new xmlpp::DomParser(configFileName, true));
const xmlpp::Document * document = parser->get_document();
gLiveSupport->configure(*(document->get_root_node()));
} catch (std::invalid_argument &e) {
std::cerr << "semantic error in configuration file" << std::endl
<< e.what() << std::endl;
exit(EXIT_FAILURE);
} catch (xmlpp::exception &e) {
std::cerr << "error parsing configuration file" << std::endl
<< e.what() << std::endl;
exit(EXIT_FAILURE);
}
gLiveSupport->show();
*/
exit(EXIT_SUCCESS);
}
/*------------------------------------------------------------------------------
* Print program version.
*----------------------------------------------------------------------------*/
static void
printVersion ( std::ostream & os )
{
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
<< copyrightNotice << std::endl;
}
/*------------------------------------------------------------------------------
* Print program usage.
*----------------------------------------------------------------------------*/
static void
printUsage ( const char invocation[],
std::ostream & os )
{
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
<< std::endl
<< "Usage: " << invocation << " [OPTION]"
<< std::endl
<< " mandatory options:" << std::endl
<< " -c, --config=file.name scheduler configuration file" << std::endl
<< " optional options:" << std::endl
<< " -h, --help display this help and exit" << std::endl
<< " -v, --version display version information and exit"
<< std::endl
<< std::endl
<< "Report bugs to " << PACKAGE_BUGREPORT << std::endl;
}

View File

@ -0,0 +1 @@
keep me

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB