Beispiel #1
0
/**
 * 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);
    }
Beispiel #2
0
static VALUE
rg_exposures_p(VALUE self)
{
    GdkGCValues val;
    gdk_gc_get_values(_SELF(self), &val);

    return CBOOL2RVAL(val.graphics_exposures);
}
Beispiel #3
0
static VALUE
rg_subwindow_mode(VALUE self)
{
    GdkGCValues val;
    gdk_gc_get_values(_SELF(self), &val);

    return GENUM2RVAL(val.subwindow_mode, GDK_TYPE_SUBWINDOW_MODE);
}
Beispiel #4
0
static VALUE
rg_clip_mask(VALUE self)
{
    GdkGCValues val;
    gdk_gc_get_values(_SELF(self), &val);

    return GOBJ2RVAL(val.clip_mask);
}
Beispiel #5
0
static VALUE
rg_stipple(VALUE self)
{
    GdkGCValues val;
    gdk_gc_get_values(_SELF(self), &val);

    return GOBJ2RVAL(val.stipple);
}
Beispiel #6
0
static VALUE
rg_fill(VALUE self)
{
    GdkGCValues val;
    gdk_gc_get_values(_SELF(self), &val);

    return GENUM2RVAL(val.fill, GDK_TYPE_FILL);
}
Beispiel #7
0
static VALUE
rg_function(VALUE self)
{
    GdkGCValues val;
    gdk_gc_get_values(_SELF(self), &val);

    return GENUM2RVAL(val.function, GDK_TYPE_FUNCTION);
}
Beispiel #8
0
static VALUE
rg_background(VALUE self)
{
    GdkGCValues val;
    gdk_gc_get_values(_SELF(self), &val);

    return BOXED2RVAL(&val.background, GDK_TYPE_COLOR);
}
Beispiel #9
0
static VALUE
rg_clip_origin(VALUE self)
{
    GdkGCValues val;
    gdk_gc_get_values(_SELF(self), &val);

    return rb_ary_new3(2, INT2NUM(val.clip_x_origin),
                       INT2NUM(val.clip_y_origin));
}
Beispiel #10
0
static VALUE
rg_line_attributes(VALUE self)
{
    GdkGCValues val;
    gdk_gc_get_values(_SELF(self), &val);

    return rb_ary_new3(4, INT2NUM(val.line_width),
                       GENUM2RVAL(val.line_style, GDK_TYPE_LINE_STYLE),
                       GENUM2RVAL(val.cap_style, GDK_TYPE_CAP_STYLE),
                       GENUM2RVAL(val.join_style, GDK_TYPE_JOIN_STYLE));
}
Beispiel #11
0
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;
}
GdkColor cl_gc_set_fg_color_shade (GdkGC *gc, GdkColormap *colormap, 
                                   GdkColor *from, gfloat s)
{
	GdkColor tmp_color;
	GdkGCValues values;

	shade (from, &tmp_color, s);
	gdk_gc_get_values (gc, &values);
	gdk_rgb_find_color (colormap, &tmp_color);
	gdk_gc_set_foreground (gc, &tmp_color);
	
	return values.foreground;
}
Beispiel #13
0
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
}
Beispiel #14
0
CAMLprim value ml_gdk_gc_get_values (value gc)
{
    CAMLparam0();
    GdkGCValues values;
    CAMLlocal2(ret, tmp);

    gdk_gc_get_values (GdkGC_val(gc), &values);
    ret = alloc (18, 0);
    tmp = Val_copy(values.foreground); Store_field(ret, 0, tmp);
    tmp = Val_copy(values.background); Store_field(ret, 1, tmp);
    if (values.font) {
        tmp = ml_some(Val_GdkFont(values.font));
        Store_field(ret, 2, tmp);
    }
    else
      Store_field(ret, 2, Val_int(0));
    Field(ret,3) = Val_function_type(values.function);
    Field(ret,4) = Val_fill(values.fill);
    if (values.tile) {
        tmp = ml_some(Val_GdkPixmap(values.tile));
        Store_field(ret, 5, tmp);
    }
    else
      Store_field(ret, 5, Val_int(0));
    if (values.stipple) {
        tmp = ml_some(Val_GdkPixmap(values.stipple));
        Store_field(ret, 6, tmp);
    }
    else
      Store_field(ret, 6, Val_int(0));
    if (values.clip_mask) {
        tmp = ml_some(Val_GdkPixmap(values.clip_mask));
        Store_field(ret, 7, tmp);
    }
    else
      Store_field(ret, 7, Val_int(0));
    Field(ret,8) = Val_subwindow_mode(values.subwindow_mode);
    Field(ret,9) = Val_int(values.ts_x_origin);
    Field(ret,10) = Val_int(values.ts_y_origin);
    Field(ret,11) = Val_int(values.clip_x_origin);
    Field(ret,12) = Val_int(values.clip_y_origin);
    Field(ret,13) = Val_bool(values.graphics_exposures);
    Field(ret,14) = Val_int(values.line_width);
    Field(ret,15) = Val_line_style(values.line_style);
    Field(ret,16) = Val_cap_style(values.cap_style);
    Field(ret,17) = Val_join_style(values.join_style);
    CAMLreturn(ret);
}
static void
gtk_plot_canvas_ellipse_select(GtkPlotCanvas *canvas, GtkPlotCanvasChild *child, GtkAllocation area)
{
  GdkGC *xor_gc = NULL;
  GdkGCValues values;
  
  gdk_gc_get_values(GTK_WIDGET(canvas)->style->fg_gc[0], &values);
  values.function = GDK_INVERT;
  values.foreground = GTK_WIDGET(canvas)->style->white;
  values.subwindow_mode = GDK_INCLUDE_INFERIORS;
  xor_gc = gdk_gc_new_with_values(GTK_WIDGET(canvas)->window,
                                  &values,
                                  GDK_GC_FOREGROUND |
                                  GDK_GC_FUNCTION |
                                  GDK_GC_SUBWINDOW);

  gdk_draw_rectangle (GTK_WIDGET(canvas)->window,
                      xor_gc,
                      FALSE,
                      area.x, area.y,
                      area.width, area.height);
  draw_marker(canvas, xor_gc, area.x, area.y);
  draw_marker(canvas, xor_gc, area.x, area.y + area.height);
  draw_marker(canvas, xor_gc, area.x + area.width, area.y);
  draw_marker(canvas, xor_gc, area.x + area.width, area.y + area.height);
  if(area.height > DEFAULT_MARKER_SIZE * 2){
    draw_marker(canvas, xor_gc, area.x, area.y + area.height / 2);
    draw_marker(canvas, xor_gc, area.x + area.width,
                                area.y + area.height / 2);
  }
  if(area.width > DEFAULT_MARKER_SIZE * 2){
    draw_marker(canvas, xor_gc, area.x + area.width / 2, area.y);
    draw_marker(canvas, xor_gc, area.x + area.width / 2,
                                area.y + area.height);
  }

  gdk_gc_set_line_attributes(xor_gc, 1, 1, 0, 0);
  gdk_draw_arc (GTK_WIDGET(canvas)->window, xor_gc,
                FALSE,
                roundint(area.x), roundint(area.y),
                roundint(area.width), roundint(area.height), 0, 25000);

  if(xor_gc) gdk_gc_unref(xor_gc);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect
  (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
  struct graphics *g;
  GdkGCValues saved;
  GtkWidget *widget;
  union widget_union w;

  g = (struct graphics *) NSA_GET_PTR (env, obj);

  gdk_threads_enter ();

  if (!g)
    {
      gdk_threads_leave ();
      return;
    }
  if (GDK_IS_WINDOW (g->drawable))
    {
      w.widget = &widget;
      gdk_window_get_user_data (GDK_WINDOW (g->drawable), w.void_widget);
      if (widget == NULL || !GTK_IS_EVENT_BOX (widget))
        gdk_window_clear_area ((GdkWindow *) g->drawable,
                               x + g->x_offset, y + g->y_offset,
                               width, height);
    }
  else
    {
      gdk_gc_get_values (g->gc, &saved);
      gdk_gc_set_foreground (g->gc, &(saved.background));
      gdk_draw_rectangle (g->drawable, g->gc, TRUE, 
			  x + g->x_offset, y + g->y_offset, width, height);
      gdk_gc_set_foreground (g->gc, &(saved.foreground));
    }

  gdk_flush ();
  gdk_threads_leave ();
}
Beispiel #17
0
static void
gerbv_gdk_draw_prim7(GdkPixmap *pixmap, GdkGC *gc, double *p, 
		 double scale, gint x, gint y)
{
    const int outside_dia_idx = 2;
    const int inside_dia_idx = 3;
    const int ch_thickness_idx = 4;
    const int rotation_idx = 5;
    const gint full_circle = 23360;
    GdkGCValues gc_val;
    int diameter, i;
    GdkGC *local_gc = gdk_gc_new(pixmap);
    GdkPoint point[4];
    double ci_thickness = (p[outside_dia_idx] - 
			   p[inside_dia_idx]) / 2.0;

    gdk_gc_copy(local_gc, gc);
    gdk_gc_set_line_attributes(local_gc, 
			       (int)round(scale * ci_thickness),
			       GDK_LINE_SOLID, 
			       GDK_CAP_BUTT, 
			       GDK_JOIN_MITER);

    /* 
     * Non filled circle 
     */
    diameter = (p[inside_dia_idx] + ci_thickness) * scale;
    gdk_draw_arc(pixmap, local_gc, 0, x - diameter / 2, y - diameter / 2, 
		 diameter, diameter, 0, full_circle);

    /*
     * Cross hair
     */ 
    /* Calculate the end points of the crosshair */    
    /* GDK doesn't always remove all of the circle (round of error probably)
       I extend the crosshair line with 2 (one pixel in each end) to make 
       sure all of the circle is removed with the crosshair */
    for (i = 0; i < 4; i++) {
	point[i].x = round((p[outside_dia_idx] / 2.0) * scale) + 2;
	point[i].y = 0;
	point[i] = rotate_point(point[i], p[rotation_idx] + 90 * i);
	point[i].x += x;
	point[i].y += y;
    }

    gdk_gc_set_line_attributes(local_gc, 
			       (int)round(scale * p[ch_thickness_idx]),
			       GDK_LINE_SOLID, 
			       GDK_CAP_BUTT, 
			       GDK_JOIN_MITER);

    /* The cross hair should "cut out" parts of the circle, hence inverse */
    gdk_gc_get_values(local_gc, &gc_val);
    if (gc_val.foreground.pixel == 1)
	gc_val.foreground.pixel = 0;
    else
	gc_val.foreground.pixel = 1;
    gdk_gc_set_foreground(local_gc, &(gc_val.foreground));

    /* Draw the actual cross */
    gdk_draw_line(pixmap, local_gc, 
		  point[0].x, point[0].y, point[2].x, point[2].y);
    gdk_draw_line(pixmap, local_gc,
		  point[1].x, point[1].y, point[3].x, point[3].y);

    gdk_gc_unref(local_gc);

    return;
} /* gerbv_gdk_draw_prim7 */
static GdkColor cl_gc_get_foreground(GdkGC *gc)
{
	GdkGCValues values;
	gdk_gc_get_values (gc, &values);
	return values.foreground;
}
Beispiel #19
0
/* Retrieves the current values from a graphics context. */
int
clip_GDK_GCGETVALUES(ClipMachine * cm)
{
	C_object      *cgc = _fetch_co_arg(cm);

	ClipVar *ret = RETPTR(cm);

	GdkGCValues gcv;
	C_object *cfont;
	ClipVar *c = NEW(ClipVar);
	C_widget *cw;

	CHECKCOBJ(cgc,GDK_IS_GC(cgc));

	gdk_gc_get_values(GDK_GC(cgc->object), &gcv);

	memset(ret,0,sizeof(*ret)); _clip_map(cm,ret);
	memset(c,0,sizeof(*c));

	/* the foreground color. */
	_clip_map(cm, c); _gdk_color_to_map(cm, gcv.foreground, c);
	_clip_madd(cm, ret, HASH_FOREGROUND, c);
	/* the background color. */
	_clip_map(cm, c); _gdk_color_to_map(cm, gcv.background, c);
	_clip_madd(cm, ret, HASH_BACKGROUND, c);

	_clip_destroy(cm,c); free(c);

	/* the default font */
	cfont = _get_cobject(cm,gcv.font,GDK_OBJECT_FONT,
		(coDestructor)gdk_object_font_destructor);
	if (cfont) _clip_madd(cm, ret, HASH_FONT, &cfont->obj);
	/* the bitwise operation used when drawing. */
	_clip_mputn(cm,ret,HASH_FUNCTION,gcv.function);
	/* the fill style. */
	_clip_mputn(cm,ret,HASH_FILL,gcv.fill);
	/* the tile pixmap. */
	if (gcv.tile)
	{
		cw = _list_get_cwidget_by_data(cm,gcv.tile);
		if (!cw)
		{
			GtkWidget *wxpm = gtk_pixmap_new(gcv.tile,NULL);
			cw = _register_widget(cm,wxpm,NULL);
		}
		if (cw) _clip_madd( cm, ret, HASH_TILE, &cw->obj);
	}
	/* the stipple pixmap. */
	if (gcv.stipple)
	{
		cw = _list_get_cwidget_by_data(cm,gcv.stipple);
		if (!cw)
		{
			GtkWidget *wxpm = gtk_pixmap_new(gcv.stipple,NULL);
			cw = _register_widget(cm,wxpm,NULL);
		}
		if (cw) _clip_madd( cm, ret, HASH_STIPPLE, &cw->obj);
	}
	/* the clip mask bitmap. */
	if (gcv.clip_mask)
	{
		cw = _list_get_cwidget_by_data(cm,gcv.clip_mask);
		if (!cw)
		{
			GtkWidget *wxpm = gtk_pixmap_new(gcv.clip_mask,NULL);
			cw = _register_widget(cm,wxpm,NULL);
		}
		if (cw) _clip_madd( cm, ret, HASH_CLIPMASK, &cw->obj);
	}
	/* the subwindow mode. */
	_clip_mputn(cm,ret,HASH_SUBWINDOWMODE,gcv.subwindow_mode);
	/* the x origin of the tile or stipple. */
	_clip_mputn(cm,ret,HASH_TSXORIGIN,gcv.ts_x_origin);
	/* the y origin of the tile or stipple. */
	_clip_mputn(cm,ret,HASH_TSYORIGIN,gcv.ts_y_origin);
	/* the x origin of the clip mask. */
	_clip_mputn(cm,ret,HASH_CLIPXORIGIN,gcv.clip_x_origin);
	/* the y origin of the clip mask. */
	_clip_mputn(cm,ret,HASH_CLIPYORIGIN,gcv.clip_y_origin);
	/* whether graphics exposures are enabled. */
	_clip_mputn(cm,ret,HASH_GRAPHICSEXPOSURES,gcv.graphics_exposures);
	/* the line width */
	_clip_mputn(cm,ret,HASH_LINEWIDTH,gcv.line_width);
	/* the way dashed lines are drawn */
	_clip_mputn(cm,ret,HASH_LINESTYLE,gcv.line_style);
	/* the way the ends of lines are drawn */
	_clip_mputn(cm,ret,HASH_CAPSTYLE,gcv.cap_style);
	/* the way joins between lines are drawn */
	_clip_mputn(cm,ret,HASH_JOINSTYLE,gcv.join_style);

	return 0;
err:
	return 1;
}
static void cl_draw_corner (GdkWindow *window, GtkWidget *widget, GtkStyle *style,
                     int x, int y, int width, int height,
                     CLRectangle *r, CLCornerSide corner)
{
	GdkColor    *color;
	GdkColor     aacolor; /* anti-aliasing color */
	GdkGCValues  values;
	GdkColor     tmp;
	GdkColor    *bgcolor;

	int x1;
	int y1;

	if (r->corners[corner] == CL_CORNER_NONE)
		return;
	
	color = cl_get_gradient_corner_color (r, corner);
	gdk_gc_get_values (r->bordergc, &values);

	if (color == NULL)
	{
		tmp = values.foreground;
		gdk_colormap_query_color (gtk_widget_get_colormap(widget), values.foreground.pixel, &tmp);
		color = &tmp;
	}

	bgcolor = get_parent_bgcolor(widget);

	if (bgcolor == NULL)
	{
		bgcolor = color;
	}

	blend (style->colormap, bgcolor, color, &aacolor, 70);

	if (r->corners[corner] == CL_CORNER_ROUND)
	{
		x1 = (corner == CL_CORNER_TOPLEFT ||
		      corner == CL_CORNER_BOTTOMLEFT) ? x+1 : x+width - 2;
		
		y1 = (corner == CL_CORNER_TOPLEFT ||
		      corner == CL_CORNER_TOPRIGHT) ? y+1 : y+height - 2;
		
		gdk_gc_set_foreground (r->bordergc, color);
		gdk_draw_point (window, r->bordergc, x1, y1);
		
		gdk_gc_set_foreground (r->bordergc, &aacolor);
		
		x1 = (corner == CL_CORNER_TOPLEFT ||
		      corner == CL_CORNER_BOTTOMLEFT) ? x+1 : x+width-2;

		y1 = (corner == CL_CORNER_TOPLEFT ||
		      corner == CL_CORNER_TOPRIGHT) ? y : y+height-1;		
		
		gdk_draw_point (window, r->bordergc, x1, y1);

		x1 = (corner == CL_CORNER_TOPLEFT ||
		      corner == CL_CORNER_BOTTOMLEFT) ? x : x+width-1;

		y1 = (corner == CL_CORNER_TOPLEFT ||
		      corner == CL_CORNER_TOPRIGHT) ? y+1 : y+height-2;

		gdk_draw_point (window, r->bordergc, x1, y1);
								
	}
	else if (r->corners[corner] == CL_CORNER_NARROW)
	{
		x1 = (corner == CL_CORNER_TOPLEFT ||
		      corner == CL_CORNER_BOTTOMLEFT) ? x : x+width-1;

		y1 = (corner == CL_CORNER_TOPLEFT ||
		      corner == CL_CORNER_TOPRIGHT) ? y : y+height-1;
				
		gdk_gc_set_foreground (r->bordergc, &aacolor);
		gdk_draw_point (window, r->bordergc, x1, y1);
 	}

	gdk_gc_set_foreground (r->bordergc, &values.foreground);
}
Beispiel #21
0
/*
 * Convert a gerber image to a GDK clip mask to be used when creating pixmap
 */
int
draw_gdk_image_to_pixmap(GdkPixmap **pixmap, gerbv_image_t *image, 
	     double scale, double trans_x, double trans_y,
	     gchar drawMode,
	     gerbv_selection_info_t *selectionInfo, gerbv_render_info_t *renderInfo,
	     gerbv_user_transformation_t transform)
{
	GdkGC *gc = gdk_gc_new(*pixmap);
	GdkGC *pgc = gdk_gc_new(*pixmap);
	GdkGCValues gc_values;
	struct gerbv_net *net;
	gerbv_netstate_t *oldState;
	gerbv_layer_t *oldLayer;
	gint x1, y1, x2, y2;
	glong xlong1, ylong1, xlong2, ylong2;
	int p1, p2;
	int cir_width = 0, cir_height = 0;
	int cp_x = 0, cp_y = 0;
	GdkColor transparent, opaque;
	gerbv_polarity_t polarity;
	gdouble tempX,tempY;
	gdouble minX=0,minY=0,maxX=0,maxY=0;

	if (transform.inverted) {
		if (image->info->polarity == GERBV_POLARITY_POSITIVE)
			polarity = GERBV_POLARITY_NEGATIVE;
		else
			polarity = GERBV_POLARITY_POSITIVE;
	} else {
		polarity = image->info->polarity;
	}
	if (drawMode == DRAW_SELECTIONS)
		polarity = GERBV_POLARITY_POSITIVE;

	gboolean useOptimizations = TRUE;
	// if the user is using any transformations for this layer, then don't bother using rendering
	//   optimizations
	if ((fabs(transform.translateX) > 0.00001) ||
			(fabs(transform.translateY) > 0.00001) ||
			(fabs(transform.scaleX - 1) > 0.00001) ||
			(fabs(transform.scaleY - 1) > 0.00001) ||
			(fabs(transform.rotation) > 0.00001) ||
			transform.mirrorAroundX || transform.mirrorAroundY)
		useOptimizations = FALSE;

	// calculate the transformation matrix for the user_transformation options
	cairo_matrix_t fullMatrix, scaleMatrix;
	cairo_matrix_init (&fullMatrix, 1, 0, 0, 1, 0, 0);
	cairo_matrix_init (&scaleMatrix, 1, 0, 0, 1, 0, 0);

	cairo_matrix_translate (&fullMatrix, trans_x, trans_y);
	cairo_matrix_scale (&fullMatrix, scale, scale);
	cairo_matrix_scale (&scaleMatrix, scale, scale);
	/* offset image */

	cairo_matrix_translate (&fullMatrix, transform.translateX, -1*transform.translateY);
	// don't use mirroring for the scale matrix
	gdouble scaleX = transform.scaleX;
	gdouble scaleY = -1*transform.scaleY;
	cairo_matrix_scale (&scaleMatrix, scaleX, -1*scaleY);
	if (transform.mirrorAroundX)
		scaleY *= -1;
	if (transform.mirrorAroundY)
		scaleX *= -1;

	cairo_matrix_scale (&fullMatrix, scaleX, scaleY);
	/* do image rotation */
	cairo_matrix_rotate (&fullMatrix, transform.rotation);
	//cairo_matrix_rotate (&scaleMatrix, transform.rotation);

	/* do image rotation */
	cairo_matrix_rotate (&fullMatrix, image->info->imageRotation);

	if (useOptimizations) {
		minX = renderInfo->lowerLeftX;
		minY = renderInfo->lowerLeftY;
		maxX = renderInfo->lowerLeftX + (renderInfo->displayWidth /
					renderInfo->scaleFactorX);
		maxY = renderInfo->lowerLeftY + (renderInfo->displayHeight /
					renderInfo->scaleFactorY);
	}

	if (image == NULL || image->netlist == NULL) {
		/*
		 * Destroy GCs before exiting
		 */
		gdk_gc_unref(gc);
		gdk_gc_unref(pgc);

		return 0;
	}

	/* Set up the two "colors" we have */
	opaque.pixel = 0; /* opaque will not let color through */
	transparent.pixel = 1; /* transparent will let color through */ 

	/*
	* Clear clipmask and set draw color depending image on image polarity
	*/
	if (polarity == GERBV_POLARITY_NEGATIVE) {
		gdk_gc_set_foreground(gc, &transparent);
		gdk_draw_rectangle(*pixmap, gc, TRUE, 0, 0, -1, -1);
		gdk_gc_set_foreground(gc, &opaque);
	} else {
		gdk_gc_set_foreground(gc, &opaque);
		gdk_draw_rectangle(*pixmap, gc, TRUE, 0, 0, -1, -1);
		gdk_gc_set_foreground(gc, &transparent);
	}
	oldLayer = image->layers;
	oldState = image->states;
	for (net = image->netlist->next ; net != NULL; net = gerbv_image_return_next_renderable_object(net)) {
		int repeat_X=1, repeat_Y=1;
		double repeat_dist_X=0.0, repeat_dist_Y=0.0;
		int repeat_i, repeat_j;

		/*
		 * If step_and_repeat (%SR%) used, repeat the drawing;
		 */
		repeat_X = net->layer->stepAndRepeat.X;
		repeat_Y = net->layer->stepAndRepeat.Y;
		repeat_dist_X = net->layer->stepAndRepeat.dist_X;
		repeat_dist_Y = net->layer->stepAndRepeat.dist_Y;

		/* check if this is a new netstate */
		if (net->state != oldState){
			/* it's a new state, so recalculate the new transformation matrix
			   for it */
			draw_gdk_apply_netstate_transformation (&fullMatrix, &scaleMatrix, net->state);
			oldState = net->state;	
		}
		/* check if this is a new layer */
		/* for now, only do layer rotations in GDK rendering */
		if (net->layer != oldLayer){
			cairo_matrix_rotate (&fullMatrix, net->layer->rotation);
			oldLayer = net->layer;
		}

		if (drawMode == DRAW_SELECTIONS) {
			int i;
			gboolean foundNet = FALSE;
			
			for (i=0; i<selectionInfo->selectedNodeArray->len; i++){
				gerbv_selection_item_t sItem = g_array_index (selectionInfo->selectedNodeArray,
					gerbv_selection_item_t, i);
				if (sItem.net == net)
					foundNet = TRUE;
			}
			if (!foundNet)
				continue;
		}

		for(repeat_i = 0; repeat_i < repeat_X; repeat_i++) {
		for(repeat_j = 0; repeat_j < repeat_Y; repeat_j++) {
		  double sr_x = repeat_i * repeat_dist_X;
		  double sr_y = repeat_j * repeat_dist_Y;
			
			if ((useOptimizations)&&((net->boundingBox.right+sr_x < minX)
					|| (net->boundingBox.left+sr_x > maxX)
					|| (net->boundingBox.top+sr_y < minY)
					|| (net->boundingBox.bottom+sr_y > maxY))) {
				continue;
			}

		/* 
		 * If circle segment, scale and translate that one too
		 */
		if (net->cirseg) {
		    tempX = net->cirseg->width;
		    tempY = net->cirseg->height;
		    cairo_matrix_transform_point (&scaleMatrix, &tempX, &tempY);
		    cir_width = (int)round(tempX);
		    cir_height = (int)round(tempY);
		    
		    tempX = net->cirseg->cp_x;
		    tempY = net->cirseg->cp_y;
		    cairo_matrix_transform_point (&fullMatrix, &tempX, &tempY);
		    cp_x = (int)round(tempX);
		    cp_y = (int)round(tempY);
		}

		/*
		 * Set GdkFunction depending on if this (gerber) layer is inverted
		 * and allow for the photoplot being negative.
		 */
		gdk_gc_set_function(gc, GDK_COPY);
		if ((net->layer->polarity == GERBV_POLARITY_CLEAR) != (polarity == GERBV_POLARITY_NEGATIVE))
		    gdk_gc_set_foreground(gc, &opaque);
		else
		    gdk_gc_set_foreground(gc, &transparent);

		/*
		 * Polygon Area Fill routines
		 */
		switch (net->interpolation) {
		case GERBV_INTERPOLATION_PAREA_START :
		    draw_gdk_render_polygon_object (net,image,sr_x,sr_y,&fullMatrix,
		    	&scaleMatrix,gc,pgc,pixmap);
		    continue;
		/* make sure we completely skip over any deleted nodes */
		case GERBV_INTERPOLATION_DELETED:
		    continue;
		default :
		    break;
		}


		/*
		 * If aperture state is off we allow use of undefined apertures.
		 * This happens when gerber files starts, but hasn't decided on 
		 * which aperture to use.
		 */
		if (image->aperture[net->aperture] == NULL) {
		  /* Commenting this out since it gets emitted every time you click on the screen 
		     if (net->aperture_state != GERBV_APERTURE_STATE_OFF)
		     GERB_MESSAGE("Aperture D%d is not defined\n", net->aperture);
		  */
		    continue;
		}

		/*
		 * Scale points with window scaling and translate them
		 */
		tempX = net->start_x + sr_x;
		tempY = net->start_y + sr_y;
		cairo_matrix_transform_point (&fullMatrix, &tempX, &tempY);
		xlong1 = (int)round(tempX);
		ylong1 = (int)round(tempY);

		tempX = net->stop_x + sr_x;
		tempY = net->stop_y + sr_y;
		cairo_matrix_transform_point (&fullMatrix, &tempX, &tempY);
		xlong2 = (int)round(tempX);
		ylong2 = (int)round(tempY);

		/* if the object is way outside our view window, just skip over it in order
		   to eliminate some GDK clipping problems at high zoom levels */
		if ((xlong1 < -10000) && (xlong2 < -10000))
			continue;
		if ((ylong1 < -10000) && (ylong2 < -10000))
			continue;
		if ((xlong1 > 10000) && (xlong2 > 10000))
			continue;
		if ((ylong1 > 10000) && (ylong2 > 10000))
			continue;

		if (xlong1 > G_MAXINT) x1 = G_MAXINT;
		else if (xlong1 < G_MININT) x1 = G_MININT;
		else x1 = (int)xlong1;

		if (xlong2 > G_MAXINT) x2 = G_MAXINT;
		else if (xlong2 < G_MININT) x2 = G_MININT;
		else x2 = (int)xlong2;

		if (ylong1 > G_MAXINT) y1 = G_MAXINT;
		else if (ylong1 < G_MININT) y1 = G_MININT;
		else y1 = (int)ylong1;

		if (ylong2 > G_MAXINT) y2 = G_MAXINT;
		else if (ylong2 < G_MININT) y2 = G_MININT;
		else y2 = (int)ylong2;
			
		switch (net->aperture_state) {
		case GERBV_APERTURE_STATE_ON :
		    tempX = image->aperture[net->aperture]->parameter[0];
		    cairo_matrix_transform_point (&scaleMatrix, &tempX, &tempY);
		    p1 = (int)round(tempX);

		   // p1 = (int)round(image->aperture[net->aperture]->parameter[0] * scale);
		    if (image->aperture[net->aperture]->type == GERBV_APTYPE_RECTANGLE)
			gdk_gc_set_line_attributes(gc, p1, 
						   GDK_LINE_SOLID, 
						   GDK_CAP_PROJECTING, 
						   GDK_JOIN_MITER);
		    else
			gdk_gc_set_line_attributes(gc, p1, 
						   GDK_LINE_SOLID, 
						   GDK_CAP_ROUND, 
						   GDK_JOIN_MITER);
		    
		    switch (net->interpolation) {
		    case GERBV_INTERPOLATION_x10 :
		    case GERBV_INTERPOLATION_LINEARx01 :
		    case GERBV_INTERPOLATION_LINEARx001 :
			GERB_MESSAGE(_("Linear != x1\n"));
			gdk_gc_set_line_attributes(gc, p1, 
						   GDK_LINE_ON_OFF_DASH, 
						   GDK_CAP_ROUND, 
						   GDK_JOIN_MITER);
			gdk_draw_line(*pixmap, gc, x1, y1, x2, y2);
			gdk_gc_set_line_attributes(gc, p1, 
						   GDK_LINE_SOLID,
						   GDK_CAP_ROUND, 
						   GDK_JOIN_MITER);
			break;
		    case GERBV_INTERPOLATION_LINEARx1 :
			if (image->aperture[net->aperture]->type != GERBV_APTYPE_RECTANGLE)
			    gdk_draw_line(*pixmap, gc, x1, y1, x2, y2);
			else {
			    gint dx, dy;
			    GdkPoint poly[6];
			    
			    tempX = image->aperture[net->aperture]->parameter[0]/2;
			    tempY = image->aperture[net->aperture]->parameter[1]/2;
			    cairo_matrix_transform_point (&scaleMatrix, &tempX, &tempY);
			    dx = (int)round(tempX);
			    dy = (int)round(tempY);

			    if(x1 > x2) dx = -dx;
			    if(y1 > y2) dy = -dy;
			    poly[0].x = x1 - dx; poly[0].y = y1 - dy;
			    poly[1].x = x1 - dx; poly[1].y = y1 + dy;
			    poly[2].x = x2 - dx; poly[2].y = y2 + dy;
			    poly[3].x = x2 + dx; poly[3].y = y2 + dy;
			    poly[4].x = x2 + dx; poly[4].y = y2 - dy;
			    poly[5].x = x1 + dx; poly[5].y = y1 - dy;
			    gdk_draw_polygon(*pixmap, gc, 1, poly, 6);
			}
				break;
		    case GERBV_INTERPOLATION_CW_CIRCULAR :
		    case GERBV_INTERPOLATION_CCW_CIRCULAR :
			gerbv_gdk_draw_arc(*pixmap, gc, cp_x, cp_y, cir_width, cir_height, 
					   net->cirseg->angle1, net->cirseg->angle2);
			break;
		    default :
			break;
		    }
		    break;
		case GERBV_APERTURE_STATE_OFF :
		    break;
		case GERBV_APERTURE_STATE_FLASH :
		    tempX = image->aperture[net->aperture]->parameter[0];
		    tempY = image->aperture[net->aperture]->parameter[1];
		    cairo_matrix_transform_point (&scaleMatrix, &tempX, &tempY);
		    p1 = (int)round(tempX);
		    p2 = (int)round(tempY);
		    tempX = image->aperture[net->aperture]->parameter[2];
		    cairo_matrix_transform_point (&scaleMatrix, &tempX, &tempY);
		    
		    switch (image->aperture[net->aperture]->type) {
		    case GERBV_APTYPE_CIRCLE :
			gerbv_gdk_draw_circle(*pixmap, gc, TRUE, x2, y2, p1);
			/*
			 * If circle has an inner diameter we must remove
			 * that part of the circle to make a hole in it.
			 * We should actually support square holes too,
			 * but due to laziness I don't.
			 */
			if (p2) {
			    gdk_gc_get_values(gc, &gc_values);
			    if (gc_values.foreground.pixel == opaque.pixel) {
				gdk_gc_set_foreground(gc, &transparent);
				gerbv_gdk_draw_circle(*pixmap, gc, TRUE, x2, y2, p2);
				gdk_gc_set_foreground(gc, &opaque);
			    } else {
				gdk_gc_set_foreground(gc, &opaque);
				gerbv_gdk_draw_circle(*pixmap, gc, TRUE, x2, y2, p2);
				gdk_gc_set_foreground(gc, &transparent);
			    }
			}

			break;
		    case GERBV_APTYPE_RECTANGLE:
			gerbv_gdk_draw_rectangle(*pixmap, gc, TRUE, x2, y2, p1, p2);
			break;
		    case GERBV_APTYPE_OVAL :
			gerbv_gdk_draw_oval(*pixmap, gc, TRUE, x2, y2, p1, p2);
			break;
		    case GERBV_APTYPE_POLYGON :
			gerbv_gdk_draw_circle(*pixmap, gc, TRUE, x2, y2, p1);
			break;
		    case GERBV_APTYPE_MACRO :
			gerbv_gdk_draw_amacro(*pixmap, gc, 
					      image->aperture[net->aperture]->simplified,
					      scale, x2, y2);
			break;
		    default :
			GERB_MESSAGE(_("Unknown aperture type\n"));
			return 0;
		    }
		    break;
		default :
		    GERB_MESSAGE(_("Unknown aperture state\n"));
		    return 0;
		}
		}
		}
	}
	/*
	* Destroy GCs before exiting
	*/
	gdk_gc_unref(gc);
	gdk_gc_unref(pgc);

	return 1;

} /* image2pixmap */
Beispiel #22
0
int GCcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
		   int attrn, Gwattr_t * attrp)
{
    PIXsize_t ps;
    int width, height;
    int ai, i;
    GdkGCValues gcv;
    int r, g, b, color;
    GdkColor *cp;

    if (!parent) {
	Gerr(POS, G_ERRNOPARENTWIDGET);
	return -1;
    }

    canvas = widget;
    WCU->func = NULL;
    WCU->needredraw = FALSE;
    WCU->buttonsdown = 0;
    WCU->bstate[0] = WCU->bstate[1] = WCU->bstate[2] = 0;
    ps.x = ps.y = MINCWSIZE;

    for (ai = 0; ai < attrn; ai++) {
	switch (attrp[ai].id) {
	case G_ATTRSIZE:
	    GETSIZE(attrp[ai].u.s, ps, MINCWSIZE);
	    break;
	case G_ATTRBORDERWIDTH:
	    break;
#ifdef FEATURE_GMAP
	case G_ATTRMODE:
	    if (Strcmp("gmap", attrp[ai].u.t) == 0) {
		gmapmode = TRUE;
	    } else {
		Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
		return -1;
	    }
	    break;
#endif
	case G_ATTRCURSOR:
	    break;
	case G_ATTRCOLOR:
	    break;
	case G_ATTRVIEWPORT:
	    break;
	case G_ATTRWINDOW:
	    break;
	case G_ATTRWINDOWID:
	    Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
	    return -1;
	case G_ATTREVENTCB:
	    WCU->func = (Gcanvascb) attrp[ai].u.func;
	    break;
	case G_ATTRUSERDATA:
	    widget->udata = attrp[ai].u.u;
	    break;
	default:
	    Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
	    return -1;
	}
    }
/*    	XtSetValues (widget->w, argp, argn);	*/

    widget->w = gtk_drawing_area_new();
    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(parent->w),
					  widget->w);
    gtk_drawing_area_size(GTK_DRAWING_AREA(widget->w), ps.x, ps.y);

    gtk_widget_add_events(widget->w, GDK_ALL_EVENTS_MASK);
    gtk_signal_connect(GTK_OBJECT(widget->w), "key_release_event",
		       GTK_SIGNAL_FUNC(Gcwkeyaction), NULL);
    gtk_signal_connect(GTK_OBJECT(widget->w), "key_press_event",
		       GTK_SIGNAL_FUNC(Gcwkeyaction), NULL);
    gtk_signal_connect(G_OBJECT(widget->w), "button_press_event",
		       GTK_SIGNAL_FUNC(Gcwbutaction), NULL);
    gtk_signal_connect(G_OBJECT(widget->w), "button_release_event",
		       GTK_SIGNAL_FUNC(Gcwbutaction), NULL);
    gtk_signal_connect(G_OBJECT(widget->w), "visibility_notify_event",
		       GTK_SIGNAL_FUNC(cweventhandler), NULL);
    gtk_signal_connect(G_OBJECT(widget->w), "expose_event",
		       GTK_SIGNAL_FUNC(exposeeventhandler), NULL);
    gtk_signal_connect(G_OBJECT(widget->w), "motion_notify_event",
		       GTK_SIGNAL_FUNC(cweventhandler), NULL);

    gtk_widget_show(widget->w);
    gtk_widget_show(parent->w);

    GC = gdk_gc_new(widget->w->window);
    WCU->cmap = gdk_colormap_get_system();
    WCU->colors[0].color.pixel = WCU->colors[1].color.pixel = 1000000;
    if (WCU->colors[0].color.pixel == 1000000) {
	gdk_gc_get_values(GC, &gcv);
	WCU->colors[0].color = gcv.background;
    }
    if (WCU->colors[1].color.pixel == 1000000) {
	gdk_gc_get_values(GC, &gcv);
	WCU->colors[1].color = gcv.foreground;
    }

    WCU->colors[0].color.red = 65535;
    WCU->colors[0].color.green = 65535;
    WCU->colors[0].color.blue = 65535;
    WCU->colors[1].color.red = 0;
    WCU->colors[1].color.green = 0;
    WCU->colors[1].color.blue = 0;

    gdk_colormap_alloc_color(WCU->cmap, &WCU->colors[0].color, FALSE,
			     TRUE);
    WCU->colors[0].inuse = TRUE;
    gdk_colormap_alloc_color(WCU->cmap, &WCU->colors[1].color, FALSE,
			     TRUE);
    WCU->colors[1].inuse = TRUE;

    WCU->allocedcolor[0] = WCU->allocedcolor[1] = FALSE;
    for (i = 2; i < G_MAXCOLORS; i++)
	WCU->colors[i].inuse = FALSE;

    WCU->gattr.color = 1;
/*	gdk_gc_set_background(GC, widget->w->style->white_gc);
	gdk_gc_set_foreground(GC, widget->w->style->black_gc);
*/

    WCU->gattr.width = 0;
    WCU->gattr.mode = 0;
    WCU->gattr.fill = 0;
    WCU->gattr.style = 0;
    WCU->defgattr = WCU->gattr;
    WCU->font = NULL;
    WCU->wrect.o.x = 0.0, WCU->wrect.o.y = 0.0;
    WCU->wrect.c.x = 1.0, WCU->wrect.c.y = 1.0;
    WCU->vsize.x = ps.x, WCU->vsize.y = ps.y;

    for (ai = 0; ai < attrn; ai++) {
	switch (attrp[ai].id) {
	case G_ATTRCURSOR:
	    if (Strcmp(attrp[ai].u.t, "default") == 0) {
		curcursori = -1;
	    }
	    break;
	case G_ATTRCOLOR:
	    color = attrp[ai].u.c.index;
	    if (color < 0 || color > G_MAXCOLORS) {
		Gerr(POS, G_ERRBADCOLORINDEX, color);
		return -1;
	    }
	    r = attrp[ai].u.c.r * 257;
	    g = attrp[ai].u.c.g * 257;
	    b = attrp[ai].u.c.b * 257;
	    cp = &WCU->colors[color].color;
	    if (WCU->colors[color].inuse)
		if (cp->red != r || cp->green != g || cp->blue != b)
		    if (color > 1 || WCU->allocedcolor[color])
			gdk_colormap_free_colors(WCU->cmap, cp, 1);

	    cp->red = r, cp->green = g, cp->blue = b;
	    if (gdk_colormap_alloc_color(WCU->cmap, cp, TRUE, TRUE)) {
		WCU->colors[color].inuse = TRUE;
		if (color <= 1)
		    WCU->allocedcolor[color] = TRUE;
	    }
	    cp->red = r, cp->green = g, cp->blue = b;
	    if (color == WCU->gattr.color)
		WCU->gattr.color = -1;
	    break;
	case G_ATTRVIEWPORT:
	    WCU->vsize.x = (int) (attrp[ai].u.s.x + 0.5);
	    WCU->vsize.y = (int) (attrp[ai].u.s.y + 0.5);
	    break;
	case G_ATTRWINDOW:
	    WCU->wrect = attrp[ai].u.r;
	    break;
	}
    }
    adjustclip(widget);
    return 0;
}
Beispiel #23
0
void
draw_check_mark(GdkWindow * window,
                GdkGC * gc,
		GdkRectangle * area,
		gint x,
		gint y,
		gint width,
		gint height,
		gint check_style)
{
   switch (check_style) {
      case FAST_CHECK : /* most common style */
        gdk_draw_line(window, gc, x, y+height-1, x, y+(height/2)-1);
        gdk_draw_line(window, gc, x+1, y+height-1, x+1, y+(height/2)-1);
        gdk_draw_line(window, gc, x+1, y+height-1, x+width, y - 1);
        gdk_draw_line(window, gc, x, y+height-1, x+width, y);
	break;
      case SLOPPY_CHECK : /* default theme style, not done so just fall through*/
      case CLEAN_CHECK :/* classic redmond style */
	x+=1;
	y+=1; 
	width-=2;
        height-=2; 

        /* short diagonal */
	gdk_draw_line(window, gc, x+0, y+height-5, x+0, y+height-2);/* Left Line */
        gdk_draw_line(window, gc, x+1, y+height-4, x+1, y+height-1);/* Right Line */

        /* Long Diagonal */
        gdk_draw_line(window, gc, x+2, y+height-3, x+width-1, y+0);/* Top Line */
        gdk_draw_line(window, gc, x+2, y+height-2, x+width-1, y+1);/* Center Line */
        gdk_draw_line(window, gc, x+2, y+height-1, x+width-1, y+2);/* Bottom Line */
	break;
      case X_CHECK : /* common(default?) style in kde themes */
        {
	  GdkGC * line_gc = NULL;
          if (width>=16) 
	  {
  	    GdkGCValues gc_vals;
	    gint off_1, off_2, off_3;
            gint line_width = ceil(((width + 1)/5));
	
	    if (!(line_width % 2)) line_width -= 1;
	    gdk_gc_get_values(gc, &gc_vals);
	    gc_vals.line_width = line_width;
	    gc_vals.cap_style = GDK_CAP_ROUND;

	    off_2 = gc_vals.line_width;
	    off_1 = off_2 - 1;
	    off_3 = off_2 + 1;

              line_gc = gdk_gc_new_with_values(window, &gc_vals,   GDK_GC_FOREGROUND | GDK_GC_BACKGROUND | GDK_GC_FUNCTION |
              GDK_GC_CLIP_MASK | GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN | GDK_GC_LINE_WIDTH | GDK_GC_LINE_STYLE |
	      GDK_GC_CAP_STYLE);

  	    /* Backward Diagonal */
            gdk_draw_line(window, line_gc, x+off_1, y+off_1, x+width-off_2, y+height-off_2);/* Center Line */

            /* Forward Diagonal */
            gdk_draw_line(window, line_gc, x+off_1, y+height - off_2, x+width-off_2, y+off_1);/* Center Line */

  	    gdk_gc_unref(line_gc);
	  } else {
	    /* Backward Diagonal */
            if (width>=7) 
	      gdk_draw_line(window, gc, x+2, y+1, x+width-2, y+height-3);/* Top Line */
            gdk_draw_line(window, gc, x+1, y+1, x+width-2, y+height-2);/* Center Line */
            if (width>=7) 
              gdk_draw_line(window, gc, x+1, y+2, x+width-3, y+height-2);/* Bottom Line */

            /* Forward Diagonal */
            if (width>=7) 
              gdk_draw_line(window, gc, x+1, y+height-3, x+width-3, y+1);/* Top Line */
            gdk_draw_line(window, gc, x+1, y+height - 2, x+width-2, y+1);/* Center Line */
            if (width>=7) 
              gdk_draw_line(window, gc, x+2, y+height - 2, x+width-2, y+2);/* Bottom Line */
          }	  
	}
	break;	
      case BLOCK_CHECK : /* square check style, like mist */
        gdk_draw_rectangle(window, gc, TRUE, x+1, y+1, width-2, height-2); 
	break;	
      case CIRCLE_CHECK : /* round check style, like mist, but with circles */
        gdk_draw_arc(window, gc, TRUE, x + width / 4, y + height / 4, width / 2 + 1, height / 2 + 1, 0, 360*64); 
        gdk_draw_arc(window, gc, FALSE, x + width / 4, y + height / 4, width / 2 + 1, height / 2 + 1, 0, 360*64); 
	break;	
      case DIAMOND_CHECK : /* diamond check style, like mist, but with diamonds */
	{
	  GdkPoint * points = g_new(GdkPoint, 5);
          
	  x+=1;
	  y+=1; 
	  width-=2;
	  height-=2; 
	  
	  points[0].x = x + width/2;
	  points[0].y = y;

	  points[1].x = x + width;
	  points[1].y = y + height/2;

	  points[2].x = x + width/2;
	  points[2].y = y + height;
	  
	  points[3].x = x;
	  points[3].y = y + height/2;

	  points[4].x = x + width/2;
	  points[4].y = y;
	  
	  gdk_draw_polygon(window, gc, TRUE, points, 5);
	  gdk_draw_polygon(window, gc, FALSE, points, 5);
	  
	  g_free(points);
	}
	break;	
      case XPM_CHECK : /* custom check in xpm format */
	break;	
      case NO_CHECK :
      default :
        return;
   }   
}
Beispiel #24
0
GdkFunction vik_gc_get_function ( GdkGC *gc )
{
  static GdkGCValues values;
  gdk_gc_get_values ( gc, &values );
  return values.function;
}
Beispiel #25
0
void vik_gc_get_fg_color ( GdkGC *gc, GdkColor *dest )
{
  static GdkGCValues values;
  gdk_gc_get_values ( gc, &values );
  gdk_colormap_query_color ( gdk_colormap_get_system(), values.foreground.pixel, dest );
}