Mercurial > MadButterfly
annotate nodejs/shapes.cc @ 776:77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
However, the image does not work here since it does not use the transformation of the group.
author | wycc |
---|---|
date | Mon, 30 Aug 2010 08:56:44 +0800 |
parents | 9d430b084a13 |
children | 16d8a1d48717 |
rev | line source |
---|---|
564 | 1 #include <v8.h> |
2 #include "mbfly_njs.h" | |
3 | |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
4 #include <string.h> |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
5 |
564 | 6 extern "C" { |
7 #include <mb.h> | |
8 } | |
9 | |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
10 #ifndef ASSERT |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
11 #define ASSERT(x) |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
12 #endif |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
13 |
748
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
14 #define OK 0 |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
15 |
564 | 16 using namespace v8; |
17 | |
684
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
683
diff
changeset
|
18 /*! \defgroup xnjsmb_shapes JS binding for shapes. |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
19 * \ingroup xnjsmb |
564 | 20 * |
21 * @{ | |
22 */ | |
748
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
23 /*! \brief This function is called when GC collecting a shape. |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
24 * |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
25 * It was installed by Persistent<Object>::MakeWeak(). |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
26 */ |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
27 static void |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
28 xnjsmb_shape_recycled(Persistent<Value> obj, void *parameter) { |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
29 Persistent<Object> *self_hdl = (Persistent<Object> *)parameter; |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
30 Handle<Object> js_rt; |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
31 redraw_man_t *rdman; |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
32 shape_t *shape; |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
33 |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
34 shape = (shape_t *)UNWRAP(*self_hdl); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
35 if(shape == NULL) |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
36 return; |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
37 |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
38 WRAP(*self_hdl, NULL); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
39 |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
40 js_rt = GET(*self_hdl, "mbrt")->ToObject(); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
41 rdman = xnjsmb_rt_rdman(js_rt); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
42 rdman_shape_changed(rdman, shape); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
43 rdman_shape_free(rdman, shape); |
764
194e24d8ecab
Delete weak handle for shape objects before GC
Thinker K.F. Li <thinker@codemud.net>
parents:
749
diff
changeset
|
44 |
766
be0e02948c1d
Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
764
diff
changeset
|
45 self_hdl->Dispose(); |
764
194e24d8ecab
Delete weak handle for shape objects before GC
Thinker K.F. Li <thinker@codemud.net>
parents:
749
diff
changeset
|
46 delete self_hdl; |
748
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
47 } |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
48 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
49 static void |
743
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
50 xnjsmb_shape_mod(Handle<Object> self, shape_t *sh) { |
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
51 Persistent<Object> *self_hdl; |
766
be0e02948c1d
Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
764
diff
changeset
|
52 static int count = 0; |
743
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
53 |
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
54 /* Keep associated js object in property store for retrieving, |
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
55 * later, without create new js object. |
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
56 */ |
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
57 self_hdl = new Persistent<Object>(); |
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
58 *self_hdl = Persistent<Object>::New(self); |
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
59 mb_prop_set(&sh->obj.props, PROP_JSOBJ, self_hdl); |
748
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
60 |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
61 self_hdl->MakeWeak(self_hdl, xnjsmb_shape_recycled); |
766
be0e02948c1d
Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
764
diff
changeset
|
62 |
be0e02948c1d
Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
764
diff
changeset
|
63 /* XXX: should be remove. It is for trace recycle of shape */ |
be0e02948c1d
Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
764
diff
changeset
|
64 count++; |
be0e02948c1d
Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
764
diff
changeset
|
65 if(count > 10000) { |
be0e02948c1d
Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
764
diff
changeset
|
66 V8::LowMemoryNotification(); |
be0e02948c1d
Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
764
diff
changeset
|
67 count = 0; |
be0e02948c1d
Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
764
diff
changeset
|
68 } |
743
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
69 } |
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
70 |
dd1f3382d6a4
Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents:
690
diff
changeset
|
71 static void |
689
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
72 xnjsmb_sh_stext_set_style(shape_t *sh, Handle<Object> self, |
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
73 Handle<Value> blks, const char **err) { |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
74 Array *blksobj; |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
75 Array *blkobj; |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
76 mb_style_blk_t *mb_blks; |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
77 int nblks; |
689
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
78 Handle<Object> rt; |
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
79 redraw_man_t *rdman; |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
80 int r; |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
81 int i; |
564 | 82 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
83 blksobj = Array::Cast(*blks); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
84 nblks = blksobj->Length(); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
85 mb_blks = new mb_style_blk_t[nblks]; |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
86 for(i = 0; i < nblks; i++) { |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
87 blkobj = Array::Cast(*blksobj->Get(i)); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
88 mb_blks[i].n_chars = blkobj->Get(0)->ToInt32()->Value(); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
89 mb_blks[i].face = (mb_font_face_t *)UNWRAP(blkobj->Get(1)->ToObject()); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
90 mb_blks[i].font_sz = blkobj->Get(2)->ToNumber()->Value(); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
91 } |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
92 |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
93 r = sh_stext_set_style(sh, mb_blks, nblks); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
94 if(r != 0) { |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
95 *err = "Unknown error"; |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
96 return; |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
97 } |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
98 |
689
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
99 /* |
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
100 * Mark changed. |
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
101 */ |
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
102 rt = GET(self, "mbrt")->ToObject(); |
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
103 ASSERT(rt != NULL); |
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
104 rdman = xnjsmb_rt_rdman(rt); |
a05a4a27ff46
Fix bug of losting rdman in xnjsmb_sh_stext_set_style
Thinker K.F. Li <thinker@branda.to>
parents:
688
diff
changeset
|
105 |
688
cadebc13be2f
Mark stext changed when its style being changed
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
106 if(sh_get_coord(sh)) |
cadebc13be2f
Mark stext changed when its style being changed
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
107 rdman_shape_changed(rdman, sh); |
cadebc13be2f
Mark stext changed when its style being changed
Thinker K.F. Li <thinker@branda.to>
parents:
687
diff
changeset
|
108 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
109 delete mb_blks; |
564 | 110 } |
111 | |
112 static Handle<Value> | |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
113 xnjsmb_shape_stroke_width_get(Handle<Object> self, shape_t *sh, |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
114 const char **err) { |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
115 float stroke_width; |
564 | 116 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
117 stroke_width = sh_get_stroke_width(sh); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
118 return Number::New(stroke_width); |
564 | 119 } |
120 | |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
121 static void |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
122 xnjsmb_shape_stroke_width_set(Handle<Object> self, shape_t *sh, |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
123 Handle<Value> value, const char **err) { |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
124 float stroke_width; |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
125 Handle<Object> rt; |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
126 redraw_man_t *rdman; |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
127 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
128 stroke_width = value->Int32Value(); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
129 sh_set_stroke_width(sh, stroke_width); |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
130 |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
131 /* |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
132 * Mark changed. |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
133 */ |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
134 rt = GET(self, "mbrt")->ToObject(); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
135 ASSERT(rt != NULL); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
136 rdman = xnjsmb_rt_rdman(rt); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
137 |
576
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
574
diff
changeset
|
138 if(sh_get_coord(sh)) |
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
574
diff
changeset
|
139 rdman_shape_changed(rdman, sh); |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
140 } |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
141 |
690
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
142 static void |
749
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
143 xnjsmb_shape_show(shape_t *sh, Handle<Object> self) { |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
144 Handle<Object> js_rt; |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
145 redraw_man_t *rdman; |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
146 |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
147 js_rt = GET(self, "mbrt")->ToObject(); |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
148 ASSERT(js_rt != NULL); |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
149 rdman = xnjsmb_rt_rdman(js_rt); |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
150 |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
151 sh_show(sh); |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
152 rdman_shape_changed(rdman, sh); |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
153 } |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
154 |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
155 static void |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
156 xnjsmb_shape_hide(shape_t *sh, Handle<Object> self) { |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
157 Handle<Object> js_rt; |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
158 redraw_man_t *rdman; |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
159 |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
160 js_rt = GET(self, "mbrt")->ToObject(); |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
161 ASSERT(js_rt != NULL); |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
162 rdman = xnjsmb_rt_rdman(js_rt); |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
163 |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
164 sh_hide(sh); |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
165 rdman_shape_changed(rdman, sh); |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
166 } |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
167 |
ed59e659a202
Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents:
748
diff
changeset
|
168 static void |
748
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
169 xnjsmb_shape_remove(shape_t *sh, Handle<Object> self) { |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
170 Handle<Object> js_rt; |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
171 redraw_man_t *rdman; |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
172 Persistent<Object> *self_hdl; |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
173 int r; |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
174 |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
175 self_hdl = (Persistent<Object> *)mb_prop_get(&sh->obj.props, |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
176 PROP_JSOBJ); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
177 |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
178 SET(*self_hdl, "valid", Boolean::New(0)); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
179 WRAP(*self_hdl, NULL); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
180 |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
181 js_rt = GET(*self_hdl, "mbrt")->ToObject(); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
182 ASSERT(js_rt != NULL); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
183 rdman = xnjsmb_rt_rdman(js_rt); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
184 |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
185 rdman_shape_changed(rdman, sh); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
186 r = rdman_shape_free(rdman, sh); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
187 if(r != OK) |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
188 THROW_noret("Can not free a shape for unknown reason"); |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
189 |
766
be0e02948c1d
Improve resource management for coords, shapes and paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
764
diff
changeset
|
190 self_hdl->Dispose(); |
748
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
191 delete self_hdl; |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
192 } |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
193 |
56a5e08cd8af
Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents:
743
diff
changeset
|
194 static void |
690
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
195 xnjsmb_sh_rect_set(shape_t *sh, Handle<Object> self, float x, float y, |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
196 float w, float h, float rx, float ry) { |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
197 Handle<Object> rt; |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
198 redraw_man_t *rdman; |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
199 |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
200 sh_rect_set(sh, x, y, w, h, rx, ry); |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
201 |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
202 /* |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
203 * Mark changed. |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
204 */ |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
205 rt = GET(self, "mbrt")->ToObject(); |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
206 ASSERT(rt != NULL); |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
207 rdman = xnjsmb_rt_rdman(rt); |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
208 |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
209 if(sh_get_coord(sh)) |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
210 rdman_shape_changed(rdman, sh); |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
211 } |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
212 |
564 | 213 /* @} */ |
214 | |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
215 #include "shapes-inc.h" |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
216 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
217 /*! \defgroup xnjsmb_shapes_wraps Exported wrapper makers for shapes |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
218 * \ingroup xnjsmb_shapes |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
219 * |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
220 * These functions are used by methods of mb_rt to wrap shape objects |
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
221 * as Javascript objects. |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
222 * |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
223 * @{ |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
224 */ |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
225 Handle<Value> |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
226 export_xnjsmb_auto_path_new(shape_t *sh) { |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
227 return xnjsmb_auto_path_new(sh); |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
228 } |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
229 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
230 Handle<Value> |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
231 export_xnjsmb_auto_stext_new(shape_t *sh) { |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
232 return xnjsmb_auto_stext_new(sh); |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
233 } |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
234 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
235 Handle<Value> |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
236 export_xnjsmb_auto_image_new(shape_t *sh) { |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
237 return xnjsmb_auto_image_new(sh); |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
238 } |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
239 |
690
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
240 Handle<Value> |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
241 export_xnjsmb_auto_rect_new(shape_t *sh) { |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
242 return xnjsmb_auto_rect_new(sh); |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
243 } |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
244 |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
245 /* @} */ |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
246 |
687
da12923a789a
Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
684
diff
changeset
|
247 /*! \defgroup xnjsmb_shapes_cons Constructor of shapes |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
248 * \ingroup xnjsmb_shapes |
574
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
249 * |
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
250 * @{ |
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
251 */ |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
252 shape_t * |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
253 xnjsmb_path_new(njs_runtime_t *rt, const char *d) { |
574
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
254 redraw_man_t *rdman; |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
255 shape_t *sh; |
574
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
256 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
257 rdman = X_njs_MB_rdman(rt); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
258 sh = rdman_shape_path_new(rdman, d); |
767
9d430b084a13
Free string allocated by code generator
Thinker K.F. Li <thinker@codemud.net>
parents:
766
diff
changeset
|
259 /* Code generator supposes that callee should free the memory */ |
9d430b084a13
Free string allocated by code generator
Thinker K.F. Li <thinker@codemud.net>
parents:
766
diff
changeset
|
260 free((void *)d); |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
261 |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
262 return sh; |
574
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
263 } |
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
264 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
265 shape_t * |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
266 xnjsmb_stext_new(njs_runtime_t *rt, const char *txt, float x, float y) { |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
267 redraw_man_t *rdman; |
576
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
574
diff
changeset
|
268 shape_t *sh; |
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
574
diff
changeset
|
269 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
270 rdman = X_njs_MB_rdman(rt); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
271 sh = rdman_shape_stext_new(rdman, txt, x, y); |
767
9d430b084a13
Free string allocated by code generator
Thinker K.F. Li <thinker@codemud.net>
parents:
766
diff
changeset
|
272 /* Code generator supposes that callee should free the memory */ |
9d430b084a13
Free string allocated by code generator
Thinker K.F. Li <thinker@codemud.net>
parents:
766
diff
changeset
|
273 free((void *)txt); |
576
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
574
diff
changeset
|
274 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
275 return sh; |
574
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
276 } |
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
277 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
278 shape_t * |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
279 xnjsmb_image_new(njs_runtime_t *rt, float x, float y, float w, float h) { |
641
f60d8fa1c55b
Javascript binding for shape_image_t
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
280 redraw_man_t *rdman; |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
281 shape_t *sh; |
641
f60d8fa1c55b
Javascript binding for shape_image_t
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
282 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
283 rdman = X_njs_MB_rdman(rt); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
284 sh = rdman_shape_image_new(rdman, x, y, w, h); |
641
f60d8fa1c55b
Javascript binding for shape_image_t
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
285 |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
286 return sh; |
641
f60d8fa1c55b
Javascript binding for shape_image_t
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
287 } |
f60d8fa1c55b
Javascript binding for shape_image_t
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
288 |
690
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
289 shape_t * |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
290 xnjsmb_rect_new(njs_runtime_t *rt, float x, float y, float w, float h, |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
291 float rx, float ry, const char **err) { |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
292 redraw_man_t *rdman; |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
293 shape_t *sh; |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
294 |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
295 rdman = X_njs_MB_rdman(rt); |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
296 sh = rdman_shape_rect_new(rdman, x, y, w, h, rx, ry); |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
297 if(sh == NULL) { |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
298 *err = "Can not create a sh_rect_t"; |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
299 return NULL; |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
300 } |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
301 |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
302 return sh; |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
303 } |
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
304 |
641
f60d8fa1c55b
Javascript binding for shape_image_t
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
305 /* @} */ |
f60d8fa1c55b
Javascript binding for shape_image_t
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
306 |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
307 /*! \brief Set properties of template of mb_rt. |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
308 * \ingroup xnjsmb_shapes |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
309 */ |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
310 void |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
311 xnjsmb_shapes_init_mb_rt_temp(Handle<FunctionTemplate> rt_temp) { |
574
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
312 HandleScope scope; |
a2faee809514
Implement stext type for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
313 Handle<FunctionTemplate> path_new_temp, stext_new_temp; |
641
f60d8fa1c55b
Javascript binding for shape_image_t
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
314 Handle<FunctionTemplate> image_new_temp; |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
315 Handle<ObjectTemplate> rt_proto_temp; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
316 static int temp_init_flag = 0; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
317 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
318 if(temp_init_flag == 0) { |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
319 xnjsmb_auto_shape_init(); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
320 xnjsmb_auto_path_init(); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
321 xnjsmb_auto_stext_init(); |
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
322 xnjsmb_auto_image_init(); |
690
86c6ebf1de25
Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents:
689
diff
changeset
|
323 xnjsmb_auto_rect_init(); |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
324 temp_init_flag = 1; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
325 } |
683
7685c57e29d0
Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents:
675
diff
changeset
|
326 return; |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
327 } |