static bool paintMozWidget(RenderTheme* theme, GtkThemeWidgetType type, RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) { // No GdkWindow to render to, so return true to fall back if (!i.context->gdkDrawable()) return true; // Painting is disabled so just claim to have succeeded if (i.context->paintingDisabled()) return false; GtkWidgetState mozState; setMozState(theme, &mozState, o); int flags; // We might want to make setting flags the caller's job at some point rather than doing it here. switch (type) { case MOZ_GTK_BUTTON: flags = GTK_RELIEF_NORMAL; break; case MOZ_GTK_CHECKBUTTON: case MOZ_GTK_RADIOBUTTON: flags = theme->isChecked(o); break; default: flags = 0; break; } AffineTransform ctm = i.context->getCTM(); IntPoint pos = ctm.mapPoint(rect.location()); GdkRectangle gdkRect = IntRect(pos.x(), pos.y(), rect.width(), rect.height()); GtkTextDirection direction = gtkTextDirection(o->style()->direction()); // Find the clip rectangle cairo_t *cr = i.context->platformContext(); double clipX1, clipX2, clipY1, clipY2; cairo_clip_extents(cr, &clipX1, &clipY1, &clipX2, &clipY2); GdkRectangle gdkClipRect; gdkClipRect.width = clipX2 - clipX1; gdkClipRect.height = clipY2 - clipY1; IntPoint clipPos = ctm.mapPoint(IntPoint(clipX1, clipY1)); gdkClipRect.x = clipPos.x(); gdkClipRect.y = clipPos.y(); gdk_rectangle_intersect(&gdkRect, &gdkClipRect, &gdkClipRect); return moz_gtk_widget_paint(type, i.context->gdkDrawable(), &gdkRect, &gdkClipRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS; }
void MCNativeTheme::drawTab(MCDC *t_dc, const MCWidgetInfo &winfo, const MCRectangle &drect, GdkPixmap *tpix) { int flags = 0; GdkRectangle rect, cliprect; GtkWidgetState state = WThemeStateToGtkWidgetState(winfo); rect = MCRectangleToGdkRectangle(drect); cliprect = MCRectangleToGdkRectangle(drect); rect.x = cliprect.x = 0; rect.y = cliprect.y = 0; if(winfo.attributes & WTHEME_ATT_TABFIRSTSELECTED) flags |= MOZ_GTK_TAB_FIRST; //if(winfo.attributes & WTHEME_ATT_TABBEFORESELECTED) if (winfo.attributes & WTHEME_ATT_TABLEFTEDGE) flags |= MOZ_GTK_TAB_BEFORE_SELECTED; if(winfo.state & WTHEME_STATE_HILITED) { flags |= MOZ_GTK_TAB_SELECTED; state.active = 0; } if(winfo.attributes & WTHEME_ATT_TABPOSBOTTOM) flags |= MOZ_GTK_TAB_POS_BOTTOM; else if(winfo.attributes & WTHEME_ATT_TABPOSLEFT) flags |= MOZ_GTK_TAB_POS_LEFT; else if(winfo.attributes & WTHEME_ATT_TABPOSRIGHT) flags |= MOZ_GTK_TAB_POS_RIGHT; else flags |= MOZ_GTK_TAB_POS_TOP; moz_gtk_widget_paint(MOZ_GTK_TAB, tpix, &rect, &cliprect, &state, flags); }
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; }