/** * gdk_pixbuf_render_pixmap_and_mask_for_colormap: * @pixbuf: A pixbuf. * @colormap: A #GdkColormap * @pixmap_return: Location to store a pointer to the created pixmap, * or %NULL if the pixmap is not needed. * @mask_return: Location to store a pointer to the created mask, * or %NULL if the mask is not needed. * @alpha_threshold: Threshold value for opacity values. * * Creates a pixmap and a mask bitmap which are returned in the @pixmap_return * and @mask_return arguments, respectively, and renders a pixbuf and its * corresponding tresholded alpha mask to them. This is merely a convenience * function; applications that need to render pixbufs with dither offsets or to * given drawables should use gdk_draw_pixbuf(), and gdk_pixbuf_render_threshold_alpha(). * * The pixmap that is created uses the #GdkColormap specified by @colormap. * This colormap must match the colormap of the window where the pixmap * will eventually be used or an error will result. * * If the pixbuf does not have an alpha channel, then *@mask_return will be set * to %NULL. **/ void gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf, GdkColormap *colormap, GdkPixmap **pixmap_return, GdkBitmap **mask_return, int alpha_threshold) { GdkScreen *screen; g_return_if_fail (GDK_IS_PIXBUF (pixbuf)); g_return_if_fail (GDK_IS_COLORMAP (colormap)); screen = gdk_colormap_get_screen (colormap); if (pixmap_return) { GdkGC *gc; *pixmap_return = gdk_pixmap_new (gdk_screen_get_root_window (screen), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_colormap_get_visual (colormap)->depth); gdk_drawable_set_colormap (GDK_DRAWABLE (*pixmap_return), colormap); gc = _gdk_drawable_get_scratch_gc (*pixmap_return, FALSE); /* If the pixbuf has an alpha channel, using gdk_pixbuf_draw would give * random pixel values in the area that are within the mask, but semi- * transparent. So we treat the pixbuf like a pixbuf without alpha channel; * see bug #487865. */ if (gdk_pixbuf_get_has_alpha (pixbuf)) gdk_draw_rgb_32_image (*pixmap_return, gc, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), GDK_RGB_DITHER_NORMAL, gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_rowstride (pixbuf)); else gdk_draw_pixbuf (*pixmap_return, gc, pixbuf, 0, 0, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), GDK_RGB_DITHER_NORMAL, 0, 0); } if (mask_return) { if (gdk_pixbuf_get_has_alpha (pixbuf)) { *mask_return = gdk_pixmap_new (gdk_screen_get_root_window (screen), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), 1); gdk_pixbuf_render_threshold_alpha (pixbuf, *mask_return, 0, 0, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), alpha_threshold); } else *mask_return = NULL; } }
gboolean time_line_internal_draw_layer_name(TimeLinePrivate *priv, gint layer_number) { // Local variables const GdkColor colour_black = {0, 0, 0, 0 }; static GdkColormap *colourmap = NULL; // Colourmap used for drawing static GdkGC *display_buffer_gc = NULL; static PangoContext *font_context = NULL; static PangoFontDescription *font_description = NULL; static PangoLayout *font_layout = NULL; layer *layer_data; GList *layer_pointer; // Points to the layers in the selected slide GString *message = NULL; message = g_string_new(NULL); // Initialisation if (NULL == colourmap) { colourmap = gdk_colormap_get_system(); gdk_drawable_set_colormap(GDK_DRAWABLE(priv->display_buffer_bot_left), GDK_COLORMAP(colourmap)); } if (NULL == font_context) { font_context = gdk_pango_context_get(); } if (NULL == font_layout) { font_layout = pango_layout_new(font_context); } if (NULL == display_buffer_gc) { display_buffer_gc = gdk_gc_new(GDK_DRAWABLE(priv->display_buffer_bot_left)); } if (NULL == font_description) { font_description = pango_font_description_from_string("Sans , 15px"); pango_layout_set_font_description(font_layout, font_description); } // Retrieve the layer name string layer_pointer = get_current_slide_layers_pointer(); layer_pointer = g_list_first(layer_pointer); layer_data = g_list_nth_data(layer_pointer, layer_number); // g_string_printf(message, "%d %s ",layer_number,layer_data->name->str); pango_layout_set_text(font_layout, layer_data->name->str, -1); // Set a clip mask // clip_region.x = 0; // clip_region.y = (layer_number <= 0)?0:(layer_number * priv->row_height); // clip_region.width = priv->left_border_width - 1; // clip_region.height = priv->row_height * 2; // gdk_gc_set_clip_rectangle(GDK_GC(display_buffer_gc), &clip_region); // Draw the text string gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black); gdk_draw_layout(GDK_DRAWABLE(priv->display_buffer_bot_left), GDK_GC(display_buffer_gc), 5, (layer_number * priv->row_height)+1,font_layout); return TRUE; }
void _HYPlatformGraphicPane::_SetPaneSize (int h,int w, int d) { g_object_unref (thePane); g_object_unref (theContext); thePane = gdk_pixmap_new (NULL, w, h, 24/*d<24?d:24*/); theContext = gdk_gc_new (thePane); gdk_drawable_set_colormap (thePane, gdk_colormap_get_system ()); // ? gdk_gc_set_colormap (theContext, gdk_colormap_get_system ()); // ? }
static VALUE rg_set_colormap(VALUE self, VALUE colormap) { VALUE old_colormap; old_colormap = GOBJ2RVAL(gdk_drawable_get_colormap(_SELF(self))); G_CHILD_REMOVE(self, old_colormap); G_CHILD_ADD(self, colormap); gdk_drawable_set_colormap(_SELF(self), GDK_COLORMAP(RVAL2GOBJ(colormap))); return self; }
GdkWindow * create_gdk_window (Window xframe) { GdkDisplay *display = gdk_display_get_default (); GdkScreen *screen = gdk_display_get_default_screen (display); GdkWindow *window = create_foreign_window (xframe); GdkColormap *cmap = gdk_screen_get_rgb_colormap (screen); gdk_drawable_set_colormap (GDK_DRAWABLE (window), cmap); return window; }
GdkPixmap * create_pixmap (int w, int h, GtkWidget *parent_style_window) { GdkWindow *window; if (w == 0 || h == 0) abort (); window = gtk_widget_get_window (parent_style_window); GdkPixmap *pixmap = gdk_pixmap_new (GDK_DRAWABLE (window), w, h, -1 /* CopyFromParent */); GdkColormap *cmap = get_colormap_for_drawable (GDK_DRAWABLE (pixmap)); gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap); return pixmap; }
_HYPlatformGraphicPane::_HYPlatformGraphicPane(int h, int w, int d) { fillColor = (GdkColor){0,0,0,0}; //printf ("Allocating pixmap\n"); thePane = gdk_pixmap_new (NULL, w, h, 24/*d<24?d:24*/); //printf ("Allocating context\n"); theContext = gdk_gc_new (thePane); //printf ("Allocating context\n"); textLayout = pango_layout_new (screenPContext); theFont = pango_font_description_new (); //printf ("Setting colormaps\n"); gdk_drawable_set_colormap (thePane, gdk_colormap_get_system ()); // ? gdk_gc_set_colormap (theContext, gdk_colormap_get_system ()); // ? charCachePangoItems = NULL; for (long k=0; k<=60; k=k+1) cachedCharacterGlyphs[k] = NULL; }
GdkPixmap * create_native_pixmap_and_wrap (int w, int h, GtkWidget *parent_style_window) { GdkWindow *window; if (w <= 0 || h <= 0) abort (); window = gtk_widget_get_window (parent_style_window); GdkPixmap *pixmap = gdk_pixmap_foreign_new (XCreatePixmap (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), GDK_WINDOW_XID (window), w, h, gdk_drawable_get_depth (window))); GdkColormap *cmap = get_colormap_for_drawable (GDK_DRAWABLE (pixmap)); gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap); return pixmap; }
GtkWidget *build_line(gint start_x, gint start_y , gint width, gint height, GtkWidget *hour_line, GdkColor *line_color) { GdkColormap *pic1_cmap; GdkVisual *pic1_vis; GdkPixmap *pic1; GdkGC *pic1_gc; GtkWidget *new_hour_line; gint depth = 16; gboolean first = FALSE; /* * GdkPixbuf *scaled; scaled = gdk_pixbuf_scale_simple (pix, w, h, GDK_INTERP_BILINEAR); */ pic1_cmap = gdk_colormap_get_system(); pic1_vis = gdk_colormap_get_visual(pic1_cmap); depth = pic1_vis->depth; if (hour_line == NULL) { pic1 = gdk_pixmap_new(NULL, width, height, depth); gdk_drawable_set_colormap(pic1, pic1_cmap); first = TRUE; } else gtk_image_get_pixmap(GTK_IMAGE(hour_line), &pic1, NULL); pic1_gc = gdk_gc_new(pic1); if (first) { gdk_gc_set_foreground(pic1_gc, line_color); gdk_draw_rectangle(pic1, pic1_gc, TRUE, start_x, start_y, width, height); } else { gdk_draw_rectangle(pic1, pic1_gc, TRUE, start_x, start_y, width, height); } new_hour_line = gtk_image_new_from_pixmap(pic1, NULL); g_object_unref(pic1_gc); g_object_unref(pic1); return(new_hour_line); }
GdkPixmap* create_pixmap (int width, int height) { GdkColormap* colormap; GdkDrawable* drawable; cairo_t * cr; colormap = gdk_screen_get_system_colormap (gdk_screen_get_default ()); g_assert (colormap); drawable = gdk_pixmap_new (NULL, 200, 200, gdk_colormap_get_visual (colormap)->depth); g_test_queue_unref (drawable); gdk_drawable_set_colormap (drawable, colormap); cr = gdk_cairo_create (drawable); cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); cairo_paint (cr); cairo_destroy (cr); return drawable; }
static void cdpalette(cdCtxCanvas *ctxcanvas, int n, const long int *palette, int mode) { int i; GdkColor clr; if (mode == CD_FORCE) { /* if was POLITE then allocates own palette */ if (ctxcanvas->colormap == gdk_gc_get_colormap(ctxcanvas->gc)) ctxcanvas->colormap = gdk_colormap_new(ctxcanvas->vis, FALSE); /* allocate all the palette colors to the CD */ for (i = 0; i < n; i++) { clr = cdColorToGdk(palette[i]); gdk_colormap_alloc_color(ctxcanvas->colormap, &clr, FALSE, FALSE); } /* set directly on the drawable */ gdk_drawable_set_colormap(ctxcanvas->wnd, ctxcanvas->colormap); } else { /* if was FORCE, remove the own palette */ if (ctxcanvas->colormap != gdk_gc_get_colormap(ctxcanvas->gc)) { g_object_unref(ctxcanvas->colormap); ctxcanvas->colormap = gdk_gc_get_colormap(ctxcanvas->gc); } /* if POLITE then just try to allocate all the colors of the palette */ for (i = 0; i < n; i++) { clr = cdColorToGdk(palette[i]); gdk_colormap_alloc_color(ctxcanvas->colormap, &clr, FALSE, TRUE); } } }
static gboolean xfwmPixmapDrawFromGdkPixbuf (xfwmPixmap * pm, GdkPixbuf *pixbuf) { GdkPixmap *dest_pixmap; GdkPixmap *dest_bitmap; GdkVisual *gvisual; GdkColormap *cmap; gint width, height; gint dest_x, dest_y; gint alpha_threshold; g_return_val_if_fail (pm != NULL, FALSE); g_return_val_if_fail (pm->pixmap != None, FALSE); g_return_val_if_fail (pm->mask != None, FALSE); dest_pixmap = gdk_xid_table_lookup (pm->pixmap); if (dest_pixmap) { g_object_ref (G_OBJECT (dest_pixmap)); } else { dest_pixmap = gdk_pixmap_foreign_new (pm->pixmap); } if (!dest_pixmap) { g_warning ("Cannot get pixmap"); return FALSE; } dest_bitmap = gdk_xid_table_lookup (pm->mask); if (dest_bitmap) { g_object_ref (G_OBJECT (dest_bitmap)); } else { dest_bitmap = gdk_pixmap_foreign_new (pm->mask); } if (!dest_bitmap) { g_warning ("Cannot get bitmap"); g_object_unref (dest_pixmap); return FALSE; } gvisual = gdk_screen_get_system_visual (pm->screen_info->gscr); cmap = gdk_x11_colormap_foreign_new (gvisual, pm->screen_info->cmap); if (!cmap) { g_warning ("Cannot create colormap"); g_object_unref (dest_pixmap); g_object_unref (dest_bitmap); return FALSE; } width = MIN (gdk_pixbuf_get_width (pixbuf), pm->width); height = MIN (gdk_pixbuf_get_height (pixbuf), pm->height); dest_x = (pm->width - width) / 2; dest_y = (pm->height - height) / 2; gdk_drawable_set_colormap (GDK_DRAWABLE (dest_pixmap), cmap); gdk_draw_pixbuf (GDK_DRAWABLE (dest_pixmap), NULL, pixbuf, 0, 0, dest_x, dest_y, width, height, GDK_RGB_DITHER_NONE, 0, 0); alpha_threshold = (gdk_pixbuf_get_has_alpha (pixbuf) ? 0xFF : 0); gdk_pixbuf_render_threshold_alpha (pixbuf, dest_bitmap, 0, 0, dest_x, dest_y, width, height, alpha_threshold); g_object_unref (cmap); g_object_unref (dest_pixmap); g_object_unref (dest_bitmap); return TRUE; }
static XImage * drawtheme_calc_alpha ( MCThemeDrawInfo &p_info) { XImage *t_bm_black ; XImage *t_bm_white ; GdkPixmap *t_black ; GdkPixmap *t_white ; GdkColormap *cm ; GdkVisual *best_vis ; uint4 t_w ; uint4 t_h ; t_w = p_info.drect.width ; t_h = p_info.drect.height ; // MM-2013-11-06: [[ Bug 11360 ]] Make sure we take into account the screen depth when creating pixmaps. uint4 t_screen_depth; t_screen_depth = ((MCScreenDC*) MCscreen) -> getdepth(); // Create two new pixmaps t_black = gdk_pixmap_new( NULL, t_w, t_h, t_screen_depth); t_white = gdk_pixmap_new( NULL, t_w, t_h, t_screen_depth); // We need to attach a colourmap to the Drawables in GDK best_vis = gdk_visual_get_best_with_depth(t_screen_depth); cm = gdk_colormap_new( best_vis , False ) ; gdk_drawable_set_colormap( t_black, cm); gdk_drawable_set_colormap( t_white, cm); //gdk_flush(); // Render solid black into one and white into the other. //black_and_white_masks ( gdk_x11_drawable_get_xid( t_black ) , gdk_x11_drawable_get_xid(t_white)); fill_gdk_drawable(t_black, cm, 0, 0, 0, t_w, t_h); fill_gdk_drawable(t_white, cm, 65535, 65535, 65535, t_w, t_h); MCThemeDrawInfo t_info; t_info = p_info; moz_gtk_widget_paint ( p_info.moztype, t_white , &t_info.drect, &t_info.cliprect, &t_info.state, t_info.flags ) ; t_info = p_info; moz_gtk_widget_paint ( p_info.moztype, t_black , &t_info.drect, &t_info.cliprect, &t_info.state, t_info.flags ) ; gdk_flush(); // Get the byte data for each of these pixmaps t_bm_black = ((MCScreenDC*)MCscreen) -> getimage ( gdk_x11_drawable_get_xid(t_black), 0, 0, t_w, t_h, False ) ; t_bm_white = ((MCScreenDC*)MCscreen) -> getimage ( gdk_x11_drawable_get_xid(t_white), 0, 0, t_w, t_h, False ) ; // Calculate the alpha from these two bitmaps --- the t_bm_black image now has full ARGB calc_alpha_from_bitmaps ( t_bm_black, t_bm_white ) ; // clean up. g_object_unref( t_black ) ; g_object_unref( t_white ) ; g_object_unref( cm ) ; return ( t_bm_black ) ; }
static GdkPixbuf* drawtheme_calc_alpha (MCThemeDrawInfo &p_info) { GdkPixbuf *t_pb_black; GdkPixbuf *t_pb_white; GdkPixmap *t_black ; GdkPixmap *t_white ; GdkColormap *cm ; GdkVisual *best_vis ; uint4 t_w ; uint4 t_h ; t_w = p_info.drect.width ; t_h = p_info.drect.height ; // MM-2013-11-06: [[ Bug 11360 ]] Make sure we take into account the screen depth when creating pixmaps. uint4 t_screen_depth; t_screen_depth = ((MCScreenDC*) MCscreen) -> getdepth(); // Create two new pixmaps t_black = gdk_pixmap_new(NULL, t_w, t_h, t_screen_depth); t_white = gdk_pixmap_new(NULL, t_w, t_h, t_screen_depth); // We need to attach a colourmap to the Drawables in GDK best_vis = gdk_visual_get_best_with_depth(t_screen_depth); if (best_vis == NULL) return NULL; cm = gdk_colormap_new(best_vis, FALSE) ; gdk_drawable_set_colormap(t_black, cm); gdk_drawable_set_colormap(t_white, cm); // Render solid black into one and white into the other. fill_gdk_drawable(t_black, cm, 0, 0, 0, t_w, t_h); fill_gdk_drawable(t_white, cm, 65535, 65535, 65535, t_w, t_h); MCThemeDrawInfo t_info; t_info = p_info; moz_gtk_widget_paint ( p_info.moztype, t_white , &t_info.drect, &t_info.cliprect, &t_info.state, t_info.flags ) ; t_info = p_info; moz_gtk_widget_paint ( p_info.moztype, t_black , &t_info.drect, &t_info.cliprect, &t_info.state, t_info.flags ) ; gdk_flush(); // Convert the server-side pixmaps into client-side pixbufs. The black // pixbuf will need to have an alpha channel so that we can fill it in. t_pb_black = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, t_w, t_h); if (t_pb_black == NULL) return NULL; t_pb_white = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, t_w, t_h); if (t_pb_white == NULL) return NULL; t_pb_black = gdk_pixbuf_get_from_drawable(t_pb_black, t_black, NULL, 0, 0, 0, 0, t_w, t_h); if (t_pb_black == NULL) return NULL; t_pb_white = gdk_pixbuf_get_from_drawable(t_pb_white, t_white, NULL, 0, 0, 0, 0, t_w, t_h); if (t_pb_white == NULL) return NULL; // Calculate the alpha from these two bitmaps --- the t_bm_black image now has full ARGB // Note that this also frees the t_pb_white pixbuf calc_alpha_from_pixbufs(t_pb_black, t_pb_white); // clean up. g_object_unref(t_black); g_object_unref(t_white); g_object_unref(cm); return t_pb_black; }
int main(int argc, char *argv[]) { // GtkWidget *window; GtkWidget *fixed; GtkWidget *area; // gtk_init(&argc, &argv); // Window window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "gui"); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_container_set_border_width(GTK_CONTAINER(window), 0); gtk_window_set_default_size(GTK_WINDOW(window), width, height); printf("window ok\n"); // layout fixed = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), fixed); printf("fixed ok\n"); // Image GList *visuals = gdk_list_visuals(); void tst(gpointer data, gpointer udata) { if (((GdkVisual*)data)->depth == 32) printf("visual :\n\ttype = %d\n\ttype = %d\n\tdepth = %d\n\tbits/rgb = %d\n\torder = %d\n\tred = %08X\n\tgreen = %08X\n\tblue = %08X\n" , ((GdkVisual*)data)->type , ((GdkVisual*)data)->colormap_size , ((GdkVisual*)data)->depth , ((GdkVisual*)data)->bits_per_rgb , ((GdkVisual*)data)->byte_order , ((GdkVisual*)data)->red_mask , ((GdkVisual*)data)->green_mask , ((GdkVisual*)data)->blue_mask ); } g_list_foreach(visuals, &tst, NULL); GdkVisual *visu = gdk_visual_get_best_with_depth(32); ximg = gdk_image_new(GDK_IMAGE_SHARED, visu, width, height); printf("GdkImage : bytes/pix = %d, linesize = %d, bits/pix = %d ; type %d (mem = %p)\n" , ximg->bpp, ximg->bpl, ximg->bits_per_pixel , ximg->type, ximg->mem ); // GdkPixbufAnimation //gtk_image_set_from_pixbuf // GdkColormap *dcm = gdk_colormap_new(visu, FALSE); // drawing area area = gtk_drawing_area_new(); gdk_drawable_set_colormap(window, dcm); gdk_drawable_set_colormap(area, dcm); gtk_drawing_area_size(GTK_DRAWING_AREA(area), width, height); printf("area ok\n"); // gtk_fixed_put(GTK_FIXED(fixed), area, 0, 0); printf("fixed ok\n"); // bgra_alloc650(&bgra, width, height); bgra_origin650(&bgra, +width/2, +height/2); bgra_scale650(&bgra, 1, -1); printf("bgra alloc ok\n"); maj(); printf("bgra maj done, still (%p <- %p)\n", ximg->mem, bgra.data); // // Ximg // memcpy(ximg->mem, bgra.data, bgra.size); // printf("mcpy done\n"); // Pixmap GdkColor bg; GdkColor fg; fg.pixel = 0xff000000; fg.red = 0; fg.green = 0; fg.blue = 0; bg.pixel = 0xff000000; bg.red = 0; bg.green = 0; bg.blue = 0; pixmap = gdk_pixmap_create_from_data( GTK_WINDOW(window) , bgra.data , width , height , 32 , &fg , &bg ); // img = gdk_pixbuf_new_from_data( // (guchar*)bgra.data // , GDK_COLORSPACE_RGB // , TRUE // , 8 // , width // , height // , width << 2 // , &pbd, NULL // ); // printf("PixBuf new ok\n"); // // Image // frame = gtk_image_new_from_pixbuf(img); //// frame = gtimg; // gtk_fixed_put(GTK_FIXED(fixed), frame, 0, 0); // printf("fixed ok\n"); // Events g_signal_connect(area, "expose-event", G_CALLBACK (on_expose_event), NULL); // g_signal_connect(frame, "expose-event", G_CALLBACK (on_expose_event), NULL); g_signal_connect(window, "delete-event", G_CALLBACK (delete_event), NULL); g_signal_connect(window, "destroy", G_CALLBACK (destroy), NULL); printf("signals ok\n"); // Show // gtk_widget_show(area); gtk_widget_show(fixed); gtk_widget_show_all(window); printf("show ok\n"); // Timer g_timeout_add(500, (GSourceFunc)time_handler, (gpointer)area); printf("timer ok\n"); gtk_main(); return 0; }
GdkPixbuf* gwy_graph_export_pixmap(GwyGraph *graph, G_GNUC_UNUSED gboolean export_title, G_GNUC_UNUSED gboolean export_axis, G_GNUC_UNUSED gboolean export_labels) { GdkColor color = { 0, 65535, 65535, 65535 }; GdkPixbuf *pixbuf; GdkColormap *cmap; GdkGC *gc; GdkVisual *visual; GdkPixmap *pixmap; PangoLayout *layout; PangoContext *context; gint width, height, topheight, bottomheight, rightwidth, leftwidth; gint labelx, labely, labelw, labelh; width = (GTK_WIDGET(graph))->allocation.width; height = (GTK_WIDGET(graph))->allocation.height; topheight = (GTK_WIDGET(graph->axis[GTK_POS_TOP]))->allocation.height; bottomheight = (GTK_WIDGET(graph->axis[GTK_POS_BOTTOM]))->allocation.height; leftwidth = (GTK_WIDGET(graph->axis[GTK_POS_LEFT]))->allocation.width; rightwidth = (GTK_WIDGET(graph->axis[GTK_POS_RIGHT]))->allocation.width; labelx = (GTK_WIDGET(graph->area->lab))->allocation.x + leftwidth; labely = (GTK_WIDGET(graph->area->lab))->allocation.y + topheight; labelw = (GWY_GRAPH_LABEL(graph->area->lab))->reqwidth; labelh = (GWY_GRAPH_LABEL(graph->area->lab))->reqheight; visual = gdk_visual_get_best(); cmap = gdk_colormap_new(visual, FALSE); pixmap = gdk_pixmap_new(NULL, width, height, visual->depth); gdk_drawable_set_colormap(pixmap, cmap); gc = gdk_gc_new(pixmap); gdk_gc_set_colormap(gc, cmap); gdk_gc_set_rgb_fg_color(gc, &color); gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, width, height); gwy_graph_area_draw_on_drawable(graph->area, pixmap, gc, leftwidth, topheight, width - leftwidth - rightwidth, height - topheight - bottomheight); /* Draw axes */ gwy_axis_draw_on_drawable(graph->axis[GTK_POS_TOP], pixmap, gc, leftwidth, 0, width - leftwidth - rightwidth, topheight); gwy_axis_draw_on_drawable(graph->axis[GTK_POS_BOTTOM], pixmap, gc, leftwidth, height - bottomheight, width - leftwidth - rightwidth, bottomheight); gwy_axis_draw_on_drawable(graph->axis[GTK_POS_LEFT], pixmap, gc, 0, topheight, leftwidth, height - topheight - bottomheight); gwy_axis_draw_on_drawable(graph->axis[GTK_POS_RIGHT], pixmap, gc, width - rightwidth, topheight, rightwidth, height - topheight - bottomheight); context = gdk_pango_context_get_for_screen(gdk_screen_get_default()); pango_context_set_font_description(context, graph->area->lab->font_desc); layout = pango_layout_new(context); gwy_graph_label_draw_on_drawable(graph->area->lab, pixmap, gc, layout, labelx, labely, labelw, labelh); pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, cmap, 0, 0, 0, 0, -1, -1); g_object_unref(pixmap); g_object_unref(layout); g_object_unref(context); g_object_unref(gc); g_object_unref(cmap); return pixbuf; }
gboolean time_line_internal_draw_layer_duration(TimeLinePrivate *priv, gint layer_number) { // Local variables const GdkColor colour_black = {0, 0, 0, 0 }; const GdkColor colour_fade = {0, (160 << 8), (160 << 8), (190 << 8) }; const GdkColor colour_fully_visible = {0, (200 << 8), (200 << 8), (230 << 8) }; static GdkColormap *colourmap = NULL; // Colormap used for drawing static GdkGC *display_buffer_gc = NULL; gint layer_height; layer *layer_data; GList *layer_pointer; // Points to the layers in the selected slide gint layer_width; gint layer_x; gint layer_y; gint left_border; // Initialisation if (NULL == colourmap) { colourmap = gdk_colormap_get_system(); gdk_drawable_set_colormap(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_COLORMAP(colourmap)); } if (NULL == display_buffer_gc) { display_buffer_gc = gdk_gc_new(GDK_DRAWABLE(priv->display_buffer_bot_right)); } left_border = 0;// time_line_get_left_border_width(priv); // Select the layer we're working with layer_pointer = get_current_slide_layers_pointer(); layer_pointer = g_list_first(layer_pointer); layer_data = g_list_nth_data(layer_pointer, layer_number); // Set the height related variables layer_y = (layer_number * priv->row_height) + 2; layer_height = priv->row_height - 3; // Check if there's a fade in transition for this layer if (TRANS_LAYER_FADE == layer_data->transition_in_type) { // Draw the fade in layer_x = left_border + (layer_data->start_time * time_line_get_pixels_per_second()) + 1; layer_width = (layer_data->transition_in_duration * time_line_get_pixels_per_second()); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_fade); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), TRUE, layer_x, layer_y, layer_width, layer_height); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), FALSE, layer_x, layer_y, layer_width, layer_height - 1); // Draw the fully visible duration layer_x = left_border + ((layer_data->start_time + layer_data->transition_in_duration) * time_line_get_pixels_per_second()) + 1; layer_width = (layer_data->duration * time_line_get_pixels_per_second()); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_fully_visible); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), TRUE, layer_x, layer_y, layer_width, layer_height); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), FALSE, layer_x - 1, layer_y, layer_width, layer_height -1); } else { // There's no fade in transition for this layer layer_x = left_border + (layer_data->start_time * time_line_get_pixels_per_second()) + 1; layer_width = (layer_data->duration * time_line_get_pixels_per_second()); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_fully_visible); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), TRUE, layer_x, layer_y, layer_width, layer_height); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), FALSE, layer_x, layer_y, layer_width - 1, layer_height - 1); } // Check if there's a fade out transition for this layer if (TRANS_LAYER_FADE == layer_data->transition_out_type) { // Draw the fade out layer_x += (layer_data->duration * time_line_get_pixels_per_second()); layer_width = (layer_data->transition_out_duration * time_line_get_pixels_per_second()); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_fade); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), TRUE, layer_x, layer_y, layer_width, layer_height); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), FALSE, layer_x - 1, layer_y, layer_width, layer_height - 1); } return TRUE; }
/* * draw_border_shape * Returns: void * Description: Draws a slight border around the decoration */ static void draw_border_shape (Display *xdisplay, Pixmap pixmap, Picture picture, int width, int height, decor_context_t *c, void *closure) { static XRenderColor white = { 0xffff, 0xffff, 0xffff, 0xffff }; GdkColormap *colormap; decor_t d; decor_shadow_info_t *info = (decor_shadow_info_t *) closure; double save_decoration_alpha; memset (&d, 0, sizeof (d)); if (info) { gwd_decor_frame_ref (info->frame); d.frame = info->frame; d.state = info->state; d.actions = info->active; } else { d.frame = gwd_get_decor_frame ("normal"); d.state = 0; d.active = TRUE; } d.pixmap = gdk_pixmap_foreign_new_for_display (gdk_display_get_default (), pixmap); d.width = width; d.height = height; d.active = TRUE; d.draw = theme_draw_window_decoration; d.picture = picture; d.context = c; /* we use closure argument if maximized */ if (info) d.state = info->state; else d.state = 0; decor_get_default_layout (c, 1, 1, &d.border_layout); colormap = get_colormap_for_drawable (GDK_DRAWABLE (d.pixmap)); gdk_drawable_set_colormap (d.pixmap, colormap); /* create shadow from opaque decoration * FIXME: Should not modify settings value * like this */ save_decoration_alpha = decoration_alpha; decoration_alpha = 1.0; (*d.draw) (&d); decoration_alpha = save_decoration_alpha; XRenderFillRectangle (xdisplay, PictOpSrc, picture, &white, c->left_space, c->top_space, width - c->left_space - c->right_space, height - c->top_space - c->bottom_space); if (!info) gwd_decor_frame_unref (d.frame); g_object_unref (G_OBJECT (d.pixmap)); }