static void gtk_databox_marker_real_create_gc (GtkDataboxGraph *graph, GtkDataboxCanvas *canvas) { GtkDataboxMarker *marker = GTK_DATABOX_MARKER (graph); GdkGCValues values; g_return_if_fail (GTK_DATABOX_IS_MARKER (graph)); GTK_DATABOX_GRAPH_CLASS (parent_class)->create_gc (graph, canvas); if (marker->priv->type == GTK_DATABOX_MARKER_DASHED_LINE) { values.line_style = GDK_LINE_ON_OFF_DASH; values.cap_style = GDK_CAP_BUTT; values.join_style = GDK_JOIN_MITER; gdk_gc_set_values (graph->gc, &values, GDK_GC_LINE_STYLE | GDK_GC_CAP_STYLE | GDK_GC_JOIN_STYLE); } if (marker->priv->label_gc) g_object_unref (marker->priv->label_gc); marker->priv->label_gc = gdk_gc_new (canvas->pixmap); gdk_gc_copy(marker->priv->label_gc, graph->gc); gdk_gc_set_line_attributes (marker->priv->label_gc, 1, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND); }
static void iDrawSetLineStyle(IdrawCanvas* dc, int style) { GdkGCValues gcval; if (style == IUP_DRAW_STROKE || style == IUP_DRAW_FILL) gcval.line_style = GDK_LINE_SOLID; else { if (style == IUP_DRAW_STROKE_DASH) { gint8 dashes[2] = { 9, 3 }; gdk_gc_set_dashes(dc->pixmap_gc, 0, dashes, 2); } else if (style == IUP_DRAW_STROKE_DOT) { gint8 dashes[2] = { 1, 2 }; gdk_gc_set_dashes(dc->pixmap_gc, 0, dashes, 2); } else if (style == IUP_DRAW_STROKE_DASH_DOT) { gint8 dashes[4] = { 7, 3, 1, 3 }; gdk_gc_set_dashes(dc->pixmap_gc, 0, dashes, 4); } else if (style == IUP_DRAW_STROKE_DASH_DOT_DOT) { gint8 dashes[6] = { 7, 3, 1, 3, 1, 3 }; gdk_gc_set_dashes(dc->pixmap_gc, 0, dashes, 6); } gcval.line_style = GDK_LINE_ON_OFF_DASH; } gdk_gc_set_values(dc->pixmap_gc, &gcval, GDK_GC_LINE_STYLE); }
/** * gwy_vector_layer_draw: * @layer: A vector data view layer. * @drawable: A drawable to draw on. * @target: Rendering target. * * Draws @layer on given drawable (which should be a #GwyDataView window). **/ void gwy_vector_layer_draw(GwyVectorLayer *layer, GdkDrawable *drawable, GwyRenderingTarget target) { GwyVectorLayerClass *layer_class = GWY_VECTOR_LAYER_GET_CLASS(layer); GdkGC *gc = NULL; g_assert(layer_class); g_return_if_fail(layer_class->draw); if (target == GWY_RENDERING_TARGET_PIXMAP_IMAGE) { GwyDataView *data_view; GdkGCValues gcvalues; gint xres, yres, w, h; gdouble zoom; data_view = GWY_DATA_VIEW(GWY_DATA_VIEW_LAYER(layer)->parent); g_return_if_fail(data_view); gwy_data_view_get_pixel_data_sizes(data_view, &xres, &yres); gdk_drawable_get_size(drawable, &w, &h); zoom = sqrt(((gdouble)(w*h))/(xres*yres)); gc = gdk_gc_new(drawable); gdk_gc_get_values(gc, &gcvalues); gcvalues.line_width = ROUND(MAX(zoom, 1.0)); gcvalues.function = GDK_SET; gdk_gc_set_values(gc, &gcvalues, GDK_GC_LINE_WIDTH | GDK_GC_FUNCTION); GWY_SWAP(GdkGC*, layer->gc, gc); }
// Choix de l'épaisseur de ligne utilisée pour un tracé. // Cette méthode est privée et utilisée par les méthodes de dessin void Fenetre::choixEpaisseurTrace(int e) { if (existe) { GdkGCValues valeurs; valeurs.line_width=e; gdk_gc_set_values(fenetre->style->fg_gc[GTK_STATE_NORMAL], &valeurs,GDK_GC_LINE_WIDTH); traiteEvenements(); } }
static int cdlinejoin(cdCtxCanvas *ctxcanvas, int join) { int cd2x_join[] = {GDK_JOIN_MITER, GDK_JOIN_BEVEL, GDK_JOIN_ROUND}; ctxcanvas->gcval.join_style = cd2x_join[join]; gdk_gc_set_values(ctxcanvas->gc, &ctxcanvas->gcval, GDK_GC_JOIN_STYLE); return join; }
static int cdlinecap(cdCtxCanvas *ctxcanvas, int cap) { int cd2x_cap[] = {GDK_CAP_BUTT, GDK_CAP_PROJECTING, GDK_CAP_ROUND}; ctxcanvas->gcval.cap_style = cd2x_cap[cap]; gdk_gc_set_values(ctxcanvas->gc, &ctxcanvas->gcval, GDK_GC_CAP_STYLE); return cap; }
static int cdlinewidth(cdCtxCanvas *ctxcanvas, int width) { if (width == 1) ctxcanvas->gcval.line_width = 0; else ctxcanvas->gcval.line_width = width; gdk_gc_set_values(ctxcanvas->gc, &ctxcanvas->gcval, GDK_GC_LINE_WIDTH); return width; }
static void iDrawSetLineWidth(IdrawCanvas* dc, int line_width) { GdkGCValues gcval; if (line_width == 1) gcval.line_width = 0; else gcval.line_width = line_width; gdk_gc_set_values(dc->pixmap_gc, &gcval, GDK_GC_LINE_WIDTH); }
gboolean Update(gpointer data) { int c,x,y,cx,cy; GtkWidget *dc=GetWidget("drawingarea1"); GdkGC *gc=dc->style->fg_gc[GTK_WIDGET_STATE(dc)]; GdkGCValues gcsave; gdk_gc_get_values(gc,&gcsave); cx=dc->allocation.width/2; cy=dc->allocation.height/2; { // clear the display GdkColor c={0,0xffff,0xffff,0xffff}; gdk_gc_set_rgb_fg_color(gc,&c); gdk_draw_rectangle(dc->window,gc,TRUE,0,0,dc->allocation.width,dc->allocation.height); } { // Draw the listener GdkColor c={0,0x8000,0x8000,0x8000}; gdk_gc_set_rgb_fg_color(gc,&c); gdk_draw_arc(dc->window,gc,TRUE,cx-4,cy-4,8,8,0,360*64); } for (c=0;c<chanc;c++) { // If the channel's playing then update it's position if (BASS_ChannelIsActive(chans[c].channel)==BASS_ACTIVE_PLAYING) { // Check if channel has reached the max distance if (chans[c].pos.z>=MAXDIST || chans[c].pos.z<=-MAXDIST) chans[c].vel.z=-chans[c].vel.z; if (chans[c].pos.x>=MAXDIST || chans[c].pos.x<=-MAXDIST) chans[c].vel.x=-chans[c].vel.x; // Update channel position chans[c].pos.z+=chans[c].vel.z*TIMERPERIOD/1000; chans[c].pos.x+=chans[c].vel.x*TIMERPERIOD/1000; BASS_ChannelSet3DPosition(chans[c].channel,&chans[c].pos,NULL,&chans[c].vel); } { // Draw the channel position indicator static GdkColor cols[2]={{0,0xffff,0xc000,0xc000},{0,0xffff,0,0}}; gdk_gc_set_rgb_fg_color(gc,&cols[chan==c]); x=cx+(int)((cx-10)*chans[c].pos.x/MAXDIST); y=cy-(int)((cy-10)*chans[c].pos.z/MAXDIST); gdk_draw_arc(dc->window,gc,TRUE,x-4,y-4,8,8,0,360*64); } } // Apply the 3D changes BASS_Apply3D(); gdk_gc_set_values(gc,&gcsave,GDK_GC_FOREGROUND); return TRUE; }
static int cdlinestyle(cdCtxCanvas *ctxcanvas, int style) { switch (style) { case CD_CONTINUOUS: ctxcanvas->gcval.line_style = GDK_LINE_SOLID; break; case CD_DASHED: case CD_DOTTED: case CD_DASH_DOT: case CD_DASH_DOT_DOT: { static struct { int size; signed char list[6]; } dashes[4] = { { 2, { 6, 2 } }, { 2, { 2, 2 } }, { 4, { 6, 2, 2, 2 } }, { 6, { 6, 2, 2, 2, 2, 2 } } }; if (ctxcanvas->canvas->back_opacity == CD_OPAQUE) ctxcanvas->gcval.line_style = GDK_LINE_DOUBLE_DASH; else ctxcanvas->gcval.line_style = GDK_LINE_ON_OFF_DASH; gdk_gc_set_dashes(ctxcanvas->gc, 0, dashes[style-CD_DASHED].list, dashes[style-CD_DASHED].size); break; } case CD_CUSTOM: { int i; signed char* dash_style = (signed char*)malloc(ctxcanvas->canvas->line_dashes_count); for (i = 0; i < ctxcanvas->canvas->line_dashes_count; i++) dash_style[i] = (char)ctxcanvas->canvas->line_dashes[i]; if (ctxcanvas->canvas->back_opacity == CD_OPAQUE) ctxcanvas->gcval.line_style = GDK_LINE_DOUBLE_DASH; else ctxcanvas->gcval.line_style = GDK_LINE_ON_OFF_DASH; gdk_gc_set_dashes(ctxcanvas->gc, 0, dash_style, ctxcanvas->canvas->line_dashes_count); free(dash_style); break; } } gdk_gc_set_values(ctxcanvas->gc, &ctxcanvas->gcval, GDK_GC_LINE_STYLE); return style; }
void SDC::SetLineWidth(int width) { #ifdef __WXMSW__ wxColour c = m_pen.GetColour(); wxPen npen = wxPen(c, width == 1 ? 0 : width, wxSOLID); (HPEN) SelectObject(m_gc, (HPEN)npen.GetResourceHandle()); m_pen = npen; #else GdkGCValues vals; gdk_gc_get_values(m_gc, &vals); vals.line_width = width == 1 ? 0 : width; gdk_gc_set_values(m_gc, &vals, GDK_GC_LINE_WIDTH); #endif }
void iupDrawLine(IdrawCanvas* dc, int x1, int y1, int x2, int y2, unsigned char r, unsigned char g, unsigned char b, int style) { GdkGCValues gcval; GdkColor color; iupgdkColorSet(&color, r, g, b); gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &color); if (style==IUP_DRAW_STROKE_DASH) gcval.line_style = GDK_LINE_ON_OFF_DASH; else gcval.line_style = GDK_LINE_SOLID; gdk_gc_set_values(dc->pixmap_gc, &gcval, GDK_GC_LINE_STYLE); gdk_draw_line(dc->pixmap, dc->pixmap_gc, x1, y1, x2, y2); }
void iupDrawPolygon(IdrawCanvas* dc, int* points, int count, unsigned char r, unsigned char g, unsigned char b, int style) { GdkColor color; iupgdkColorSet(&color, r, g, b); gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &color); if (style!=IUP_DRAW_FILL) { GdkGCValues gcval; if (style==IUP_DRAW_STROKE_DASH) gcval.line_style = GDK_LINE_ON_OFF_DASH; else gcval.line_style = GDK_LINE_SOLID; gdk_gc_set_values(dc->pixmap_gc, &gcval, GDK_GC_LINE_STYLE); } gdk_draw_polygon(dc->pixmap, dc->pixmap_gc, style==IUP_DRAW_FILL, (GdkPoint*)points, count); }
void iupDrawArc(IdrawCanvas* dc, int x1, int y1, int x2, int y2, double a1, double a2, unsigned char r, unsigned char g, unsigned char b, int style) { GdkColor color; iupgdkColorSet(&color, r, g, b); gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &color); if (style!=IUP_DRAW_FILL) { GdkGCValues gcval; if (style==IUP_DRAW_STROKE_DASH) gcval.line_style = GDK_LINE_ON_OFF_DASH; else gcval.line_style = GDK_LINE_SOLID; gdk_gc_set_values(dc->pixmap_gc, &gcval, GDK_GC_LINE_STYLE); } gdk_draw_arc(dc->pixmap, dc->pixmap_gc, style==IUP_DRAW_FILL, x1, y1, x2-x1+1, y2-y1+1, iupROUND(a1*64), iupROUND((a2 - a1)*64)); }
void iupDrawRectangle(IdrawCanvas* dc, int x1, int y1, int x2, int y2, unsigned char r, unsigned char g, unsigned char b, int style) { GdkColor color; iupgdkColorSet(&color, r, g, b); gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &color); if (style==IUP_DRAW_FILL) gdk_draw_rectangle(dc->pixmap, dc->pixmap_gc, TRUE, x1, y1, x2-x1+1, y2-y1+1); else { GdkGCValues gcval; if (style==IUP_DRAW_STROKE_DASH) gcval.line_style = GDK_LINE_ON_OFF_DASH; else gcval.line_style = GDK_LINE_SOLID; gdk_gc_set_values(dc->pixmap_gc, &gcval, GDK_GC_LINE_STYLE); gdk_draw_rectangle(dc->pixmap, dc->pixmap_gc, FALSE, x1, y1, x2-x1, y2-y1); /* outlined rectangle is actually of size w+1,h+1 */ } }
static void iDrawSetLineStyle(IdrawCanvas* dc, int style) { GdkGCValues gcval; if (style == IUP_DRAW_STROKE || style == IUP_DRAW_FILL) gcval.line_style = GDK_LINE_SOLID; else { gint8 dashes[2] = { 6, 2 }; gint8 dots[2] = { 2, 2 }; if (style == IUP_DRAW_STROKE_DASH) gdk_gc_set_dashes(dc->pixmap_gc, 0, dashes, 2); else gdk_gc_set_dashes(dc->pixmap_gc, 0, dots, 2); gcval.line_style = GDK_LINE_ON_OFF_DASH; } gdk_gc_set_values(dc->pixmap_gc, &gcval, GDK_GC_LINE_STYLE); }