From de4216cafde908a11645344e6e4fdc866434695e Mon Sep 17 00:00:00 2001 From: maroy Date: Mon, 7 Feb 2005 16:12:55 +0000 Subject: [PATCH] first version of WhiteWindow --- livesupport/modules/widgets/etc/Makefile.in | 4 +- .../include/LiveSupport/Widgets/BlueBin.h | 73 ++--- .../LiveSupport/Widgets/CornerImages.h | 193 +++++++++++++ .../include/LiveSupport/Widgets/WhiteWindow.h | 255 ++++++++++++++++++ .../LiveSupport/Widgets/WidgetFactory.h | 113 +++----- livesupport/modules/widgets/src/BlueBin.cxx | 182 +++++-------- .../modules/widgets/src/CornerImages.cxx | 129 +++++++++ .../modules/widgets/src/ImageButton.cxx | 10 +- .../modules/widgets/src/TestWindow.cxx | 12 +- livesupport/modules/widgets/src/TestWindow.h | 7 +- .../modules/widgets/src/WhiteWindow.cxx | 254 +++++++++++++++++ .../modules/widgets/src/WidgetFactory.cxx | 146 +++------- .../widgets/var/imageButton/delete.png | Bin 0 -> 3513 bytes .../widgets/var/imageButton/deleteRoll.png | Bin 0 -> 3492 bytes .../widgets/var/whiteWindow/bottom.png | Bin 0 -> 2834 bytes .../widgets/var/whiteWindow/bottomLeft.png | Bin 0 -> 2927 bytes .../widgets/var/whiteWindow/bottomRight.png | Bin 0 -> 2920 bytes .../modules/widgets/var/whiteWindow/left.png | Bin 0 -> 2826 bytes .../modules/widgets/var/whiteWindow/right.png | Bin 0 -> 2825 bytes .../modules/widgets/var/whiteWindow/top.png | Bin 0 -> 2831 bytes .../widgets/var/whiteWindow/topLeft.png | Bin 0 -> 2908 bytes .../widgets/var/whiteWindow/topRight.png | Bin 0 -> 2942 bytes 22 files changed, 1012 insertions(+), 366 deletions(-) create mode 100644 livesupport/modules/widgets/include/LiveSupport/Widgets/CornerImages.h create mode 100644 livesupport/modules/widgets/include/LiveSupport/Widgets/WhiteWindow.h create mode 100644 livesupport/modules/widgets/src/CornerImages.cxx create mode 100644 livesupport/modules/widgets/src/WhiteWindow.cxx create mode 100644 livesupport/modules/widgets/var/imageButton/delete.png create mode 100644 livesupport/modules/widgets/var/imageButton/deleteRoll.png create mode 100644 livesupport/modules/widgets/var/whiteWindow/bottom.png create mode 100644 livesupport/modules/widgets/var/whiteWindow/bottomLeft.png create mode 100644 livesupport/modules/widgets/var/whiteWindow/bottomRight.png create mode 100644 livesupport/modules/widgets/var/whiteWindow/left.png create mode 100644 livesupport/modules/widgets/var/whiteWindow/right.png create mode 100644 livesupport/modules/widgets/var/whiteWindow/top.png create mode 100644 livesupport/modules/widgets/var/whiteWindow/topLeft.png create mode 100644 livesupport/modules/widgets/var/whiteWindow/topRight.png diff --git a/livesupport/modules/widgets/etc/Makefile.in b/livesupport/modules/widgets/etc/Makefile.in index 62b38d625..fefdb2bb7 100644 --- a/livesupport/modules/widgets/etc/Makefile.in +++ b/livesupport/modules/widgets/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: maroy $ -# Version : $Revision: 1.4 $ +# Version : $Revision: 1.5 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/etc/Makefile.in,v $ # # @configure_input@ @@ -110,6 +110,8 @@ LDFLAGS = @LDFLAGS@ -pthread \ WIDGETS_LIB_OBJS = ${TMP_DIR}/ImageButton.o \ ${TMP_DIR}/Button.o \ ${TMP_DIR}/BlueBin.o \ + ${TMP_DIR}/WhiteWindow.o \ + ${TMP_DIR}/CornerImages.o \ ${TMP_DIR}/WidgetFactory.o TEST_EXE_OBJS = ${TMP_DIR}/TestWindow.o \ ${TMP_DIR}/main.o diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/BlueBin.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/BlueBin.h index 0a68b8e10..2b6c9ee82 100644 --- a/livesupport/modules/widgets/include/LiveSupport/Widgets/BlueBin.h +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/BlueBin.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/BlueBin.h,v $ ------------------------------------------------------------------------------*/ @@ -43,6 +43,7 @@ #include #include "LiveSupport/Core/Ptr.h" +#include "LiveSupport/Widgets/CornerImages.h" namespace LiveSupport { @@ -62,7 +63,7 @@ using namespace LiveSupport::Core; * A container holding exactly one child, habing a light blue border to it. * * @author $Author: maroy $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class BlueBin : public Gtk::Bin { @@ -88,44 +89,9 @@ class BlueBin : public Gtk::Bin Gdk::Color bgColor; /** - * The top left image of the border. + * The corner images. */ - Glib::RefPtr topLeftImage; - - /** - * The left image of the border. - */ - Glib::RefPtr leftImage; - - /** - * The top image of the border. - */ - Glib::RefPtr topImage; - - /** - * The top right image of the border. - */ - Glib::RefPtr topRightImage; - - /** - * The right image of the border. - */ - Glib::RefPtr rightImage; - - /** - * The bottom left image of the border. - */ - Glib::RefPtr bottomLeftImage; - - /** - * The bottom image of the border. - */ - Glib::RefPtr bottomImage; - - /** - * The bottom right image of the border. - */ - Glib::RefPtr bottomRightImage; + Ptr::Ref cornerImages; /** * Default constructor. @@ -134,6 +100,17 @@ class BlueBin : public Gtk::Bin { } + /** + * Render an image. + * + * @param image the image to render + * @param x the x coordinate to render to + * @param y the y coordinate to render to + */ + void + renderImage(Glib::RefPtr image, + int x, + int y) throw (); protected: /** @@ -232,24 +209,10 @@ class BlueBin : public Gtk::Bin * Constructor, with only one state. * * @param backgroundColor the RGB value for the background color. - * @param topLeftImage the top left image of the border - * @param leftImage the left image of the border - * @param topImage the top image of the border - * @param topRightImage the top right image of the border - * @param rightImage the right image of the border - * @param bottomLeftImage the bottom left image of the border - * @param bottomImage the bottom image of the border - * @param bottomRightImage the bottom right image of the border + * @param cornerImages the corner images. */ BlueBin(unsigned int backgroundColor, - Glib::RefPtr topLeftImage, - Glib::RefPtr leftImage, - Glib::RefPtr topImage, - Glib::RefPtr topRightImage, - Glib::RefPtr rightImage, - Glib::RefPtr bottomLeftImage, - Glib::RefPtr bottomImage, - Glib::RefPtr bottomRightImage) + Ptr::Ref cornerImages) throw (); /** diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/CornerImages.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/CornerImages.h new file mode 100644 index 000000000..9199961b4 --- /dev/null +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/CornerImages.h @@ -0,0 +1,193 @@ +/*------------------------------------------------------------------------------ + + 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/CornerImages.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef LiveSupport_Widgets_CornerImages_h +#define LiveSupport_Widgets_CornerImages_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include + +#include "gdkmm/pixbuf.h" + + +namespace LiveSupport { +namespace Widgets { + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * A helper class to hold a set of corner images. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + */ +class CornerImages +{ + private: + /** + * Load an image relative the path, and signal error if not found. + * + * @param path the path to find the image for. + * @param imageName the name of the image, relative to path + * @return the loaded image + * @exception std::invalid_argument if the image was not found + */ + Glib::RefPtr + loadImage(const std::string path, + const std::string imageName) + throw (std::invalid_argument); + + + public: + /** + * The top left image. + */ + Glib::RefPtr topLeftImage; + + /** + * The left image. + */ + Glib::RefPtr leftImage; + + /** + * The top image. + */ + Glib::RefPtr topImage; + + /** + * The top right image. + */ + Glib::RefPtr topRightImage; + + /** + * The right image. + */ + Glib::RefPtr rightImage; + + /** + * The bottom left image. + */ + Glib::RefPtr bottomLeftImage; + + /** + * The bottom image. + */ + Glib::RefPtr bottomImage; + + /** + * The bottom right image. + */ + Glib::RefPtr bottomRightImage; + + /** + * The default constructor. + */ + CornerImages(void) throw () + { + } + + /** + * Constructor with image references. + * If any of the images is not available, the result is undefined. + * + * @param topLeftImage the top left image of the border + * @param leftImage the left image of the border + * @param topImage the top image of the border + * @param topRightImage the top right image of the border + * @param rightImage the right image of the border + * @param bottomLeftImage the bottom left image of the border + * @param bottomImage the bottom image of the border + * @param bottomRightImage the bottom right image of the border + */ + CornerImages(Glib::RefPtr topLeftImage, + Glib::RefPtr leftImage, + Glib::RefPtr topImage, + Glib::RefPtr topRightImage, + Glib::RefPtr rightImage, + Glib::RefPtr bottomLeftImage, + Glib::RefPtr bottomImage, + Glib::RefPtr bottomRightImage) + throw () + { + this->topLeftImage = topLeftImage; + this->leftImage = leftImage; + this->topImage = topImage; + this->topRightImage = topRightImage; + this->rightImage = rightImage; + this->bottomLeftImage = bottomLeftImage; + this->bottomImage = bottomImage; + this->bottomRightImage = bottomRightImage; + } + + /** + * Constructor based on a path, where all the images can be loaded + * from. + * + * @param path the path where all the images can be loaded from. + */ + CornerImages(const std::string path) throw (); + + /** + * A virtual destructor, as this class has virtual functions. + */ + virtual + ~CornerImages(void) throw () + { + } + + +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace Widgets +} // namespace LiveSupport + +#endif // LiveSupport_Widgets_CornerImages_h + diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/WhiteWindow.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/WhiteWindow.h new file mode 100644 index 000000000..af4397c13 --- /dev/null +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/WhiteWindow.h @@ -0,0 +1,255 @@ +/*------------------------------------------------------------------------------ + + 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/WhiteWindow.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef LiveSupport_Widgets_WhiteWindow_h +#define LiveSupport_Widgets_WhiteWindow_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include +#include +#include +#include + +#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 container holding exactly one child, habing a light blue border to it. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + */ +class WhiteWindow : public Gtk::Window +{ + private: + /** + * The rounded container for the window. + */ + Ptr::Ref blueBin; + + /** + * The layout of the window. + */ + Ptr::Ref layout; + + /** + * The left alignment contaner for the title. + */ + Ptr::Ref titleAlignment; + + /** + * The title of the window. + */ + Ptr::Ref title; + + /** + * The right alignment contaner for the close button. + */ + Ptr::Ref closeButtonAlignment; + + /** + * The close button. + */ + Ptr::Ref closeButton; + + /** + * Just a container for the main content of the window. + */ + Ptr::Ref childContainer; + + /** + * The event handler for the title being clicked on. + * + * @param event the button click event. + * @return true if the the event was handled, false otherwise. + */ + bool + onTitleClicked(GdkEventButton * event) throw (); + + /** + * Signal handler for the close button clicked. + */ + virtual void + onCloseButtonClicked(void) throw (); + + /** + * Default constructor. + */ + WhiteWindow(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 (); + + + public: + /** + * Constructor. + * + * @param backgroundColor the RGB value for the background color. + * @param cornerImages the corner images. + */ + WhiteWindow(unsigned int backgroundColor, + Ptr::Ref cornerImages) + throw (); + + /** + * A virtual destructor. + */ + virtual + ~WhiteWindow(void) throw (); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace Widgets +} // namespace LiveSupport + +#endif // LiveSupport_Widgets_WhiteWindow_h + diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h index 963762028..511fe2270 100644 --- a/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $ ------------------------------------------------------------------------------*/ @@ -44,7 +44,9 @@ #include "LiveSupport/Core/Configurable.h" +#include "LiveSupport/Widgets/CornerImages.h" #include "LiveSupport/Widgets/Button.h" +#include "LiveSupport/Widgets/ImageButton.h" #include "LiveSupport/Widgets/BlueBin.h" @@ -80,11 +82,18 @@ using namespace LiveSupport::Core; * * * @author $Author: maroy $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class WidgetFactory : virtual public Configurable { + public: + /** + * The types of available buttons. + */ + typedef enum { deleteButton } ButtonType; + + private: /** * The name of the configuration XML elmenent used by this object. @@ -132,84 +141,19 @@ class WidgetFactory : Glib::RefPtr buttonRollImageRight; /** - * The top left image of the border for BlueBin. + * The corner images for the blue bin. */ - Glib::RefPtr blueBinTopLeftImage; + Ptr::Ref blueBinImages; /** - * The left image of the border for BlueBin. + * The corner images for the dark blue bin. */ - Glib::RefPtr blueBinLeftImage; + Ptr::Ref darkBlueBinImages; /** - * The top image of the border for BlueBin. + * The corner images for the white window. */ - Glib::RefPtr blueBinTopImage; - - /** - * The top right image of the border for BlueBin. - */ - Glib::RefPtr blueBinTopRightImage; - - /** - * The right image of the border for BlueBin. - */ - Glib::RefPtr blueBinRightImage; - - /** - * The bottom left image of the border for BlueBin. - */ - Glib::RefPtr blueBinBottomLeftImage; - - /** - * The bottom image of the border for BlueBin. - */ - Glib::RefPtr blueBinBottomImage; - - /** - * The bottom right image of the border for BlueBin. - */ - Glib::RefPtr blueBinBottomRightImage; - - /** - * The top left image of the border for dark BlueBin. - */ - Glib::RefPtr darkBlueBinTopLeftImage; - - /** - * The left image of the border for dark BlueBin. - */ - Glib::RefPtr darkBlueBinLeftImage; - - /** - * The top image of the border for dark BlueBin. - */ - Glib::RefPtr darkBlueBinTopImage; - - /** - * The top right image of the border for dark BlueBin. - */ - Glib::RefPtr darkBlueBinTopRightImage; - - /** - * The right image of the border for dark BlueBin. - */ - Glib::RefPtr darkBlueBinRightImage; - - /** - * The bottom left image of the border for dark BlueBin. - */ - Glib::RefPtr darkBlueBinBottomLeftImage; - - /** - * The bottom image of the border for dark BlueBin. - */ - Glib::RefPtr darkBlueBinBottomImage; - - /** - * The bottom right image of the border for dark BlueBin. - */ - Glib::RefPtr darkBlueBinBottomRightImage; + Ptr::Ref whiteWindowImages; /** * The default constructor. @@ -281,17 +225,40 @@ class WidgetFactory : Ptr