Exemplo n.º 1
0
Arquivo: button.c Projeto: att/uwin
/**
*** select_button()
*** Given (x,y) and uberbutton, returns pointer to referred button, or NULL
**/
button_info *select_button(button_info *ub,int x,int y)
{
  int i;
  int row;
  int column;
  button_info *b;

  if (!(ub->flags&b_Container))
    return ub;

  x -= buttonXPad(ub) + buttonFrame(ub);
  y -= buttonYPad(ub) + buttonFrame(ub);

  if(x >= ub->c->width || x < 0 || y >= ub->c->height || y < 0)
    return ub;

  column = x * ub->c->num_columns / ub->c->width;
  row = y * ub->c->num_rows / ub->c->height;
  i = button_belongs_to(ub, column + row * ub->c->num_columns);
  if (i == -1)
    return ub;
  b = ub->c->buttons[i];

  return select_button(
      b, x + ub->c->xpos - buttonXPos(b, i),
      y + ub->c->ypos - buttonYPos(b, i));
}
Exemplo n.º 2
0
/**
*** get_xy_button()
*** Function that returns the button that covers the given row/column in the
*** button matrix. Returns NULL if none.
**/
button_info *get_xy_button(button_info *ub, int row, int column)
{
	int i;

	if (!ub->flags.b_Container)
	{
		return NULL;
	}
	i = button_belongs_to(ub, column + row * ub->c->num_columns);
	if (i == -1)
	{
		return NULL;
	}

	return ub->c->buttons[i];
}