Mercurial > MadButterfly
annotate examples/svg2code_ex/main.c @ 84:42698de1f653
Support translate() function for transform attribute of 'g' tag.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 22 Aug 2008 12:52:48 +0800 |
parents | ea758bb3bbe2 |
children | 565b55508c8d |
rev | line source |
---|---|
78 | 1 #include <stdio.h> |
2 #include <mb_types.h> | |
3 #include <X_supp.h> | |
4 #include "svg2code_ex.h" | |
5 | |
83 | 6 typedef struct _ex_rt ex_rt_t; |
7 struct _ex_rt { | |
8 X_MB_runtime_t *rt; | |
9 svg2code_ex_t *code; | |
10 }; | |
11 | |
12 static void file_button_handler(event_t *evt, void *arg) { | |
13 ex_rt_t *ex_rt = (ex_rt_t *)arg; | |
14 | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
15 switch(evt->type) { |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
16 case EVT_MOUSE_BUT_PRESS: |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
17 coord_show(ex_rt->code->file_menu); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
18 rdman_coord_changed(ex_rt->rt->rdman, ex_rt->code->file_menu); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
19 rdman_redraw_changed(ex_rt->rt->rdman); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
20 break; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
21 } |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
22 } |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
23 |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
24 static void file_menu_handler(event_t *evt, void *arg) { |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
25 ex_rt_t *ex_rt = (ex_rt_t *)arg; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
26 |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
27 switch(evt->type) { |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
28 case EVT_MOUSE_BUT_PRESS: |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
29 coord_hide(ex_rt->code->file_menu); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
30 rdman_coord_changed(ex_rt->rt->rdman, ex_rt->code->file_menu); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
31 rdman_redraw_changed(ex_rt->rt->rdman); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
32 break; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
33 } |
83 | 34 } |
35 | |
78 | 36 int main(int argc, char * const argv[]) { |
37 X_MB_runtime_t rt; | |
38 svg2code_ex_t *svg2code; | |
83 | 39 ob_factory_t *factory; |
40 subject_t *subject; | |
41 ex_rt_t ex_rt; | |
78 | 42 int r; |
43 | |
79
5bcb329a5157
Fix bug of core dump caused by forget to check if parent is NULL, root.
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
44 r = X_MB_init(":0.0", 800, 600, &rt); |
78 | 45 |
46 svg2code = svg2code_ex_new(rt.rdman); | |
47 | |
83 | 48 factory = rdman_get_ob_factory(rt.rdman); |
49 subject = coord_get_mouse_event(svg2code->file_button); | |
50 ex_rt.rt = &rt; | |
51 ex_rt.code = svg2code; | |
52 subject_add_observer(factory, subject, file_button_handler, &ex_rt); | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
53 subject = coord_get_mouse_event(svg2code->file_menu); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
54 subject_add_observer(factory, subject, file_menu_handler, &ex_rt); |
83 | 55 |
56 X_MB_handle_connection(&rt); | |
57 | |
58 svg2code_ex_free(svg2code); | |
78 | 59 X_MB_destroy(&rt); |
60 | |
61 return 0; | |
62 } |