コード例 #1
0
ファイル: window.c プロジェクト: d33tah/whitix
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));
	}
}
コード例 #2
0
ファイル: taskbar.c プロジェクト: jetlive/xynth
void taskbar_start_menu_icon (s_window_t *window)
{
        s_surface_t *srf;
        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;

        if (s_surface_create(&srf, tbar_smenu->img->w, tbar_smenu->img->h, window->surface->bitsperpixel)) {
        	return;
        }
        s_getbox(window->surface, tbar_smenu->rect.x, tbar_smenu->rect.y, tbar_smenu->img->w, tbar_smenu->img->h, srf->vbuf);
        s_putboxrgba(srf, 0, 0, tbar_smenu->img->w, tbar_smenu->img->h, tbar_smenu->img->rgba);
        s_putbox(window->surface, tbar_smenu->rect.x, tbar_smenu->rect.y, tbar_smenu->img->w, tbar_smenu->img->h, srf->vbuf);
        s_surface_destroy(srf);
}
コード例 #3
0
ファイル: taskbar.c プロジェクト: jetlive/xynth
void taskbar_start_menu_handler_rh (s_window_t *window, s_event_t *event, s_handler_t *handler)
{
        int x;
        s_surface_t *srf;
        tbar_data_t *tbar_data;
        tbar_progs_t *tbar_progs;
        tbar_smenu_t *tbar_smenu;

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

        if (s_surface_create(&srf, (tbar_smenu->rect.w + tbar_progs->tbar_img->w + 2), (tbar_smenu->rect.h + 2), window->surface->bitsperpixel)) {
        	return;
        }
	for (x = 0; x <= tbar_smenu->rect.w + 2; x++) {
		s_putboxpart(srf, x, 0, tbar_progs->tbar_img->w, tbar_smenu->rect.h + 2, tbar_progs->tbar_img->w, tbar_progs->tbar_img->h, tbar_progs->tbar_img->buf, 0, tbar_smenu->rect.y);
	}
        s_putboxrgba(srf, 0, 0, tbar_smenu->img->w, tbar_smenu->img->h, tbar_smenu->img->rgba);
	s_putbox(window->surface, tbar_smenu->rect.x, tbar_smenu->rect.y, srf->width, srf->height, srf->vbuf);
	s_surface_destroy(srf);
}
コード例 #4
0
ファイル: menu.c プロジェクト: 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);
}
コード例 #5
0
ファイル: xynthlogout.c プロジェクト: d33tah/whitix
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;
}
コード例 #6
0
ファイル: taskbar.c プロジェクト: jetlive/xynth
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;
}