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; }
static void handler_set (s_window_t *window, S_KEYCODE_CODE key, void (*func) (s_window_t *, s_event_t *, s_handler_t *)) { s_handler_t *hndl; s_handler_init(&hndl); hndl->type = KEYBD_HANDLER; hndl->keybd.flag = 0; hndl->keybd.button = key; hndl->keybd.r = func; s_handler_add(window, hndl); }
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; }
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); }
void s_server_window_handlers_add_mouse (int id) { int v = 1; s_handler_t *hndl; /* menu */ hndl = server->whndl[0]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].button[MENU].x + server->theme.button[v][MENU].handler->x; hndl->mouse.y = server->client[id].button[MENU].y + server->theme.button[v][MENU].handler->y; hndl->mouse.w = server->theme.button[v][MENU].handler->w; hndl->mouse.h = server->theme.button[v][MENU].handler->h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_menu_p; hndl->mouse.r = s_server_window_btn_menu_r; hndl->mouse.oh = s_server_window_btn_menu_oh; hndl->mouse.ho = s_server_window_btn_menu_ho; hndl->mouse.hoh = s_server_window_btn_menu_oh; s_handler_add(server->window, hndl); /* hide */ hndl = server->whndl[1]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].button[HIDE].x + server->theme.button[v][HIDE].handler->x; hndl->mouse.y = server->client[id].button[HIDE].y + server->theme.button[v][HIDE].handler->y; hndl->mouse.w = server->theme.button[v][HIDE].handler->w; hndl->mouse.h = server->theme.button[v][HIDE].handler->h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_hide_p; hndl->mouse.r = s_server_window_btn_hide_r; hndl->mouse.oh = s_server_window_btn_hide_oh; hndl->mouse.ho = s_server_window_btn_hide_ho; hndl->mouse.hoh = s_server_window_btn_hide_oh; s_handler_add(server->window, hndl); /* close */ hndl = server->whndl[2]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].button[CLOSE].x + server->theme.button[v][CLOSE].handler->x; hndl->mouse.y = server->client[id].button[CLOSE].y + server->theme.button[v][CLOSE].handler->y; hndl->mouse.w = server->theme.button[v][CLOSE].handler->w; hndl->mouse.h = server->theme.button[v][CLOSE].handler->h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_close_p; hndl->mouse.r = s_server_window_btn_close_r; hndl->mouse.oh = s_server_window_btn_close_oh; hndl->mouse.ho = s_server_window_btn_close_ho; hndl->mouse.hoh = s_server_window_btn_close_oh; s_handler_add(server->window, hndl); if (server->client[id].resizeable == 1) { /* maximize */ hndl = server->whndl[3]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].button[MAXIMIZE].x + server->theme.button[v][MAXIMIZE].handler->x; hndl->mouse.y = server->client[id].button[MAXIMIZE].y + server->theme.button[v][MAXIMIZE].handler->y; hndl->mouse.w = server->theme.button[v][MAXIMIZE].handler->w; hndl->mouse.h = server->theme.button[v][MAXIMIZE].handler->h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_maximize_p; hndl->mouse.r = s_server_window_btn_maximize_r; hndl->mouse.oh = s_server_window_btn_maximize_oh; hndl->mouse.ho = s_server_window_btn_maximize_ho; hndl->mouse.hoh = s_server_window_btn_maximize_oh; s_handler_add(server->window, hndl); } if (server->client[id].win.w > server->theme.form_min.w) { /* move 2 */ hndl = server->whndl[4]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_2].x; hndl->mouse.y = server->client[id].form[TOP_2].y + server->theme.form[v][TOP_2].handler->y + 4; hndl->mouse.w = server->client[id].form[TOP_2].w; hndl->mouse.h = server->theme.form[v][TOP_2].handler->h - 4; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_move; s_handler_add(server->window, hndl); /* move 3 */ hndl = server->whndl[5]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_3].x; hndl->mouse.y = server->client[id].form[TOP_3].y + server->theme.form[v][TOP_3].handler->y + 4; hndl->mouse.w = server->client[id].form[TOP_3].w; hndl->mouse.h = server->theme.form[v][TOP_3].handler->h - 4; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_move; s_handler_add(server->window, hndl); /* move 4 */ hndl = server->whndl[6]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_4].x; hndl->mouse.y = server->client[id].form[TOP_4].y + server->theme.form[v][TOP_4].handler->y + 4; hndl->mouse.w = server->client[id].form[TOP_4].w; hndl->mouse.h = server->theme.form[v][TOP_4].handler->h - 4; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_move; s_handler_add(server->window, hndl); } /* move 5*/ hndl = server->whndl[7]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_5].x; hndl->mouse.y = server->client[id].form[TOP_5].y + server->theme.form[v][TOP_5].handler->y + 4; hndl->mouse.w = server->client[id].form[TOP_5].w; hndl->mouse.h = server->theme.form[v][TOP_5].handler->h - 4; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_move; s_handler_add(server->window, hndl); if (server->client[id].resizeable == 0) { return; } /* resize u1 */ hndl = server->whndl[8]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_1].x; hndl->mouse.y = server->client[id].form[TOP_1].y + server->theme.form[v][TOP_1].handler->y; hndl->mouse.w = server->client[id].form[TOP_1].w; hndl->mouse.h = 4; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_up; hndl->mouse.o = s_server_window_btn_resize_u_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); if (server->client[id].win.w > server->theme.form_min.w) { /* resize u2 */ hndl = server->whndl[9]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_2].x; hndl->mouse.y = server->client[id].form[TOP_2].y + server->theme.form[v][TOP_2].handler->y; hndl->mouse.w = server->client[id].form[TOP_2].w; hndl->mouse.h = 4; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_up; hndl->mouse.o = s_server_window_btn_resize_u_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); /* resize u3 */ hndl = server->whndl[10]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_3].x; hndl->mouse.y = server->client[id].form[TOP_3].y + server->theme.form[v][TOP_3].handler->y; hndl->mouse.w = server->client[id].form[TOP_3].w; hndl->mouse.h = 4; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_up; hndl->mouse.o = s_server_window_btn_resize_u_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); /* resize u4 */ hndl = server->whndl[11]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_4].x; hndl->mouse.y = server->client[id].form[TOP_4].y + server->theme.form[v][TOP_4].handler->y; hndl->mouse.w = server->client[id].form[TOP_4].w; hndl->mouse.h = 4; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_up; hndl->mouse.o = s_server_window_btn_resize_u_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); } /* resize u5 */ hndl = server->whndl[12]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_5].x; hndl->mouse.y = server->client[id].form[TOP_5].y + server->theme.form[v][TOP_5].handler->y; hndl->mouse.w = server->client[id].form[TOP_5].w; hndl->mouse.h = 4; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_up; hndl->mouse.o = s_server_window_btn_resize_u_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); /* resize ul */ hndl = server->whndl[13]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_L].x + server->theme.form[v][TOP_L].handler->x; hndl->mouse.y = server->client[id].form[TOP_L].y + server->theme.form[v][TOP_L].handler->y; hndl->mouse.w = server->theme.form[v][TOP_L].handler->w; hndl->mouse.h = server->theme.form[v][TOP_L].handler->h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_up_left; hndl->mouse.o = s_server_window_btn_resize_ul_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); /* resize ur */ hndl = server->whndl[14]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[TOP_R].x; hndl->mouse.y = server->client[id].form[TOP_R].y + server->theme.form[v][TOP_R].handler->y; hndl->mouse.w = server->theme.form[v][TOP_R].handler->w; hndl->mouse.h = server->theme.form[v][TOP_R].handler->h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_up_right; hndl->mouse.o = s_server_window_btn_resize_ur_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); /* resize l */ hndl = server->whndl[15]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[LEFT].x + server->theme.form[v][LEFT].handler->x; hndl->mouse.y = server->client[id].form[LEFT].y; hndl->mouse.w = server->theme.form[v][LEFT].handler->w; hndl->mouse.h = server->client[id].form[LEFT].h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_left; hndl->mouse.o = s_server_window_btn_resize_l_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); /* resize r */ hndl = server->whndl[16]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[RIGHT].x; hndl->mouse.y = server->client[id].form[RIGHT].y; hndl->mouse.w = server->theme.form[v][RIGHT].handler->w; hndl->mouse.h = server->client[id].form[RIGHT].h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_right; hndl->mouse.o = s_server_window_btn_resize_r_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); /* resize d */ hndl = server->whndl[17]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[BTM].x; hndl->mouse.y = server->client[id].form[BTM].y; hndl->mouse.w = server->client[id].form[BTM].w; hndl->mouse.h = server->theme.form[v][BTM].handler->h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_down; hndl->mouse.o = s_server_window_btn_resize_d_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); /* resize dl */ hndl = server->whndl[18]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[BTM_L].x + server->theme.form[v][BTM_L].handler->x; hndl->mouse.y = server->client[id].form[BTM_L].y; hndl->mouse.w = server->theme.form[v][BTM_L].handler->w; hndl->mouse.h = server->theme.form[v][BTM_L].handler->h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_down_left; hndl->mouse.o = s_server_window_btn_resize_dl_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); /* resize dr */ hndl = server->whndl[19]; hndl->type = MOUSE_HANDLER; hndl->mouse.x = server->client[id].form[BTM_R].x; hndl->mouse.y = server->client[id].form[BTM_R].y; hndl->mouse.w = server->theme.form[v][BTM_R].handler->w; hndl->mouse.h = server->theme.form[v][BTM_R].handler->h; hndl->mouse.button = MOUSE_LEFTBUTTON; hndl->mouse.p = s_server_window_btn_resize_down_right; hndl->mouse.o = s_server_window_btn_resize_dr_o; hndl->mouse.oh = s_server_window_btn_resize_oh; s_handler_add(server->window, hndl); }
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); }
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; }
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); }