Beispiel #1
0
void s_server_window_title (int id, char *title)
{
	int i;
        int v;
        int h;
        int yo;
	s_font_t *font;
	s_surface_t *srf;

        if ((id < 0) ||
	    (title == NULL) ||
	    (server->client[id].type & WINDOW_NOFORM)) {
		return;
	}
	
        for (v = 0; v < 2; v++) {
		font = server->theme.font[v];
		s_font_set_str(font, title);
		s_font_get_glyph(font);
		s_image_get_mat(font->glyph.img);
		s_image_get_handler(font->glyph.img);

		font->glyph.img->buf = (char *) s_calloc(1, font->glyph.img->w * font->glyph.img->h * server->window->surface->bytesperpixel);
		if (s_surface_create_from_data(&srf, font->glyph.img->w, font->glyph.img->h, server->window->surface->bitsperpixel, font->glyph.img->buf)) {
			goto out;
		}

		if ((i = font->glyph.img->w / server->theme.form[v][TOP_3].w) > 0) {
			while (i--) {
				yo = server->theme.text_v_off[v] - font->glyph.img->handler->y + (server->theme.form[v][TOP_3].handler->h - font->glyph.img->handler->h) / 2;
				if ((font->glyph.img->h + yo) > server->theme.form[v][TOP_3].h) {
					h = server->theme.form[v][TOP_3].h - yo;
				} else {
					h = font->glyph.img->h;
				}
				s_putboxpart(srf, i * server->theme.form[v][TOP_3].w, 0, server->theme.form[v][TOP_3].w, h, server->theme.form[v][TOP_3].w, server->theme.form[v][TOP_3].h, server->theme.form[v][TOP_3].buf, 0, yo);
			}
		}
		if ((i = font->glyph.img->w % server->theme.form[v][TOP_3].w) > 0) {
				s_putboxpart(srf, font->glyph.img->w - server->theme.form[v][TOP_3].w, 0, server->theme.form[v][TOP_3].w, font->glyph.img->h, server->theme.form[v][TOP_3].w, server->theme.form[v][TOP_3].h, server->theme.form[v][TOP_3].buf, 0, server->theme.text_v_off[v] - font->glyph.img->handler->y + (server->theme.form[v][TOP_3].handler->h - font->glyph.img->handler->h) / 2);
		}
		s_putboxrgba(srf, 0, 0, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba);

		s_free(server->client[id].title.img[v].mat);
		s_free(server->client[id].title.img[v].buf);
		server->client[id].title.img[v].mat = (unsigned char *) s_malloc(font->glyph.img->w * font->glyph.img->h);
		server->client[id].title.img[v].buf = (char *) s_malloc(font->glyph.img->w * font->glyph.img->h * server->window->surface->bytesperpixel);
		server->client[id].title.img[v].w = font->glyph.img->w;
		server->client[id].title.img[v].h = font->glyph.img->h;
		server->client[id].title.hy[v] = font->glyph.img->handler->y;
		server->client[id].title.hh[v] = font->glyph.img->handler->h;
		memcpy(server->client[id].title.img[v].mat, font->glyph.img->mat, font->glyph.img->w * font->glyph.img->h);
		memcpy(server->client[id].title.img[v].buf, font->glyph.img->buf, font->glyph.img->w * font->glyph.img->h * server->window->surface->bytesperpixel);
		s_surface_destroy(srf);
out:		s_image_uninit(font->glyph.img);
		s_image_init(&(font->glyph.img));
	}
}
Beispiel #2
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));
}
Beispiel #3
0
jobject Java_java_awt_Toolkit_imgCreateFromFile (JNIEnv *env, jclass clazz UNUSED, jstring fileName)
{
	char *fname;
	s_image_t *img;
	DEBUGF("Enter");
	fname = java2CString(env, fileName);
	s_image_init(&img);
	if (s_image_img(fname, img)) {
		s_image_uninit(img);
		AWT_FREE(fname);
		return NULL;
	}
	AWT_FREE(fname);
	DEBUGF("Leave");
	return JCL_NewRawDataObject(env, img);
}
Beispiel #4
0
int s_image_layer_init (s_image_t **lyr)
{
	return s_image_init(lyr);
}
Beispiel #5
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;
}
Beispiel #6
0
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);
}
Beispiel #7
0
void w_frame_draw_image (w_object_t *object, w_frame_image_t *fimg)
{
	int i;
	int j;
	switch (fimg->names->nb_elt) {
		case 1:
		{
			char *name;
			s_image_t *img;
			name = (char *) s_list_get(fimg->names, 0);
#if defined(WIDGET_OPTIMIZE_MEMORY) && WIDGET_OPTIMIZE_MEMORY >= 1
			s_image_init(&img);
			s_image_img(name, img);
#else
			img = w_window_image_get(object->window, name);
#endif
			s_image_get_mat(img);
			if (fimg->rotation == FRAME_IMAGE_SOLID) {
				s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
				              0, 0, img->w, img->h, img->w, img->h, img->mat, 0, 0);
				s_putboxrgb(object->surface, 0, 0, img->w, img->h, img->rgba);
			} else if (fimg->rotation == FRAME_IMAGE_VERTICAL) {
				for (i = 0; i < object->surface->height; i++) {
					s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
					              0, i, img->w, img->h, img->w, img->h, img->mat, 0, 0);
					s_putboxrgb(object->surface, 0, i, img->w, img->h, img->rgba);
				}
			}
			s_image_free_mat(img);
#if defined(WIDGET_OPTIMIZE_MEMORY) && WIDGET_OPTIMIZE_MEMORY >= 1
			s_image_uninit(img);
#endif
			break;	
		}
		case 9:
		{
			char *name[9];
			s_image_t *imgs[9];
			name[0] = (char *) s_list_get(fimg->names, 0);
			name[1] = (char *) s_list_get(fimg->names, 1);
			name[2] = (char *) s_list_get(fimg->names, 2);
			name[3] = (char *) s_list_get(fimg->names, 3);
			name[4] = (char *) s_list_get(fimg->names, 4);
			name[5] = (char *) s_list_get(fimg->names, 5);
			name[6] = (char *) s_list_get(fimg->names, 6);
			name[7] = (char *) s_list_get(fimg->names, 7);
			name[8] = (char *) s_list_get(fimg->names, 8);
#if defined(WIDGET_OPTIMIZE_MEMORY) && WIDGET_OPTIMIZE_MEMORY >= 1
			s_image_init(&imgs[0]);
			s_image_img(name[0], imgs[0]);
			s_image_init(&imgs[1]);
			s_image_img(name[1], imgs[1]);
			s_image_init(&imgs[2]);
			s_image_img(name[2], imgs[2]);
			s_image_init(&imgs[3]);
			s_image_img(name[3], imgs[3]);
			s_image_init(&imgs[4]);
			s_image_img(name[4], imgs[4]);
			s_image_init(&imgs[5]);
			s_image_img(name[5], imgs[5]);
			s_image_init(&imgs[6]);
			s_image_img(name[6], imgs[6]);
			s_image_init(&imgs[7]);
			s_image_img(name[7], imgs[7]);
			s_image_init(&imgs[8]);
			s_image_img(name[8], imgs[8]);
#else
			imgs[0] = w_window_image_get(object->window, name[0]);
			imgs[1] = w_window_image_get(object->window, name[1]);
			imgs[2] = w_window_image_get(object->window, name[2]);
			imgs[3] = w_window_image_get(object->window, name[3]);
			imgs[4] = w_window_image_get(object->window, name[4]);
			imgs[5] = w_window_image_get(object->window, name[5]);
			imgs[6] = w_window_image_get(object->window, name[6]);
			imgs[7] = w_window_image_get(object->window, name[7]);
			imgs[8] = w_window_image_get(object->window, name[8]);
#endif
			s_image_get_mat(imgs[0]);
			s_image_get_mat(imgs[1]);
			s_image_get_mat(imgs[2]);
			s_image_get_mat(imgs[3]);
			s_image_get_mat(imgs[4]);
			s_image_get_mat(imgs[5]);
			s_image_get_mat(imgs[6]);
			s_image_get_mat(imgs[7]);
			s_image_get_mat(imgs[8]);
			
			/* 0 1 2
			 * 3 4 5
			 * 6 7 8
			 */
			for (j = 0; j < object->surface->height; j+= imgs[4]->h) {
				for (i = 0; i < object->surface->width; i+= imgs[4]->w) {
					s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
					              i, j, imgs[4]->w, imgs[4]->h, imgs[4]->w, imgs[4]->h, imgs[4]->mat, 0, 0);
					s_putboxrgb(object->surface, i, j, imgs[4]->w, imgs[4]->h, imgs[4]->rgba);
				}
			}
			for (i = 0; i < object->surface->width; i += imgs[1]->w) {
				s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
				              i, 0, imgs[1]->w, imgs[1]->h, imgs[1]->w, imgs[1]->h, imgs[1]->mat, 0, 0);
				s_putboxrgb(object->surface, i, 0, imgs[1]->w, imgs[1]->h, imgs[1]->rgba);
			}
			for (i = 0; i < object->surface->width; i += imgs[7]->w) {
				s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
				              i, object->surface->height - imgs[7]->h, imgs[7]->w, imgs[7]->h, imgs[7]->w, imgs[7]->h, imgs[7]->mat, 0, 0);
				s_putboxrgb(object->surface, i, object->surface->height - imgs[7]->h, imgs[7]->w, imgs[7]->h, imgs[7]->rgba);
			}
			for (i = 0; i < object->surface->height; i += imgs[3]->h) {
				s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
				              0, i, imgs[3]->w, imgs[3]->h, imgs[3]->w, imgs[3]->h, imgs[3]->mat, 0, 0);
				s_putboxrgb(object->surface, 0, i, imgs[3]->w, imgs[3]->h, imgs[3]->rgba);
			}
			for (i = 0; i < object->surface->height; i += imgs[5]->h) {
				s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
				              object->surface->width - imgs[5]->w, i, imgs[5]->w, imgs[5]->h, imgs[5]->w, imgs[5]->h, imgs[5]->mat, 0, 0);
				s_putboxrgb(object->surface, object->surface->width - imgs[5]->w, i, imgs[5]->w, imgs[5]->h, imgs[5]->rgba);
			}
			s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
			              0, 0, imgs[0]->w, imgs[0]->h, imgs[0]->w, imgs[0]->h, imgs[0]->mat, 0, 0);
			s_putboxrgb(object->surface, 0, 0, imgs[0]->w, imgs[0]->h, imgs[0]->rgba);
			s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
			              object->surface->width - imgs[2]->w, 0, imgs[2]->w, imgs[2]->h, imgs[2]->w, imgs[2]->h, imgs[2]->mat, 0, 0);
			s_putboxrgb(object->surface, object->surface->width - imgs[2]->w, 0, imgs[2]->w, imgs[2]->h, imgs[2]->rgba);
			s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
			              0, object->surface->height - imgs[6]->h, imgs[6]->w, imgs[6]->h, imgs[6]->w, imgs[6]->h, imgs[6]->mat, 0, 0);
			s_putboxrgb(object->surface, 0, object->surface->height - imgs[6]->h, imgs[6]->w, imgs[6]->h, imgs[6]->rgba);
			s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
			              object->surface->width - imgs[8]->w, object->surface->height - imgs[8]->h, imgs[8]->w, imgs[8]->h, imgs[8]->w, imgs[8]->h, imgs[8]->mat, 0, 0);
			s_putboxrgb(object->surface, object->surface->width - imgs[8]->w, object->surface->height - imgs[8]->h, imgs[8]->w, imgs[8]->h, imgs[8]->rgba);

			s_image_free_mat(imgs[0]);
			s_image_free_mat(imgs[1]);
			s_image_free_mat(imgs[2]);
			s_image_free_mat(imgs[3]);
			s_image_free_mat(imgs[4]);
			s_image_free_mat(imgs[5]);
			s_image_free_mat(imgs[6]);
			s_image_free_mat(imgs[7]);
			s_image_free_mat(imgs[8]);
#if defined(WIDGET_OPTIMIZE_MEMORY) && WIDGET_OPTIMIZE_MEMORY >= 1
			s_image_uninit(imgs[0]);
			s_image_uninit(imgs[1]);
			s_image_uninit(imgs[2]);
			s_image_uninit(imgs[3]);
			s_image_uninit(imgs[4]);
			s_image_uninit(imgs[5]);
			s_image_uninit(imgs[6]);
			s_image_uninit(imgs[7]);
			s_image_uninit(imgs[8]);
#endif
			break;
		}
		case 3:
		{
			char *name[3];
			s_image_t *imgs[3];
			name[0] = (char *) s_list_get(fimg->names, 0);
			name[1] = (char *) s_list_get(fimg->names, 1);
			name[2] = (char *) s_list_get(fimg->names, 2);
#if defined(WIDGET_OPTIMIZE_MEMORY) && WIDGET_OPTIMIZE_MEMORY >= 1
			s_image_init(&imgs[0]);
			s_image_img(name[0], imgs[0]);
			s_image_init(&imgs[1]);
			s_image_img(name[1], imgs[1]);
			s_image_init(&imgs[2]);
			s_image_img(name[2], imgs[2]);
#else
			imgs[0] = w_window_image_get(object->window, name[0]);
			imgs[1] = w_window_image_get(object->window, name[1]);
			imgs[2] = w_window_image_get(object->window, name[2]);
#endif
			s_image_get_mat(imgs[0]);
			s_image_get_mat(imgs[1]);
			s_image_get_mat(imgs[2]);
			if (fimg->rotation == FRAME_IMAGE_VERTICAL) {
				s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
				              0, 0, imgs[0]->w, imgs[0]->h, imgs[0]->w, imgs[0]->h, imgs[0]->mat, 0, 0);
				s_putboxrgb(object->surface, 0, 0, imgs[0]->w, imgs[0]->h, imgs[0]->rgba);
				for (i = imgs[0]->h; i < object->surface->height - imgs[2]->h; i++) {
					s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
					              0, i, imgs[1]->w, imgs[1]->h, imgs[1]->w, imgs[1]->h, imgs[1]->mat, 0, 0);
					s_putboxrgb(object->surface, 0, i, imgs[1]->w, imgs[1]->h, imgs[1]->rgba);
				}
				s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
				              0, object->surface->height - imgs[2]->h, imgs[2]->w, imgs[2]->h, imgs[2]->w, imgs[2]->h,
				              imgs[2]->mat, 0, 0);
				s_putboxrgb(object->surface, 0, object->surface->height - imgs[2]->h, imgs[2]->w, imgs[2]->h, imgs[2]->rgba);
			} else if (fimg->rotation == FRAME_IMAGE_HORIZONTAL) {
				s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
				              0, 0, imgs[0]->w, imgs[0]->h, imgs[0]->w, imgs[0]->h, imgs[0]->mat, 0, 0);
				s_putboxrgb(object->surface, 0, 0, imgs[0]->w, imgs[0]->h, imgs[0]->rgba);
				for (i = imgs[0]->w; i < object->surface->width - imgs[2]->w; i++) {
					s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
					              i, 0, imgs[1]->w, imgs[1]->h, imgs[1]->w, imgs[1]->h, imgs[1]->mat, 0, 0);
					s_putboxrgb(object->surface, i, 0, imgs[1]->w, imgs[1]->h, imgs[1]->rgba);
				}
				s_putmaskpart(object->surface->matrix, object->surface->width, object->surface->height,
				              object->surface->width - imgs[2]->w, 0, imgs[2]->w, imgs[2]->h, imgs[2]->w, imgs[2]->h,
				              imgs[2]->mat, 0, 0);
				s_putboxrgb(object->surface, object->surface->width - imgs[2]->w, 0, imgs[2]->w, imgs[2]->h, imgs[2]->rgba);
			}
			s_image_free_mat(imgs[0]);
			s_image_free_mat(imgs[1]);
			s_image_free_mat(imgs[2]);
#if defined(WIDGET_OPTIMIZE_MEMORY) && WIDGET_OPTIMIZE_MEMORY >= 1
			s_image_uninit(imgs[0]);
			s_image_uninit(imgs[1]);
			s_image_uninit(imgs[2]);
#endif
			break;
		}
	}				
}
Beispiel #8
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);
}
Beispiel #9
0
Mines::Mines (int argc, char *argv[])
{
        int r;
        int c;
        int o;
        char *tmp;
	SButton *sbutton;
	MButton *mbutton;
        unsigned int *rgba;
        char *flag_img = {"        .     "
        	          "....... .     "
	                  ".,,,,,. .     "
	                  ".,,,,,. .     "
	                  ".,,,,,. .     "
	                  ".,,,,,. .     "
	                  "....... .     "
	                  "        .     "
	                  "        .     "
	                  "        .     "
	                  "        .     "
	                  "      ....    "
	                  "     ......   "
	                  "   ..........."};
	char *mine_img = {"      .       "
        	          "      .       "
	                  " .  .....     "
	                  "  .........   "
	                  "  .........   "
	                  " ...,,......  "
	                  " ...,,......  "
	                  ".............."
	                  " ...........  "
	                  " ...........  "
	                  "  .........   "
	                  "  .........   "
	                  " .  .....  .  "
	                  "      .       "};

	minesC = 40;
	minesW = 17;
	minesH = 17;

	while ((o = getopt(argc, argv, "m:w:h:")) != -1) {
		switch (o) {
			case 'm':
				minesC = atoi(optarg);
				break;
			case 'w':
				minesW = atoi(optarg);
				break;
			case 'h':
				minesH = atoi(optarg);
				break;
			default:
				break;
		}
	}

	minesMatrix = new int*[minesH];
	minesMatrix_ = new int*[minesH];
	for (o = 0; o < minesH; o++) {
		minesMatrix[o] = new int[minesW];
		minesMatrix_[o] = new int[minesW];
	}
	
	minesWindow = new SWindow();

	s_image_init(&minesFlag);
	minesFlag->rgba = (unsigned int *) s_malloc(14 * 14 * sizeof(unsigned int));
	tmp = flag_img;
	rgba = minesFlag->rgba;
	minesFlag->w = 14;
	minesFlag->h = 14;
	for (r = 0; r < 14; r++) {
		for (c = 0; c < 14; c++) {
			if (*tmp == '.') {
				*rgba = 0x00000000;
			} else if (*tmp == ',') {
				*rgba = 0xFF000000;
			} else {
				*rgba = 0x000000FF;
			}
			tmp++;
			rgba++;
		}
	}
	s_image_get_mat(minesFlag);
	s_image_get_buf(minesWindow->objectWindow->surface, minesFlag);
	
	s_image_init(&minesMine);
	minesMine->rgba = (unsigned int *) s_malloc(14 * 14 * sizeof(unsigned int));
	tmp = mine_img;
	rgba = minesMine->rgba;
	minesMine->w = 14;
	minesMine->h = 14;
	for (r = 0; r < 14; r++) {
		for (c = 0; c < 14; c++) {
			if (*tmp == '.') {
				*rgba = 0x00000000;
			} else if (*tmp == ',') {
				*rgba = 0xFFFFFF00;
			} else {
				*rgba = 0x000000FF;
			}
			tmp++;
			rgba++;
		}
	}
	s_image_get_mat(minesMine);
	s_image_get_buf(minesWindow->objectWindow->surface, minesMine);
	
	topLayout = new SLayout(minesWindow, 1, 1);
	topLayout->layoutSetColSpacing(10);
	topLayout->layoutSetRowSpacing(10);
	
	btnsLayout = new SLayout(NULL, 1, 3);
	btnsLayout->layoutSetColSpacing(5);
	btnsLayout->layoutSetRowSpacing(5);
	
	minesLayout = new SLayout(NULL, minesH, minesW);
	minesLayout->layoutSetColSpacing(1);
	minesLayout->layoutSetRowSpacing(1);

//	topLayout->layoutInsertObject(btnsLayout, 0, 0);
	topLayout->layoutInsertObject(minesLayout, 0, 0);
	
	sbutton = new SButton(NULL, SFrame::Panel);
	btnsLayout->layoutInsertObject(sbutton, 0, 1);
	
	for (r = 0; r < minesH; r++) {
		for (c = 0; c < minesW; c++) {
			mbutton = new MButton();
			mbutton->buttonR = r;
			mbutton->buttonC = c;
			mbutton->buttonMines = this;
			minesLayout->layoutInsertObject(mbutton, r, c);
		}
	}
	
	minesWindow->windowSetCoor(0, 0, minesW * 25, minesH * 25);
	minesWindow->windowSetTitle("Demo - %s", argv[0]);
	
	minesInit();

#ifdef DEBUG
	for (r = 0; r < minesH; r++) {
		for (c = 0; c < minesW; c++) {
			printf("%3d", minesMatrix[r][c]);
		}
		printf("\n");
	}
#endif
	
	minesWindow->windowShow();
	minesWindow->windowMain();
}