int send_mouse_message(window_t *win, uint32_t msg) { ctrl_t *child; if(mouse_capture) return send_message(mouse_capture, msg, 0, old_pos.val); if(pt_in_rect(&win->client, old_pos.x, old_pos.y)) return send_message((ctrl_t*)win, msg, 0, old_pos.val); if(win->win_state == FULLSCREEN) return 0; if(pt_in_rect(&win->caption.ctrl.rc, old_pos.x, old_pos.y)) { return send_message(&win->caption.ctrl, msg, 0, old_pos.val); } if(pt_in_rect(&win->panel.ctrl.rc, old_pos.x, old_pos.y)) { // old_pos.x-= win->panel.ctrl.rc.l; // old_pos.y-= win->panel.ctrl.rc.t; return send_message(&win->panel.ctrl, msg, 0, old_pos.val); } return send_message(&win->frame, msg, 0, old_pos .val); // if( ( old_pos.x < win->rc.r) && ( old_pos.y < win->rc.b)) // send_message((ctrl_t*)win, msg, 0, old_pos.val); };
/* Generic "elem generator" special (callback) */ static void elem_generator_callback(game_t *p_game, int id, void *p_priv_in) { elem_generator_priv_t *p_priv = (elem_generator_priv_t*)p_priv_in; point_t new_pt = pt_add_dir(p_priv->pt, p_priv->dir); mask_tile_t *p_mask_tile; tile_t *p_tile; /* Reduce the speed */ if ( !(p_priv->toggle = !p_priv->toggle) ) return; assert(pt_in_rect(new_pt, pt(0,0), pt(p_game->p_cur_level->w, p_game->p_cur_level->h))); p_tile = &p_game->p_cur_level->p_level_data[new_pt.y * p_game->p_cur_level->w + new_pt.x]; p_mask_tile = &MTILE_AT(p_game, new_pt.x, new_pt.y); if (!MASK_TILE_IS_EMPTY(*p_mask_tile)) return; /* This is the last entry */ if (p_priv->n_elems-- <= 0) { callback_unregister(p_game, p_priv->id); return; } elem_add(p_game, p_priv->elem_type, pt_to_sprite(new_pt), p_priv->elem_extra_arg); }
/* Generic "growing-wall" special (callback) */ static void growing_wall_callback(game_t *p_game, int id, void *p_priv_in) { growing_wall_priv_t *p_priv = (growing_wall_priv_t*)p_priv_in; point_t new_pt = pt_add_dir(p_priv->pt, get_dx(p_priv->dir)); mask_tile_t *p_mask_tile; tile_t *p_tile; /* Reduce the speed */ if ( !(p_priv->toggle = !p_priv->toggle) ) return; assert(pt_in_rect(new_pt, pt(0,0), pt(p_game->p_cur_level->w, p_game->p_cur_level->h))); p_tile = &p_game->p_cur_level->p_level_data[new_pt.y * p_game->p_cur_level->w + new_pt.x]; p_mask_tile = &MTILE_AT(p_game, new_pt.x, new_pt.y); if (!MASK_TILE_IS_WALKABLE(*p_mask_tile)) { status_enqueue_message(p_game, "THE ROARING STOPS"); callback_unregister(p_game, p_priv->id); return; } p_priv->pt = new_pt; *p_tile = p_priv->tile; p_mask_tile->id = MASK_ID(p_priv->tile); }
//#include "timer.h" ctrl_t *win_get_child(window_t *win, int x, int y) { ctrl_t *child = NULL; if( win ) { if(pt_in_rect(&win->client, x, y)) { ctrl_t *tmp = (ctrl_t*)win->child.next; while( &tmp->link != &win->child ) { if(pt_in_rect(&tmp->rc, x, y)) { child = get_child(tmp, x, y); return child == NULL ? tmp : child; }; tmp = (ctrl_t*)tmp->link.next; }; } else child = (ctrl_t*)(&win->frame); }; return child; };