Mercurial > MadButterfly
annotate examples/menu/main.c @ 296:2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
* Add appleTV style list demo. We need to add animation latter. It is staic for now.
author | wycc |
---|---|
date | Sun, 01 Feb 2009 16:28:28 +0800 |
parents | |
children | e885dc875f30 |
rev | line source |
---|---|
296
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
1 /*! \file |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
2 * |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
3 * This is the demo program for the animated menu. We will use to test the MBAF API. |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
4 */ |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
5 #include <stdio.h> |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
6 #include <mb.h> |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
7 #include <string.h> |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
8 #include "menu.h" |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
9 #include "mbapp.h" |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
10 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
11 char *menus[] = { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
12 "Item 1", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
13 "Item 2", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
14 "Item 3", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
15 "Item 4", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
16 "Item 5", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
17 "Item 6", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
18 "Item 7", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
19 "Item 8", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
20 "Item 9", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
21 "Item 10", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
22 "Item 11", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
23 "Item 12", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
24 "Item 13", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
25 "Item 14", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
26 "Item 15", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
27 "Item 16", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
28 "Item 17", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
29 "Item 18", |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
30 }; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
31 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
32 typedef struct { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
33 int top; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
34 int cur; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
35 int max; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
36 }MyAppData; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
37 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
38 MBApp *myApp; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
39 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
40 static void fillMenuContent() |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
41 { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
42 int i; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
43 MyAppData *data = MBAPP_DATA(myApp,MyAppData); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
44 mb_sprite_t *sprite=myApp->rootsprite; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
45 shape_t *text; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
46 coord_t *group; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
47 coord_t *lightbar; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
48 char name[255]; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
49 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
50 for(i=0;i<8;i++) { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
51 if (i+data->top > data->max) break; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
52 snprintf(name,sizeof(name),"item%dtext", i+1); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
53 text = (shape_t *) MB_SPRITE_GET_OBJ(sprite, name); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
54 if (text == NULL) { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
55 printf("Can not find object %s\n",name); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
56 continue; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
57 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
58 sh_text_set_text(text,menus[i+data->top]); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
59 rdman_shape_changed(MBAPP_RDMAN(myApp), text); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
60 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
61 for(;i<8;i++) { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
62 snprintf(name,sizeof(name),"item%dtext", i+1); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
63 text = (shape_t *) MB_SPRITE_GET_OBJ(sprite, name); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
64 if (text == NULL) { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
65 printf("Can not find object %s\n",name); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
66 continue; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
67 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
68 sh_text_set_text(text,""); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
69 rdman_shape_changed(MBAPP_RDMAN(myApp), text); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
70 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
71 lightbar = (coord_t *) MB_SPRITE_GET_OBJ(sprite, "lightbar"); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
72 snprintf(name,sizeof(name),"item%d", data->cur+1); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
73 group = (coord_t *) MB_SPRITE_GET_OBJ(sprite, name); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
74 coord_x(lightbar) = coord_x(group); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
75 coord_y(lightbar) = coord_y(group); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
76 rdman_coord_changed(MBAPP_RDMAN(myApp), lightbar); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
77 rdman_redraw_changed(MBAPP_RDMAN(myApp)); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
78 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
79 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
80 void menu_up() |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
81 { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
82 MyAppData *data = MBAPP_DATA(myApp,MyAppData); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
83 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
84 if (data->cur > 5) |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
85 data->cur--; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
86 else { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
87 if (data->top > 0) { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
88 data->top--; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
89 } else { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
90 if (data->cur == 0) |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
91 return; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
92 data->cur--; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
93 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
94 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
95 fillMenuContent(); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
96 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
97 void menu_down() |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
98 { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
99 MyAppData *data = MBAPP_DATA(myApp,MyAppData); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
100 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
101 if (data->cur < 5) { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
102 if (data->top+data->cur <= data->max) |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
103 data->cur++; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
104 } else { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
105 if ((data->top+8) < data->max) { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
106 data->top++; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
107 } else { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
108 if (data->cur+data->top < data->max-1) |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
109 data->cur++; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
110 else |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
111 return; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
112 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
113 printf("top=%d\n",data->top); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
114 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
115 fillMenuContent(); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
116 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
117 void menu_select() |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
118 { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
119 MyAppData *data = MBAPP_DATA(myApp,MyAppData); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
120 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
121 printf("menu '%s' is selected\n", menus[data->top+data->cur]); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
122 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
123 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
124 void keyHandler(event_t *ev, void *arg) |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
125 { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
126 X_kb_event_t *xkey = (X_kb_event_t *)ev; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
127 if(xkey->event.type != EVT_KB_PRESS) { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
128 return; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
129 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
130 switch(xkey->sym) { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
131 case 0xff51: /* left */ |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
132 break; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
133 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
134 case 0xff52: /* up */ |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
135 menu_up(); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
136 break; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
137 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
138 case 0xff53: /* right */ |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
139 break; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
140 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
141 case 0xff54: /* down */ |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
142 menu_down(); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
143 break; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
144 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
145 case 0xff0d: /* enter */ |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
146 menu_select(); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
147 break; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
148 default: |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
149 return; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
150 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
151 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
152 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
153 MyApp_InitContent() |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
154 { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
155 MyAppData *data = MBAPP_DATA(myApp,MyAppData); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
156 subject_t *key = MBAPP_keySubject(myApp); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
157 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
158 data->top = 0; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
159 data->cur = 0; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
160 data->max = sizeof(menus)/sizeof(int)-1; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
161 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
162 fillMenuContent(); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
163 subject_add_observer(key, keyHandler,NULL); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
164 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
165 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
166 int main(int argc, char * const argv[]) { |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
167 subject_t *subject; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
168 mb_obj_t *button; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
169 MyAppData data; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
170 mb_timeval_t tmo,interval; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
171 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
172 if (argc > 1) |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
173 myApp = MBApp_Init(argv[1]); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
174 else |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
175 myApp = MBApp_Init("list"); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
176 MBApp_setData(myApp,&data); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
177 MyApp_InitContent(); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
178 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
179 MBApp_loop(myApp); |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
180 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
181 return 0; |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
182 } |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
183 |
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff
changeset
|
184 /* vim: set ts=4 */ |