# HG changeset patch
# User wycc
# Date 1233392043 -28800
# Node ID 22d771e1b7102444b51d4c748ec5465456ca6a11
# Parent 248a40d514734fe9db0a6035d49375d6b3e3326f
Add text program for text API
diff -r 248a40d51473 -r 22d771e1b710 examples/dynamic/mytext.svg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/dynamic/mytext.svg Sat Jan 31 16:54:03 2009 +0800
@@ -0,0 +1,105 @@
+
+
+
diff -r 248a40d51473 -r 22d771e1b710 examples/dynamic/text.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/dynamic/text.c Sat Jan 31 16:54:03 2009 +0800
@@ -0,0 +1,71 @@
+/*! \file
+ *
+ * svg2code_ex is an example that show programmers how to create a
+ * menu with MadButterfly.
+ *
+ */
+#include
+#include
+#include
+#include "menu.h"
+#include "mbapp.h"
+
+
+MBApp *myApp;
+
+typedef struct {
+ shape_t *rect;
+ co_aix orx,ory;
+ int start_x,start_y;
+ observer_t *obs1,*obs2;
+ int currentscene;
+}MyAppData;
+
+
+void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg)
+{
+ MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData );
+ mb_timeval_t timer,interval;
+ shape_t *text = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite,"mytext");
+
+
+ get_now(&timer);
+ MB_TIMEVAL_SET(&interval, 1 ,0);
+ MB_TIMEVAL_ADD(&timer, &interval);
+ mb_tman_timeout( MBApp_getTimer(myApp), &timer, switch_scene, myApp);
+
+ en->currentscene = (en->currentscene + 1) % 2;
+ printf("xxx\n");
+ if (en->currentscene == 0) {
+ sh_text_set_text(text,"This is 0");
+ } else {
+ sh_text_set_text(text,"This is 1");
+ }
+ rdman_shape_changed(MBAPP_RDMAN(myApp), text);
+ rdman_redraw_changed(MBAPP_RDMAN(myApp));
+}
+
+int main(int argc, char * const argv[]) {
+ subject_t *subject;
+ mb_button_t *b;
+ mb_obj_t *button;
+ MyAppData data;
+ mb_timeval_t tmo,interval;
+
+ if (argc > 1)
+ myApp = MBApp_Init(argv[1]);
+ else
+ myApp = MBApp_Init("mytext");
+ data.currentscene=0;
+ MBApp_setData(myApp,&data);
+ get_now(&tmo);
+ MB_TIMEVAL_SET(&interval, 1 ,0);
+ mb_tman_timeout( MBApp_getTimer(myApp), &tmo, switch_scene, myApp);
+
+
+ MBApp_loop(myApp);
+
+ return 0;
+}
+
+/* vim: set ts=4 */