comparison examples/dynamic/text.c @ 286:22d771e1b710

Add text program for text API
author wycc
date Sat, 31 Jan 2009 16:54:03 +0800
parents
children 13ce87b6dbf5
comparison
equal deleted inserted replaced
285:248a40d51473 286:22d771e1b710
1 /*! \file
2 *
3 * svg2code_ex is an example that show programmers how to create a
4 * menu with MadButterfly.
5 *
6 */
7 #include <stdio.h>
8 #include <mb.h>
9 #include <string.h>
10 #include "menu.h"
11 #include "mbapp.h"
12
13
14 MBApp *myApp;
15
16 typedef struct {
17 shape_t *rect;
18 co_aix orx,ory;
19 int start_x,start_y;
20 observer_t *obs1,*obs2;
21 int currentscene;
22 }MyAppData;
23
24
25 void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg)
26 {
27 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData );
28 mb_timeval_t timer,interval;
29 shape_t *text = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite,"mytext");
30
31
32 get_now(&timer);
33 MB_TIMEVAL_SET(&interval, 1 ,0);
34 MB_TIMEVAL_ADD(&timer, &interval);
35 mb_tman_timeout( MBApp_getTimer(myApp), &timer, switch_scene, myApp);
36
37 en->currentscene = (en->currentscene + 1) % 2;
38 printf("xxx\n");
39 if (en->currentscene == 0) {
40 sh_text_set_text(text,"This is 0");
41 } else {
42 sh_text_set_text(text,"This is 1");
43 }
44 rdman_shape_changed(MBAPP_RDMAN(myApp), text);
45 rdman_redraw_changed(MBAPP_RDMAN(myApp));
46 }
47
48 int main(int argc, char * const argv[]) {
49 subject_t *subject;
50 mb_button_t *b;
51 mb_obj_t *button;
52 MyAppData data;
53 mb_timeval_t tmo,interval;
54
55 if (argc > 1)
56 myApp = MBApp_Init(argv[1]);
57 else
58 myApp = MBApp_Init("mytext");
59 data.currentscene=0;
60 MBApp_setData(myApp,&data);
61 get_now(&tmo);
62 MB_TIMEVAL_SET(&interval, 1 ,0);
63 mb_tman_timeout( MBApp_getTimer(myApp), &tmo, switch_scene, myApp);
64
65
66 MBApp_loop(myApp);
67
68 return 0;
69 }
70
71 /* vim: set ts=4 */