2009-11-15 13:54:31 -08:00
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
#include <ecorexx/Ecorexx.h>
|
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
typedef struct _MyProgressbar
|
2009-11-15 13:54:31 -08:00
|
|
|
{
|
2009-11-30 15:31:37 -08:00
|
|
|
Progressbar *pb1;
|
|
|
|
Progressbar *pb2;
|
|
|
|
Progressbar *pb3;
|
|
|
|
Progressbar *pb4;
|
|
|
|
Progressbar *pb5;
|
|
|
|
Progressbar *pb6;
|
|
|
|
Progressbar *pb7;
|
2009-11-15 13:54:31 -08:00
|
|
|
bool run;
|
2009-11-30 15:31:37 -08:00
|
|
|
Ecorexx::Timer *timer;
|
|
|
|
} MyProgressbar;
|
2009-11-15 13:54:31 -08:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
static MyProgressbar _test_progressbar;
|
2009-11-15 13:54:31 -08:00
|
|
|
|
2011-03-06 00:33:13 -08:00
|
|
|
static void _my_progressbar_value_set ()
|
2009-11-15 13:54:31 -08:00
|
|
|
{
|
|
|
|
double progress;
|
|
|
|
|
|
|
|
progress = _test_progressbar.pb1->getValue ();
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-15 13:54:31 -08:00
|
|
|
if (progress < 1.0)
|
|
|
|
{
|
|
|
|
progress += 0.0123;
|
|
|
|
}
|
2011-04-13 06:25:55 -07:00
|
|
|
else
|
2009-11-15 13:54:31 -08:00
|
|
|
{
|
|
|
|
progress = 0.0;
|
|
|
|
}
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-15 13:54:31 -08:00
|
|
|
_test_progressbar.pb1->setValue (progress);
|
|
|
|
_test_progressbar.pb4->setValue (progress);
|
|
|
|
_test_progressbar.pb3->setValue (progress);
|
|
|
|
_test_progressbar.pb6->setValue (progress);
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-17 14:17:37 -08:00
|
|
|
if (progress > 1.0)
|
2009-11-15 13:54:31 -08:00
|
|
|
{
|
2009-11-17 14:17:37 -08:00
|
|
|
_test_progressbar.run = false;
|
2011-03-06 00:33:13 -08:00
|
|
|
//timer->del ();
|
|
|
|
// FIXME: new design offern no timers pointer!
|
2009-11-15 13:54:31 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-31 14:35:16 -07:00
|
|
|
static void my_progressbar_test_start (Evasxx::Object &obj, void *event_info)
|
2009-11-15 13:54:31 -08:00
|
|
|
{
|
|
|
|
_test_progressbar.pb2->pulse (true);
|
|
|
|
_test_progressbar.pb5->pulse (true);
|
|
|
|
_test_progressbar.pb7->pulse (true);
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-15 13:54:31 -08:00
|
|
|
if (!_test_progressbar.run)
|
|
|
|
{
|
2009-11-30 15:31:37 -08:00
|
|
|
_test_progressbar.timer = new Ecorexx::Timer (0.1);
|
2009-11-17 14:17:37 -08:00
|
|
|
_test_progressbar.timer->timeout.connect (sigc::ptr_fun (&_my_progressbar_value_set));
|
2009-11-15 13:54:31 -08:00
|
|
|
_test_progressbar.run = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-31 14:35:16 -07:00
|
|
|
static void _test_stop ()
|
2009-11-15 13:54:31 -08:00
|
|
|
{
|
|
|
|
_test_progressbar.pb2->pulse (false);
|
|
|
|
_test_progressbar.pb5->pulse (false);
|
|
|
|
_test_progressbar.pb7->pulse (false);
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-15 13:54:31 -08:00
|
|
|
if (_test_progressbar.run)
|
|
|
|
{
|
2009-11-17 14:17:37 -08:00
|
|
|
_test_progressbar.timer->del ();
|
2009-11-15 13:54:31 -08:00
|
|
|
_test_progressbar.run = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-31 14:35:16 -07:00
|
|
|
static void my_progressbar_test_stop (Evasxx::Object &obj, void *event_info)
|
2009-11-15 13:54:31 -08:00
|
|
|
{
|
2010-05-31 14:35:16 -07:00
|
|
|
_test_stop ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void my_progressbar_destroy (Evasxx::Object &obj, void *event_info)
|
|
|
|
{
|
|
|
|
_test_stop ();
|
|
|
|
delete &obj;
|
2009-11-15 13:54:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_progressbar(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2009-11-30 15:31:37 -08:00
|
|
|
Progressbar *pb = NULL;
|
|
|
|
Icon *ic1 = NULL;
|
|
|
|
Icon *ic2 = NULL;
|
|
|
|
Button *bt = NULL;
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-15 13:54:31 -08:00
|
|
|
// start in stop mode
|
|
|
|
_test_progressbar.run = false;
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
Window *win = Window::factory ("progressbar", ELM_WIN_BASIC);
|
2009-11-15 13:54:31 -08:00
|
|
|
win->setTitle ("Progressbar");
|
2009-11-15 14:06:19 -08:00
|
|
|
win->getEventSignal ("delete,request")->connect (sigc::ptr_fun (&my_progressbar_destroy));
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
Background *bg = Background::factory (*win);
|
2009-11-15 13:54:31 -08:00
|
|
|
win->addObjectResize (*bg);
|
|
|
|
bg->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
bg->show ();
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
Box *bx = Box::factory (*win);
|
2009-11-15 13:54:31 -08:00
|
|
|
win->addObjectResize (*bx);
|
|
|
|
bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
bx->show ();
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
pb = Progressbar::factory (*win);
|
2009-11-15 13:54:31 -08:00
|
|
|
pb->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
pb->setAlignHintSize (EVAS_HINT_FILL, 0.5);
|
|
|
|
bx->packEnd (*pb);
|
|
|
|
pb->show ();
|
|
|
|
_test_progressbar.pb1 = pb;
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
pb = Progressbar::factory (*win);
|
2009-11-15 13:54:31 -08:00
|
|
|
pb->setAlignHintSize (EVAS_HINT_FILL, 0.5);
|
|
|
|
pb->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
pb->setLabel ("Infinite bounce");
|
|
|
|
pb->setPulse (true);
|
|
|
|
bx->packEnd (*pb);
|
|
|
|
pb->show ();
|
|
|
|
_test_progressbar.pb2 = pb;
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
ic1 = Icon::factory (*win);
|
2009-11-15 13:54:31 -08:00
|
|
|
ic1->setFile (searchPixmapFile ("elementaryxx/logo_small.png"));
|
|
|
|
ic1->setAspectHintSize (EVAS_ASPECT_CONTROL_VERTICAL, Size (1, 1));
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
pb = Progressbar::factory (*win);
|
2009-11-15 13:54:31 -08:00
|
|
|
pb->setLabel ("Label");
|
|
|
|
pb->setIcon (*ic1);
|
|
|
|
pb->setInverted (true);
|
|
|
|
pb->setUnitFormat ("%1.1f units");
|
|
|
|
pb->setSpanSize (200);
|
|
|
|
pb->setAlignHintSize (EVAS_HINT_FILL, 0.5);
|
|
|
|
pb->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
bx->packEnd (*pb);
|
|
|
|
ic1->show ();
|
|
|
|
pb->show ();
|
|
|
|
_test_progressbar.pb3 = pb;
|
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
Box *hbx = Box::factory (*win);
|
|
|
|
hbx->setOrientation (Box::Horizontal);
|
2009-11-15 13:54:31 -08:00
|
|
|
hbx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
hbx->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
bx->packEnd (*hbx);
|
|
|
|
hbx->show ();
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
pb = Progressbar::factory (*win);
|
|
|
|
pb->setOrientation (Progressbar::Vertical);
|
2009-11-15 13:54:31 -08:00
|
|
|
pb->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
pb->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
hbx->packEnd (*pb);
|
|
|
|
pb->setSpanSize (60);
|
|
|
|
pb->setLabel ("percent");
|
|
|
|
pb->show ();
|
|
|
|
_test_progressbar.pb4 = pb;
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
pb = Progressbar::factory (*win);
|
|
|
|
pb->setOrientation (Progressbar::Vertical);
|
2009-11-15 13:54:31 -08:00
|
|
|
pb->setAlignHintSize (EVAS_HINT_FILL, 0.5);
|
|
|
|
pb->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
pb->setSpanSize (80);
|
2009-11-15 14:06:19 -08:00
|
|
|
pb->hideUnitFormat ();
|
2009-11-15 13:54:31 -08:00
|
|
|
pb->setLabel ("Infinite bounce");
|
|
|
|
hbx->packEnd (*pb);
|
|
|
|
pb->show ();
|
|
|
|
_test_progressbar.pb5 = pb;
|
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
ic2 = Icon::factory (*win);
|
2009-11-15 13:54:31 -08:00
|
|
|
ic2->setFile (searchPixmapFile ("elementaryxx/logo_small.png"));
|
|
|
|
ic2->setAspectHintSize (EVAS_ASPECT_CONTROL_HORIZONTAL, Size (1, 1));
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
pb = Progressbar::factory (*win);
|
|
|
|
pb->setOrientation (Progressbar::Vertical);
|
2009-11-15 13:54:31 -08:00
|
|
|
pb->setLabel ("Label");
|
|
|
|
pb->setIcon (*ic2);
|
|
|
|
pb->setInverted (true);
|
|
|
|
pb->setUnitFormat ("%1.2f%%");
|
|
|
|
pb->setSpanSize (200);
|
|
|
|
pb->setAlignHintSize (EVAS_HINT_FILL, 0.5);
|
|
|
|
pb->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
hbx->packEnd (*pb);
|
|
|
|
pb->show ();
|
|
|
|
_test_progressbar.pb6 = pb;
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
pb = Progressbar::factory (*win);
|
2009-11-15 13:54:31 -08:00
|
|
|
pb->setStyle ("wheel");
|
|
|
|
pb->setLabel ("Style: wheel");
|
|
|
|
pb->setAlignHintSize (EVAS_HINT_FILL, 0.5);
|
|
|
|
pb->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
bx->packEnd (*pb);
|
|
|
|
pb->show ();
|
|
|
|
_test_progressbar.pb7 = pb;
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
Box *bt_bx = Box::factory (*win);
|
|
|
|
bt_bx->setOrientation (Box::Horizontal);
|
2009-11-15 13:54:31 -08:00
|
|
|
bt_bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
bx->packEnd (*bt_bx);
|
|
|
|
bt_bx->show ();
|
2011-04-13 06:25:55 -07:00
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
bt = Button::factory (*win);
|
2009-11-15 13:54:31 -08:00
|
|
|
bt->setLabel ("Start");
|
|
|
|
bt->getEventSignal ("clicked")->connect (sigc::ptr_fun (&my_progressbar_test_start));
|
|
|
|
bt_bx->packEnd (*bt);
|
|
|
|
bt->show ();
|
|
|
|
|
2009-11-30 15:31:37 -08:00
|
|
|
bt = Button::factory (*win);
|
2009-11-15 13:54:31 -08:00
|
|
|
bt->setLabel ("Stop");
|
|
|
|
bt->getEventSignal ("clicked")->connect (sigc::ptr_fun (&my_progressbar_test_stop));
|
|
|
|
bt_bx->packEnd (*bt);
|
|
|
|
bt->show ();
|
|
|
|
|
|
|
|
win->show ();
|
|
|
|
}
|