a fix to issue #810

see http://bugs.campware.org/view.php?id=810
This commit is contained in:
maroy 2005-04-15 12:54:32 +00:00
parent a0d4eb8d8c
commit 47d6dc0ede
22 changed files with 1791 additions and 86 deletions

View file

@ -20,8 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Author : $Author: fgerlits $
# Version : $Revision: 1.12 $
# Author : $Author: maroy $
# Version : $Revision: 1.13 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/etc/Makefile.in,v $
#
# @configure_input@
@ -119,7 +119,8 @@ WIDGETS_LIB_OBJS = ${TMP_DIR}/ImageButton.o \
${TMP_DIR}/WidgetFactory.o \
${TMP_DIR}/ZebraTreeView.o \
${TMP_DIR}/ZebraCellRenderer.o \
${TMP_DIR}/Colors.o
${TMP_DIR}/Colors.o \
${TMP_DIR}/MessageWindow.o
TEST_EXE_OBJS = ${TMP_DIR}/TestWindow.o \
${TMP_DIR}/main.o

File diff suppressed because it is too large Load diff

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.10 $
Author : $Author: maroy $
Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WhiteWindow.h,v $
------------------------------------------------------------------------------*/
@ -69,10 +69,33 @@ using namespace LiveSupport::Core;
/* =============================================================== data types */
/**
* A container holding exactly one child, habing a light blue border to it.
* A container holding exactly one child, having a light blue border to it.
*
* @author $Author: fgerlits $
* @version $Revision: 1.10 $
* To create a white window, subclass your window class from WhiteWindow,
* and supply appropriate parameters to the WhiteWindow constructor,
* upon construction.
*
* For example:
* <code><pre>
* class MyWindow : public WhiteWindow
* {
* MyWindow(void);
* ...
* };
*
* MyWindow::MyWindow(void)
* : WhiteWindow("window title",
* Colors::White,
* WidgetFactory::getInstance()->getWhiteWindowCorners())
* {
* ...
* }
* </code></pre>
*
* @author $Author: maroy $
* @version $Revision: 1.11 $
* @see WidgetFactory
* @see WidgetFactory#getWhiteWindowCorners
*/
class WhiteWindow : public Gtk::Window
{

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.13 $
Author : $Author: maroy $
Version : $Revision: 1.14 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $
------------------------------------------------------------------------------*/
@ -68,6 +68,8 @@ using namespace LiveSupport::Core;
/* =============================================================== data types */
class WhiteWindow;
/**
* A factory to provide access to LiveSupport Widgets.
*
@ -86,8 +88,8 @@ using namespace LiveSupport::Core;
* <!ATTLIST widgetFactory path CDATA #REQUIRED >
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.13 $
* @author $Author: maroy $
* @version $Revision: 1.14 $
*/
class WidgetFactory :
virtual public Configurable
@ -334,6 +336,17 @@ class WidgetFactory :
ZebraTreeView *
createTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
throw ();
/**
* Create a window with a single line of text, and an OK button.
* Good for displaying error messages.
* It is the reponsibility of the caller to dispose of the created
* object properly.
*
* @param message the message to include in the window.
*/
WhiteWindow *
createMessageWindow(Ptr<Glib::ustring>::Ref message) throw ();
};

View file

@ -0,0 +1,99 @@
/*------------------------------------------------------------------------------
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/MessageWindow.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/Colors.h"
#include "MessageWindow.h"
using namespace LiveSupport::Widgets;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
MessageWindow :: MessageWindow (Ptr<Glib::ustring>::Ref message)
throw ()
: WhiteWindow(*message,
Colors::White,
WidgetFactory::getInstance()->getWhiteWindowCorners())
{
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
messageLabel = Gtk::manage(new Gtk::Label(*message));
// init the okButton
// TODO: localize the OK text on the button
okButton = Gtk::manage(widgetFactory->createButton("OK"));
okButton->signal_clicked().connect(sigc::mem_fun(*this,
&MessageWindow::onOkButtonClicked));
layout = Gtk::manage(new Gtk::VBox());
layout->pack_start(*messageLabel, true, true);
layout->pack_start(*okButton);
add(*layout);
show_all();
}
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
MessageWindow :: ~MessageWindow (void) throw ()
{
}
/*------------------------------------------------------------------------------
* Event handler for the OK button clicked
*----------------------------------------------------------------------------*/
void
MessageWindow :: onOkButtonClicked(void) throw ()
{
hide();
}

View file

@ -0,0 +1,121 @@
/*------------------------------------------------------------------------------
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/MessageWindow.h,v $
------------------------------------------------------------------------------*/
#ifndef MessageWindow_h
#define MessageWindow_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Widgets/WhiteWindow.h"
namespace LiveSupport {
namespace Widgets {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* A message window, displaying a single line of message, with an OK
* button.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
*/
class MessageWindow : public WhiteWindow
{
protected:
/**
* The vertical box holding the message and the button.
*/
Gtk::Box * layout;
/**
* The message.
*/
Gtk::Label * messageLabel;
/**
* The OK button.
*/
Button * okButton;
/**
* The event handler for the OK button clicked.
*/
virtual void
onOkButtonClicked(void) throw ();
public:
/**
* Constructor.
*
* @param message the message to display in the window
*/
MessageWindow(Ptr<Glib::ustring>::Ref message) throw ();
/**
* Virtual destructor.
*/
virtual
~MessageWindow(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Widgets
} // namespace LiveSupport
#endif // MessageWindow_h

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.15 $
Author : $Author: maroy $
Version : $Revision: 1.16 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -33,7 +33,7 @@
#include "configure.h"
#endif
#include <iostream>
#include <gtkmm/main.h>
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/Colors.h"
@ -78,6 +78,8 @@ TestWindow :: TestWindow (void)
// create a button
button = Gtk::manage(widgetFactory->createButton("Hello, World!"));
button->signal_clicked().connect(sigc::mem_fun(*this,
&TestWindow::onButtonClicked));
// create a combo box
comboBoxText = Gtk::manage(widgetFactory->createComboBoxText());
@ -119,6 +121,21 @@ TestWindow :: ~TestWindow (void) throw ()
}
/*------------------------------------------------------------------------------
* Event handler for the button being clicked.
*----------------------------------------------------------------------------*/
void
TestWindow :: onButtonClicked(void) throw ()
{
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
Ptr<Glib::ustring>::Ref message(new Glib::ustring("Hello, World!"));
WhiteWindow * helloWindow = wf->createMessageWindow(message);
Gtk::Main::run(*helloWindow);
delete helloWindow;
}
/*------------------------------------------------------------------------------
* Change the image from "play" to "stop" on the button when pressed.
*----------------------------------------------------------------------------*/

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Author : $Author: maroy $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.h,v $
------------------------------------------------------------------------------*/
@ -71,8 +71,8 @@ using namespace LiveSupport::Core;
/**
* A window, enabling interactive testing of UI components.
*
* @author $Author: fgerlits $
* @version $Revision: 1.9 $
* @author $Author: maroy $
* @version $Revision: 1.10 $
*/
class TestWindow : public WhiteWindow
{
@ -140,6 +140,12 @@ class TestWindow : public WhiteWindow
*/
BlueBin * blueBin;
/**
* Event handler for the button being clicked.
*/
virtual void
onButtonClicked(void) throw ();
public:
/**

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.12 $
Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WhiteWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -352,7 +352,7 @@ WhiteWindow :: set_title(const Glib::ustring & title) throw ()
Glib::ustring
WhiteWindow :: get_title(void) const throw ()
{
titleLabel->get_label();
return titleLabel->get_label();
}

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.15 $
Author : $Author: maroy $
Version : $Revision: 1.16 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $
------------------------------------------------------------------------------*/
@ -36,8 +36,9 @@
#include <gtkmm/entry.h>
#include "LiveSupport/Widgets/Colors.h"
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "MessageWindow.h"
using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
@ -425,3 +426,14 @@ WidgetFactory :: createTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
return new ZebraTreeView(treeModel);
}
/*------------------------------------------------------------------------------
* Create a message window.
*----------------------------------------------------------------------------*/
WhiteWindow *
WidgetFactory :: createMessageWindow(Ptr<Glib::ustring>::Ref message)
throw ()
{
return new MessageWindow(message);
}