Beispiel #1
0
static void
draw (uih_context * c, void *data)
{
  int x, y, w;
  int n = (int) data;
  if (c->messg.message[n] != NULL)
    {
      int h = xtextheight (c->font);
      y = c->messg.messagestart + h * n;
      w = xtextwidth (c->font, c->messg.message[n]);
      x = (c->image->width - w) / 2;
      if (c->messg.messagetype[n])
	xprint (c->image, c->font, x, y, c->messg.message[n],
		(c->image->flags & AAIMAGE) ? BGCOLOR (c) : SELCOLOR (c),
		BGCOLOR (c), 0);
      else
	xprint (c->image, c->font, x, y, c->messg.message[n],
		(c->image->flags & AAIMAGE) ? BGCOLOR (c) : FGCOLOR (c),
		BGCOLOR (c), 0);
    }
}
Beispiel #2
0
Datei: main.c Projekt: hiciu/ekg2
static char *fstring_reverse(fstring_t *fstr) {
	const char *str;
	const fstr_attr_t *attr;
	string_t asc;
	int i;

	if (!fstr)
		return NULL;

	attr = fstr->attr;
	str = fstr->str;

	if (!attr || !str)
		return NULL;

	asc = string_init(NULL);

	for (i = 0; str[i]; i++) {
#define prev	attr[i-1]
#define cur	attr[i]
		int reset = 0;

		if (i) {
			if (!(cur & FSTR_BOLD) && (prev & FSTR_BOLD))		reset = 1;
			if (!(cur & FSTR_BLINK) && (prev & FSTR_BLINK))		reset = 1;
			if (!(cur & FSTR_UNDERLINE) && (prev & FSTR_UNDERLINE))	reset = 1;
			if (!(cur & FSTR_REVERSE) && (prev & FSTR_REVERSE))	reset = 1;
			if ((cur & FSTR_NORMAL) && !(prev & FSTR_NORMAL))	reset = 1;	/* colors disappear */

			if (reset)
				string_append(asc, "%n");
		} else
			reset = 1;

	/* attr */
		if ((cur & FSTR_BLINK) &&	(reset || !(prev & FSTR_BLINK)))	string_append(asc, "%i");
//		if ((cur & FSTR_UNDERLINE) &&	(reset || !(prev & FSTR_UNDERLINE)))	string_append(asc, "%");
//		if ((cur & FSTR_REVERSE) &&	(reset || !(prev & FSTR_REVERSE)))	string_append(asc, "%");

		if (!(cur & FSTR_NORMAL)) {
		/* background color XXX */
#define BGCOLOR(x)	-1
			if (0 && ((reset || BGCOLOR(cur) != BGCOLOR(prev)))) {
				string_append_c(asc, '%');
				switch (BGCOLOR(cur)) {
					case (0): string_append_c(asc, 'l'); break;
					case (1): string_append_c(asc, 's'); break;
					case (2): string_append_c(asc, 'h'); break;
					case (3): string_append_c(asc, 'z'); break;
					case (4): string_append_c(asc, 'e'); break;
					case (5): string_append_c(asc, 'q'); break;
					case (6): string_append_c(asc, 'd'); break;
					case (7): string_append_c(asc, 'x'); break;
				}
			}
#undef BGCOLOR

		/* foreground color */
#define FGCOLOR(x)	((!(x & FSTR_NORMAL)) ? (x & FSTR_FOREMASK) : -1)
			if (((reset || FGCOLOR(cur) != FGCOLOR(prev)) || (i && (prev & FSTR_BOLD) != (cur & FSTR_BOLD)))) {
				string_append_c(asc, '%');
				switch ((cur & FSTR_FOREMASK)) {
					case (0): string_append_c(asc, (cur & FSTR_BOLD) ? 'K' : 'k'); break;
					case (1): string_append_c(asc, (cur & FSTR_BOLD) ? 'R' : 'r'); break;
					case (2): string_append_c(asc, (cur & FSTR_BOLD) ? 'G' : 'g'); break;
					case (3): string_append_c(asc, (cur & FSTR_BOLD) ? 'Y' : 'y'); break;
					case (4): string_append_c(asc, (cur & FSTR_BOLD) ? 'B' : 'b'); break;
					case (5): string_append_c(asc, (cur & FSTR_BOLD) ? 'M' : 'm'); break; /* | fioletowy	 | %m/%p  | %M/%P | %q	| */
					case (6): string_append_c(asc, (cur & FSTR_BOLD) ? 'C' : 'c'); break;
					case (7): string_append_c(asc, (cur & FSTR_BOLD) ? 'W' : 'w'); break;
				}
			}
#undef FGCOLOR
		} else {	/* no color */
			if ((cur & FSTR_BOLD) && (reset || !(prev & FSTR_BOLD)))
				string_append(asc, "%T");
		}

	/* str */
		if (str[i] == '%' || str[i] == '\\')
			string_append_c(asc, '\\');
		string_append_c(asc, str[i]);
	}

/* reset, and return. */
	string_append(asc, "%n");
	return string_free(asc, 0);

#undef prev
#undef cur
}
Beispiel #3
0
static void drawfile(uih_context * c, void *data)
{
    int i;
    int ypos;
    int h = xtextheight(uih->image, uih->font);
    uih_drawborder(uih, filex + BORDERWIDTH, DIRSTART,
		   filewidth - 2 * BORDERWIDTH, BUTTONHEIGHT,
		   BORDER_PRESSED | BORDER_LIGHT);
    uih_drawborder(uih, filex + BORDERWIDTH, FILESTART,
		   filewidth - 2 * BORDERWIDTH, BUTTONHEIGHT,
		   BORDER_PRESSED | BORDER_LIGHT);

    ui_drawbutton("OK", (pressedbutton == 0), active == AOK
		  && activebutton == 0, filex + BORDERWIDTH,
		  filex + filewidth / 2 - BORDERWIDTH, OKSTART);
    ui_drawbutton(gettext("Cancel"), (pressedbutton == 1), active == AOK
		  && activebutton == 1,
		  filex + filewidth / 2 + BORDERWIDTH,
		  filex + filewidth - BORDERWIDTH, OKSTART);

    uih_drawborder(uih, filex + BORDERWIDTH, LISTSTART,
		   LISTWIDTH + 3 * BORDERWIDTH + SCROLLWIDTH,
		   LISTEND - LISTSTART, BORDER_PRESSED);
    uih_drawborder(uih, filex + filewidth / 2 + BORDERWIDTH, LISTSTART,
		   LISTWIDTH + 3 * BORDERWIDTH + SCROLLWIDTH,
		   LISTEND - LISTSTART, BORDER_PRESSED);
    ypos = LISTSTART + BORDERHEIGHT;
    for (i = 0; ypos + h < LISTEND && i + namestart < nnames; i++) {
	if (i + namestart == selectedname) {
	    xrectangle(uih->image, filex + 2 * BORDERWIDTH, ypos,
		       LISTWIDTH, h,
		       (uih->palette->
			type & BITMAPS) ? BGCOLOR(uih) :
		       LIGHTGRAYCOLOR(uih));
	}
	if (uih->palette->type & BITMAPS)
	    xprint(uih->image, uih->font, filex + 2 * BORDERWIDTH, ypos,
		   snames[i + namestart], 
		   i + namestart ==
		   selectedname ? FGCOLOR(uih) : BGCOLOR(uih),
		   BGCOLOR(uih), TEXT_PRESSED);
	else
	    xprint(uih->image, uih->font, filex + 2 * BORDERWIDTH, ypos,
		   snames[i + namestart], 
		   (i + namestart) == selectedname
		   && active == AFILELIST ? SELCOLOR(uih) : FGCOLOR(uih),
		   BGCOLOR(uih), 0);
	ypos += h;
    }
    if (nnames) {
	int xstart = (namestart) * (LISTEND - LISTSTART) / nnames;
	int xend = (namestart + NVISIBLE) * (LISTEND - LISTSTART) / nnames;
	if (xstart > (LISTEND - LISTSTART - 2 * BORDERHEIGHT))
	    xstart = LISTEND - LISTSTART - 2 * BORDERHEIGHT;
	if (xend > (LISTEND - LISTSTART - 2 * BORDERHEIGHT))
	    xend = LISTEND - LISTSTART - 2 * BORDERHEIGHT;
	uih_drawborder(uih, filex + LISTWIDTH + 3 * BORDERWIDTH, LISTSTART + xstart + BORDERHEIGHT, SCROLLWIDTH, xend - xstart,	/*1|BORDER_LIGHT */
		       0);
    }

    ypos = LISTSTART + BORDERHEIGHT;
    for (i = 0; ypos + h < LISTEND && i + dirstart < ndirs; i++) {
	if (i + dirstart == selecteddir) {
	    xrectangle(uih->image, filex + filewidth / 2 + 2 * BORDERWIDTH,
		       ypos, LISTWIDTH, h,
		       (uih->palette->type & BITMAPS) ? BGCOLOR(uih) :
		       LIGHTGRAYCOLOR(uih));
	}
	if (uih->palette->type & BITMAPS)
	    xprint(uih->image, uih->font,
		   filex + filewidth / 2 + 2 * BORDERWIDTH, ypos,
		   sdirs[i + dirstart], 
		   i + dirstart ==
		   selecteddir ? FGCOLOR(uih) : BGCOLOR(uih), BGCOLOR(uih),
		   TEXT_PRESSED);
	else
	    xprint(uih->image, uih->font,
		   filex + filewidth / 2 + 2 * BORDERWIDTH, ypos,
		   sdirs[i + dirstart], 
		   (i + dirstart) == selecteddir
		   && active == ADIRLIST ? SELCOLOR(uih) : FGCOLOR(uih),
		   BGCOLOR(uih), 0);
	ypos += h;
    }
    if (ndirs) {
	int xstart = (dirstart) * (LISTEND - LISTSTART) / ndirs;
	int xend = (dirstart + NVISIBLE) * (LISTEND - LISTSTART) / ndirs;
	if (xstart > (LISTEND - LISTSTART - 2 * BORDERHEIGHT))
	    xstart = LISTEND - LISTSTART - 2 * BORDERHEIGHT;
	if (xend > (LISTEND - LISTSTART - 2 * BORDERHEIGHT))
	    xend = LISTEND - LISTSTART - 2 * BORDERHEIGHT;
	uih_drawborder(uih, filex + filewidth / 2 + LISTWIDTH + 3 * BORDERWIDTH, LISTSTART + xstart + BORDERHEIGHT, SCROLLWIDTH, xend - xstart,	/*1|BORDER_LIGHT */
		       0);
    }
    ui_drawtext(filename, active == AFILE);
    ui_drawtext(dir, active == ADIR);
}
Beispiel #4
0
static void
draw (uih_context * c, void *data)
{
  int num = (int) data;
  int flags = 0;
  int xmax, n, nr, i;
  int x = 0, y = 0;
  char *string;
  int fgcolor = 0, bgcolor = 0;
  if (c->text[num] == NULL)
    return;
  prepare (c, c->text[num], &xmax, &n);
  nr = n * xtextheight (c->font);
  switch (c->textcolor[num])
    {
    case 0:
      fgcolor = FGCOLOR (c);
      bgcolor = BGCOLOR (c);
      break;
    case 1:
      fgcolor = BGCOLOR (c);
      bgcolor = BGCOLOR (c);
      flags = TEXT_PRESSED;
      break;
    case 2:
      fgcolor = SELCOLOR (c);
      bgcolor = BGCOLOR (c);
      break;
    default:
      x_fatalerror ("playtext:unknown color\n");
    }
  if (c->image->flags & AAIMAGE)
    fgcolor = BGCOLOR (c);
  switch (num)
    {
    case 0:
      y = 0;
      break;
    case 1:
      y = (c->image->height - nr) / 2;
      break;
    case 2:
      y = c->image->height - nr;
      break;
    }
  string = c->text[num];
  for (i = 0; i < n; i++)
    {
      xmax = xtextwidth (c->font, string);
      switch (c->textpos[num])
	{
	case 0:
	  x = 0;
	  break;
	case 1:
	  x = (c->image->width - xmax) / 2;
	  break;
	case 2:
	  x = c->image->width - xmax;
	  break;
	}
      string +=
	xprint (c->image, c->font, x, y, string, fgcolor, bgcolor, flags) + 1;
      y += xtextheight (c->font);
    }
}