void winpool_init() { min = parse_png("/usr/share/icons/min.png"); max = parse_png("/usr/share/icons/max.png"); clos = parse_png("/usr/share/icons/close.png"); }
void iconview_redraw(iconview_t *iv) { int sb_x, sb_y, sb_width, sb_height; int sr_x, sr_y, sr_width, sr_height; int rows, iheight, i; if (!iv->parent) return; /* clear the tmp buf */ for (i = 0; i < iv->active->width * iv->active->height; i++) iv->active->buf[i] = 0xFFFFFFFF; /* clear the parent window (we do this because the iv contains some * transparent pixels that needs white background. */ pixbuf_paint(iv->active, iv->parent->pixbuf, iv->x, iv->y); /* draw the active part of the iconview to the tmp buf */ pixbuf_crop(iv->pixbuf, iv->active, 0, iv->scroll_y); /* draw the scroll bar to the tmp buf */ if (!up_png) { up_png = parse_png("/usr/share/icons/up.png"); down_png = parse_png("/usr/share/icons/down.png"); } if (iv->show_scroll) { pixbuf_paint(up_png, iv->active, iv->width-up_png->width, 0); pixbuf_paint(down_png, iv->active, iv->width-down_png->width, iv->height-down_png->height); sb_x = iv->width-up_png->width; sb_y = up_png->height; sb_width = up_png->width; sb_height = iv->height-up_png->height-down_png->height; draw_solid(iv->active, sb_x, sb_y, sb_width, sb_height, 0xFFFF9494); rows = iv->cur/iv->icons_per_row + (iv->cur%iv->icons_per_row?1:0); iheight = iv->height > rows*iv->each_height? iv->height : rows*iv->each_height; sr_x = sb_x + 2; sr_y = sb_y + (iv->scroll_y*sb_height)/iheight; sr_width = sb_width-4; sr_height = (iv->height*sb_height)/iheight; draw_solid(iv->active, sr_x, sr_y, sr_width, sr_height, 0xFFA93131); } /* draw the tmp buf on the parent window */ pixbuf_paint(iv->active, iv->parent->pixbuf, iv->x, iv->y); /* flush the window buffer to VGA */ window_flush(iv->parent, iv->x, iv->y, iv->width, iv->height); }
void read_raw_image(const std::string& url, char** data, size_t& length, size_t& width, size_t& height, size_t& channels, Format& format, const std::string& format_hint) { general_ifstream fin(url); length = fin.file_size(); *data = new char[length]; try { fin.read(*data, length); if (format_hint == "JPG") { format = Format::JPG; } else if (format_hint == "PNG") { format = Format::PNG; } else { if (boost::algorithm::iends_with(url, "jpg") || boost::algorithm::iends_with(url, "jpeg")) { format = Format::JPG; } else if (boost::algorithm::iends_with(url, "png")) { format = Format::PNG; } } if (format == Format::JPG) { parse_jpeg(*data, length, width, height, channels); } else if (format == Format::PNG) { parse_png(*data, length, width, height, channels); } else { log_and_throw(std::string("Unsupported image format. Supported formats are JPG and PNG")); } } catch (...) { delete[] *data; *data = NULL; length = 0; throw; } fin.close(); };
int main() { pixbuf_t *icon1 = parse_png("/usr/share/icons/browser48.png"); pixbuf_t *icon2 = parse_png("/usr/share/icons/edit48.png"); pixbuf_t *icon3 = parse_png("/usr/share/icons/qonsole48.png"); pixbuf_t *icon4 = parse_png("/usr/share/icons/cpanel48.png"); pixbuf_t *icon5 = parse_png("/usr/share/icons/poweroff48.png"); window_t *win; iconview_t *iconview; /* allocate a window */ win = window_alloc("Quafios Launcher", /* title */ 465, /* width */ 100, /* height */ -2, /* x (center) */ -2, /* y (center) */ 0xFFC0C0C0, /* bg color */ "/usr/share/icons/launcher16.png" /* iconfile */); /* allocate iconview */ iconview = iconview_alloc(5, 48, 48, win->pixbuf->width, win->pixbuf->height, 0); /* insert iconview */ window_insert(win, iconview, 0, 0); /* insert icons */ iconview_insert(iconview, icon1, "Home"); iconview_insert(iconview, icon2, "Editor"); iconview_insert(iconview, icon3, "Qonsole"); iconview_insert(iconview, icon4, "Settings"); iconview_insert(iconview, icon5, "Turn off"); /* initialize events */ iconview->double_click = launch; /* redraw on the window */ iconview_redraw(iconview); /* loop */ gui_loop(); /* done */ return 0; }
void mouse_init() { /* open the mouse driver */ mouse_fd = open("/dev/mouse", 0); /* read cursor PNG */ cursor = parse_png("/usr/share/icons/mouse.png"); /* create the temporary pixbuf */ tmp = pixbuf_alloc(cursor->width, cursor->height); /* register winman at mouse driver */ ioctl(mouse_fd, MOUSE_REG, (void *) PREFIX_MOUSE); }
void add_window(int pid, wm_reg_t *req) { char fname[255]; int fd; unsigned int *buf; win_info_t *win_info; /* allocate win_info structure */ win_info = malloc(sizeof(win_info_t)); /* get window shared file name */ get_win_shfname(fname, pid, req->id); /* open the shared file */ fd = open(fname, 0); /* map the pixel buffer */ buf = mmap(NULL, req->width*req->height*4, MMAP_TYPE_FILE, MMAP_FLAGS_SHARED, fd, 0); /* close the shared file */ close(fd); /* initialize win_info structure */ win_info->next = first; win_info->pid = pid; win_info->wid = req->id; win_info->visible = req->visible; strcpy(win_info->title, req->title); strcpy(win_info->iconfile, req->iconfile); win_info->ico = parse_png(win_info->iconfile); /* allocate pixel buffer structure */ win_info->pixbuf = malloc(sizeof(pixbuf_t)); /* initialize pixbuf */ win_info->pixbuf->width = req->width; win_info->pixbuf->height = req->height; win_info->pixbuf->buf = buf; /* x and y */ if (req->x == -1) { /* generate random offsets */ rand += 100; if (rand >= vga_get_width() || rand >= vga_get_height()) rand = 100; win_info->x = rand; win_info->y = rand; } else if (req->x == -2) { win_info->x = (get_osm()->width-req->width)/2; win_info->y = (get_osm()->height-req->height)/2; } else { win_info->x = req->x; win_info->y = req->y; } /* add to the linked list */ first = win_info; wincount++; /* update screen if window is visible */ /* if (req->visible) */ draw_window(win_info, 1, 1); }