Mercurial > MadButterfly
comparison nodejs/coord.cc @ 1449:ef3908d9a3d2
Revert 4be04f29fa70
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 12 Apr 2011 14:50:10 +0800 |
parents | 4be04f29fa70 |
children | 5d89aa30310c |
comparison
equal
deleted
inserted
replaced
1448:e18c51c1c48f | 1449:ef3908d9a3d2 |
---|---|
6 extern "C" { | 6 extern "C" { |
7 #include "mb.h" | 7 #include "mb.h" |
8 #include "mb_X_supp.h" | 8 #include "mb_X_supp.h" |
9 #include "mb_tools.h" | 9 #include "mb_tools.h" |
10 #include "njs_mb_supp.h" | 10 #include "njs_mb_supp.h" |
11 #include <string.h> | |
12 } | 11 } |
13 | 12 |
14 #include "mbfly_njs.h" | 13 #include "mbfly_njs.h" |
15 | 14 |
16 #ifndef ASSERT | 15 #ifndef ASSERT |
17 #define ASSERT(x) | 16 #define ASSERT(x) |
18 #endif | 17 #endif |
18 | |
19 #define OK 0 | 19 #define OK 0 |
20 | 20 |
21 /*! \page jsgc How to Manage Life-cycle of Objects for Javascript. | 21 /*! \page jsgc How to Manage Life-cycle of Objects for Javascript. |
22 * | 22 * |
23 * The life-cycle of MadButterfly ojects are simple. A object is live | 23 * The life-cycle of MadButterfly ojects are simple. A object is live |
405 yy = GET(self,"_y")->ToNumber()->NumberValue(); | 405 yy = GET(self,"_y")->ToNumber()->NumberValue(); |
406 | 406 |
407 x = cc(0)*xx+cc(1)*yy+cc(2); | 407 x = cc(0)*xx+cc(1)*yy+cc(2); |
408 return Number::New(x); | 408 return Number::New(x); |
409 } | 409 } |
410 | |
411 static int | |
412 xnjsmb_coord_set_text_recursive(coord_t *coord, Handle<Object> self, | |
413 const char *txt) { | |
414 shape_t *sh; | |
415 coord_t *child; | |
416 Handle<Object> rt; | |
417 redraw_man_t *rdman; | |
418 | |
419 FOR_COORD_SHAPES(coord, sh) { | |
420 printf("shape type %d\n",sh->obj.obj_type); | |
421 if (sh->obj.obj_type == MBO_STEXT) { | |
422 sh_stext_set_text(sh, txt); | |
423 /* | |
424 * Mark changed. | |
425 */ | |
426 rt = GET(self, "mbrt")->ToObject(); | |
427 ASSERT(rt != NULL); | |
428 rdman = xnjsmb_rt_rdman(rt); | |
429 | |
430 if(sh_get_coord(sh)) | |
431 rdman_shape_changed(rdman, sh); | |
432 return 1; | |
433 } | |
434 } | |
435 for((child) = STAILQ_HEAD((coord)->children); | |
436 (child) != NULL; | |
437 (child) = STAILQ_NEXT(coord_t, sibling, (child))) { | |
438 /* Invalidate members of a coord */ | |
439 if ( xnjsmb_coord_set_text_recursive(child, self, txt)) | |
440 return 1; | |
441 } | |
442 return 0; | |
443 | |
444 } | |
445 | |
446 static void | |
447 xnjsmb_coord_set_text(coord_t *coord, Handle<Object> self, | |
448 const char *txt) { | |
449 printf("text=%s\n",txt); | |
450 xnjsmb_coord_set_text_recursive(coord,self,txt); | |
451 } | |
452 | |
453 | |
454 #undef m | 410 #undef m |
455 | 411 |
456 #include "coord-inc.h" | 412 #include "coord-inc.h" |
457 | 413 |
458 /*! \brief This function used by \ref xnjsmb_mb_rt to wrap coord object. | 414 /*! \brief This function used by \ref xnjsmb_mb_rt to wrap coord object. |