added resizing functionality to the WhiteWindow class

This commit is contained in:
fgerlits 2005-03-22 11:14:30 +00:00
parent 655dc8a9a0
commit 905552c619
5 changed files with 106 additions and 11 deletions

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.5 $
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WhiteWindow.h,v $
------------------------------------------------------------------------------*/
@ -44,6 +44,7 @@
#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"
@ -68,8 +69,8 @@ using namespace LiveSupport::Core;
/**
* A container holding exactly one child, habing a light blue border to it.
*
* @author $Author: maroy $
* @version $Revision: 1.5 $
* @author $Author: fgerlits $
* @version $Revision: 1.6 $
*/
class WhiteWindow : public Gtk::Window
{
@ -119,6 +120,21 @@ class WhiteWindow : public Gtk::Window
*/
ImageButton * closeButton;
/**
* The right alignment contaner for the resize image.
*/
Gtk::Alignment * resizeAlignment;
/**
* The event box container for the resize image.
*/
Gtk::EventBox * resizeEventBox;
/**
* The resize image.
*/
Gtk::Image * resizeImage;
/**
* Just a container for the main content of the window.
*/
@ -139,6 +155,15 @@ class WhiteWindow : public Gtk::Window
virtual void
onCloseButtonClicked(void) throw ();
/**
* The event handler for the resize being clicked on.
*
* @param event the button click event.
* @return true if the the event was handled, false otherwise.
*/
bool
onResizeClicked(GdkEventButton * event) throw ();
/**
* Default constructor.
*/

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/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $
------------------------------------------------------------------------------*/
@ -41,6 +41,7 @@
#endif
#include <stdexcept>
#include <gtkmm/image.h>
#include "LiveSupport/Core/Configurable.h"
@ -85,7 +86,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.8 $
* @version $Revision: 1.9 $
*/
class WidgetFactory :
virtual public Configurable
@ -165,6 +166,11 @@ class WidgetFactory :
*/
Glib::RefPtr<Gdk::Pixbuf> comboBoxRightImage;
/**
* The image for the resize handle.
*/
Glib::RefPtr<Gdk::Pixbuf> resizeImage;
/**
* The default constructor.
*/
@ -302,6 +308,16 @@ class WidgetFactory :
{
return whiteWindowImages;
}
/**
* Create and return a container holding a resize image.
* It is the reponsibility of the caller to dispose of the created
* object properly.
*
* @return the container holding the resize image.
*/
Gtk::Image *
createResizeImage(void) throw ();
};

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.1 $
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/CornerImages.cxx,v $
------------------------------------------------------------------------------*/
@ -124,6 +124,10 @@ CornerImages :: loadImage(const std::string path,
throw std::invalid_argument("Missing " + image);
}
// activate alpha channel (transparency)
// but it doesn't seem to work :(
// image->add_alpha(false, 0, 0, 0);
return image;
}

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.6 $
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WhiteWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -104,6 +104,17 @@ WhiteWindow :: WhiteWindow(Glib::ustring title,
childContainer = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_CENTER));
layout->attach(*childContainer, 0, 2, 1, 2);
// create the resize image
resizeImage = Gtk::manage(wf->createResizeImage());
resizeEventBox = Gtk::manage(new Gtk::EventBox());
resizeEventBox->modify_bg(Gtk::STATE_NORMAL, bgColor);
resizeEventBox->add(*resizeImage);
resizeAlignment = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_RIGHT,
Gtk::ALIGN_CENTER,
0, 0));
resizeAlignment->add(*resizeEventBox);
layout->attach(*resizeAlignment, 1, 2, 2, 3, Gtk::FILL, Gtk::SHRINK);
// add the corners
blueBin = Gtk::manage(new BlueBin(backgroundColor, cornerImages));
blueBin->add(*layout);
@ -120,6 +131,9 @@ WhiteWindow :: WhiteWindow(Glib::ustring title,
closeButton->signal_clicked().connect(sigc::mem_fun(*this,
&WhiteWindow::onCloseButtonClicked));
resizeEventBox->add_events(Gdk::BUTTON_PRESS_MASK);
resizeEventBox->signal_button_press_event().connect(sigc::mem_fun(*this,
&WhiteWindow::onResizeClicked));
}
@ -321,3 +335,21 @@ WhiteWindow :: set_default_size(int width,
defaultHeight = height;
}
/*------------------------------------------------------------------------------
* The event of the resize image being clicked
*----------------------------------------------------------------------------*/
bool
WhiteWindow :: onResizeClicked(GdkEventButton * event) throw ()
{
if (event->button == 1) {
begin_resize_drag(Gdk::WINDOW_EDGE_SOUTH_EAST,
event->button,
(int) event->x_root,
(int) event->y_root,
event->time);
}
return false;
}

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/src/WidgetFactory.cxx,v $
------------------------------------------------------------------------------*/
@ -152,6 +152,11 @@ static const std::string comboBoxCenterName = "combo/center.png";
*/
static const std::string comboBoxRightName = "combo/right.png";
/**
* The name of the image for the resize handle.
*/
static const std::string resizeName = "whiteWindow/resize.png";
/* =============================================== local function prototypes */
@ -209,6 +214,9 @@ WidgetFactory :: configure(const xmlpp::Element & element)
// load the white window corner images
whiteWindowImages.reset(new CornerImages(path + whiteWindowPath));
// load the bottom right resize image
resizeImage = loadImage(resizeName);
}
@ -328,3 +336,13 @@ WidgetFactory :: createButton(ImageButtonType type) throw ()
return new ImageButton(passiveImage, rollImage);
}
/*------------------------------------------------------------------------------
* Create a resize image
*----------------------------------------------------------------------------*/
Gtk::Image *
WidgetFactory :: createResizeImage(void) throw ()
{
return new Gtk::Image(resizeImage);
}