Example #1
0
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;
}
Example #2
0
int s_window_new (s_window_t *window, S_WINDOW type, s_window_t *parent)
{
    if (!(type & (WINDOW_MAIN | WINDOW_CHILD | WINDOW_TEMP))) {
        goto err;
    }
    window->type = type;
    if (window->surface->width <= 0) {
        window->surface->width = window->surface->linear_buf_width;
    }
    if (window->surface->height <= 0) {
        window->surface->height = window->surface->linear_buf_height;
    }
    if (window->type & (WINDOW_TEMP | WINDOW_CHILD)) {
        window->parent = parent;
    } else {
        window->parent = NULL;
    }

    s_socket_request(window, SOC_DATA_NEW);
//	window->surface->need_expose = SURFACE_NEEDSTREAM;
    s_surface_attach(window);

    s_fillbox(window->surface, 0, 0, window->surface->width,
              window->surface->height, s_rgbcolor(window->surface, 0xD4, 0xD0, 0xC8));

    return 0;
err:
    return 1;
}
Example #3
0
void taskbar_start_menu_handler_p (s_window_t *window, s_event_t *event, s_handler_t *handler)
{
        char *box;
        tbar_data_t *tbar_data;
        tbar_smenu_t *tbar_smenu;

        tbar_data = (tbar_data_t *) window->data;
        tbar_smenu = (tbar_smenu_t *) tbar_data->tbar_smenu;

        while (tbar_data->tbar_smenu->running) {
		usleep(20000);
	}

	box = (char *) s_malloc(tbar_smenu->rect.w * tbar_smenu->rect.h * window->surface->bytesperpixel);
	s_getbox(window->surface, tbar_smenu->rect.x, tbar_smenu->rect.y, tbar_smenu->rect.w, tbar_smenu->rect.h, box);
	s_fillbox(window->surface, tbar_smenu->rect.x, tbar_smenu->rect.y, tbar_smenu->rect.w + 2, tbar_smenu->rect.h + 2, s_rgbcolor(window->surface, 115, 117, 115));
	s_fillbox(window->surface, tbar_smenu->rect.x + 1, tbar_smenu->rect.y + 1, tbar_smenu->rect.w + 1, tbar_smenu->rect.h + 1, s_rgbcolor(window->surface, 255, 255, 255));
	s_putbox(window->surface, tbar_smenu->rect.x + 1, tbar_smenu->rect.y + 1, tbar_smenu->rect.w, tbar_smenu->rect.h, box);
	s_free(box);
	start_menu_start(window, tbar_data->tbar_smenu->progs, window->surface->buf->x, window->surface->buf->y);
}
Example #4
0
File: hide.c Project: jetlive/xynth
int main (int argc, char *argv[])
{
	int x = 60;
	int y = 60;
	int w = 300;
	int h = 200;
	int mw = 1000;
	int mh = 1000;

	s_timer_t *timer;
	s_window_t *window;

	srand(time(NULL));

	s_window_init(&window);

	s_window_new(window, WINDOW_TYPE_MAIN, NULL);
	mw = window->surface->width;
	mh = window->surface->height;

	s_window_set_title(window, "Demo - %s", argv[0]);
	s_window_set_coor(window, 0, x, y, MIN(mw, w), MIN(mh, h));

	s_fillbox(window->surface, mw/4, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 255, 0, 0));
	s_fillbox(window->surface, mw/2, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 0, 255, 0));
	s_fillbox(window->surface, mw/4, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 0, 0, 255));
	s_fillbox(window->surface, mw/2, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 255, 255, 255));

	s_timer_init(&timer);
	timer->timeval = SLEEP_TIME;
	timer->cb = hide_timer;
	s_timer_add(window, timer);

	s_window_atevent(window, s_event_dump);

	s_window_show(window);
	s_window_main(window);

	return 0;
}
Example #5
0
int main (int argc, char *argv[])
{
	int x = 60;
	int y = 60;
	int w = 400;
	int h = 300;
	int mw = 1000;
	int mh = 1000;
	char *box;
	s_timer_t *timer;
	s_handler_t *hndl;
	s_window_t *window;

	s_window_init(&window);

	s_window_new(window, WINDOW_TYPE_MAIN, NULL);
	mw = window->surface->width;
	mh = window->surface->height;
	box = (char *) s_malloc(sizeof(char) * (mw / 4) * (mh / 4) * window->surface->bytesperpixel);

	s_window_set_title(window, "Demo - %s", argv[0]);
	s_window_set_coor(window, 0, x, y, w, h);

	s_fillbox(window->surface, mw/4, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 255, 0, 0));
	s_fillbox(window->surface, mw/2, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 0, 255, 0));
	s_fillbox(window->surface, mw/4, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 0, 0, 255));
	s_fillbox(window->surface, mw/2, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 255, 255, 255));

	s_getbox(window->surface, mw/4, mh/4, mw/4, mh/4, box);
	s_putbox(window->surface, 0, 0, mw/4, mh/4, box);
	s_free(box);

	s_fillbox(window->surface, 0, 0, 20, 20, s_rgbcolor(window->surface, 222, 222, 222));
	s_fillbox(window->surface, 2, 2, 16, 16, s_rgbcolor(window->surface, 0, 0, 0));
	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = 2;
	hndl->mouse.y = 2;
	hndl->mouse.w = 16;
	hndl->mouse.h = 16;
	hndl->mouse.p = timer_handler_p;
	hndl->mouse.button = MOUSE_BUTTON_LEFT;
	s_handler_add(window, hndl);

	s_timer_init(&timer);
	timer->timeval = 2000;
	timer->cb = timer0_cb;
	s_timer_add(window, timer);

	s_timer_init(&timer);
	timer->timeval = 2500;
	timer->cb = timer1_cb;
	s_timer_add(window, timer);

	s_window_show(window);
	s_window_main(window);

	return 0;
}
Example #6
0
File: temp.c Project: jetlive/xynth
static void temp_handler (s_window_t *window, s_event_t *event, s_handler_t *handler)
{
        int mw;
        int mh;

	s_handler_t *hndl;
	s_window_t *child;
	s_window_init(&child);
	s_window_new(child, WINDOW_TYPE_TEMP | WINDOW_TYPE_NOFORM, window);
	s_window_set_coor(child, 0, window->surface->buf->x + 30,
	                            window->surface->buf->y + 30,
	                            150,
	                            150);
	s_window_set_title(child, "Demo - Temp");
	mw = child->surface->buf->w;
	mh = child->surface->buf->h;

	s_fillbox(child->surface, 0, 0, mw, mh, s_rgbcolor(child->surface, 255, 255, 255));
	s_fillbox(child->surface, 1, 1, mw - 2, mh - 2, s_rgbcolor(child->surface, 0, 0, 0));
	s_fillbox(child->surface, 2, 2, mw - 4, mh - 4, s_rgbcolor(child->surface, 180, 180, 180));

	s_fillbox(child->surface, 2, 2, 20, 20, s_rgbcolor(window->surface, 0, 0, 0));
	s_fillbox(child->surface, 4, 4, 16, 16, s_rgbcolor(window->surface, 255, 0, 0));

	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = 2;
	hndl->mouse.y = 2;
	hndl->mouse.w = 20;
	hndl->mouse.h = 20;
	hndl->mouse.p = temp_handler;
	hndl->mouse.button = MOUSE_BUTTON_LEFT;
	s_handler_add(child, hndl);

	s_window_show(child);
	s_window_main(child);
}
Example #7
0
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));
}
Example #8
0
static void lxynth_fill_area (struct graphics_device *dev, int left, int top, int right, int bottom, long color)
{
	lxynth_device_t *wd;

	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);

	FILL_CLIP_PREFACE;

        if (lxynth_root->running == 0) return;
        s_thread_mutex_lock(lxynth_root->gd->mut);
        if (lxynth_root->gd->active != dev) {
		s_thread_mutex_unlock(lxynth_root->gd->mut);
		return;
	}

	wd = (lxynth_device_t *) dev->driver_data;
	s_fillbox(wd->surface, left, top, right - left, bottom - top, color);
	lxynth_surface_update(dev, left, top, right - left, bottom - top);
	s_thread_mutex_unlock(lxynth_root->gd->mut);
}
Example #9
0
File: temp.c Project: jetlive/xynth
int main (int argc, char *argv[])
{
	int x = 60;
	int y = 60;
	int w = 400;
	int h = 300;
	int mw = 1000;
	int mh = 1000;
	s_handler_t *hndl;
	s_window_t *window;

	s_window_init(&window);

	s_window_new(window, WINDOW_TYPE_MAIN, NULL);
	mw = window->surface->width;
	mh = window->surface->height;

	s_window_set_title(window, "Demo - %s  ", argv[0]);
	s_window_set_coor(window, 0, x, y, MIN(mw, w), MIN(mh, h));

	s_fillbox(window->surface, mw/4, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 255, 0, 0));
	s_fillbox(window->surface, mw/2, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 0, 255, 0));
	s_fillbox(window->surface, mw/4, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 0, 0, 255));
	s_fillbox(window->surface, mw/2, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 255, 255, 255));

	s_fillbox(window->surface, 0, 0, 20, 20, s_rgbcolor(window->surface, 222, 222, 222));
	s_fillbox(window->surface, 2, 2, 16, 16, s_rgbcolor(window->surface, 0, 0, 0));
	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = 0;
	hndl->mouse.y = 0;
	hndl->mouse.w = 20;
	hndl->mouse.h = 20;
	hndl->mouse.p = temp_handler;
	hndl->mouse.button = MOUSE_BUTTON_LEFT;
	s_handler_add(window, hndl);

	s_window_show(window);
	s_window_main(window);

	return 0;
}
Example #10
0
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;
}
Example #11
0
File: menu.c Project: d33tah/whitix
void start_menu_start (s_window_t *pwindow, s_list_t *progs, int wx, int wy)
{
	int p;
	int fy;
	int fx;
	int fw;
	int fh;
	char *file;
	char *tbuf;
	s_surface_t *s;
	s_font_t *font;
	s_image_t *img;
	s_window_t *temp;
	s_handler_t *hndl;
	smenu_prog_t *sprog;
        tbar_data_t *tbar_data;

	fx = 30;
	fy = 22;
	fw = 160;
	fh = progs->nb_elt * fy + 13;
        tbar_data = (tbar_data_t *) pwindow->data;

	tbar_data->tbar_smenu->running = 1;

	s_window_init(&temp);
        s_window_new(temp, WINDOW_TEMP | WINDOW_NOFORM, pwindow);
        s_window_set_coor(temp, 0, wx, wy - fh - 1, fw, fh);

	s_fillbox(temp->surface, 0, 0, temp->surface->buf->w, temp->surface->buf->h, s_rgbcolor(temp->surface, 0, 0, 0));
	s_fillbox(temp->surface, 1, 1, temp->surface->buf->w - 2, temp->surface->buf->h - 2, s_rgbcolor(temp->surface, 255, 255, 255));
	s_fillbox(temp->surface, 1, 1, 24, temp->surface->buf->h - 2, s_rgbcolor(temp->surface, 197, 198, 189));
	
	s_font_init(&font, "arial.ttf");
	s_font_set_size(font, 13);

	p = 0;
	while (!s_list_eol(progs, p)) {
		sprog = (smenu_prog_t *) s_list_get(progs, p++);
		if ((sprog->icon != NULL) && (*(sprog->icon) != '\0')) {
			s_image_init(&img);
			file = (char *) s_malloc(sizeof(char) * (strlen(DESKTOPDIR "/img/icons/") + strlen(sprog->icon) + 1));
			sprintf(file, "%s/img/icons/%s", DESKTOPDIR, sprog->icon);
			s_image_img(file, img);
			s_image_get_handler(img);
			tbuf = (char *) s_malloc(temp->surface->bytesperpixel * 18 * 18);
			if (s_surface_create(&s, img->w, img->h, temp->surface->bitsperpixel)) {
				goto out;
			}
			s_fillbox(s, 0, 0, img->w, img->h, s_rgbcolor(s, 197, 198, 199));
			s_putboxrgba(s, 0, 0, img->w, img->h, img->rgba);
			s_scalebox(temp->surface, img->w, img->h, s->vbuf, 18, 18, tbuf);
			s_putbox(temp->surface, 4, 2 + fy - 16, 18, 18, tbuf);
			s_surface_destroy(s);
out:			s_image_uninit(img);
			s_free(file);
			s_free(tbuf);
		}

		s_font_set_str(font, sprog->name);
		s_font_get_glyph(font);
		s_image_get_handler(font->glyph.img);
		s_putboxrgba(temp->surface, fx, fy - font->glyph.yMax, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba);

		s_handler_init(&hndl);
		hndl->type = MOUSE_HANDLER;
		hndl->mouse.x = fx;
		hndl->mouse.y = fy - font->glyph.img->h + font->glyph.img->handler->y;
		hndl->mouse.w = fw - 50;
		hndl->mouse.h = font->glyph.img->h;
		hndl->mouse.p = start_menu_handler;
		hndl->mouse.button = MOUSE_LEFTBUTTON;
		hndl->data = sprog;
		s_handler_add(temp, hndl);

		if (sprog->type == SMENU_MENU) {
			s_font_set_str(font, ">");
			s_font_get_glyph(font);
			s_image_get_handler(font->glyph.img);
			s_putboxrgba(temp->surface, fw - font->glyph.img->w - 10, fy - font->glyph.yMax, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba);
		}

		fy += 22;
	}

	s_font_uninit(font);

	s_window_atexit(temp, start_menu_atexit);
	temp->data = tbar_data;

	s_window_show(temp);
	s_window_main(temp);
}
Example #12
0
void frame_two_area_red_draw (w_object_t *object)
{
	s_fillbox(object->surface, 0, 0, object->surface->width, object->surface->height, s_rgbcolor(object->surface, 255, 0, 0));
}
Example #13
0
int main (int argc, char *argv[])
{
	int x;
	int y;
	int w;
	int h;
	s_font_t *font;
	s_handler_t *hndl;
	s_window_t *window;

	s_window_init(&window);

	s_window_new(window, WINDOW_MAIN | WINDOW_NOFORM | WINDOW_DESKTOP, NULL);

	s_window_set_resizeable(window, 0);
	s_window_set_alwaysontop(window, 1);
	s_window_set_title(window, "Xynth logout");

	w = 300;
	h = 100;
	x = (window->surface->width - w) / 2;
	y = (window->surface->height - h) / 2;
	s_window_set_coor(window, WINDOW_NOFORM, x, y, w, h);

	s_free(window->surface->vbuf);
	window->surface->width = w;
	window->surface->height = h;
	window->surface->vbuf = (unsigned char *) malloc(w * h * window->surface->bytesperpixel);

	s_window_atevent(window, xynthlogout_atevent);

	s_fillbox(window->surface, 0, 0, w, h, s_rgbcolor(window->surface, 0, 0, 0));
	for (y = 2; y < h - 2; y++) {
		s_fillbox(window->surface, 2, y, w - 4, 1, s_rgbcolor(window->surface, 255 - (int) ((float) y * 255.00 / 100.00),
		                                                                       255 - (int) ((float) y * 255.00 / 100.00),
		                                                                       255));
	}

	s_font_init(&font, "arial.ttf");
	s_font_set_str(font, "Close Xynth Windowing System...");
	s_font_set_size(font, 16);
	s_font_get_glyph(font);
	s_image_get_handler(font->glyph.img);
	s_putboxrgba(window->surface, 18, 13, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba);

	s_fillbox(window->surface, 18, 15 + font->glyph.img->h + 2, font->glyph.img->w, 2, 0);
	s_font_uninit(font);

	s_fillbox(window->surface, 40, 48, 35, 35, s_rgbcolor(window->surface, 0, 0, 0));
	s_fillbox(window->surface, 42, 50, 31, 31, s_rgbcolor(window->surface, 255, 30, 30));

	s_font_init(&font, "arial.ttf");
	s_font_set_str(font, "Shutdown");
	s_font_set_size(font, 16);
	s_font_get_glyph(font);
	s_image_get_handler(font->glyph.img);
	s_putboxrgba(window->surface, 40 + 35 + 5, 48 + 12, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba);
	s_font_uninit(font);
	
	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = 40;
	hndl->mouse.y = 48;
	hndl->mouse.w = 35;
	hndl->mouse.h = 35;
	hndl->mouse.r = xynthlogout_logout;
	hndl->mouse.button = MOUSE_LEFTBUTTON;
	s_handler_add(window, hndl);

	s_fillbox(window->surface, 175, 48, 35, 35, s_rgbcolor(window->surface, 0, 0, 0));
	s_fillbox(window->surface, 177, 50, 31, 31, s_rgbcolor(window->surface, 30, 255, 30));

	s_font_init(&font, "arial.ttf");
	s_font_set_str(font, "Cancel");
	s_font_set_size(font, 16);
	s_font_get_glyph(font);
	s_image_get_handler(font->glyph.img);
	s_putboxrgba(window->surface, 175 + 35 + 5, 48 + 12, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba);
	s_font_uninit(font);

	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = 175;
	hndl->mouse.y = 48;
	hndl->mouse.w = 35;
	hndl->mouse.h = 35;
	hndl->mouse.r = xynthlogout_cancel;
	hndl->mouse.button = MOUSE_LEFTBUTTON;
	s_handler_add(window, hndl);

	s_window_show(window);
	s_window_main(window);
	
	return 0;
}
Example #14
0
void taskbar_start (s_window_t *window, s_config_t *cfg)
{
        int x;
	s_timer_t *timer;
	s_handler_t *hndl;
        tbar_data_t *tbar_data;

	s_window_set_coor(window, WINDOW_TYPE_NOFORM, 0, window->surface->height - 30, window->surface->width, 30);
	s_window_set_alwaysontop(window, 1);
	s_window_set_resizeable(window, 0);
	s_window_atevent(window, taskbar_atevent);
	s_window_atexit(window, taskbar_atexit);

	s_free(window->surface->vbuf);
	window->surface->width = window->surface->buf->w;
	window->surface->height = window->surface->buf->h;
	window->surface->vbuf = (unsigned char *) s_malloc(window->surface->width * window->surface->height * window->surface->bytesperpixel);

        tbar_data = (tbar_data_t *) s_malloc(sizeof(tbar_data_t));
        tbar_data->tbar_clock = (tbar_clock_t *) s_malloc(sizeof(tbar_clock_t));
        tbar_data->tbar_smenu = (tbar_smenu_t *) s_malloc(sizeof(tbar_smenu_t));
	s_list_init(&(tbar_data->tbar_smenu->progs));
	s_image_init(&(tbar_data->tbar_smenu->img));
	s_image_img(DESKTOPDIR "/img/icons/xynth.png", tbar_data->tbar_smenu->img);
	s_image_get_handler(tbar_data->tbar_smenu->img);
	tbar_data->tbar_smenu->running = 0;

        tbar_data->tbar_progs = (tbar_progs_t *) s_malloc(sizeof(tbar_progs_t));
	tbar_data->tbar_progs->desktop = (s_desktop_t *) s_malloc(sizeof(s_desktop_t));
	s_list_init(&(tbar_data->tbar_progs->desktop->clients));

	s_font_init(&(tbar_data->tbar_progs->prog_font), "arial.ttf");

	s_image_init(&(tbar_data->tbar_progs->tbar_img));
	s_image_img(DESKTOPDIR "/img/widget/taskbar.png", tbar_data->tbar_progs->tbar_img);
	s_image_get_buf(window->surface, tbar_data->tbar_progs->tbar_img);

	s_image_init(&(tbar_data->tbar_progs->prog_img[0]));
	s_image_img(DESKTOPDIR "/img/widget/button4.png", tbar_data->tbar_progs->prog_img[0]);
	s_image_get_buf(window->surface, tbar_data->tbar_progs->prog_img[0]);

	s_image_init(&(tbar_data->tbar_progs->prog_img[1]));
	s_image_img(DESKTOPDIR "/img/widget/button3.png", tbar_data->tbar_progs->prog_img[1]);
	s_image_get_buf(window->surface, tbar_data->tbar_progs->prog_img[1]);

	window->data = (void *) tbar_data;

	s_fillbox(window->surface, 0, 0, window->surface->buf->w, window->surface->buf->h, s_rgbcolor(window->surface, 255, 255, 255));
	s_fillbox(window->surface, 1, 1, window->surface->buf->w - 1, window->surface->buf->h - 1, s_rgbcolor(window->surface, 115, 117, 115));

	for (x = 1; x <= window->surface->buf->w; x++) {
		s_putboxpart(window->surface, x, 1, 1, window->surface->buf->h - 2, 1, 30, tbar_data->tbar_progs->tbar_img->buf, 0, 1);
	}

	tbar_data->tbar_clock->clock = NULL;
        tbar_data->tbar_clock->rect.x = window->surface->width - 3 - 75;
        tbar_data->tbar_clock->rect.y = 3;
        tbar_data->tbar_clock->rect.w = 75;
        tbar_data->tbar_clock->rect.h = window->surface->height - 6;
	s_font_init(&(tbar_data->tbar_clock->font), "veramono.ttf");
	s_font_set_size(tbar_data->tbar_clock->font, tbar_data->tbar_clock->rect.h);

        tbar_data->tbar_smenu->rect.x = 3;
        tbar_data->tbar_smenu->rect.y = 3;
        tbar_data->tbar_smenu->rect.w = window->surface->height - 6;
        tbar_data->tbar_smenu->rect.h = window->surface->height - 6;

	tbar_data->tbar_progs->rect.x = 3 + tbar_data->tbar_smenu->rect.w + 3;
	tbar_data->tbar_progs->rect.y = 3;
	tbar_data->tbar_progs->rect.w = window->surface->width - 3 - tbar_data->tbar_smenu->rect.w - 3 - 3 - tbar_data->tbar_clock->rect.w - 3;
	tbar_data->tbar_progs->rect.h = window->surface->height - 6;

	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = tbar_data->tbar_progs->rect.x;
	hndl->mouse.y = tbar_data->tbar_progs->rect.y;
	hndl->mouse.w = tbar_data->tbar_progs->rect.w;
	hndl->mouse.h = tbar_data->tbar_progs->rect.h;
	hndl->mouse.r = taskbar_progs_handler_r;
	hndl->mouse.button = MOUSE_BUTTON_LEFT;
	s_handler_add(window, hndl);

	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = tbar_data->tbar_smenu->rect.x;
	hndl->mouse.y = tbar_data->tbar_smenu->rect.y;
	hndl->mouse.w = tbar_data->tbar_smenu->rect.w;
	hndl->mouse.h = tbar_data->tbar_smenu->rect.h;
	hndl->mouse.p = taskbar_start_menu_handler_p;
	hndl->mouse.button = MOUSE_BUTTON_LEFT;
	s_handler_add(window, hndl);
	taskbar_start_menu_icon(window);

	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = tbar_data->tbar_clock->rect.x;
	hndl->mouse.y = tbar_data->tbar_clock->rect.y;
	hndl->mouse.w = tbar_data->tbar_clock->rect.w;
	hndl->mouse.h = tbar_data->tbar_clock->rect.h;
	hndl->mouse.o = taskbar_clock_handler_o;
	hndl->mouse.oh = taskbar_clock_handler_oh;
	hndl->data = NULL;
	s_handler_add(window, hndl);
	
	start_menu_setup(window, cfg);

	s_timer_init(&timer);
	timer->timeval = 1000;
	timer->cb = taskbar_clock_draw;
	s_timer_add(window, timer);
	taskbar_clock_draw(window, timer);
	
	s_window_show(window);
	s_window_main(window);
}
Example #15
0
void taskbar_clock_handler_o (s_window_t *window, s_event_t *event, s_handler_t *handler)
{
	time_t t_;
	char *text;
	struct tm *t;
        int wday =  0;
        s_font_t *font;
	s_window_t *temp;
        tbar_data_t *tbar_data;
        tbar_clock_t *tbar_clock;
	int mon[] = {0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5};
	char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
	char *mons[] = {"January", "February", "March", "April", "May", "June", "July",
	                "August", "September", "October", "November", "December"};

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

	if (tbar_clock->clock != NULL) {
		return;
	}

	t_ = time(NULL);
        t = localtime(&t_);
	text = (char *) s_malloc(sizeof(char) * 256);

	s_window_init(&temp);
        s_window_new(temp, WINDOW_TYPE_TEMP | WINDOW_TYPE_NOFORM, window);
        s_window_set_alwaysontop(temp, 1);

	/* W = C + Y + L + M + D (mod 7)
	   Where:
	   W is the day of the week (0 = Sunday, through 6 = Saturday)
	   C is a code for the century from this table (for the Gregorian calendar only):
	   	1400s, 1800s, 2200s	2	1800�is�not�a�leap�year
	   	1500s, 1900s, 2300s�����0�������1900�is�not�a�leap�year
	   	1600s, 2000s, 2400s�����5�������2000�is�a�leap�year
	   	1700s, 2100s, 2500s�����4�������2100�is�not�a�leap�year
	   Y is the last two digits of the year.
	   L is the number of leap days since the beginning of the century.
	   	Step 1:	Divide the year (two digits) by 4 and throw away the fraction.
	    	Step 2:	Notice that 1900 and 1800 were not leap years, and 2000 was. Only century
	     		years divisible by 400 are leap years. So, add 1 for those centuries
	       		divisible by 4 (as we haven't counted the leap day for year 00 yet).
		Step 3:	Also, don't count a leap day if it happens after the date that you are
			calculating. In other words subtract one, if you are calculating a date of
			January or February of a leap year.
	   M is the code for the month, from this table:
	   	1. Jan. 0	5.�May��1	9.� Sep. 5
	    	2. Feb. 3	6.�June�4	10.�Oct.�0
	     	3. Mar. 3	7.�July�6	11.�Nov. 3
	        4. Apr. 6	8.�Aug.�2	12.�Dec. 5
	   D is the date (day of month).
	*/
        switch ((t->tm_year + 1900) / 100) {
		case 14: case 18: case 22: wday = 2; break;
		case 15: case 19: case 23: wday = 0; break;
		case 16: case 20: case 24: wday = 5; break;
		case 17: case 21: case 25: wday = 4; break;
	}
	wday += t->tm_year % 100;
	wday += ((t->tm_year % 100) / 4);
	wday += ((((t->tm_year + 1900) / 100) % 4) == 0) ? 1 : 0;
	wday += mon[t->tm_mon];
	wday += t->tm_mday;
	wday %= 7;

        sprintf(text, "%s %d %s %d", days[wday], t->tm_mday, mons[t->tm_mon], t->tm_year + 1900);

	s_font_init(&font, "arial.ttf");
	s_font_set_str(font, text);
	s_font_set_size(font, 12);
	s_font_get_glyph(font);
	s_image_get_handler(font->glyph.img);

	s_window_set_coor(temp, 0, event->mouse->x - font->glyph.img->handler->w - 8,
	                           event->mouse->y - font->glyph.img->handler->h - 8,
	                           font->glyph.img->handler->w + 8,
	                           font->glyph.img->handler->h + 8);
	s_fillbox(temp->surface, 0, 0, temp->surface->buf->w, temp->surface->buf->h, s_rgbcolor(temp->surface, 0, 0, 0));
	s_fillbox(temp->surface, 1, 1, temp->surface->buf->w - 2, temp->surface->buf->h - 2, s_rgbcolor(temp->surface, 255, 255, 222));
	s_putboxrgba(temp->surface, 4, 4, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba);
	s_font_uninit(font);
	s_free(text);

	s_window_atevent(temp, taskbar_clock_popup_atevent);
	s_window_atexit(temp, taskbar_clock_popup_atexit);

	s_window_show(temp);
	s_window_main(temp);

	tbar_clock->clock = temp;
}
Example #16
0
static void object_draw_black (w_object_t *object)
{
	s_fillbox(object->surface, 0, 0, object->surface->width, object->surface->height, s_rgbcolor(object->surface, 0, 0, 0));
}
Example #17
0
static void object_draw_white (w_object_t *object)
{
	s_fillbox(object->surface, 0, 0, object->surface->width, object->surface->height, s_rgbcolor(object->surface, 255, 255, 255));
}
Example #18
0
void w_frame_draw (w_object_t *object)
{
	int i;
	int j;
	int c[4];
	w_frame_t *frame;
	w_frame_image_t *fimg;
	frame = (w_frame_t *) object->data[OBJECT_FRAME];

	if (object->surface->vbuf == NULL) {
		return;
	}

	if (object->focused) {
		frame->style |=  FRAME_FOCUSED;
	} else {
		frame->style &=  ~FRAME_FOCUSED;
	}

        for (i = 0; !s_list_eol(frame->images, i); i++) {
        	fimg = (w_frame_image_t *) s_list_get(frame->images, i);
        	if (frame->style == fimg->style) {
        		memset(object->surface->matrix, 0x00, sizeof(char) * object->surface->width * object->surface->height);
        		w_frame_draw_image(object, fimg);
        		return;
        	}
        }
        
	memset(object->surface->matrix, 0xff, sizeof(char) * object->surface->width * object->surface->height);
        switch (frame->style & FRAME_MSHAPE) {
        	case FRAME_EMPTY:
        		s_free(object->surface->matrix);
        		s_free(object->surface->vbuf);
        		object->surface->matrix = NULL;
        		object->surface->vbuf = NULL;
        		return;
		case FRAME_NOFRAME:
			memset(object->surface->matrix, 0x00, sizeof(char) * object->surface->width * object->surface->height);
			return;
		case FRAME_BOX:
		case FRAME_GROUPBOXPANEL:
			switch (frame->style & FRAME_MSHADOW) {
				case FRAME_PLAIN:
sbox_plain:				s_fillbox(object->surface, 0, 0, object->surface->buf->w, object->surface->buf->h, s_rgbcolor(object->surface, 0, 0, 0));
					break;
				case FRAME_RAISED:
					c[0] = s_rgbcolor(object->surface, 96, 96, 96);
					c[1] = s_rgbcolor(object->surface, 128, 128, 128);
					c[2] = s_rgbcolor(object->surface, 255, 255, 255);
sbox_raised:				for (i = 0; i < frame->linewidth; i++) {
						s_fillbox(object->surface, i, i, object->surface->buf->w - (i * 2), object->surface->buf->h - (i * 2), c[2]);
						s_fillbox(object->surface, i + 1, i + 1, object->surface->buf->w - (i * 2) - 1, object->surface->buf->h - (i * 2) - 1, c[0]);
					}
					s_fillbox(object->surface, i, i, object->surface->buf->w - (i * 2), object->surface->buf->h - (i * 2), c[1]);
					for (j = 0; j < frame->linewidth; j++) {
						s_fillbox(object->surface, j + i + frame->midlinewidth, j + i + frame->midlinewidth, object->surface->buf->w - ((j + i + frame->midlinewidth) * 2), object->surface->buf->h - ((j + i + frame->midlinewidth) * 2), c[0]);
						s_fillbox(object->surface, j + 1 + i + frame->midlinewidth, j + 1 + i + frame->midlinewidth, object->surface->buf->w - ((j + i + frame->midlinewidth) * 2) - 1, object->surface->buf->h - ((j + i + frame->midlinewidth) * 2) - 1, c[2]);
					}
					break;
				case FRAME_SUNKEN:
					c[2] = s_rgbcolor(object->surface, 96, 96, 96);
					c[1] = s_rgbcolor(object->surface, 128, 128, 128);
					c[0] = s_rgbcolor(object->surface, 255, 255, 255);
					goto sbox_raised;
					break;
			}
			break;
		case FRAME_PANEL:
		case FRAME_STYLEDPANEL:
			switch (frame->style & FRAME_MSHADOW) {
				case FRAME_PLAIN:
					goto sbox_plain;
					break;
				case FRAME_RAISED:
					c[0] = s_rgbcolor(object->surface, 96, 96, 96);
					c[1] = s_rgbcolor(object->surface, 255, 255, 255);
spanel_raised:				for (i = 0; i < frame->linewidth; i++) {
						s_fillbox(object->surface, i, i, object->surface->buf->w - (i * 2), object->surface->buf->h - (i * 2), c[0]);
						s_fillbox(object->surface, i, i, object->surface->buf->w - (i * 2) - 1, object->surface->buf->h - (i * 2) - 1, c[1]);
					}
					break;
				case FRAME_SUNKEN:
					c[1] = s_rgbcolor(object->surface, 96, 96, 96);
					c[0] = s_rgbcolor(object->surface, 255, 255, 255);
					goto spanel_raised;
					break;
			}
			break;
		case FRAME_WINPANEL:
		case FRAME_POPUPPANEL:
			switch (frame->style & FRAME_MSHADOW) {
				case FRAME_PLAIN:
					goto sbox_plain;
					break;
				case FRAME_RAISED:
swinpanel_raised:			c[0] = s_rgbcolor(object->surface, 0, 0, 0);
					c[1] = s_rgbcolor(object->surface, 96, 96, 96);
					c[2] = s_rgbcolor(object->surface, 220, 220, 220);
					c[3] = s_rgbcolor(object->surface, 255, 255, 255);
					s_fillbox(object->surface, 0, 0, object->surface->buf->w, object->surface->buf->h, c[0]);
					s_fillbox(object->surface, 0, 0, object->surface->buf->w - 1, object->surface->buf->h - 1, c[2]);
					s_fillbox(object->surface, 1, 1, object->surface->buf->w - 2, object->surface->buf->h - 2, c[1]);
					s_fillbox(object->surface, 1, 1, object->surface->buf->w - 3, object->surface->buf->h - 3, c[3]);
					break;
swinpanel_sunken:		case FRAME_SUNKEN:
					c[0] = s_rgbcolor(object->surface, 0, 0, 0);
					c[1] = s_rgbcolor(object->surface, 96, 96, 96);
					c[2] = s_rgbcolor(object->surface, 220, 220, 220);
					c[3] = s_rgbcolor(object->surface, 255, 255, 255);
					s_fillbox(object->surface, 0, 0, object->surface->buf->w, object->surface->buf->h, c[1]);
					s_fillbox(object->surface, 1, 1, object->surface->buf->w - 1, object->surface->buf->h - 1, c[2]);
					s_fillbox(object->surface, 1, 1, object->surface->buf->w - 2, object->surface->buf->h - 2, c[0]);
					s_fillbox(object->surface, 2, 2, object->surface->buf->w - 3, object->surface->buf->h - 3, c[3]);
					break;
			}
			break;
		case FRAME_MENUBARPANEL:
			s_fillbox(object->surface, 0, 0, object->surface->buf->w, object->surface->buf->h, s_rgbcolor(object->surface, 220, 220, 220));
			break;
		case FRAME_TOOLBARPANEL:
			c[0] = s_rgbcolor(object->surface, 96, 96, 96);
			c[1] = s_rgbcolor(object->surface, 255, 255, 255);
			s_fillbox(object->surface, 0, 0, object->surface->buf->w, object->surface->buf->h, c[0]);
			s_fillbox(object->surface, 0, 0, object->surface->buf->w - 1, object->surface->buf->h - 1, c[1]);
			break;
		case FRAME_LINEEDITPANEL:
		case FRAME_TABWIDGETPANEL:
			switch (frame->style & FRAME_MSHADOW) {
				case FRAME_PLAIN:
				case FRAME_RAISED:
					goto swinpanel_raised;
					break;
				case FRAME_SUNKEN:
					goto swinpanel_sunken;
					break;
			}
			break;
		case FRAME_HLINE:
		case FRAME_VLINE:
			break;
	}

	s_fillbox(object->surface, object->content->x, 
	                           object->content->y,
	                           object->content->w,
	                           object->content->h,
	                           s_rgbcolor(object->surface, 220, 220, 220));
}