comparison examples/svg2code_ex/main.c @ 83:ea758bb3bbe2

example
author Thinker K.F. Li <thinker@branda.to>
date Fri, 22 Aug 2008 00:12:04 +0800
parents 5bcb329a5157
children 42698de1f653
comparison
equal deleted inserted replaced
82:4bb6451ef036 83:ea758bb3bbe2
1 #include <stdio.h> 1 #include <stdio.h>
2 #include <mb_types.h> 2 #include <mb_types.h>
3 #include <X_supp.h> 3 #include <X_supp.h>
4 #include "svg2code_ex.h" 4 #include "svg2code_ex.h"
5 5
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
15 coord_show(ex_rt->code->file_menu);
16 rdman_coord_changed(ex_rt->rt->rdman, ex_rt->code->file_menu);
17 rdman_redraw_changed(ex_rt->rt->rdman);
18 }
19
6 int main(int argc, char * const argv[]) { 20 int main(int argc, char * const argv[]) {
7 X_MB_runtime_t rt; 21 X_MB_runtime_t rt;
8 svg2code_ex_t *svg2code; 22 svg2code_ex_t *svg2code;
23 ob_factory_t *factory;
24 subject_t *subject;
25 ex_rt_t ex_rt;
9 int r; 26 int r;
10 27
11 r = X_MB_init(":0.0", 800, 600, &rt); 28 r = X_MB_init(":0.0", 800, 600, &rt);
12 29
13 svg2code = svg2code_ex_new(rt.rdman); 30 svg2code = svg2code_ex_new(rt.rdman);
14 X_MB_handle_connection(rt.display, rt.rdman, rt.tman);
15 31
32 factory = rdman_get_ob_factory(rt.rdman);
33 subject = coord_get_mouse_event(svg2code->file_button);
34 ex_rt.rt = &rt;
35 ex_rt.code = svg2code;
36 subject_add_observer(factory, subject, file_button_handler, &ex_rt);
37
38 X_MB_handle_connection(&rt);
39
40 svg2code_ex_free(svg2code);
16 X_MB_destroy(&rt); 41 X_MB_destroy(&rt);
17 42
18 return 0; 43 return 0;
19 } 44 }