Exemple #1
0
SWindow::SWindow (s_window_type_t type, s_window_t *parent) : SObject()
{
	s_window_init(&objectWindow);

	s_window_new(objectWindow, type, parent);
	
        s_window_atexit(objectWindow, windowAtExitCallback);
	s_window_atevent(objectWindow, windowAtEventCallback);

	objectWindow->data = this;

        s_free(objectWindow->surface->vbuf);
	objectWindow->surface->vbuf = NULL;
}
Exemple #2
0
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;
}
Exemple #3
0
static unsigned char * lxynth_init_driver (unsigned char *param, unsigned char *display)
{
        int bpp;
        int Bpp;

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

	lxynth_root = (lxynth_root_t *) s_malloc(sizeof(lxynth_root_t));
	lxynth_root->eventq = (lxynth_eventq_t *) s_malloc(sizeof(lxynth_eventq_t));
	s_list_init(&(lxynth_root->eventq->list));
	s_thread_mutex_init(&(lxynth_root->eventq->mut));
	lxynth_root->gd = (lxynth_gd_t *) s_malloc(sizeof(lxynth_gd_t));
	s_list_init(&(lxynth_root->gd->list));
	s_thread_mutex_init(&(lxynth_root->gd->mut));
	lxynth_root->gd->active = NULL;

	s_window_init(&(lxynth_root->window));
	s_window_new(lxynth_root->window, WINDOW_MAIN, NULL);
	s_window_set_coor(lxynth_root->window, WINDOW_NOFORM, 50, 50,
	                                                      (lxynth_root->window->surface->width * 2) / 3,
	                                                      (lxynth_root->window->surface->height * 2) / 3);
        bpp = lxynth_root->window->surface->bitsperpixel;
        Bpp = lxynth_root->window->surface->bytesperpixel;

        if (bpp ==  32) {
		bpp = 24;
	}
	xynth_driver.depth = (bpp << 3) | Bpp;

	s_window_show(lxynth_root->window);
	lxynth_root->tid = s_thread_create(s_window_main, lxynth_root->window);
	s_window_atevent(lxynth_root->window, lxynth_atevent);
	s_window_atexit(lxynth_root->window, lxynth_atexit);
	lxynth_root->running = 1;

	install_timer(20, lxynth_timer, NULL);

	return NULL;
}
Exemple #4
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;
}
Exemple #5
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);
}
Exemple #6
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;
}