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
Arquivo: button.c Projeto: att/uwin
/**
*** buttonInfo()
*** Give lots of info for this button: XPos, YPos, XPad, YPad, Frame(signed)
**/
void buttonInfo(button_info *b,int *x,int *y,int *px,int *py,int *f)
{
  ushort w=b_Padding|b_Frame;
  *x=buttonXPos(b,b->n);
  *y=buttonYPos(b,b->n);
  *px=b->xpad;
  *py=b->ypad;
  *f=b->framew;
  w&=~(b->flags&(b_Frame|b_Padding));

  if(b->flags&b_Container && w&b_Frame)
  {
    *f=0;
    w&=~b_Frame;
  }
  if((b->flags&b_Container || b->flags&b_Swallow) && w&b_Padding)
  {
    *px=*py=0;
    w&=~b_Padding;
  }

  while(w && (b=b->parent))
  {
    if(w&b_Frame && b->c->flags&b_Frame)
    {
      *f=b->c->framew;
      w&=~b_Frame;
    }
    if(w&b_Padding && b->c->flags&b_Padding)
    {
      *px=b->c->xpad;
      *py=b->c->ypad;
      w&=~b_Padding;
    }
  }
}
Exemplo n.º 3
0
/**
*** buttonInfo()
*** Give lots of info for this button: XPos, YPos, XPad, YPad, Frame(signed)
**/
void buttonInfo(const button_info *b, int *x, int *y, int *px, int *py, int *f)
{
  ushort bPadding = (b->flags.b_Padding ? 0 : 1);
  ushort bFrame = (b->flags.b_Frame ? 0 : 1);
  *x=buttonXPos(b,b->n);
  *y=buttonYPos(b,b->n);
  *px=b->xpad;
  *py=b->ypad;
  *f=b->framew;

  if(b->flags.b_Container && bFrame)
  {
    *f=0;
    bFrame = 0;
  }
  if((b->flags.b_Container || b->flags.b_Swallow) && bPadding)
  {
    *px=*py=0;
    bPadding = 0;
  }

  while((bPadding || bFrame) && (b=b->parent))
  {
    if(bFrame && b->c->flags.b_Frame)
    {
      *f=b->c->framew;
      bFrame = 0;
    }
    if(bPadding && b->c->flags.b_Padding)
    {
      *px=b->c->xpad;
      *py=b->c->ypad;
      bPadding = 0;
    }
  }
}
Exemplo n.º 4
0
/**
*** DumpButtons()
*** Debug function. May only be called after ShuffleButtons has been called.
**/
void DumpButtons(button_info *b)
{
	if (!b)
	{
		fprintf(stderr, "NULL\n");
		return;
	}
	if (b != UberButton)
	{
		int button = buttonNum(b);
		fprintf(stderr,
			"0x%lx(%ix%i@(%i,%i)): ",
			(unsigned long)b, b->BWidth, b->BHeight,
			buttonXPos(b, button), buttonYPos(b, button));
	}
	else
	{
		fprintf(stderr,
			"0x%lx(%ix%i@): ",
			(unsigned long)b, b->BWidth, b->BHeight);
	}

	if (b->flags.b_Font)
		fprintf(stderr,
			"Font(%s,0x%lx) ",
			b->font_string, (unsigned long)b->Ffont);
	if (b->flags.b_Padding)
		fprintf(stderr, "Padding(%i,%i) ", b->xpad, b->ypad);
	if (b->flags.b_Frame)
		fprintf(stderr, "Framew(%i) ", b->framew);
	if (b->flags.b_Title)
		fprintf(stderr, "Title(%s) ", b->title);
	if (b->flags.b_Icon)
		fprintf(stderr, "Icon(%s,%i) ", b->icon_file, (int)b->IconWin);
	if (b->flags.b_Icon)
		fprintf(stderr, "Panelw(%i) ", (int)b->PanelWin);
	if (b->flags.b_Action)
		fprintf(stderr,
			"\n  Action(%s,%s,%s,%s) ",
			b->action[0] ? b->action[0] : "",
			b->action[1] ? b->action[1] : "",
			b->action[2] ? b->action[2] : "",
			b->action[3] ? b->action[3] : "");
	if (b->flags.b_Swallow)
	{
		fprintf(stderr, "Swallow(0x%02x) ", b->swallow);
		if (b->swallow & b_Respawn)
			fprintf(stderr, "\n  Respawn(%s) ", b->spawn);
		if (b->newflags.do_swallow_new)
			fprintf(stderr, "\n  SwallowNew(%s) ", b->spawn);
	}
	if (b->flags.b_Panel)
	{
		fprintf(stderr, "Panel(0x%02x) ", b->swallow);
		if (b->swallow & b_Respawn)
			fprintf(stderr, "\n  Respawn(%s) ", b->spawn);
		if (b->newflags.do_swallow_new)
			fprintf(stderr, "\n  SwallowNew(%s) ", b->spawn);
	}
	if (b->flags.b_Hangon)
		fprintf(stderr, "Hangon(%s) ", b->hangon);
	fprintf(stderr, "\n");
	if (b->flags.b_Container)
	{
		int i = 0;
		fprintf(stderr,
			"  Container(%ix%i=%i buttons (alloc %i),"
			" size %ix%i, pos %i,%i)\n{ ",
			b->c->num_columns, b->c->num_rows, b->c->num_buttons,
			b->c->allocated_buttons,
			b->c->width, b->c->height, b->c->xpos, b->c->ypos);
		/*
		  fprintf(stderr,"  font(%s,%i) framew(%i) pad(%i,%i) { ",
		  b->c->font_string,(int)b->c->Ffont,b->c->framew,b->c->xpad,
		  b->c->ypad);
		*/
		while (i<b->c->num_buttons)
		{
			fprintf(stderr,
				"0x%lx ", (unsigned long)b->c->buttons[i++]);
		}
		fprintf(stderr, "}\n");
		i = 0;
		while (i < b->c->num_buttons)
		{
			DumpButtons(b->c->buttons[i++]);
		}
		return;
	}
}