/* Copy the set of values from one graphics context onto another graphics context. */ int clip_GDK_GCCOPY(ClipMachine * cm) { C_object *cdst_gc = _fetch_co_arg(cm); C_object *csrc_gc = _fetch_cobject(cm,_clip_spar(cm,2)); CHECKCOBJ(cdst_gc,GDK_IS_GC(cdst_gc)); CHECKARG2(2,MAP_t,NUMERIC_t); CHECKCOBJ(csrc_gc,GDK_IS_GC(csrc_gc)); gdk_gc_copy(GDK_GC(cdst_gc->object), GDK_GC(csrc_gc->object)); return 0; err: return 1; }
/* Sets the clip mask for a graphics context from a rectangle. * The clip mask is interpreted relative to the clip origin. * (See gdk_gc_set_clip_origin()). */ int clip_GDK_GCSETCLIPRECTANGLE(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); gint16 x = _clip_parni(cm,2); gint16 y = _clip_parni(cm,3); guint16 width = _clip_parni(cm,4); guint16 height = _clip_parni(cm,5); double d; GdkRectangle rect; CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKARG2(2,MAP_t,NUMERIC_t); CHECKOPT(3,NUMERIC_t); CHECKOPT(4,NUMERIC_t); CHECKOPT(5,NUMERIC_t); if (_clip_parinfo(cm,2)==MAP_t) { ClipVar *cv = _clip_spar(cm,2); _clip_mgetn(cm, cv, HASH_X, &d); rect.x = (gint16)d; _clip_mgetn(cm, cv, HASH_Y, &d); rect.y = (gint16)d; _clip_mgetn(cm, cv, HASH_WIDTH, &d); rect.width = (gint16)d; _clip_mgetn(cm, cv, HASH_HEIGHT, &d); rect.height = (gint16)d; } else { rect.x = x; rect.y = y; rect.width = width; rect.height = height; } gdk_gc_set_clip_rectangle(GDK_GC(cgc->object), &rect); return 0; err: return 1; }
/* Sets the font for a graphics context. * (Note that all text-drawing functions in GDK take a font argument; * the value set here is used when that argument is NULL.) */ int clip_GDK_GCSETFONT(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); ClipVar *c; GdkFont *font = 0; C_object *cfont; CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKARG3(2,CHARACTER_t,MAP_t,NUMERIC_t); switch ( _clip_parinfo(cm,2) ) { case CHARACTER_t: c = _clip_spar(cm,2); font = gdk_font_load(c->s.str.buf); break; case MAP_t: case NUMERIC_t: cfont = _fetch_cobject(cm,_clip_spar(cm,2)); if (cfont) { font = (GdkFont*)cfont->object; cfont->ref_count++; } break; default: break; } if (font) { gdk_gc_set_font(GDK_GC(cgc->object), font); gdk_font_ref (font); } return 0; err: return 1; }
CLIP_DLLEXPORT int gdk_object_gc_destructor(ClipMachine *cm, C_object *cgc) { if (cgc && GDK_IS_GC(cgc) && cgc->ref_count>=0) gdk_gc_unref(GDK_GC(cgc->object)); return 0; }
/* Draws a line, using the foreground color and other attributes of the GdkGC. */ int clip_GDK_DRAWLINE(ClipMachine * ClipMachineMemory) { C_widget *cwid = _fetch_cw_arg(ClipMachineMemory); C_object *cgc = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2)); gint x1 = _clip_parni(ClipMachineMemory, 3); gint y1 = _clip_parni(ClipMachineMemory, 4); gint x2 = _clip_parni(ClipMachineMemory, 5); gint y2 = _clip_parni(ClipMachineMemory, 6); GdkDrawable *drw = NULL; CHECKCWID(cwid, GTK_IS_WIDGET); CHECKOPT2(2, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType); CHECKCOBJ(cgc, GDK_IS_GC(cgc)); CHECKOPT(3, NUMERIC_type_of_ClipVarType); CHECKOPT(4, NUMERIC_type_of_ClipVarType); CHECKOPT(5, NUMERIC_type_of_ClipVarType); CHECKOPT(6, NUMERIC_type_of_ClipVarType); drw = cwid->widget->window; if (GTK_IS_PIXMAP(cwid->widget)) drw = GTK_PIXMAP(cwid->widget)->pixmap; gdk_draw_line(drw, GDK_GC(cgc->object), x1, y1, x2, y2); return 0; err: return 1; }
/* Note: A rectangle drawn filled is 1 pixel smaller in both dimensions * than a rectangle outlined. Calling gdk_draw_rectangle (window, gc, TRUE, 0, 0, 20, 20) * results in a filled rectangle 20 pixels wide and 20 pixels high. Calling * gdk_draw_rectangle (window, gc, FALSE, 0, 0, 20, 20) results in an outlined * rectangle with corners at (0, 0), (0, 20), (20, 20), and (20, 0), which makes * it 21 pixels wide and 21 pixels high. */ int clip_GDK_DRAWRECTANGLE(ClipMachine * ClipMachineMemory) { C_widget *cwid = _fetch_cw_arg(ClipMachineMemory); C_object *cgc = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2)); gint filled = BOOL_OPTION(ClipMachineMemory, 3, TRUE); gint x = _clip_parni(ClipMachineMemory, 4); gint y = _clip_parni(ClipMachineMemory, 5); gint width = _clip_parni(ClipMachineMemory, 6); gint height = _clip_parni(ClipMachineMemory, 7); GdkDrawable *drw = NULL; CHECKCWID(cwid, GTK_IS_WIDGET); CHECKOPT2(2, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType); CHECKCOBJ(cgc, GDK_IS_GC(cgc)); CHECKOPT(3, LOGICAL_type_of_ClipVarType); CHECKOPT(4, NUMERIC_type_of_ClipVarType); CHECKOPT(5, NUMERIC_type_of_ClipVarType); CHECKOPT(6, NUMERIC_type_of_ClipVarType); CHECKOPT(7, NUMERIC_type_of_ClipVarType); drw = cwid->widget->window; if (GTK_IS_PIXMAP(cwid->widget)) drw = GTK_PIXMAP(cwid->widget)->pixmap; gdk_draw_rectangle(drw, GDK_GC(cgc->object), filled, x, y, width, height); return 0; err: return 1; }
/* Determines how the current pixel values and the pixel values being * drawn are combined to produce the final pixel values. */ int clip_GDK_GCSETFUNCTION(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); GdkFunction function = _clip_parni(cm,2); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKOPT(2,NUMERIC_t); gdk_gc_set_function(GDK_GC(cgc->object), function); return 0; err: return 1; }
/* Increase the reference count on a graphics context. */ int clip_GDK_GCREF(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); gdk_gc_ref(GDK_GC(cgc->object)); cgc->ref_count++; return 0; err: return 1; }
/* 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; }
/* Sets the clip mask for a graphics context from a bitmap. * The clip mask is interpreted relative to the clip origin. * (See gdk_gc_set_clip_origin()). */ int clip_GDK_GCSETCLIPMASK(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); C_widget *cxpm = _fetch_cwidget(cm,_clip_spar(cm,2)); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKARG2(2,MAP_t,NUMERIC_t); CHECKCWID(cxpm,GTK_IS_PIXMAP); gdk_gc_set_clip_mask(GDK_GC(cgc->object), GTK_PIXMAP(cxpm->widget)->pixmap); return 0; err: return 1; }
/* Sets the origin of the clip mask. The coordinates are interpreted relative to * the upper-left corner of the destination drawable of the current operation. */ int clip_GDK_GCSETCLIPORIGIN(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); gint x = _clip_parni(cm,2); gint y = _clip_parni(cm,3); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKOPT(2,NUMERIC_t); CHECKOPT(3,NUMERIC_t); gdk_gc_set_clip_origin(GDK_GC(cgc->object), x, y); return 0; err: return 1; }
/* GDK_CLIP_BY_CHILDREN only draw onto the window itself. GDK_INCLUDE_INFERIORS Draw onto the window and child windows. */ int clip_GDK_GCSETSUBWINDOW(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); GdkSubwindowMode mode = _clip_parni (cm, 2); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKARG(2,NUMERIC_t); gdk_gc_set_subwindow(GDK_GC(cgc->object), mode); return 0; err: return 1; }
/* Sets whether copying non-visible portions of a drawable using this graphics * context generate exposure events for the corresponding regions of the * destination drawable. (See gdk_draw_pixmap()). */ int clip_GDK_GCSETEXPOSURES(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); gint exposures = _clip_parni (cm, 2); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKARG(2,NUMERIC_t); gdk_gc_set_exposures(GDK_GC(cgc->object), exposures); return 0; err: return 1; }
/* Sets the foreground color for a graphics context. */ int clip_GDK_GCSETFOREGROUND(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); ClipVar *mcolor = _clip_spar ( cm, 2); GdkColor color; CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKARG(2,MAP_t); _map_colors_to_gdk(cm, mcolor, &color); gdk_gc_set_foreground(GDK_GC(cgc->object), &color); return 0; err: return 1; }
/* Sets the clip mask for a graphics context from a region structure. * The clip mask is interpreted relative to the clip origin. * (See gdk_gc_set_clip_origin()). */ int clip_GDK_GCSETCLIPREGION(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); C_object *creg = _fetch_cobject(cm,_clip_spar(cm,2)); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKARG2(2,MAP_t,NUMERIC_t); CHECKCOBJ(creg,GDK_IS_REGION(creg)); gdk_gc_set_clip_region(GDK_GC(cgc->object), (GdkRegion*)(creg->object)); return 0; err: return 1; }
GdkPixmap *make_pixmap(GtkScrollbox *self, gchar *value) { GdkWindow *rootwin; PangoLayout *pl; gint width, height, middle; GdkPixmap *pixmap; GtkRequisition widgsize = {0, }; GtkWidget *widget = (GtkWidget *)self; /* If we can't draw yet, don't do anything to avoid screwing things */ if (!GDK_IS_GC(widget->style->bg_gc[0])) return NULL; rootwin = gtk_widget_get_root_window(widget); pl = gtk_widget_create_pango_layout(widget, NULL); pango_layout_set_markup(pl, value, -1); pango_layout_get_pixel_size(pl, &width, &height); pixmap = gdk_pixmap_new(GDK_DRAWABLE(rootwin), width, height, -1); gdk_draw_rectangle(GDK_DRAWABLE(pixmap), widget->style->bg_gc[0], TRUE, 0, 0, width, height); gdk_draw_layout(GDK_DRAWABLE(pixmap), widget->style->fg_gc[0], 0, 0, pl); g_object_unref(pl); gtk_widget_size_request(widget, &widgsize); if (width <= widgsize.width) width = widgsize.width; if (height <= widgsize.height) height = widgsize.height; else self->draw_maxoffset = -height; if (width != widgsize.width || height != widgsize.height) gtk_widget_set_size_request(widget, width, height); middle = width / 2; if (self->draw_maxmiddle < middle) self->draw_maxmiddle = middle; return pixmap; }
/* Decrease the reference count on a graphics context. If the resulting * reference count is zero, the graphics context will be destroyed. */ int clip_GDK_GCUNREF(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); cgc->ref_count--; if (cgc->ref_count > 0) gdk_gc_unref(GDK_GC(cgc->object)); else destroy_c_object(cgc); // gdk_gc_unref(GDK_GC(cgc->object)); return 0; err: return 1; }
/* Sets the way dashed-lines are drawn. Lines will be drawn with alternating * on and off segments of the lengths specified in dash_list. The manner in * which the on and off segments are drawn is determined by the line_style * value of the GC. (This can be changed with gdk_gc_set_line_attributes) */ int clip_GDK_GCSETDASHES(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); gint dash_offset = _clip_parni (cm, 2); gchar *dash_list = _clip_parc (cm, 3); gint n = _clip_parni (cm, 4); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKOPT(2,NUMERIC_t); CHECKARG(3,CHARACTER_t); CHECKOPT(4,NUMERIC_t); if (_clip_parinfo(cm,4)==UNDEF_t) n = strlen(dash_list); gdk_gc_set_dashes(GDK_GC(cgc->object), dash_offset,(gint8 *)dash_list,n); return 0; err: return 1; }
/* Sets various attributes of how lines are drawn. See the corresponding * members of GdkGCValues for full explanations of the arguments. */ int clip_GDK_GCSETLINEATTRIBUTES(ClipMachine * cm) { C_object *cgc = _fetch_co_arg(cm); gint line_width = INT_OPTION (cm, 2, 0); GdkLineStyle line_style = _clip_parni (cm, 3); GdkCapStyle cap_style = _clip_parni (cm, 4); GdkJoinStyle join_style = _clip_parni (cm, 5); CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKOPT(2,NUMERIC_t); CHECKOPT(3,NUMERIC_t); CHECKOPT(4,NUMERIC_t); CHECKOPT(5,NUMERIC_t); gdk_gc_set_line_attributes(GDK_GC(cgc->object), line_width, line_style, cap_style, join_style); return 0; err: return 1; }
/* Alena */ int clip_GDK_DRAWPIXMAP(ClipMachine * ClipMachineMemory) { C_widget *cwid = _fetch_cw_arg(ClipMachineMemory); C_object *cgc = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2)); C_widget *cpix = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 3)); gint xsrc = _clip_parni(ClipMachineMemory, 4); gint ysrc = _clip_parni(ClipMachineMemory, 5); gint xdest = _clip_parni(ClipMachineMemory, 6); gint ydest = _clip_parni(ClipMachineMemory, 7); gint width = _clip_parni(ClipMachineMemory, 8); gint height = _clip_parni(ClipMachineMemory, 9); GdkDrawable *drw = NULL; CHECKARG2(1, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType); CHECKCWID(cwid, GTK_IS_WIDGET); CHECKARG2(2, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType); CHECKCOBJ(cgc, GDK_IS_GC(cgc)); CHECKARG2(3, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType); CHECKCWID(cpix, GTK_IS_WIDGET); CHECKARG(4, NUMERIC_type_of_ClipVarType); CHECKARG(5, NUMERIC_type_of_ClipVarType); CHECKARG(6, NUMERIC_type_of_ClipVarType); CHECKARG(7, NUMERIC_type_of_ClipVarType); CHECKARG(8, NUMERIC_type_of_ClipVarType); CHECKARG(9, NUMERIC_type_of_ClipVarType); drw = cwid->widget->window; if (GTK_IS_PIXMAP(cwid->widget)) drw = GTK_PIXMAP(cwid->widget)->pixmap; gdk_draw_pixmap(drw, GDK_GC(cgc->object), GTK_PIXMAP(cpix->widget)->pixmap, xsrc, ysrc, xdest, ydest, width, height); return 0; err: return 1; }
/* Draws a number of characters in the given font or fontset. */ int clip_GDK_DRAWTEXT(ClipMachine * ClipMachineMemory) { C_widget *cwid = _fetch_cw_arg(ClipMachineMemory); C_object *cgc = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2)); C_object *font = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 3)); gint x = _clip_parni(ClipMachineMemory, 4); gint y = _clip_parni(ClipMachineMemory, 5); gchar *text = _clip_parc(ClipMachineMemory, 6); gint length = _clip_parni(ClipMachineMemory, 7); GdkDrawable *drw = NULL; CHECKCWID(cwid, GTK_IS_WIDGET); CHECKOPT2(2, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType); CHECKCOBJ(cgc, GDK_IS_GC(cgc)); CHECKOPT2(3, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType); CHECKCOBJ(cgc, GDK_IS_FONT(font)); CHECKOPT(4, NUMERIC_type_of_ClipVarType); CHECKOPT(5, NUMERIC_type_of_ClipVarType); CHECKOPT(6, CHARACTER_type_of_ClipVarType); CHECKOPT(7, NUMERIC_type_of_ClipVarType); drw = cwid->widget->window; if (GTK_IS_PIXMAP(cwid->widget)) drw = GTK_PIXMAP(cwid->widget)->pixmap; LOCALE_TO_UTF(text); gdk_draw_text(drw, GDK_FONT(font->object), GDK_GC(cgc->object), x, y, text, length); FREE_TEXT(text); return 0; err: return 1; }
/* 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; }