added test for buttons with an image which changes when clicked

This commit is contained in:
fgerlits 2005-04-15 10:53:34 +00:00
parent 19da95806a
commit 68221f1548
8 changed files with 110 additions and 21 deletions

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.12 $ Version : $Revision: 1.13 $
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 $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -86,8 +86,8 @@ using namespace LiveSupport::Core;
* <!ATTLIST widgetFactory path CDATA #REQUIRED > * <!ATTLIST widgetFactory path CDATA #REQUIRED >
* </code></pre> * </code></pre>
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.12 $ * @version $Revision: 1.13 $
*/ */
class WidgetFactory : class WidgetFactory :
virtual public Configurable virtual public Configurable
@ -103,7 +103,8 @@ class WidgetFactory :
*/ */
typedef enum { deleteButton, typedef enum { deleteButton,
smallPlayButton, smallPauseButton, smallStopButton, smallPlayButton, smallPauseButton, smallStopButton,
hugePlayButton } hugePlayButton,
cuePlayButton, cueStopButton }
ImageButtonType; ImageButtonType;
/** /**

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.14 $ Version : $Revision: 1.15 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -57,16 +57,24 @@ using namespace LiveSupport::Widgets;
* Constructor. * Constructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
TestWindow :: TestWindow (void) TestWindow :: TestWindow (void)
throw () throw ()
: WhiteWindow("test window", : WhiteWindow("test window",
Colors::White, Colors::White,
WidgetFactory::getInstance()->getWhiteWindowCorners()) WidgetFactory::getInstance()->getWhiteWindowCorners())
{ {
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance(); Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
// init the imageButton // init the imageButtons
imageButton = Gtk::manage( hugeImageButton = Gtk::manage(
widgetFactory->createButton(WidgetFactory::hugePlayButton)); widgetFactory->createButton(WidgetFactory::hugePlayButton));
cuePlayImageButton = Gtk::manage(
widgetFactory->createButton(WidgetFactory::cuePlayButton));
cuePlayImageButton->signal_clicked().connect(sigc::mem_fun(*this,
&TestWindow::onPlayButtonPressed));
cueStopImageButton = Gtk::manage(
widgetFactory->createButton(WidgetFactory::cueStopButton));
cueStopImageButton->signal_clicked().connect(sigc::mem_fun(*this,
&TestWindow::onStopButtonPressed));
// create a button // create a button
button = Gtk::manage(widgetFactory->createButton("Hello, World!")); button = Gtk::manage(widgetFactory->createButton("Hello, World!"));
@ -93,19 +101,42 @@ TestWindow :: TestWindow (void)
// create and set up the layout // create and set up the layout
layout = Gtk::manage(new Gtk::Table()); layout = Gtk::manage(new Gtk::Table());
layout->attach(*imageButton, 0, 1, 0, 1); layout->attach(*hugeImageButton, 0, 1, 0, 1);
layout->attach(*notebook, 0, 1, 1, 2); layout->attach(*cuePlayImageButton, 1, 2, 0, 1);
layout->attach(*notebook, 0, 2, 1, 2);
blueBin->add(*layout); blueBin->add(*layout);
add(*blueBin); add(*blueBin);
show_all(); show_all();
layout->attach(*cueStopImageButton, 1, 2, 0, 1);
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Destructor. * Destructor.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
TestWindow :: ~TestWindow (void) throw () TestWindow :: ~TestWindow (void) throw ()
{ {
} }
/*------------------------------------------------------------------------------
* Change the image from "play" to "stop" on the button when pressed.
*----------------------------------------------------------------------------*/
void
TestWindow :: onPlayButtonPressed(void) throw ()
{
cuePlayImageButton->hide();
cueStopImageButton->show();
}
/*------------------------------------------------------------------------------
* Change the image from "stop" to "play" on the button when pressed.
*----------------------------------------------------------------------------*/
void
TestWindow :: onStopButtonPressed(void) throw ()
{
cueStopImageButton->hide();
cuePlayImageButton->show();
}

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.8 $ Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -71,11 +71,24 @@ using namespace LiveSupport::Core;
/** /**
* A window, enabling interactive testing of UI components. * A window, enabling interactive testing of UI components.
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.8 $ * @version $Revision: 1.9 $
*/ */
class TestWindow : public WhiteWindow class TestWindow : public WhiteWindow
{ {
private:
/**
* Change the image from "play" to "stop" on the button when pressed.
*/
void
onPlayButtonPressed(void) throw ();
/**
* Change the image from "stop" to "play" on the button when pressed.
*/
void
onStopButtonPressed(void) throw ();
protected: protected:
/** /**
* The layout used in the window. * The layout used in the window.
@ -88,9 +101,19 @@ class TestWindow : public WhiteWindow
Notebook * notebook; Notebook * notebook;
/** /**
* An image button. * An image button with transparent background.
*/ */
ImageButton * imageButton; ImageButton * hugeImageButton;
/**
* A clickable image button showing a "play" icon.
*/
ImageButton * cuePlayImageButton;
/**
* A clickable image button showing a "stop" icon.
*/
ImageButton * cueStopImageButton;
/** /**
* A button. * A button.

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.14 $ Version : $Revision: 1.15 $
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 $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -150,6 +150,30 @@ static const std::string hugePlayButtonPassiveName
static const std::string hugePlayButtonRollName static const std::string hugePlayButtonRollName
= "imageButton/hugePlayRoll.png"; = "imageButton/hugePlayRoll.png";
/**
* The name of the passive image for the cue play button.
*/
static const std::string cuePlayButtonPassiveName
= "imageButton/cuePlay.png";
/**
* The name of the rollover image for the cue play button.
*/
static const std::string cuePlayButtonRollName
= "imageButton/cuePlayRoll.png";
/**
* The name of the passive image for the cue stop button.
*/
static const std::string cueStopButtonPassiveName
= "imageButton/cueStop.png";
/**
* The name of the rollover image for the cue stop button.
*/
static const std::string cueStopButtonRollName
= "imageButton/cueStopRoll.png";
/** /**
* The name of the combo box left image. * The name of the combo box left image.
*/ */
@ -350,6 +374,16 @@ WidgetFactory :: createButton(ImageButtonType type) throw ()
rollImage = loadImage(hugePlayButtonRollName); rollImage = loadImage(hugePlayButtonRollName);
break; break;
case cuePlayButton:
passiveImage = loadImage(cuePlayButtonPassiveName);
rollImage = loadImage(cuePlayButtonRollName);
break;
case cueStopButton:
passiveImage = loadImage(cueStopButtonPassiveName);
rollImage = loadImage(cueStopButtonRollName);
break;
default: default:
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB