Mercurial > MadButterfly
diff examples/calculator/main.c @ 192:54fdc2a65242
Remove factory from observer APIs.
- Save factory that used to new a subject as subject's attribute.
- Get factory from subject himself instead of passing as an argument.
- It make API of observer more simple and clean.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 18 Nov 2008 21:42:30 +0800 |
parents | 530bb7728546 |
children | c990a9a9648f a90fd749af82 |
line wrap: on
line diff
--- a/examples/calculator/main.c Tue Nov 18 13:55:09 2008 +0800 +++ b/examples/calculator/main.c Tue Nov 18 21:42:30 2008 +0800 @@ -151,22 +151,18 @@ static void setup_observers(calc_data_t *calc_data) { calculator_scr_t *calculator_scr; - ob_factory_t *factory; subject_t *subject; coord_t *coord; - redraw_man_t *rdman; int off; int i; calculator_scr = calc_data->code; - rdman = X_MB_rdman(calc_data->rt); - factory = rdman_get_ob_factory(rdman); for(i = 0; i < 16; i++) { off = tgt_list[i].off; coord = OFF2TYPE(calculator_scr, off, coord_t *); subject = coord_get_mouse_event(coord); - subject_add_observer(factory, subject, buttons_handler, calc_data); + subject_add_observer(subject, buttons_handler, calc_data); } }