added WhiteWindow constructor for windows with image titles (instead of text);

changed Scratchpad window title to an image
This commit is contained in:
fgerlits 2005-04-11 15:58:59 +00:00
parent 2d4269991c
commit ae1989488c
5 changed files with 117 additions and 39 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.8 $ Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WhiteWindow.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WhiteWindow.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -71,7 +71,7 @@ using namespace LiveSupport::Core;
* A container holding exactly one child, habing a light blue border to it. * A container holding exactly one child, habing a light blue border to it.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.8 $ * @version $Revision: 1.9 $
*/ */
class WhiteWindow : public Gtk::Window class WhiteWindow : public Gtk::Window
{ {
@ -107,9 +107,9 @@ class WhiteWindow : public Gtk::Window
Gtk::Alignment * titleAlignment; Gtk::Alignment * titleAlignment;
/** /**
* The title of the window. * The title of the window (if it's of text type, otherwise 0).
*/ */
Gtk::Label * title; Gtk::Label * titleLabel;
/** /**
* The right alignment contaner for the close button. * The right alignment contaner for the close button.
@ -264,10 +264,37 @@ class WhiteWindow : public Gtk::Window
virtual GtkType virtual GtkType
child_type_vfunc() const throw (); child_type_vfunc() const throw ();
/**
* The common part of both constructors.
*
* @param backgroundColor the background color.
* @param cornerImages the corner images.
* @param resizable true if the user can resize the window.
*/
void
constructWindow(Colors::ColorName backgroundColor,
Ptr<CornerImages>::Ref cornerImages,
bool resizable = true)
throw ();
public: public:
/** /**
* Constructor. * Constructor for windows with image titles.
*
* @param title the title of the window.
* @param backgroundColor the background color.
* @param cornerImages the corner images.
* @param resizable true if the user can resize the window.
*/
WhiteWindow(WidgetFactory::ImageType title,
Colors::ColorName backgroundColor,
Ptr<CornerImages>::Ref cornerImages,
bool resizable = true)
throw ();
/**
* Constructor for windows with text titles.
* *
* @param title the title of the window. * @param title the title of the window.
* @param backgroundColor the background color. * @param backgroundColor the background color.

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.10 $ Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -87,7 +87,7 @@ using namespace LiveSupport::Core;
* </code></pre> * </code></pre>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.10 $ * @version $Revision: 1.11 $
*/ */
class WidgetFactory : class WidgetFactory :
virtual public Configurable virtual public Configurable
@ -105,6 +105,13 @@ class WidgetFactory :
smallPlayButton, smallPauseButton, smallStopButton } smallPlayButton, smallPauseButton, smallStopButton }
ImageButtonType; ImageButtonType;
/**
* The list of available miscellaneous images.
*/
typedef enum { resizeImage,
scratchpadWindowTitleImage }
ImageType;
private: private:
/** /**
@ -167,11 +174,6 @@ class WidgetFactory :
*/ */
Glib::RefPtr<Gdk::Pixbuf> comboBoxRightImage; Glib::RefPtr<Gdk::Pixbuf> comboBoxRightImage;
/**
* The image for the resize handle.
*/
Glib::RefPtr<Gdk::Pixbuf> resizeImage;
/** /**
* The default constructor. * The default constructor.
*/ */
@ -311,14 +313,14 @@ class WidgetFactory :
} }
/** /**
* Create and return a container holding a resize image. * Create and return a container holding an image.
* It is the reponsibility of the caller to dispose of the created * It is the reponsibility of the caller to dispose of the created
* object properly. * object properly.
* *
* @return the container holding the resize image. * @return the container holding the requested image.
*/ */
Gtk::Image * Gtk::Image *
createResizeImage(void) throw (); createImage(ImageType imageName) throw ();
/** /**
* Create and return a ZebraTreeView instance. * Create and return a ZebraTreeView instance.

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.9 $ Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WhiteWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WhiteWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -54,7 +54,27 @@ using namespace LiveSupport::Widgets;
/* ============================================================= module code */ /* ============================================================= module code */
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Constructor. * Constructor for windows with image titles.
*----------------------------------------------------------------------------*/
WhiteWindow :: WhiteWindow(WidgetFactory::ImageType title,
Colors::ColorName backgroundColor,
Ptr<CornerImages>::Ref cornerImages,
bool resizable)
throw ()
: Gtk::Window(Gtk::WINDOW_TOPLEVEL)
{
// do the image title-specific stuff
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
Gtk::Image* titleImage = Gtk::manage(wf->createImage(title));
titleEventBox = Gtk::manage(new Gtk::EventBox());
titleEventBox->add(*titleImage);
constructWindow(backgroundColor, cornerImages, resizable);
}
/*------------------------------------------------------------------------------
* Constructor for windows with text titles.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
WhiteWindow :: WhiteWindow(Glib::ustring title, WhiteWindow :: WhiteWindow(Glib::ustring title,
Colors::ColorName backgroundColor, Colors::ColorName backgroundColor,
@ -62,6 +82,25 @@ WhiteWindow :: WhiteWindow(Glib::ustring title,
bool resizable) bool resizable)
throw () throw ()
: Gtk::Window(Gtk::WINDOW_TOPLEVEL) : Gtk::Window(Gtk::WINDOW_TOPLEVEL)
{
// do the text title-specific stuff
titleLabel = Gtk::manage(new Gtk::Label(title));
titleLabel->modify_font(Pango::FontDescription("Bitstream Vera 10"));
titleEventBox = Gtk::manage(new Gtk::EventBox());
titleEventBox->add(*titleLabel);
constructWindow(backgroundColor, cornerImages, resizable);
}
/*------------------------------------------------------------------------------
* The common part of both constructors.
*----------------------------------------------------------------------------*/
void
WhiteWindow :: constructWindow(Colors::ColorName backgroundColor,
Ptr<CornerImages>::Ref cornerImages,
bool resizable)
throw ()
{ {
set_decorated(false); set_decorated(false);
defaultWidth = -1; defaultWidth = -1;
@ -74,18 +113,13 @@ WhiteWindow :: WhiteWindow(Glib::ustring title,
// create the background color, as it is needed by the event box // create the background color, as it is needed by the event box
Gdk::Color bgColor = Colors::getColor(backgroundColor); Gdk::Color bgColor = Colors::getColor(backgroundColor);
// set the window title // create the title
this->title = Gtk::manage(new Gtk::Label(title)); titleEventBox->modify_bg(Gtk::STATE_NORMAL, bgColor);
this->title->modify_font(Pango::FontDescription("Bitstream Vera 10"));
titleAlignment = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_LEFT, titleAlignment = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_LEFT,
Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER,
0, 0)); 0, 0));
titleEventBox = Gtk::manage(new Gtk::EventBox()); titleAlignment->add(*titleEventBox);
titleEventBox->set_visible_window(); layout->attach(*titleAlignment, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK);
titleEventBox->modify_bg(Gtk::STATE_NORMAL, bgColor);
titleAlignment->add(*this->title);
titleEventBox->add(*titleAlignment);
layout->attach(*titleEventBox, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK);
// create the close button // create the close button
closeButton = Gtk::manage(wf->createButton(WidgetFactory::deleteButton)); closeButton = Gtk::manage(wf->createButton(WidgetFactory::deleteButton));
@ -101,7 +135,7 @@ WhiteWindow :: WhiteWindow(Glib::ustring title,
// create the resize image // create the resize image
if (resizable) { if (resizable) {
resizeImage = Gtk::manage(wf->createResizeImage()); resizeImage = Gtk::manage(wf->createImage(WidgetFactory::resizeImage));
resizeEventBox = Gtk::manage(new Gtk::EventBox()); resizeEventBox = Gtk::manage(new Gtk::EventBox());
resizeEventBox->modify_bg(Gtk::STATE_NORMAL, bgColor); resizeEventBox->modify_bg(Gtk::STATE_NORMAL, bgColor);
resizeEventBox->add(*resizeImage); resizeEventBox->add(*resizeImage);
@ -309,7 +343,7 @@ WhiteWindow :: onCloseButtonClicked (void) throw ()
void void
WhiteWindow :: set_title(const Glib::ustring & title) throw () WhiteWindow :: set_title(const Glib::ustring & title) throw ()
{ {
this->title->set_label(title); titleLabel->set_label(title);
} }
@ -319,7 +353,7 @@ WhiteWindow :: set_title(const Glib::ustring & title) throw ()
Glib::ustring Glib::ustring
WhiteWindow :: get_title(void) const throw () WhiteWindow :: get_title(void) const throw ()
{ {
return title->get_label(); titleLabel->get_label();
} }

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.12 $ Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -156,7 +156,13 @@ static const std::string comboBoxRightName = "combo/right.png";
/** /**
* The name of the image for the resize handle. * The name of the image for the resize handle.
*/ */
static const std::string resizeName = "whiteWindow/resize.png"; static const std::string resizeImageName = "whiteWindow/resize.png";
/**
* The name of the image for the title of the login window.
*/
static const std::string scratchpadWindowTitleImageName
= "titleImages/scratchpadWindowTitle.png";
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -215,9 +221,6 @@ WidgetFactory :: configure(const xmlpp::Element & element)
// load the white window corner images // load the white window corner images
whiteWindowImages.reset(new CornerImages(path + whiteWindowPath)); whiteWindowImages.reset(new CornerImages(path + whiteWindowPath));
// load the bottom right resize image
resizeImage = loadImage(resizeName);
} }
@ -342,9 +345,22 @@ WidgetFactory :: createButton(ImageButtonType type) throw ()
* Create a resize image * Create a resize image
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Gtk::Image * Gtk::Image *
WidgetFactory :: createResizeImage(void) throw () WidgetFactory :: createImage(ImageType imageName) throw ()
{ {
return new Gtk::Image(resizeImage); Glib::RefPtr<Gdk::Pixbuf> rawImage;
switch (imageName) {
case resizeImage:
rawImage = loadImage(resizeImageName);
break;
case scratchpadWindowTitleImage:
rawImage = loadImage(scratchpadWindowTitleImageName);
break;
default:
return 0;
}
return new Gtk::Image(rawImage);
} }

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.2 $ Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -64,7 +64,7 @@ using namespace LiveSupport::GLiveSupport;
ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport, ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle)
throw () throw ()
: WhiteWindow("", : WhiteWindow(WidgetFactory::scratchpadWindowTitleImage,
Colors::White, Colors::White,
WidgetFactory::getInstance()->getWhiteWindowCorners()), WidgetFactory::getInstance()->getWhiteWindowCorners()),
LocalizedObject(bundle) LocalizedObject(bundle)
@ -74,7 +74,6 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance(); Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
try { try {
set_title(*getResourceUstring("windowTitle"));
playButton = Gtk::manage(widgetFactory->createButton( playButton = Gtk::manage(widgetFactory->createButton(
WidgetFactory::smallPlayButton)); WidgetFactory::smallPlayButton));
pauseButton = Gtk::manage(widgetFactory->createButton( pauseButton = Gtk::manage(widgetFactory->createButton(