static void on_main_win_realize(GtkWidget * widget, gpointer user_data) { GtkStyle *style; // Get the current style style = gtk_widget_get_style(main_win); // Create the pix gc pix_gc = gdk_gc_new(main_win->window); g_object_ref(pix_gc); gdk_gc_set_fill(pix_gc, GDK_TILED); bg_gc = gdk_gc_new(main_win->window); gdk_gc_copy(bg_gc, style->mid_gc[3]); g_object_ref(bg_gc); gdk_gc_set_fill(bg_gc, GDK_SOLID); last_gc = gdk_gc_new(main_win->window); gdk_gc_copy(last_gc, style->light_gc[3]); g_object_ref(last_gc); gdk_gc_set_fill(last_gc, GDK_SOLID); /* Use configuration options. They've already been loaded. */ gdk_colormap_alloc_color(gtk_widget_get_colormap(main_win), last_color, TRUE, TRUE); gdk_colormap_alloc_color(gtk_widget_get_colormap(main_win), back_color, TRUE, TRUE); g_object_set_data(G_OBJECT(main_win), "last_color", last_color); g_object_set_data(G_OBJECT(main_win), "back_color", back_color); gdk_gc_set_foreground(bg_gc, back_color); gdk_gc_set_foreground(last_gc, last_color); board_resized(); }
/** Convert Dia color objects into GDK color objects. * If the highlight color is set, that will be used instead. This allows * rendering of an object to do highlight rendering. * @param renderer The renderer to check for highlight color. * @param col A color object to convert. * @param gdk_col Resulting GDK convert. */ static void renderer_color_convert(DiaGdkRenderer *renderer, Color *col, GdkColor *gdk_col) { if (renderer->highlight_color != NULL) { color_convert(renderer->highlight_color, gdk_col); } else { color_convert(col, gdk_col); } if (col->alpha != renderer->current_alpha) { if (col->alpha == 1.0) gdk_gc_set_fill(renderer->gc, GDK_SOLID); else { static gchar bits[9][4] = { { 0x00, 0x00, 0x00, 0x00 }, /* 0% */ { 0x20, 0x02, 0x20, 0x02 }, { 0x22, 0x88, 0x22, 0x88 }, /* 25% */ { 0x4A, 0xA4, 0x4A, 0xA4 }, { 0x5A, 0xA5, 0x5A, 0xA5 }, /* 50% */ { 0x57, 0xBA, 0x57, 0xBA }, { 0xBE, 0xEB, 0xBE, 0xEB }, /* 75% */ { 0xEF, 0xFE, 0xEF, 0xFE }, { 0xFF, 0xFF, 0xFF, 0xFF }, /* 100% */ }; GdkBitmap *stipple = gdk_bitmap_create_from_data (NULL, bits[(int)(9*col->alpha+.49)], 4, 4); gdk_gc_set_stipple (renderer->gc, stipple); g_object_unref (stipple); gdk_gc_set_fill(renderer->gc, GDK_STIPPLED); } renderer->current_alpha = col->alpha; } }
/* gdk_cursor_new_from_pixmap is broken on Windows. this is a workaround using gdk_cursor_new_from_pixbuf. */ GdkCursor* fixed_gdk_cursor_new_from_pixmap(GdkPixmap *source, GdkPixmap *mask, const GdkColor *fg, const GdkColor *bg, gint x, gint y) { GdkPixmap *rgb_pixmap; GdkGC *gc; GdkPixbuf *rgb_pixbuf, *rgba_pixbuf; GdkCursor *cursor; int width, height; /* HACK! It seems impossible to work with RGBA pixmaps directly in GDK-Win32. Instead we pick some third color, different from fg and bg, and use that as the 'transparent color'. We do this using colors_too_similar (see above) because two colors could be unequal in GdkColor's 16-bit/sample, but equal in GdkPixbuf's 8-bit/sample. */ GdkColor candidates[3] = {{0,65535,0,0}, {0,0,65535,0}, {0,0,0,65535}}; GdkColor *trans = &candidates[0]; if (colors_too_similar(trans, fg) || colors_too_similar(trans, bg)) { trans = &candidates[1]; if (colors_too_similar(trans, fg) || colors_too_similar(trans, bg)) { trans = &candidates[2]; } } /* trans is now guaranteed to be unique from fg and bg */ /* create an empty pixmap to hold the cursor image */ gdk_drawable_get_size(source, &width, &height); rgb_pixmap = gdk_pixmap_new(NULL, width, height, 24); /* blit the bitmaps defining the cursor onto a transparent background */ gc = gdk_gc_new(rgb_pixmap); gdk_gc_set_fill(gc, GDK_SOLID); gdk_gc_set_rgb_fg_color(gc, trans); gdk_draw_rectangle(rgb_pixmap, gc, TRUE, 0, 0, width, height); gdk_gc_set_fill(gc, GDK_OPAQUE_STIPPLED); gdk_gc_set_stipple(gc, source); gdk_gc_set_clip_mask(gc, mask); gdk_gc_set_rgb_fg_color(gc, fg); gdk_gc_set_rgb_bg_color(gc, bg); gdk_draw_rectangle(rgb_pixmap, gc, TRUE, 0, 0, width, height); gdk_gc_unref(gc); /* create a cursor out of the created pixmap */ rgb_pixbuf = gdk_pixbuf_get_from_drawable( NULL, rgb_pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, width, height); gdk_pixmap_unref(rgb_pixmap); rgba_pixbuf = gdk_pixbuf_add_alpha( rgb_pixbuf, TRUE, trans->red, trans->green, trans->blue); gdk_pixbuf_unref(rgb_pixbuf); cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), rgba_pixbuf, x, y); gdk_pixbuf_unref(rgba_pixbuf); return cursor; }
void SetUpStatusBarStuff (GtkWidget* aWindow) { _String fName = baseDirectory & "GTKResources/striped.xpm"; statusBarLayout = pango_layout_new (screenPContext); statusBarFontDesc = pango_font_description_new (); stripedFill = gdk_pixmap_create_from_xpm (GDK_DRAWABLE(aWindow->window), NULL, NULL, fName.sData); stripedFillGC = gdk_gc_new (GDK_DRAWABLE(aWindow->window)); if (stripedFill) { gdk_gc_set_fill (stripedFillGC,GDK_TILED); gdk_gc_set_tile (stripedFillGC,stripedFill); } else { printf ("Failed to load a status bar .xpm from %s\n", fName.sData); } gdk_gc_set_line_attributes (stripedFillGC, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); GdkColor saveFG = {0,0,0,0}; gdk_gc_set_foreground (stripedFillGC, &saveFG); pango_font_description_set_family (statusBarFontDesc, statusBarFont.face.sData); pango_font_description_set_style (statusBarFontDesc, (statusBarFont.style & HY_FONT_ITALIC) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); pango_font_description_set_weight (statusBarFontDesc, (statusBarFont.style & HY_FONT_BOLD) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL); pango_font_description_set_size (statusBarFontDesc, statusBarFont.size*PANGO_SCALE); pango_layout_set_font_description (statusBarLayout, statusBarFontDesc ); // ref ? pango_layout_set_width (statusBarLayout, -1); redButtonIcon = (GdkPixbuf*)ProcureIconResource(4000); yellowButtonIcon = (GdkPixbuf*)ProcureIconResource(4001); greenButtonIcon = (GdkPixbuf*)ProcureIconResource(4002); orangeButtonIcon = (GdkPixbuf*)ProcureIconResource(4003); }
static void draw_pixel_line(DiaRenderer *object, int x1, int y1, int x2, int y2, Color *color) { DiaGdkRenderer *renderer = DIA_GDK_RENDERER (object); GdkGC *gc = renderer->gc; GdkColor gdkcolor; int target_width, target_height; dia_gdk_renderer_set_dashes(renderer, x1+y1); gdk_drawable_get_size (GDK_DRAWABLE (renderer->pixmap), &target_width, &target_height); if ( (x1 < 0 && x2 < 0) || (y1 < 0 && y2 < 0) || (x1 > target_width && x2 > target_width) || (y1 > target_height && y2 > target_height)) return; /* clip early rather than failing in Gdk */ color_convert(color, &gdkcolor); gdk_gc_set_foreground(gc, &gdkcolor); /* reset stippling (alpha emulation) */ gdk_gc_set_fill(gc, GDK_SOLID); renderer->current_alpha = 1.0; gdk_draw_line(renderer->pixmap, gc, x1, y1, x2, y2); }
static void fill_pixel_rect(DiaRenderer *object, int x, int y, int width, int height, Color *color) { DiaGdkRenderer *renderer = DIA_GDK_RENDERER (object); GdkGC *gc = renderer->gc; GdkColor gdkcolor; int target_width, target_height; gdk_drawable_get_size (GDK_DRAWABLE (renderer->pixmap), &target_width, &target_height); if (x + width < 0 || y + height < 0 || x > target_width || y > target_height) return; /* clip early rather than failing in Gdk */ color_convert(color, &gdkcolor); gdk_gc_set_foreground(gc, &gdkcolor); /* reset stippling (alpha emulation) */ gdk_gc_set_fill(gc, GDK_SOLID); renderer->current_alpha = 1.0; gdk_draw_rectangle (renderer->pixmap, gc, TRUE, x, y, width, height); }
void make_background() { if( background ) g_object_unref( background ); if( ! (*bg_filename && (background = gdk_pixmap_create_from_xpm( window->window, NULL, NULL, bg_filename ))) ) { int i, j; background = gdk_pixmap_new( window->window, ws_width, ws_height, -1 ); gdk_draw_rectangle( background, gc[bg], TRUE, 1, 1, ws_width, ws_height ); /* draw the boundaries of the different viewports */ if( vp_width < ws_width-1 || vp_height < ws_height-1 ) for( i=1; i<ws_width; i+=vp_width ) for( j=1; j<ws_height; j+=vp_height ) gdk_draw_rectangle( background, gc[vp_divider], FALSE, i+1, j+1, vp_width-3, vp_height-3 ); /* draw the workspace-boundary (repeated by tiling) */ gdk_draw_line( background, gc[ws_divider], 0, 0, 0, ws_height ); gdk_draw_line( background, gc[ws_divider], 1, 0, ws_width, 0 ); } gdk_gc_set_fill( gc[bg], GDK_TILED ); gdk_gc_set_tile( gc[bg], background ); }
gboolean gaugebar_expose (GtkWidget *widget, GdkEventExpose *event, gpointer data) { GList* it; GdkGC *gc; GdkColor black = {0, 0, 0, 0}; PangoLayout *layout; GtkDrawingArea *gaugebar = GTK_DRAWING_AREA (widget); g_return_val_if_fail (gaugebar != NULL, FALSE); GAUGELIST *gl = (GAUGELIST *) g_object_get_data (GTK_OBJECT (gaugebar), "gaugelist"); g_return_val_if_fail (gl != NULL, FALSE); int width = widget->allocation.width; int height = widget->allocation.height; gc = gdk_gc_new (widget->window); // clear the widget GdkColor bgc = gtk_widget_get_style ( GTK_WIDGET (gl->sess->tab))->bg[GTK_STATE_NORMAL]; gdk_gc_set_rgb_bg_color (gc, &bgc); gdk_gc_set_rgb_fg_color (gc, &bgc); gdk_gc_set_fill (gc, GDK_SOLID); gdk_draw_rectangle (widget->window, gc, TRUE, 0, 0, width+1, height+1); // paint the new widget ... int X = 2; for (it = g_list_first (gl->list); it; it = g_list_next (it)) { GAUGE *g = (GAUGE *) it->data; // paint the text int xd; layout = gtk_widget_create_pango_layout (GTK_WIDGET (gaugebar), g->variable); gdk_gc_set_rgb_fg_color (gc, &black); gdk_draw_layout (widget->window, gc, X, 2, layout); pango_layout_get_pixel_size (layout, &xd, NULL); X += xd + 2; // paint the gauge int val = g->cur * 100 / (g->max ? g->max : 100); if (val > 100) val = 100; gdk_gc_set_line_attributes (gc, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); gdk_gc_set_rgb_fg_color (gc, &black); gdk_draw_rectangle (widget->window, gc, FALSE, X, 2, 102, 20); if (val) { gdk_gc_set_rgb_fg_color (gc, &g->color); gdk_draw_rectangle (widget->window, gc, TRUE, X+1, 3, val+1, 19); } g_object_unref (layout); X += 110; } }
/* passe en mode color, decharge le pixmap (mais pas le nom) */ void tansetcolormode(GdkColor *acolor, int gcnbr){ GdkPixmap *pixmap; GdkGC *gc; GdkColor *pcolor; GdkColormap *syscmap; gc = tabgc[gcnbr]; pcolor = &colortab[gcnbr]; syscmap = gdk_colormap_get_system(); if (tabcolalloc[gcnbr]) gdk_colormap_free_colors (syscmap, pcolor, 1); if ( gcnbr>=PXSTART && gcnbr<PXSTART+PXNBR ){ tabpxpixmode[gcnbr] = FALSE; if ( (pixmap = tabpxpx[gcnbr])!=NULL ){ tabpxpx[gcnbr] = NULL; gdk_pixmap_unref(pixmap); } } pcolor->red = acolor->red; pcolor->green = acolor->green; pcolor->blue = acolor->blue; tabcolalloc[gcnbr] = gdk_colormap_alloc_color (syscmap, pcolor, FALSE, TRUE); gdk_gc_set_fill (gc, GDK_SOLID); gdk_gc_set_foreground (gc, pcolor); }
/** Load/construct the images */ static void load_pixmaps(QuoteView * qv) { static gboolean init = FALSE; int width, height; GdkPixmap *pixmap; GdkGC *gc; if (init) return; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); pixmap = gdk_pixmap_new(qv->quotes->window, width, height, gtk_widget_get_visual(qv->quotes)->depth); gc = gdk_gc_new(pixmap); gdk_gc_set_fill(gc, GDK_TILED); gdk_gc_set_tile(gc, theme_get_terrain_pixmap(SEA_TERRAIN)); gdk_gc_set_foreground(gc, &black); gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, width, height); maritime_pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, 0, -1, -1); g_object_unref(pixmap); g_object_unref(gc); cross_pixbuf = gtk_widget_render_icon(qv->quotes, GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU, NULL); init = TRUE; }
/* do not use clip mask; only one tile under mask was drawn */ void _zune_fill_tiled_rectangle(struct MUI_ImageSpec *img, struct MUI_RenderInfo *mri, LONG left, LONG top, LONG width, LONG height, LONG xoffset, LONG yoffset) { GdkPixmap *pixmap; g_return_if_fail((pixmap = __zune_imspec_get_pixmap(img)) != NULL); gdk_gc_set_fill(mri->mri_RastPort, GDK_TILED); gdk_gc_set_tile(mri->mri_RastPort, pixmap); gdk_gc_set_ts_origin(mri->mri_RastPort, xoffset, yoffset); gdk_draw_rectangle (mri->mri_Window, mri->mri_RastPort, TRUE, left, top, width, height); gdk_gc_set_fill(mri->mri_RastPort, GDK_SOLID); gdk_gc_set_ts_origin(mri->mri_RastPort, 0, 0); }
static void cdgdkCheckSolidStyle(cdCtxCanvas *ctxcanvas, int set) { if (ctxcanvas->canvas->interior_style == CD_SOLID) return; if (set) gdk_gc_set_fill(ctxcanvas->gc, GDK_SOLID); else cdinteriorstyle(ctxcanvas, ctxcanvas->canvas->interior_style); }
/* Set the fill mode for a graphics context. */ int clip_GDK_GCSETFILL(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); GdkFill fill = _clip_parni(cm,2); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKOPT(2,NUMERIC_t); gdk_gc_set_fill(GDK_GC(cgc->object), fill); return 0; err: return 1; }
/* * fill a rectangle with a preset MUI pattern */ void _zune_fill_pattern_rectangle(struct MUI_ImageSpec *img, struct MUI_RenderInfo *mri, LONG left, LONG top, LONG width, LONG height, LONG xoffset, LONG yoffset, LONG flags) { zune_render_set_pattern(mri, img->u.pattern); gdk_draw_rectangle (mri->mri_Window, mri->mri_RastPort, TRUE, left, top, width, height); gdk_gc_set_fill(mri->mri_RastPort, GDK_SOLID); }
void ZLGtkPaintContext::setFillColor(ZLColor color, FillStyle style) { if (style == SOLID_FILL) { ::setColor(myFillGC, color); gdk_gc_set_fill(myFillGC, GDK_SOLID); } else { gdk_gc_set_fill(myFillGC, GDK_TILED); if (myPixmap != 0) { if (myTilePixmap != 0) { gdk_pixmap_unref(myTilePixmap); } static GdkColor fgColor; ::setColor(fgColor, color); static GdkColor bgColor; ::setColor(bgColor, myBackColor); static char data[] = { 0x0C, 0x0C, 0x03, 0x03 }; myTilePixmap = gdk_pixmap_create_from_data( myPixmap, data, 4, 4, gdk_drawable_get_depth(myPixmap), &fgColor, &bgColor ); gdk_gc_set_tile(myFillGC, myTilePixmap); } } }
void DrawString(GdkWindow* window, GdkFont* font, GdkGC* gc, gint dstx, gint dsty, gchar* str) { GdkColor color; color.red = 0; color.green = 0; color.blue = 0; gdk_color_alloc(gdk_colormap_get_system(), &color); gdk_gc_set_fill(gc, GDK_SOLID); gdk_gc_set_foreground(gc, &color); gdk_draw_string(window, font, gc, dstx, dsty, str); }
static void zune_render_set_pattern (struct MUI_RenderInfo *mri, LONG pattern) { SetAPen(mri->mri_RastPort, mri->mri_Pens[patternPens[pattern - MUII_BACKGROUND].fg]); SetBPen(mri->mri_RastPort, mri->mri_Pens[patternPens[pattern - MUII_BACKGROUND].bg]); gdk_gc_set_fill(mri->mri_RastPort, GDK_OPAQUE_STIPPLED); if (!mri->mri_PatternStipple) { mri->mri_PatternStipple = gdk_bitmap_create_from_data(mri->mri_Window, patstipple_bits, patstipple_width, patstipple_height); } gdk_gc_set_stipple(mri->mri_RastPort, mri->mri_PatternStipple); }
void quote_view_theme_changed(QuoteView * qv) { int width, height; GdkPixmap *pixmap; GdkGC *gc; QuoteInfo *quote; if (!qv->with_maritime) return; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); pixmap = gdk_pixmap_new(qv->quotes->window, width, height, gtk_widget_get_visual(qv->quotes)->depth); gc = gdk_gc_new(pixmap); gdk_gc_set_foreground(gc, &black); gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, width, height); gdk_gc_set_fill(gc, GDK_TILED); gdk_gc_set_tile(gc, theme_get_terrain_pixmap(SEA_TERRAIN)); gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, width, height); if (maritime_pixbuf) g_object_unref(maritime_pixbuf); maritime_pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, 0, -1, -1); g_object_unref(gc); g_object_unref(pixmap); /* Remove all maritime quotes */ quote = quotelist_first(qv->quote_list); while (quote != NULL) { QuoteInfo *curr = quote; quote = quotelist_next(quote); if (curr->is_domestic) break; remove_quote(qv, curr); } /* Add all of the maritime trades that can be performed */ check_maritime_trades(qv); }
/* charge un pixmap, si necessaire desalloue et/ou (re)alloue la couleur */ gboolean tansetpixmapmode(GtkWidget *widget, char *aname, int gcnbr){ GdkPixmap *pixmap; GdkGC *gc; char *pname; gboolean ret; pixmap=tabpxpx[gcnbr]; pname=tabpxnam[gcnbr]; gc=tabgc[gcnbr]; if (tabcolalloc[gcnbr]){ gdk_colormap_free_colors (gdk_colormap_get_system(), &colortab[gcnbr], 1); tabcolalloc[gcnbr] = FALSE; } if (pixmap!=NULL) gdk_pixmap_unref(pixmap); ret=FALSE; if ( (pixmap=gdk_pixmap_create_from_xpm (widget->window, NULL, NULL, aname))!=NULL ){ tanallocname(&pname,aname); gdk_gc_set_fill (gc, GDK_TILED); gdk_gc_set_tile (gc, pixmap); ret=TRUE; } if (pname==NULL) tanallocname(&pname,"LoadPixmapFailed"); tabpxpx[gcnbr] = pixmap; tabpxnam[gcnbr] = pname; tabpxpixmode[gcnbr] = ret; if (!ret) tansetcolormode(&colortab[gcnbr],gcnbr); return (ret); }
static int cdinteriorstyle(cdCtxCanvas *ctxcanvas, int style) { GdkFill sty = GDK_SOLID; switch (style) { case CD_SOLID: sty = GDK_SOLID; break; case CD_HATCH : if (!ctxcanvas->last_hatch) return ctxcanvas->canvas->interior_style; gdk_gc_set_stipple(ctxcanvas->gc, ctxcanvas->last_hatch); if (ctxcanvas->canvas->back_opacity == CD_OPAQUE) sty = GDK_OPAQUE_STIPPLED; else sty = GDK_STIPPLED; break; case CD_STIPPLE: gdk_gc_set_stipple(ctxcanvas->gc, ctxcanvas->last_stipple); if (ctxcanvas->canvas->back_opacity == CD_OPAQUE) sty = GDK_OPAQUE_STIPPLED; else sty = GDK_STIPPLED; break; case CD_PATTERN: gdk_gc_set_tile(ctxcanvas->gc, ctxcanvas->last_pattern); sty = GDK_TILED; break; } gdk_gc_set_fill(ctxcanvas->gc, sty); return style; }
void XftTextRenderer::drawRect(int x, int y, int w, int h, const GdkColor* color) { #if defined(USE_XFT_DRAWRECT) g_warning("(%d,%d,%d,%d)", x,y,w,h); XftColor xft_c; XRenderColor xrender_c; getXRenderColorFromGdkColor(color, &xrender_c); XftColorAllocValue(xdisplay, xvisual, xcmap, &xrender_c, &xft_c); x -= gdkxoff; y -= gdkyoff; XftDrawRect(xftdraw, &xft_c, x, y, w, h); XftColorFree(xdisplay, xvisual, xcmap, &xft_c); #else gdk_gc_set_rgb_fg_color(gdkgc, const_cast<GdkColor*>(color)); x -= gdkxoff; y -= gdkyoff; gdk_gc_set_fill (gdkgc, GDK_SOLID); gdk_draw_rectangle(gdkdrawable, gdkgc, TRUE, x, y, w, h); #endif }
static VALUE rg_set_fill(VALUE self, VALUE fill) { gdk_gc_set_fill(_SELF(self), RVAL2GENUM(fill, GDK_TYPE_FILL)); return self; }
void SDC::SetObjects(GdkGC *gc, GdkBitmap *bmp) { m_gc = gc; m_gdkbmp = bmp; SetBlackForeground(); gdk_gc_set_fill(m_gc, GDK_SOLID); }
bool wxMask::Create( const wxBitmap& bitmap, const wxColour& colour ) { if (m_bitmap) { gdk_bitmap_unref( m_bitmap ); m_bitmap = (GdkBitmap*) NULL; } wxImage image = bitmap.ConvertToImage(); if (!image.Ok()) return FALSE; m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 ); GdkGC *gc = gdk_gc_new( m_bitmap ); GdkColor color; color.red = 65000; color.green = 65000; color.blue = 65000; color.pixel = 1; gdk_gc_set_foreground( gc, &color ); gdk_gc_set_fill( gc, GDK_SOLID ); gdk_draw_rectangle( m_bitmap, gc, TRUE, 0, 0, image.GetWidth(), image.GetHeight() ); unsigned char *data = image.GetData(); int index = 0; unsigned char red = colour.Red(); unsigned char green = colour.Green(); unsigned char blue = colour.Blue(); GdkVisual *visual = wxTheApp->GetGdkVisual(); int bpp = visual->depth; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; if (bpp == 15) { red = red & 0xf8; green = green & 0xf8; blue = blue & 0xf8; } else if (bpp == 16) { red = red & 0xf8; green = green & 0xfc; blue = blue & 0xf8; } else if (bpp == 12) { red = red & 0xf0; green = green & 0xf0; blue = blue & 0xf0; } color.red = 0; color.green = 0; color.blue = 0; color.pixel = 0; gdk_gc_set_foreground( gc, &color ); for (int j = 0; j < image.GetHeight(); j++) { int start_x = -1; int i; for (i = 0; i < image.GetWidth(); i++) { if ((data[index] == red) && (data[index+1] == green) && (data[index+2] == blue)) { if (start_x == -1) start_x = i; } else { if (start_x != -1) { gdk_draw_line( m_bitmap, gc, start_x, j, i-1, j ); start_x = -1; } } index += 3; } if (start_x != -1) gdk_draw_line( m_bitmap, gc, start_x, j, i, j ); } gdk_gc_unref( gc ); return TRUE; }
static void gtk_text_render_state_update (GtkTextRenderState *state, GtkTextAppearance *new_appearance) { GdkScreen *screen = gtk_widget_get_screen (state->widget); if (!state->last_appearance || !gdk_color_equal (&new_appearance->fg_color, &state->last_appearance->fg_color)) gtk_text_render_state_set_color (state, state->fg_gc, &new_appearance->fg_color); if (!state->last_appearance || new_appearance->fg_stipple != state->last_appearance->fg_stipple) { if (new_appearance->fg_stipple) { if (screen == gdk_drawable_get_screen (new_appearance->fg_stipple)) { gdk_gc_set_fill (state->fg_gc, GDK_STIPPLED); gdk_gc_set_stipple (state->fg_gc, new_appearance->fg_stipple); } else g_warning ("gtk_text_render_state_update:\n" "The foreground stipple bitmap has been created on the wrong screen.\n" "Ignoring the stipple bitmap information."); } else { gdk_gc_set_fill (state->fg_gc, GDK_SOLID); } } if (new_appearance->draw_bg) { if (!state->last_bg_appearance || !gdk_color_equal (&new_appearance->bg_color, &state->last_bg_appearance->bg_color)) gtk_text_render_state_set_color (state, state->bg_gc, &new_appearance->bg_color); if (!state->last_bg_appearance || new_appearance->bg_stipple != state->last_bg_appearance->bg_stipple) { if (new_appearance->bg_stipple) { if (screen == gdk_drawable_get_screen (new_appearance->bg_stipple)) { gdk_gc_set_fill (state->bg_gc, GDK_STIPPLED); gdk_gc_set_stipple (state->bg_gc, new_appearance->bg_stipple); } else g_warning ("gtk_text_render_state_update:\n" "The background stipple bitmap has been created on the wrong screen.\n" "Ignoring the stipple bitmap information."); } else { gdk_gc_set_fill (state->bg_gc, GDK_SOLID); } } state->last_bg_appearance = new_appearance; } state->last_appearance = new_appearance; }
void _HYConsoleWindow::_PaintStatusBar(Ptr,bool force) { if (GTK_WIDGET_MAPPED (theWindow)) { _Parameter vL; checkParameter (VerbosityLevelString, vL, 0.0); if (vL<-0.5 && !force) { clock_t curMeasure = clock(); _Parameter diff = 1.0/CLOCKS_PER_SEC*(curMeasure-lastMeasure); if (diff < -vL) { return; } lastMeasure = curMeasure; } if (!stripedFillGC) { SetUpStatusBarStuff (theWindow); } GdkRectangle wRC = {0,0,theWindow->allocation.width,HY_SCROLLER_WIDTH}, w2RC; if (!_hyConsoleWindowGC) { _hyConsoleWindowGC = gdk_gc_new (theWindow->window); gdk_gc_set_tile (_hyConsoleWindowGC, stripedFill); gdk_gc_set_line_attributes(_hyConsoleWindowGC,1,GDK_LINE_SOLID,GDK_CAP_NOT_LAST,GDK_JOIN_MITER); _hyConsoleLayout = pango_layout_new (screenPContext); pango_layout_set_width (_hyConsoleLayout, -1); statusBarBold = pango_font_description_new (); statusBarNormal = pango_font_description_new (); _HYFont consoleFont = {_HY_MONO_FONT,9,HY_FONT_PLAIN}; HYFont2PangoFontDesc (consoleFont,statusBarNormal); consoleFont.style = HY_FONT_BOLD; HYFont2PangoFontDesc (consoleFont,statusBarBold); } GdkPixmap * offBitmap = gdk_pixmap_new (theWindow->window, wRC.width, wRC.height,-1); if (offBitmap) { gdk_gc_set_fill (_hyConsoleWindowGC,GDK_TILED); gdk_draw_rectangle (offBitmap,_hyConsoleWindowGC,true,-1,-1,wRC.width+2,wRC.height+2); gdk_gc_set_fill (_hyConsoleWindowGC,GDK_SOLID); gdk_gc_set_foreground (_hyConsoleWindowGC,&_BLACKBRUSH_); gdk_draw_line(offBitmap,_hyConsoleWindowGC,0,0,wRC.width,0); pango_layout_set_font_description(_hyConsoleLayout,statusBarNormal); pango_layout_set_text(_hyConsoleLayout,fileName.getStr(),fileName.sLength); gdk_draw_layout(offBitmap,_hyConsoleWindowGC,33,wRC.height-13,_hyConsoleLayout); if (inputStatus == 1) { pango_layout_set_text(_hyConsoleLayout,cInput.getStr(),cInput.sLength); } else { pango_layout_set_text(_hyConsoleLayout,action.getStr(),action.sLength); } gdk_draw_layout(offBitmap,_hyConsoleWindowGC,193,wRC.height-13,_hyConsoleLayout); gdk_gc_set_foreground (_hyConsoleWindowGC,&_DARKGREYBRUSH_); gdk_draw_rectangle (offBitmap,_hyConsoleWindowGC,true,0,1,30,wRC.height-1); gdk_draw_rectangle (offBitmap,_hyConsoleWindowGC,true,150,1,40,wRC.height-1); gdk_draw_rectangle (offBitmap,_hyConsoleWindowGC,true,wRC.width-55,1,55,wRC.height-1); gdk_gc_set_foreground (_hyConsoleWindowGC,&_WHITEBRUSH_); pango_layout_set_font_description(_hyConsoleLayout,statusBarBold); pango_layout_set_text(_hyConsoleLayout,cState.getStr(),cState.sLength); gdk_draw_layout(offBitmap,_hyConsoleWindowGC,3,wRC.height-13,_hyConsoleLayout); pango_layout_set_text(_hyConsoleLayout,cTask.getStr(),cTask.sLength); gdk_draw_layout(offBitmap,_hyConsoleWindowGC,151,wRC.height-13,_hyConsoleLayout); pango_layout_set_font_description(_hyConsoleLayout,statusBarNormal); pango_layout_set_text(_hyConsoleLayout,timer.getStr(),timer.sLength); gdk_draw_layout(offBitmap,_hyConsoleWindowGC,wRC.width-53,wRC.height-13,_hyConsoleLayout); if (percentDone>0 || percentDone == -HY_SL_DONE) { GdkColor blackBrush = HYColorToGDKColor((_HYColor) { 80,80,80 }), orangeBrush = HYColorToGDKColor((_HYColor) { 255,153,102 }); gdk_gc_set_foreground (_hyConsoleWindowGC,&orangeBrush); gdk_draw_rectangle (offBitmap,_hyConsoleWindowGC,true,wRC.width-135,wRC.height-14,(percentDone>=0?percentDone:100.)*0.75,12); gdk_gc_set_foreground (_hyConsoleWindowGC,&blackBrush); gdk_draw_rectangle (offBitmap,_hyConsoleWindowGC,false,wRC.width-135,wRC.height-14,75,12); //gdk_gc_set_foreground (_hyConsoleWindowGC,&_WHITEBRUSH_); _String pLine; if (percentDone>=0) { pLine = _String(percentDone)&"%"; } else { pLine = "DONE"; } pango_layout_set_text(_hyConsoleLayout,pLine.getStr(),pLine.sLength); gdk_draw_layout(offBitmap,_hyConsoleWindowGC,wRC.width-107,wRC.height-13,_hyConsoleLayout); } } gdk_draw_drawable (theWindow->window, _hyConsoleWindowGC, offBitmap, 0, 0, theWindow->allocation.x, theWindow->allocation.y+theWindow->allocation.height-wRC.height, -1, -1); g_object_unref (offBitmap); } }
static void vga_realize(GtkWidget *widget) { GdkWindowAttr attributes; gint attributes_mask; //GdkCursor * cursor; VGAText *vga; #ifdef VGA_DEBUG fprintf(stderr, "vga_realize()\n"); #endif g_return_if_fail(widget != NULL); g_return_if_fail(VGA_IS_TEXT(widget)); vga = VGA_TEXT(widget); /* Set the realized flag. */ GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); /* Main widget window */ attributes.window_type = GDK_WINDOW_CHILD; attributes.x = 0; attributes.y = 0; attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual(widget); attributes.colormap = gtk_widget_get_colormap(widget); attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask); gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, widget->allocation.width, widget->allocation.height); gdk_window_set_user_data(widget->window, widget); gdk_window_show(widget->window); #ifdef USE_DEPRECATED_GDK /* Initialize private data that depends on the window */ if (vga->pvt->gc == NULL) { vga->pvt->glyphs = vga_font_get_bitmap(vga->pvt->font, widget->window); vga->pvt->gc = gdk_gc_new(widget->window); // not needed i guess? //gdk_gc_set_colormap(vga->pvt->gc, attributes.colormap); gdk_gc_set_rgb_fg_color(vga->pvt->gc, vga_palette_get_color(vga->pvt->pal, vga->pvt->fg)); gdk_gc_set_rgb_bg_color(vga->pvt->gc, vga_palette_get_color(vga->pvt->pal, vga->pvt->bg)); gdk_gc_set_stipple(vga->pvt->gc, vga->pvt->glyphs); gdk_gc_set_fill(vga->pvt->gc, GDK_OPAQUE_STIPPLED); } #else #if 0 if (vga->pvt->cr == NULL) { vga->pvt->cr = gdk_cairo_create(widget->window); cairo_set_source_rgb(vga->pvt->cr, 0.5, 0.5, 0.0); cairo_set_operator(vga->pvt->cr, CAIRO_OPERATOR_SOURCE); cairo_paint(vga->pvt->cr); cairo_set_font_face(vga->pvt->cr, vga->pvt->font->face); cairo_set_font_size(vga->pvt->cr, 1.0); cairo_move_to(vga->pvt->cr, 10.0, 370.0); cairo_set_source_rgb(vga->pvt->cr, 1.0, 1.0, 1.0); cairo_show_text(vga->pvt->cr, "Testing"); #endif #if 0 cairo_select_font_face (vga->pvt->cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(vga->pvt->cr, 12.0); } #endif #endif /* create a gdk window? is that what we really want? */ gtk_widget_grab_focus(widget); }
void tedDrawShadedRectangle( AppDrawingData * add, APP_BITMAP_IMAGE shadingPixmaps[DOCsp_COUNT], int pattern, int x0, int y0, int x1, int y1 ) { if ( ! shadingPixmaps[pattern] ) { const int wide= 8; const int high= 8; const int d= 4; int t; int s= 0; int x; int y; AppDrawingData addPat; appInitDrawingData( &addPat ); shadingPixmaps[pattern]= appMakePixmap( add, wide, high );; if ( ! shadingPixmaps[pattern] ) { XDEB(shadingPixmaps[pattern]); return; } appCloneDrawingEnvironment( &addPat, add, 1.0, 0.05, shadingPixmaps[pattern] ); appDrawSetForegroundWhite( &addPat ); appDrawFillRectangle( &addPat, 0, 0, wide, high ); appDrawSetForegroundBlack( &addPat ); switch( pattern ) { case DOCspSOLID: LDEB(pattern); t= 0; s= 0; break; case DOCspBGHORIZ: case DOCspBGVERT: case DOCspBGFDIAG: case DOCspBGBDIAG: case DOCspBGCROSS: case DOCspBGDCROSS: t= 1; s= 0; break; case DOCspBGDKHORIZ: case DOCspBGDKVERT: case DOCspBGDKFDIAG: case DOCspBGDKBDIAG: case DOCspBGDKCROSS: case DOCspBGDKDCROSS: t= 2; s= 1; break; default: LDEB(pattern); return; } if ( t > 0 ) { appDrawSetLineAttributes( &addPat, t, LINEstyleSOLID, LINEcapPROJECTING, LINEjoinMITER, (unsigned char *)0, 0 ); } switch( pattern ) { case DOCspSOLID: LDEB(pattern); break; case DOCspBGHORIZ: case DOCspBGDKHORIZ: y= 0; while( y < high ) { appDrawDrawLine( &addPat, 0, y+ s, wide- 1, y+ s ); y += d; } break; case DOCspBGVERT: case DOCspBGDKVERT: x= 0; while( x < wide ) { appDrawDrawLine( &addPat, x+ s, 0, x+ s, high- 1 ); x += d; } break; case DOCspBGFDIAG: case DOCspBGDKFDIAG: x= -high; while( x < wide ) { appDrawDrawLine( &addPat, x+ s, 0, x+ high+ s, high ); x += d; } break; case DOCspBGBDIAG: case DOCspBGDKBDIAG: x= 0; while( x < wide+ high ) { appDrawDrawLine( &addPat, x, 0, x- high, high ); x += d; } break; case DOCspBGCROSS: case DOCspBGDKCROSS: y= 0; while( y < high ) { appDrawDrawLine( &addPat, 0, y+ s, wide- 1, y+ s ); y += d; } x= 0; while( x < wide ) { appDrawDrawLine( &addPat, x+ s, 0, x+ s, high- 1 ); x += d; } break; case DOCspBGDCROSS: case DOCspBGDKDCROSS: x= -high; while( x < wide ) { /* appDrawDrawLine( &addPat, x+ s, 0, x+ high+ s, high ); */ appDrawDrawLine( &addPat, x, 0, x+ high, high ); x += d; } x= 0; while( x < wide+ high ) { appDrawDrawLine( &addPat, x, 0, x- high, high ); x += d; } break; default: LDEB(pattern); return; } appCleanDrawingData( &addPat ); } # ifdef USE_MOTIF XSetFillStyle( add->addDisplay, add->addGc, FillTiled ); XSetTile( add->addDisplay, add->addGc, shadingPixmaps[pattern] ); # endif # ifdef USE_GTK gdk_gc_set_fill( add->addGc, GDK_TILED ); gdk_gc_set_tile( add->addGc, shadingPixmaps[pattern] ); # endif appDrawFillRectangle( add, x0, y0, x1- x0+ 1, y1- y0+ 1 ); # ifdef USE_MOTIF XSetFillStyle( add->addDisplay, add->addGc, FillSolid ); # endif # ifdef USE_GTK gdk_gc_set_fill( add->addGc, GDK_SOLID ); # endif return; }
/** * gpm_applet_draw_cb: * @applet: Inhibit applet instance * * draws applet content (background + icon) **/ static gboolean gpm_applet_draw_cb (GpmInhibitApplet *applet) { gint w, h, bg_type; #if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA color; cairo_t *cr; cairo_pattern_t *pattern; GtkStyleContext *context; #else GdkColor color; GdkGC *gc; GdkPixmap *background; #endif GtkAllocation allocation; if (gtk_widget_get_window (GTK_WIDGET(applet)) == NULL) { return FALSE; } #if !GTK_CHECK_VERSION (3, 0, 0) /* Clear the window so we can draw on it later */ gdk_window_clear(gtk_widget_get_window (GTK_WIDGET (applet))); #endif /* retrieve applet size */ gpm_applet_get_icon (applet); gpm_applet_check_size (applet); if (applet->size <= 2) { return FALSE; } /* if no icon, then don't try to display */ if (applet->icon == NULL) { return FALSE; } gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation); w = allocation.width; h = allocation.height; #if GTK_CHECK_VERSION (3, 0, 0) cr = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET(applet))); #else gc = gdk_gc_new (gtk_widget_get_window (GTK_WIDGET(applet))); #endif /* draw pixmap background */ #if GTK_CHECK_VERSION (3, 0, 0) bg_type = mate_panel_applet_get_background (MATE_PANEL_APPLET (applet), &color, &pattern); #else bg_type = mate_panel_applet_get_background (MATE_PANEL_APPLET (applet), &color, &background); #endif if (bg_type == PANEL_PIXMAP_BACKGROUND) { /* fill with given background pixmap */ #if GTK_CHECK_VERSION (3, 0, 0) cairo_set_source (cr, pattern); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); #else gdk_draw_drawable (gtk_widget_get_window (GTK_WIDGET(applet)), gc, background, 0, 0, 0, 0, w, h); #endif } /* draw color background */ if (bg_type == PANEL_COLOR_BACKGROUND) { #if GTK_CHECK_VERSION (3, 0, 0) gdk_cairo_set_source_rgba (cr, &color); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); #else gdk_gc_set_rgb_fg_color (gc,&color); gdk_gc_set_fill (gc,GDK_SOLID); gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h); #endif } /* draw icon at center */ #if GTK_CHECK_VERSION (3, 0, 0) gdk_cairo_set_source_pixbuf (cr, applet->icon, (w - applet->icon_width)/2, (h - applet->icon_height)/2); cairo_paint (cr); #else gdk_draw_pixbuf (gtk_widget_get_window (GTK_WIDGET(applet)), gc, applet->icon, 0, 0, (w - applet->icon_width)/2, (h - applet->icon_height)/2, applet->icon_width, applet->icon_height, GDK_RGB_DITHER_NONE, 0, 0); #endif #if GTK_CHECK_VERSION (3, 0, 0) cairo_destroy (cr); #else g_object_unref (gc); #endif return TRUE; }