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
Author : $Author: maroy $
Version : $Revision: 1.12 $
Author : $Author: fgerlits $
Version : $Revision: 1.13 $
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 >
* </code></pre>
*
* @author $Author: maroy $
* @version $Revision: 1.12 $
* @author $Author: fgerlits $
* @version $Revision: 1.13 $
*/
class WidgetFactory :
virtual public Configurable
@ -103,7 +103,8 @@ class WidgetFactory :
*/
typedef enum { deleteButton,
smallPlayButton, smallPauseButton, smallStopButton,
hugePlayButton }
hugePlayButton,
cuePlayButton, cueStopButton }
ImageButtonType;
/**

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.14 $
Author : $Author: fgerlits $
Version : $Revision: 1.15 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -57,16 +57,24 @@ using namespace LiveSupport::Widgets;
* Constructor.
*----------------------------------------------------------------------------*/
TestWindow :: TestWindow (void)
throw ()
throw ()
: WhiteWindow("test window",
Colors::White,
WidgetFactory::getInstance()->getWhiteWindowCorners())
{
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
// init the imageButton
imageButton = Gtk::manage(
// init the imageButtons
hugeImageButton = Gtk::manage(
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
button = Gtk::manage(widgetFactory->createButton("Hello, World!"));
@ -93,19 +101,42 @@ TestWindow :: TestWindow (void)
// create and set up the layout
layout = Gtk::manage(new Gtk::Table());
layout->attach(*imageButton, 0, 1, 0, 1);
layout->attach(*notebook, 0, 1, 1, 2);
layout->attach(*hugeImageButton, 0, 1, 0, 1);
layout->attach(*cuePlayImageButton, 1, 2, 0, 1);
layout->attach(*notebook, 0, 2, 1, 2);
blueBin->add(*layout);
add(*blueBin);
show_all();
layout->attach(*cueStopImageButton, 1, 2, 0, 1);
}
/*------------------------------------------------------------------------------
* 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
Author : $Author: maroy $
Version : $Revision: 1.8 $
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
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.
*
* @author $Author: maroy $
* @version $Revision: 1.8 $
* @author $Author: fgerlits $
* @version $Revision: 1.9 $
*/
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:
/**
* The layout used in the window.
@ -88,9 +101,19 @@ class TestWindow : public WhiteWindow
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.

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.14 $
Author : $Author: fgerlits $
Version : $Revision: 1.15 $
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
= "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.
*/
@ -350,6 +374,16 @@ WidgetFactory :: createButton(ImageButtonType type) throw ()
rollImage = loadImage(hugePlayButtonRollName);
break;
case cuePlayButton:
passiveImage = loadImage(cuePlayButtonPassiveName);
rollImage = loadImage(cuePlayButtonRollName);
break;
case cueStopButton:
passiveImage = loadImage(cueStopButtonPassiveName);
rollImage = loadImage(cueStopButtonRollName);
break;
default:
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