コード例 #1
0
ファイル: taskbar.c プロジェクト: jetlive/xynth
void taskbar_clock_draw (s_window_t *window, s_timer_t *timer)
{
	int w_;
	time_t t_;
	struct tm *t;
	int _w = 0;
        char *vbuf;
        s_surface_t *srf;
        tbar_data_t *tbar_data;
        tbar_clock_t *tbar_clock;
	int c0 = s_rgbcolor(window->surface, 96, 96, 96);
	int c1 = s_rgbcolor(window->surface, 255, 255, 255);
	int c2 = s_rgbcolor(window->surface, 220, 220, 220);

	tbar_data = (tbar_data_t *) window->data;
	tbar_clock = tbar_data->tbar_clock;

	t_ = time(NULL);
        t = localtime(&t_);

	vbuf = (char *) s_malloc(sizeof(char) * 10);
	if (t->tm_sec & 1) {
		sprintf(vbuf, "%02d:%02d ", t->tm_hour, t->tm_min);
	} else {
		sprintf(vbuf, "%02d %02d ", t->tm_hour, t->tm_min);
	}
	s_font_set_str(tbar_clock->font, vbuf);
	s_free(vbuf);

	s_font_get_glyph(tbar_clock->font);

	if (s_surface_create(&srf, tbar_clock->rect.w, tbar_clock->rect.h, window->surface->bitsperpixel)) {
		return;
	}

	s_fillbox(srf, 0, 0, tbar_clock->rect.w, tbar_clock->rect.h, c0);
	s_fillbox(srf, 1, 1, tbar_clock->rect.w - 1, tbar_clock->rect.h - 1, c1);
	s_fillbox(srf, 1, 1, tbar_clock->rect.w - 2, tbar_clock->rect.h - 2, c2);

	w_ = tbar_clock->font->glyph.img->w;
	if (tbar_clock->font->glyph.img->w > (tbar_clock->rect.w - 6)) {
		w_ = tbar_clock->rect.w - 6;
		_w = tbar_clock->font->glyph.img->w - (tbar_clock->rect.w - 6);
	}
	s_putboxpartrgba(srf, 3, 4, w_, tbar_clock->font->glyph.img->h, tbar_clock->font->glyph.img->w, tbar_clock->font->glyph.img->h, tbar_clock->font->glyph.img->rgba, 0, 0);

        s_putbox(window->surface, tbar_clock->rect.x, tbar_clock->rect.y, tbar_clock->rect.w, tbar_clock->rect.h, srf->vbuf);

        s_surface_destroy(srf);
        return;
}
コード例 #2
0
ファイル: taskbar.c プロジェクト: jetlive/xynth
void taskbar_progs_draw_client (tbar_progs_t *tbar_progs, s_surface_t *surface, s_desktop_client_t *client, int x, int y, int w, int h)
{
        int x_;
        int w_ = 0;
        int _w = 0;
        char *text;
	s_font_t *font;

	x += 2;
	w -= 4;

	text = (char *) s_malloc(sizeof(char) * (50 + 1));
	snprintf(text, 50, "%s", client->title);

	font = tbar_progs->prog_font;
	s_font_set_str(font, text);
	s_font_set_size(font, h - 8);
	s_font_get_glyph(font);
	s_image_get_handler(font->glyph.img);

	s_fillbox(surface, x, y, w, h, s_rgbcolor(surface, 123, 121, 115));

	if (!client->pri) {
		for (x_ = w - 3; x_ >= 0; x_--) {
			s_putbox(surface, x + 1 + x_, y + 1, 1, h - 2, tbar_progs->prog_img[0]->buf);
		}
		x += 1;
		y += 1;
	} else {
		for (x_ = w - 3; x_ >= 0; x_--) {
			s_putbox(surface, x + 1 + x_, y + 1, 1, h - 2, tbar_progs->prog_img[1]->buf);
		}
	}

	y += 5;
	x += 4;
	w_ = font->glyph.img->w;

	if (font->glyph.img->w > (w - 8)) {
		w_ = w - 8;
		_w = font->glyph.img->w - (w - 8);
	}

	s_putboxpartrgba(surface, x, y, w_, font->glyph.img->h, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba, 0, 0);

	s_free(text);
	s_image_uninit(font->glyph.img);
	s_image_init(&(font->glyph.img));
}
コード例 #3
0
ファイル: onscreenkeyboard.c プロジェクト: d33tah/whitix
static int draw_single_box (s_surface_t *wsurface, s_rect_t *rect, osk_char_t c[4], int colors[2], image_bin_t *image_bin)
{
    int i;
    int r;
    int g;
    int b;
    int fh;
    int x = 0;
    int y = 0;
    char *tbuf;
    s_image_t *img;
    s_font_t *font;
    s_surface_t *surface;

    if (s_surface_create(&surface, rect->w, rect->h, wsurface->bitsperpixel)) {
        return -1;
    }

    s_fillbox(surface, 0, 0, rect->w, rect->h, colors[0]);

    s_image_init(&img);
    image_load(img, image_bin->width, image_bin->height, (unsigned char *) image_bin->pixel_data);
    s_image_get_buf(surface, img);
    tbuf = (char *) s_malloc(sizeof(char) * (rect->w - 2) * (rect->h - 2) * surface->bytesperpixel);
    s_scalebox(surface, img->w, img->h, img->buf, rect->w - 2, rect->h - 2, tbuf);
    s_putbox(surface, 1, 1, rect->w - 2, rect->h - 2, tbuf);
    s_free(tbuf);
    s_image_uninit(img);

    fh = rect->h / 3;

    for (i = 0; i < 4; i++) {
        s_font_init(&font, "veramono.ttf");
        s_font_set_str(font, c[i].name);
        s_colorrgb(wsurface, colors[1], &r, &g, &b);
        s_font_set_rgb(font, r, g, b);
        if (strlen(c[i].name) > 1) {
            s_font_set_size(font, fh - 5);
        } else {
            s_font_set_size(font, fh);
        }
        s_font_get_glyph(font);
        s_image_get_handler(font->glyph.img);

        font->glyph.img->handler->x = 0;
        font->glyph.img->handler->y = 0;
        font->glyph.img->handler->w = font->glyph.img->w;
        font->glyph.img->handler->h = font->glyph.img->h;

        switch (i) {
        case 0:
            x = 5;
            y = (rect->h - fh) / 2;
            break;
        case 1:
            x = (rect->w - font->glyph.img->handler->w) / 2;
            y = 2;
            break;
        case 2:
            x = rect->w - font->glyph.img->handler->w - 3;
            y = (rect->h - fh) / 2;
            break;
        case 3:
            y = rect->h - fh - 7;
            x = (rect->w - font->glyph.img->handler->w) / 2;
            break;
        }
        s_putboxpartrgba(surface, x, y + fh - font->glyph.yMax, font->glyph.img->handler->w, font->glyph.img->handler->h, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba, font->glyph.img->handler->x, font->glyph.img->handler->y);

        s_font_uninit(font);
    }

    s_putbox(wsurface, rect->x, rect->y, rect->w, rect->h, surface->vbuf);

    s_surface_destroy(surface);
    return 0;
}