Esempio n. 1
0
int main (int argc, char *argv[])
{
    int x;
    int y;
    int w;
    int h;
    s_window_t *window;

    s_window_init(&window);
    s_window_new(window, WINDOW_MAIN /*| WINDOW_NOFORM*/, NULL);
    s_window_set_title(window, "Demo - %s ", argv[0]);
    s_window_set_resizeable(window, 0);
    s_window_set_alwaysontop(window, 1);

    w = BOX_W * 3;
    h = BOX_H * 3;
    x = (window->surface->linear_buf_width - w) / 2;
    y = (window->surface->linear_buf_height - h) / 2;
    s_window_set_coor(window, WINDOW_NOFORM, x, y, w, h);

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

    draw_boxes(window);

    handler_set(window, S_KEYCODE_RIGHTSHIFT, handler_shift_up);
    handler_set(window, S_KEYCODE_LEFTSHIFT, handler_shift_down);
    handler_set(window, S_KEYCODE_LEFT, handler_left);
    handler_set(window, S_KEYCODE_RIGHT, handler_right);
    handler_set(window, S_KEYCODE_UP, handler_up);
    handler_set(window, S_KEYCODE_DOWN, handler_down);
    handler_set(window, S_KEYCODE_SPACE, handler_set_map);
    handler_set(window, S_KEYCODE_i, handler_set_up);
    handler_set(window, S_KEYCODE_j, handler_set_left);
    handler_set(window, S_KEYCODE_k, handler_set_down);
    handler_set(window, S_KEYCODE_l, handler_set_right);

    s_window_show(window);
    s_window_main(window);

    return 0;
}
Esempio n. 2
0
void SWindow::windowSetResizeable (int resizeable)
{
	s_window_set_resizeable(objectWindow, resizeable);
}
Esempio n. 3
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;
}
Esempio n. 4
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);
}