tasn pushed a commit to branch master.

http://git.enlightenment.org/bindings/cxx/eflxx.git/commit/?id=457cc83cbb5897b38834b025b363822433465fff

commit 457cc83cbb5897b38834b025b363822433465fff
Author: Andreas Volz <li...@brachttal.net>
Date:   Sun Nov 15 21:54:31 2009 +0000

    test for progressbar added
    
    
    SVN revision: 43719
---
 eflxx_examples/src/elementaryxx/full/Makefile.am   |   9 +-
 eflxx_examples/src/elementaryxx/full/main.cpp      |   8 +-
 .../src/elementaryxx/full/test_progressbar.cpp     | 214 +++++++++++++++++++++
 3 files changed, 225 insertions(+), 6 deletions(-)

diff --git a/eflxx_examples/src/elementaryxx/full/Makefile.am 
b/eflxx_examples/src/elementaryxx/full/Makefile.am
index 46a06a2..36f2c80 100644
--- a/eflxx_examples/src/elementaryxx/full/Makefile.am
+++ b/eflxx_examples/src/elementaryxx/full/Makefile.am
@@ -20,17 +20,20 @@ elementaryxx_example_full_SOURCES = \
        test_check.cpp                   \
        test_radio.cpp                   \
        test_spinner.cpp                   \
-       test_panel.cpp
+       test_panel.cpp                   \
+       test_progressbar.cpp
 
 elementaryxx_example_full_LDADD = \
        $(ELEMENTARYXX_LIBS) \
-       $(PACKAGE_SOURCE_DIR)/src/common/libeflxx_example_common.la
+       $(PACKAGE_SOURCE_DIR)/src/common/libeflxx_example_common.la \
+       $(ECOREXX_LIBS)
 
 elementaryxx_example_full_DEPENDENCIES = \
        $(PACKAGE_SOURCE_DIR)/src/common/libeflxx_example_common.la
 
 AM_CPPFLAGS = \
-       $(ELEMENTARYXX_CFLAGS)
+       $(ELEMENTARYXX_CFLAGS)\
+       $(ECOREXX_CFLAGS)
 
 ## File created by the gnome-build tools
 
diff --git a/eflxx_examples/src/elementaryxx/full/main.cpp 
b/eflxx_examples/src/elementaryxx/full/main.cpp
index 4d352fd..ed9ee68 100644
--- a/eflxx_examples/src/elementaryxx/full/main.cpp
+++ b/eflxx_examples/src/elementaryxx/full/main.cpp
@@ -49,8 +49,9 @@ void test_genlist6(void *data, Evas_Object *obj, void 
*event_info);*/
 void test_table(void *data, Evas_Object *obj, void *event_info);
 /*void test_pager(void *data, Evas_Object *obj, void *event_info);
 void test_win_state(void *data, Evas_Object *obj, void *event_info);
+*/
 void test_progressbar(void *data, Evas_Object *obj, void *event_info);
-void test_fileselector(void *data, Evas_Object *obj, void *event_info);
+/*void test_fileselector(void *data, Evas_Object *obj, void *event_info);
 void test_separator(void *data, Evas_Object *obj, void *event_info);*/
 void test_scroller(void *data, Evas_Object *obj, void *event_info);
 void test_spinner(void *data, Evas_Object *obj, void *event_info);
@@ -191,8 +192,9 @@ int main (int argc, char **argv)
   li.append("Genlist Tree", NULL, NULL, my_bt_36, NULL);
   li.append("Genlist 5", NULL, NULL, my_bt_37, NULL);
   li.append("Window States", NULL, NULL, my_bt_38, NULL);
-   
-  elm_list_item_append(li, "Progressbar", NULL, NULL, test_progressbar, NULL);
+  */
+  li->append ("Progressbar", test_progressbar, NULL);
+  /*
   elm_list_item_append(li, "File Selector", NULL, NULL, test_fileselector, 
NULL);
   elm_list_item_append(li, "Separator", NULL, NULL, test_separator, NULL);
   elm_list_item_append(li, "Scroller", NULL, NULL, test_scroller, NULL);
diff --git a/eflxx_examples/src/elementaryxx/full/test_progressbar.cpp 
b/eflxx_examples/src/elementaryxx/full/test_progressbar.cpp
new file mode 100644
index 0000000..c4af483
--- /dev/null
+++ b/eflxx_examples/src/elementaryxx/full/test_progressbar.cpp
@@ -0,0 +1,214 @@
+#include "test.h"
+
+#include <ecorexx/Ecorexx.h>
+
+typedef struct Progressbar
+{
+  ElmProgressbar *pb1;
+  ElmProgressbar *pb2;
+  ElmProgressbar *pb3;
+  ElmProgressbar *pb4;
+  ElmProgressbar *pb5;
+  ElmProgressbar *pb6;
+  ElmProgressbar *pb7;
+  bool run;
+  Ecore_Timer *timer; // TODO: port to EcoreTimer
+} Progressbar;
+
+static Progressbar _test_progressbar;
+
+static int _my_progressbar_value_set (void *data)
+{
+  double progress;
+
+  progress = _test_progressbar.pb1->getValue ();
+  
+  if (progress < 1.0)
+  {
+    progress += 0.0123;
+  }
+  else 
+  {
+    progress = 0.0;
+  }
+  
+  
+  _test_progressbar.pb1->setValue (progress);
+  _test_progressbar.pb4->setValue (progress);
+  _test_progressbar.pb3->setValue (progress);
+  _test_progressbar.pb6->setValue (progress);
+  
+  if (progress < 1.0)
+  {
+    return ECORE_CALLBACK_RENEW;
+  }
+  
+  _test_progressbar.run = false;
+
+  return ECORE_CALLBACK_CANCEL;
+}
+
+static void my_progressbar_test_start (Evas_Object *obj, void *event_info)
+{
+  _test_progressbar.pb2->pulse (true);
+  _test_progressbar.pb5->pulse (true);
+  _test_progressbar.pb7->pulse (true);
+  
+  if (!_test_progressbar.run)
+  {
+    _test_progressbar.timer = ecore_timer_add (0.1, _my_progressbar_value_set, 
NULL);
+    _test_progressbar.run = true;
+  }
+}
+
+static void my_progressbar_test_stop (Evas_Object *obj, void *event_info)
+{
+  _test_progressbar.pb2->pulse (false);
+  _test_progressbar.pb5->pulse (false);
+  _test_progressbar.pb7->pulse (false);
+   
+  if (_test_progressbar.run)
+  {
+     ecore_timer_del(_test_progressbar.timer);
+     _test_progressbar.run = false;
+  }
+}
+
+static void my_progressbar_destroy (Evas_Object *obj, void *event_info, void 
*data)
+{
+  my_progressbar_test_stop (NULL, NULL);
+  evas_object_del (obj);
+}
+
+void test_progressbar(void *data, Evas_Object *obj, void *event_info)
+{
+  Progressbar *test = NULL;
+  ElmProgressbar *pb = NULL;
+  ElmIcon *ic1 = NULL;
+  ElmIcon *ic2 = NULL;
+  ElmButton *bt = NULL;
+  
+  // start in stop mode
+  _test_progressbar.run = false;
+  
+  ElmWindow *win = ElmWindow::factory ("progressbar", ELM_WIN_BASIC);
+  win->setTitle ("Progressbar");
+  win->getEventSignal ("delete,request")->connect (sigc::bind (sigc::ptr_fun 
(&my_progressbar_destroy), test));
+  
+  ElmBackground *bg = ElmBackground::factory (*win);
+  win->addObjectResize (*bg);
+  bg->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  bg->show ();
+  
+  ElmBox *bx = ElmBox::factory (*win);
+  win->addObjectResize (*bx);
+  bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  bx->show ();
+  
+  pb = ElmProgressbar::factory (*win);
+  pb->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  pb->setAlignHintSize (EVAS_HINT_FILL, 0.5);
+  bx->packEnd (*pb);
+  pb->show ();
+  _test_progressbar.pb1 = pb;
+  
+  pb = ElmProgressbar::factory (*win);
+  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;
+  
+  ic1 = ElmIcon::factory (*win);
+  ic1->setFile (searchPixmapFile ("elementaryxx/logo_small.png"));
+  ic1->setAspectHintSize (EVAS_ASPECT_CONTROL_VERTICAL, Size (1, 1));
+  
+  pb = ElmProgressbar::factory (*win);
+  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;
+
+  ElmBox *hbx = ElmBox::factory (*win);
+  hbx->setHorizontal (true);
+  hbx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  hbx->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL);
+  bx->packEnd (*hbx);
+  hbx->show ();
+  
+  pb = ElmProgressbar::factory (*win);
+  pb->setHorizontal (false);
+  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;
+  
+  pb = ElmProgressbar::factory (*win);
+  pb->setHorizontal (false);
+  pb->setAlignHintSize (EVAS_HINT_FILL, 0.5);
+  pb->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  pb->setSpanSize (80);
+  //pb->setUnitFormat (NULL) // TODO: how to do this with std::string?
+  pb->setLabel ("Infinite bounce");
+  hbx->packEnd (*pb);
+  pb->show ();
+  _test_progressbar.pb5 = pb;
+
+  ic2 = ElmIcon::factory (*win);
+  ic2->setFile (searchPixmapFile ("elementaryxx/logo_small.png"));
+  ic2->setAspectHintSize (EVAS_ASPECT_CONTROL_HORIZONTAL, Size (1, 1));
+  
+  pb = ElmProgressbar::factory (*win);
+  pb->setHorizontal (false);
+  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;
+  
+  pb = ElmProgressbar::factory (*win);
+  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;
+  
+  ElmBox *bt_bx = ElmBox::factory (*win);
+  bt_bx->setHorizontal (true);
+  bt_bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+  bx->packEnd (*bt_bx);
+  bt_bx->show ();
+  
+  bt = ElmButton::factory (*win);
+  bt->setLabel ("Start");
+  bt->getEventSignal ("clicked")->connect (sigc::ptr_fun 
(&my_progressbar_test_start));
+  bt_bx->packEnd (*bt);
+  bt->show ();
+
+  bt = ElmButton::factory (*win);
+  bt->setLabel ("Stop");
+  bt->getEventSignal ("clicked")->connect (sigc::ptr_fun 
(&my_progressbar_test_stop));
+  bt_bx->packEnd (*bt);
+  bt->show ();
+
+  win->show ();
+}

-- 


Reply via email to