annotate examples/dynamic/main.c @ 240:d347a577a232

Rewrite the example by using the MBApp API.
author wycc
date Tue, 30 Dec 2008 09:21:23 +0800
parents 3e6da6f6a226
children d3fe0a0f3a8b
rev   line source
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
1 /*! \file
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
2 *
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
3 * svg2code_ex is an example that show programmers how to create a
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
4 * menu with MadButterfly.
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
5 *
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
6 */
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
7 #include <stdio.h>
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
8 #include <mb.h>
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
9 #include <string.h>
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
10 #include "menu.h"
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
11
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
12
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
13 typedef struct _mbapp MBApp;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
14 struct _mbapp {
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
15 void *rt;
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
16 redraw_man_t *rdman;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
17 mb_sprite_t *rootsprite;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
18 mb_obj_t *root;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
19 void *private;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
20 };
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
21
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
22 typedef struct {
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
23 shape_t *rect;
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
24 co_aix orx,ory;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
25 int start_x,start_y;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
26 observer_t *obs1,*obs2;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
27 }MyAppData;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
28
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
29 #define MBAPP_DATA(app,type) ((type *) ((app)->private))
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
30 #define MBAPP_RDMAN(app) (((MBApp *) app)->rdman)
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
31
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
32
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
33 typedef struct _mb_button {
227
a6e559fb76d7 Add dynamic loading function for sprite
wycc
parents: 226
diff changeset
34 mb_obj_t obj;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
35 MBApp *en;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
36 int state;
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
37 coord_t *root;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
38 coord_t *active;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
39 coord_t *normal;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
40 coord_t *click;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
41 void (*press)();
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
42 void *arg;
221
ad4f8a956505 Implement a workaround for the button class. However, this won't solve all issues. We can use this as example to fix the mouse out event issue. When we move the curosr over the text inside the button. The upper layer group will receive MOUSE_OUT events. This is absolute incorrect.
wycc
parents: 217
diff changeset
43 observer_t *obs_move,*obs_out,*obs_press;
226
b24d7889cbda * Change the color of click frame
wycc@wycc-desktop
parents: 224
diff changeset
44 mb_progm_t *progm;
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
45 } mb_button_t;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
46
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
47
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
48
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
49 #define CMOUSE(e) (coord_get_mouse_event(e))
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
50
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
51
221
ad4f8a956505 Implement a workaround for the button class. However, this won't solve all issues. We can use this as example to fix the mouse out event issue. When we move the curosr over the text inside the button. The upper layer group will receive MOUSE_OUT events. This is absolute incorrect.
wycc
parents: 217
diff changeset
52 static void mb_button_pressed(event_t *evt, void *arg);
ad4f8a956505 Implement a workaround for the button class. However, this won't solve all issues. We can use this as example to fix the mouse out event issue. When we move the curosr over the text inside the button. The upper layer group will receive MOUSE_OUT events. This is absolute incorrect.
wycc
parents: 217
diff changeset
53 static void mb_button_out(event_t *evt, void *arg);
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
54
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
55 void mb_button_refresh(mb_button_t *btn)
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
56 {
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
57 rdman_coord_changed(btn->en->rdman,btn->root);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
58 rdman_redraw_changed(btn->en->rdman);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
59 }
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
60
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
61 static void mb_button_move(event_t *evt, void *arg)
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
62 {
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
63 mb_button_t *btn = (mb_button_t *) arg;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
64 MBApp *en = btn->en;
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
65
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
66
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
67 printf("Mouse move\n");
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
68 arg = (void *)en;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
69 coord_show(btn->active);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
70 mb_button_refresh(btn);
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
71 }
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
72 static void mb_button_out(event_t *evt, void *arg)
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
73 {
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
74 mb_button_t *btn = (mb_button_t *) arg;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
75 MBApp *en = btn->en;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
76 arg = (void *) en;
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
77
226
b24d7889cbda * Change the color of click frame
wycc@wycc-desktop
parents: 224
diff changeset
78 if (btn->progm) {
b24d7889cbda * Change the color of click frame
wycc@wycc-desktop
parents: 224
diff changeset
79 mb_progm_abort(btn->progm);
b24d7889cbda * Change the color of click frame
wycc@wycc-desktop
parents: 224
diff changeset
80 btn->progm = NULL;
b24d7889cbda * Change the color of click frame
wycc@wycc-desktop
parents: 224
diff changeset
81 }
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
82 printf("mouse out\n");
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
83 coord_hide(btn->click);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
84 coord_hide(btn->active);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
85 coord_show(btn->normal);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
86 mb_button_refresh(btn);
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
87 }
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
88
221
ad4f8a956505 Implement a workaround for the button class. However, this won't solve all issues. We can use this as example to fix the mouse out event issue. When we move the curosr over the text inside the button. The upper layer group will receive MOUSE_OUT events. This is absolute incorrect.
wycc
parents: 217
diff changeset
89 void mb_button_show_active(event_t *evt, void *arg)
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
90 {
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
91 mb_button_t *btn = (mb_button_t *) arg;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
92 MBApp *en = btn->en;
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
93
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
94 coord_show(btn->active);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
95 mb_button_refresh(btn);
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
96 }
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
97
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
98 void mb_button_pressed(event_t *evt, void *arg)
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
99 {
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
100 mb_button_t *btn = (mb_button_t *) arg;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
101 MBApp *en = btn->en;
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
102 mb_timeval_t start, playing, now;
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
103 mb_progm_t *progm;
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
104 mb_word_t *word;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
105 arg = (void *) en;
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
106
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
107 printf("Pressed\n");
226
b24d7889cbda * Change the color of click frame
wycc@wycc-desktop
parents: 224
diff changeset
108 if (btn->progm) {
b24d7889cbda * Change the color of click frame
wycc@wycc-desktop
parents: 224
diff changeset
109 mb_progm_abort(btn->progm);
b24d7889cbda * Change the color of click frame
wycc@wycc-desktop
parents: 224
diff changeset
110 btn->progm = NULL;
b24d7889cbda * Change the color of click frame
wycc@wycc-desktop
parents: 224
diff changeset
111 }
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
112 coord_show(btn->click);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
113 coord_hide(btn->active);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
114 rdman_coord_changed(MBAPP_RDMAN(arg),btn->root);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
115 rdman_redraw_changed(MBAPP_RDMAN(arg));
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
116
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
117 btn->progm = progm = mb_progm_new(1, MBAPP_RDMAN(arg));
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
118 MB_TIMEVAL_SET(&start, 0, 500000);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
119 MB_TIMEVAL_SET(&playing, 0, 0);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
120 word = mb_progm_next_word(progm, &start, &playing);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
121 mb_visibility_new(VIS_HIDDEN, btn->click, word);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
122 mb_visibility_new(VIS_VISIBLE, btn->active, word);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
123 mb_progm_free_completed(progm);
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
124 get_now(&now);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
125 mb_progm_start(progm, X_MB_tman(en->rt), &now);
230
3e6da6f6a226 Call the button callback when the button is clicked
wycc
parents: 229
diff changeset
126 if (btn->press)
3e6da6f6a226 Call the button callback when the button is clicked
wycc
parents: 229
diff changeset
127 btn->press(btn->arg);
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
128 }
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
129 mb_button_t *mb_button_new(MBApp *app,mb_sprite_t *sp, char *name)
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
130 {
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
131 mb_button_t *btn = (mb_button_t *) malloc(sizeof(mb_button_t));
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
132 char *buf = (char *) malloc(strlen(name)+5);
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
133 MBApp *arg = app;
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
134
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
135 btn->root = (coord_t *) MB_SPRITE_GET_OBJ(sp, name);
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
136 sprintf(buf, "%s_normal", name);
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
137 btn->normal = (coord_t *) MB_SPRITE_GET_OBJ(sp, buf);
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
138 if (btn->normal == NULL) {
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
139 printf("Missing normal button, this is not a correct button\n");
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
140 }
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
141 sprintf(buf, "%s_active", name);
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
142 btn->active = (coord_t *) MB_SPRITE_GET_OBJ(sp, buf);
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
143 if (btn->active == NULL) {
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
144 printf("Missing click button, this is not a correct button\n");
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
145 }
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
146 sprintf(buf, "%s_click", name);
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
147 btn->click = (coord_t *) MB_SPRITE_GET_OBJ(sp, buf);
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
148 if (btn->active == NULL) {
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
149 printf("Missing click button, this is not a correct button\n");
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
150 }
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
151 btn->press = NULL;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
152 // Show only the normal button
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
153 coord_hide(btn->active);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
154 coord_hide(btn->click);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
155 coord_show(btn->normal);
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
156 // Move to the same position
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
157 btn->active->matrix[2] = 200;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
158 btn->active->matrix[5] = 200;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
159 btn->normal->matrix[2] = 200;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
160 btn->normal->matrix[5] = 200;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
161 btn->click->matrix[2] = 200;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
162 btn->click->matrix[5] = 200;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
163 btn->en = app;
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
164 btn->obs_move = subject_add_event_observer(CMOUSE(btn->root), EVT_MOUSE_MOVE, mb_button_move,btn);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
165 btn->obs_press = subject_add_event_observer(CMOUSE(btn->root), EVT_MOUSE_BUT_PRESS, mb_button_pressed,btn);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 221
diff changeset
166 btn->obs_out = subject_add_event_observer(CMOUSE(btn->root), EVT_MOUSE_OUT, mb_button_out,btn);
226
b24d7889cbda * Change the color of click frame
wycc@wycc-desktop
parents: 224
diff changeset
167 btn->progm = NULL;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
168 rdman_redraw_changed(MBAPP_RDMAN(arg));
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
169 return btn;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
170 }
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
171
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
172
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
173 void mb_button_add_onClick(mb_button_t *b, void (*h)(void *arg), void *arg)
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
174 {
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
175 b->press = h;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
176 b->arg = arg;
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
177 }
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
178
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
179 MBApp *MBApp_Init(char *module)
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
180 {
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
181 MBApp *app = (MBApp *) malloc(sizeof(MBApp));
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
182 X_MB_runtime_t *rt;
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
183
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
184 rt = X_MB_new(":0.0", 800, 600);
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
185
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
186 app->rt = rt;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
187 app->rdman = X_MB_rdman(rt);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
188 app->rootsprite= sprite_load("button",app->rdman, app->rdman->root_coord);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
189 return app;
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
190 }
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
191
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
192 void MBApp_setData(MBApp *app,void *data)
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
193 {
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
194 app->private = (void *) data;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
195 }
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
196
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
197 void MBApp_loop(MBApp *en)
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
198 {
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
199 /*
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
200 * Start handle connections, includes one to X server.
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
201 * User start to interact with the application.
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
202 */
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
203 X_MB_handle_connection(en->rt);
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
204
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
205 /*
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
206 * Clean
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
207 */
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
208 X_MB_free(en->rt);
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
209 free(en);
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
210 }
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
211
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
212
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
213 static void add_rect_move(event_t *evt, void *arg)
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
214 {
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
215 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData );
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
216 mouse_event_t *mev = (mouse_event_t *) evt;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
217
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
218 printf("resize rectangle\n");
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
219 sh_rect_set(en->rect, en->start_x, en->start_y, mev->x - en->start_x, mev->y-en->start_y,0,0);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
220 rdman_shape_changed(MBAPP_RDMAN(arg),en->rect);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
221 rdman_redraw_changed(MBAPP_RDMAN(arg));
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
222 }
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
223
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
224 static void add_rect_release(event_t *evt, void *arg)
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
225 {
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
226 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData );
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
227 mouse_event_t *mev = (mouse_event_t *) evt;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
228
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
229 printf("rectangle done\n");
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
230 subject_remove_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), en->obs1);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
231 subject_remove_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), en->obs2);
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
232 }
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
233
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
234 static void add_rect_2(event_t *evt, void *arg)
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
235 {
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
236 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData );
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
237 mouse_event_t *mev = (mouse_event_t *) evt;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
238 paint_t *color;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
239
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
240 printf("select first point\n");
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
241 // Add an rect path
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
242
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
243 en->start_x = mev->x;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
244 en->start_y = mev->y;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
245 subject_remove_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), en->obs1);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
246 subject_remove_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), en->obs2);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
247 en->obs1 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_MOVE, add_rect_move, en);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
248 en->obs2 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_BUT_RELEASE, add_rect_release, en);
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
249 }
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
250
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
251 static void add_rect_2_move(event_t *evt, void *arg)
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
252 {
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
253 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData );
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
254 mouse_event_t *mev = (mouse_event_t *) evt;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
255
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
256 sh_rect_set(en->rect, mev->x, mev->y, 50,50,0,0);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
257 rdman_shape_changed(MBAPP_RDMAN(arg),en->rect);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
258 rdman_redraw_changed(MBAPP_RDMAN(arg));
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
259 }
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
260
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
261 static void add_rect(event_t *evt, void *arg)
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
262 {
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
263 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData );
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
264 mouse_event_t *mev = (mouse_event_t *) evt;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
265 paint_t *color;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
266
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
267 printf("menut selected\n");
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
268 en->obs1 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_BUT_PRESS, add_rect_2, en);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
269 en->obs2 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_MOVE, add_rect_2_move, en);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
270 en->rect = rdman_shape_rect_new(MBAPP_RDMAN(arg), mev->x, mev->y, 50 , 50, 0,0);
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
271 // Paint it with color
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
272 en->obs1 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_BUT_PRESS, add_rect_2, en);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
273 en->obs2 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_MOVE, add_rect_2_move, en);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
274 en->rect = rdman_shape_rect_new(MBAPP_RDMAN(arg), mev->x, mev->y, 50 , 50, 0,0);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
275 // Paint it with color
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
276 color = rdman_paint_color_new(MBAPP_RDMAN(arg), 0.800000, 0.800000, 0.400000, 1.000000);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
277 rdman_paint_fill(MBAPP_RDMAN(arg), color, en->rect);
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
278 // Add to the stage
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
279 //rdman_add_shape(MBAPP_RDMAN(arg), en->rect, en->menu->root_coord);
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
280 }
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
281
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
282
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
283 void test(void *a)
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
284 {
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
285 printf("Button is pressed.....\n");
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
286 }
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
287
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
288 MBApp *myApp;
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
289
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
290 int main(int argc, char * const argv[]) {
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
291 subject_t *subject;
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
292 mb_button_t *b;
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
293 mb_obj_t *button;
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
294 MyAppData data;
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
295
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
296 myApp = MBApp_Init("button");
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
297 MBApp_setData(myApp,&data);
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
298 b = mb_button_new(myApp, myApp->rootsprite, "btn");
217
8d9d717c9300 Add sample code fro mb_button_t. If everything is OK, I will move it to the main src tree.
wycc@wycc-desktop
parents: 201
diff changeset
299 mb_button_add_onClick(b, test,NULL);
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
300
240
d347a577a232 Rewrite the example by using the MBApp API.
wycc
parents: 230
diff changeset
301 MBApp_loop(myApp);
201
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
302
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
303 return 0;
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
304 }
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
305
31933f9ee70e Chkec in demo for dynamic rectangle creation and button.
wycc@wycc-desktop
parents:
diff changeset
306 /* vim: set ts=4 */