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 $
Version : $Revision: 1.8 $
Version : $Revision: 1.9 $
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.
*
* @author $Author: fgerlits $
* @version $Revision: 1.8 $
* @version $Revision: 1.9 $
*/
class WhiteWindow : public Gtk::Window
{
@ -107,9 +107,9 @@ class WhiteWindow : public Gtk::Window
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.
@ -264,10 +264,37 @@ class WhiteWindow : public Gtk::Window
virtual GtkType
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:
/**
* 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 backgroundColor the background color.

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/include/LiveSupport/Widgets/WidgetFactory.h,v $
------------------------------------------------------------------------------*/
@ -87,7 +87,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.10 $
* @version $Revision: 1.11 $
*/
class WidgetFactory :
virtual public Configurable
@ -105,6 +105,13 @@ class WidgetFactory :
smallPlayButton, smallPauseButton, smallStopButton }
ImageButtonType;
/**
* The list of available miscellaneous images.
*/
typedef enum { resizeImage,
scratchpadWindowTitleImage }
ImageType;
private:
/**
@ -167,11 +174,6 @@ class WidgetFactory :
*/
Glib::RefPtr<Gdk::Pixbuf> comboBoxRightImage;
/**
* The image for the resize handle.
*/
Glib::RefPtr<Gdk::Pixbuf> resizeImage;
/**
* 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
* object properly.
*
* @return the container holding the resize image.
* @return the container holding the requested image.
*/
Gtk::Image *
createResizeImage(void) throw ();
createImage(ImageType imageName) throw ();
/**
* Create and return a ZebraTreeView instance.

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/WhiteWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -54,7 +54,27 @@ using namespace LiveSupport::Widgets;
/* ============================================================= 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,
Colors::ColorName backgroundColor,
@ -62,6 +82,25 @@ WhiteWindow :: WhiteWindow(Glib::ustring title,
bool resizable)
throw ()
: 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);
defaultWidth = -1;
@ -74,18 +113,13 @@ WhiteWindow :: WhiteWindow(Glib::ustring title,
// create the background color, as it is needed by the event box
Gdk::Color bgColor = Colors::getColor(backgroundColor);
// set the window title
this->title = Gtk::manage(new Gtk::Label(title));
this->title->modify_font(Pango::FontDescription("Bitstream Vera 10"));
// create the title
titleEventBox->modify_bg(Gtk::STATE_NORMAL, bgColor);
titleAlignment = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_LEFT,
Gtk::ALIGN_CENTER,
0, 0));
titleEventBox = Gtk::manage(new Gtk::EventBox());
titleEventBox->set_visible_window();
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);
titleAlignment->add(*titleEventBox);
layout->attach(*titleAlignment, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK);
// create the close button
closeButton = Gtk::manage(wf->createButton(WidgetFactory::deleteButton));
@ -101,7 +135,7 @@ WhiteWindow :: WhiteWindow(Glib::ustring title,
// create the resize image
if (resizable) {
resizeImage = Gtk::manage(wf->createResizeImage());
resizeImage = Gtk::manage(wf->createImage(WidgetFactory::resizeImage));
resizeEventBox = Gtk::manage(new Gtk::EventBox());
resizeEventBox->modify_bg(Gtk::STATE_NORMAL, bgColor);
resizeEventBox->add(*resizeImage);
@ -309,7 +343,7 @@ WhiteWindow :: onCloseButtonClicked (void) throw ()
void
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
WhiteWindow :: get_title(void) const throw ()
{
return title->get_label();
titleLabel->get_label();
}

View file

@ -22,7 +22,7 @@
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 $
------------------------------------------------------------------------------*/
@ -156,7 +156,13 @@ 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";
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 */
@ -215,9 +221,6 @@ 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);
}
@ -342,9 +345,22 @@ WidgetFactory :: createButton(ImageButtonType type) throw ()
* Create a resize 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 $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
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,
Ptr<ResourceBundle>::Ref bundle)
throw ()
: WhiteWindow("",
: WhiteWindow(WidgetFactory::scratchpadWindowTitleImage,
Colors::White,
WidgetFactory::getInstance()->getWhiteWindowCorners()),
LocalizedObject(bundle)
@ -74,7 +74,6 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
try {
set_title(*getResourceUstring("windowTitle"));
playButton = Gtk::manage(widgetFactory->createButton(
WidgetFactory::smallPlayButton));
pauseButton = Gtk::manage(widgetFactory->createButton(