/* 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; }
/* 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; }
/* 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; }
/* 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 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 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 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; }
/* 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; }
static VALUE rg_draw_pixbuf(VALUE self, VALUE gc, VALUE pixbuf, VALUE src_x, VALUE src_y, VALUE dest_x, VALUE dest_y, VALUE width, VALUE height, VALUE dither, VALUE x_dither, VALUE y_dither) { gdk_draw_pixbuf(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), GDK_PIXBUF(RVAL2GOBJ(pixbuf)), NUM2INT(src_x), NUM2INT(src_y), NUM2INT(dest_x), NUM2INT(dest_y), NUM2INT(width), NUM2INT(height), RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), NUM2INT(x_dither), NUM2INT(y_dither)); return self; }
static VALUE rg_draw_points(VALUE self, VALUE rbgc, VALUE rbpoints) { GdkDrawable *drawable = _SELF(self); GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc)); long n; GdkPoint *points = RVAL2GDKPOINTS(rbpoints, &n); gdk_draw_points(drawable, gc, points, n); g_free(points); return self; }
static VALUE rg_draw_segments(VALUE self, VALUE rbgc, VALUE rbsegments) { GdkDrawable *drawable = _SELF(self); GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc)); long n; GdkSegment *segments = RVAL2GDKSEGMENTS(rbsegments, &n); gdk_draw_segments(drawable, gc, segments, n); g_free(segments); return self; }
static VALUE rg_draw_trapezoids(VALUE self, VALUE rbgc, VALUE rbtrapezoids) { GdkDrawable *drawable = _SELF(self); GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc)); long n; GdkTrapezoid *trapezoids = RVAL2GDKTRAPEZOIDS(rbtrapezoids, &n); gdk_draw_trapezoids(drawable, gc, trapezoids, n); g_free(trapezoids); return self; }
static VALUE rg_draw_layout(int argc, VALUE *argv, VALUE self) { VALUE gc, x, y, layout, fg, bg; rb_scan_args(argc, argv, "42", &gc, &x, &y, &layout, &fg, &bg); gdk_draw_layout_with_colors(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), NUM2INT(x), NUM2INT(y), PANGO_LAYOUT(RVAL2GOBJ(layout)), RVAL2GDKCOLOR(fg), RVAL2GDKCOLOR(bg)); return self; }
GdkGC* _gdk_directfb_gc_new (GdkDrawable *drawable, GdkGCValues *values, GdkGCValuesMask values_mask) { GdkGC *gc; GdkGCDirectFB *private; g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_DIRECTFB (drawable), NULL); gc = GDK_GC (g_object_new (gdk_gc_directfb_get_type (), NULL)); _gdk_gc_init (gc, drawable, values, values_mask); private = GDK_GC_DIRECTFB (gc);
static VALUE rg_draw_layout_line(int argc, VALUE *argv, VALUE self) { VALUE gc, x, y, line, fg, bg; rb_scan_args(argc, argv, "42", &gc, &x, &y, &line, &fg, &bg); gdk_draw_layout_line_with_colors(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), NUM2INT(x), NUM2INT(y), (PangoLayoutLine*)RVAL2BOXED(line, PANGO_TYPE_LAYOUT_LINE), RVAL2GDKCOLOR(fg), RVAL2GDKCOLOR(bg)); return self; }
static VALUE rg_draw_polygon(VALUE self, VALUE rbgc, VALUE rbfilled, VALUE rbpoints) { GdkDrawable *drawable = _SELF(self); GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc)); gboolean filled = RVAL2CBOOL(rbfilled); long n; GdkPoint *points = RVAL2GDKPOINTS(rbpoints, &n); gdk_draw_polygon(drawable, gc, filled, points, n); g_free(points); return self; }
/* 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 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; }
/* 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; }
static void gdk_gc_directfb_finalize (GObject *object) { GdkGC *gc = GDK_GC (object); GdkGCDirectFB *private = GDK_GC_DIRECTFB (gc); if (private->clip_region.numRects) temp_region_deinit (&private->clip_region); if (private->values.clip_mask) g_object_unref (private->values.clip_mask); if (private->values.stipple) g_object_unref (private->values.stipple); if (private->values.tile) g_object_unref (private->values.tile); if (G_OBJECT_CLASS (parent_class)->finalize) G_OBJECT_CLASS (parent_class)->finalize (object); }
/* 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; }
gboolean expose_event_top_left(GtkWidget *widget,GdkEventExpose *event, gpointer user){ static GdkGC *this_gc = NULL; TimeLinePrivate *priv; priv = (TimeLinePrivate *)user; if(priv->top_left_evb->window == NULL || priv->display_buffer_top_left == NULL){ } if (NULL == this_gc) { this_gc = gdk_gc_new(GDK_DRAWABLE(priv->top_left_evb->window)); } gdk_draw_drawable(GDK_DRAWABLE(priv->top_left_evb->window), GDK_GC(this_gc), GDK_PIXMAP(priv->display_buffer_top_left),0, 0, 0, 0,priv->left_border_width, priv->top_border_height); //gtk_widget_modify_bg(GTK_WIDGET(priv->top_left_evb),GTK_STATE_NORMAL,&entireRowColor); return TRUE; }
static VALUE pixbuf_render_to_drawable(int argc, VALUE *argv, VALUE self) { VALUE gc, src_x, src_y, dest_x, dest_y, width, height, dither, x_dither, y_dither; #if GTK_CHECK_VERSION(2,2,0) rb_warn("Gdk::Pixbuf#render_to_drawable is obsolete. Use Gdk::Drawable#draw_pixbuf instead."); #endif rb_scan_args(argc, argv, "73", &gc, &src_x, &src_y, &dest_x, &dest_y, &width, &height, &dither, &x_dither, &y_dither); if (NIL_P(gc)) rb_raise(rb_eArgError, "arguments 1 must be non nil"); if (NIL_P(src_x)) rb_raise(rb_eArgError, "arguments 2 must be non nil"); if (NIL_P(src_y)) rb_raise(rb_eArgError, "arguments 3 must be non nil"); if (NIL_P(dest_x)) rb_raise(rb_eArgError, "arguments 4 must be non nil"); if (NIL_P(dest_y)) rb_raise(rb_eArgError, "arguments 5 must be non nil"); if (NIL_P(width)) rb_raise(rb_eArgError, "arguments 6 must be non nil"); if (NIL_P(height)) rb_raise(rb_eArgError, "arguments 7 must be non nil"); gdk_pixbuf_render_to_drawable(_SELF(self), GDK_DRAWABLE(RVAL2GOBJ(self)), GDK_GC(RVAL2GOBJ(gc)), NUM2INT(src_x), NUM2INT(src_y), NUM2INT(dest_x), NUM2INT(dest_y), NUM2INT(width), NUM2INT(height), NIL_P(dither) ? GDK_RGB_DITHER_NONE : RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), NIL_P(x_dither) ? 0 : NUM2INT(x_dither), NIL_P(y_dither) ? 0 : NUM2INT(y_dither)); return self; }
/* 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; }
static VALUE style_set_white_gc(VALUE self, VALUE gc) { _SELF(self)->white_gc = GDK_GC(RVAL2GOBJ(gc)); return self; }
/* 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 int pygtk_style_helper_setitem(PyGtkStyleHelper_Object *self, Py_ssize_t pos, PyObject *value) { extern PyTypeObject PyGdkGC_Type; extern PyTypeObject PyGdkPixmap_Type; if (pos < 0) pos += NUM_STATES; if (pos < 0 || pos >= NUM_STATES) { PyErr_SetString(PyExc_IndexError, "index out of range"); return -1; } switch (self->type) { case STYLE_COLOUR_ARRAY: { GdkColor *array = (GdkColor *)self->array; if (!pyg_boxed_check(value, GDK_TYPE_COLOR)) { PyErr_SetString(PyExc_TypeError, "can only assign a GdkColor"); return -1; } array[pos] = *pyg_boxed_get(value, GdkColor); return 0; } case STYLE_GC_ARRAY: { GdkGC **array = (GdkGC **)self->array; if (!pygobject_check(value, &PyGdkGC_Type)) { PyErr_SetString(PyExc_TypeError, "can only assign a GdkGC"); return -1; } if (array[pos]) { g_object_unref(array[pos]); } array[pos] = GDK_GC(g_object_ref(pygobject_get(value))); return 0; } case STYLE_PIXMAP_ARRAY: { GdkPixmap **array = (GdkPixmap **)self->array; GdkPixmap *cvalue = NULL; if (pygobject_check(value, &PyGdkPixmap_Type)) cvalue = GDK_PIXMAP(g_object_ref(pygobject_get(value))); else if (PyLong_Check(value)) { if (PyLong_AsLong(value) != GDK_PARENT_RELATIVE) { PyErr_SetString(PyExc_TypeError, "can only assign a GdkPixmap, None or " "GDK_PARENT_RELATIVE"); return -1; } cvalue = (GdkPixmap*)GDK_PARENT_RELATIVE; } else if (value != Py_None) { PyErr_SetString(PyExc_TypeError, "can only assign a GdkPixmap, None or " "GDK_PARENT_RELATIVE"); return -1; } if (array[pos] && (long)array[pos] != GDK_PARENT_RELATIVE) { g_object_unref(array[pos]); } array[pos] = cvalue; return 0; } } g_assert_not_reached(); return -1; }
gboolean time_line_internal_draw_layer_duration(TimeLinePrivate *priv, gint layer_number) { // Local variables const GdkColor colour_black = {0, 0, 0, 0 }; const GdkColor colour_fade = {0, (160 << 8), (160 << 8), (190 << 8) }; const GdkColor colour_fully_visible = {0, (200 << 8), (200 << 8), (230 << 8) }; static GdkColormap *colourmap = NULL; // Colormap used for drawing static GdkGC *display_buffer_gc = NULL; gint layer_height; layer *layer_data; GList *layer_pointer; // Points to the layers in the selected slide gint layer_width; gint layer_x; gint layer_y; gint left_border; // Initialisation if (NULL == colourmap) { colourmap = gdk_colormap_get_system(); gdk_drawable_set_colormap(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_COLORMAP(colourmap)); } if (NULL == display_buffer_gc) { display_buffer_gc = gdk_gc_new(GDK_DRAWABLE(priv->display_buffer_bot_right)); } left_border = 0;// time_line_get_left_border_width(priv); // Select the layer we're working with layer_pointer = get_current_slide_layers_pointer(); layer_pointer = g_list_first(layer_pointer); layer_data = g_list_nth_data(layer_pointer, layer_number); // Set the height related variables layer_y = (layer_number * priv->row_height) + 2; layer_height = priv->row_height - 3; // Check if there's a fade in transition for this layer if (TRANS_LAYER_FADE == layer_data->transition_in_type) { // Draw the fade in layer_x = left_border + (layer_data->start_time * time_line_get_pixels_per_second()) + 1; layer_width = (layer_data->transition_in_duration * time_line_get_pixels_per_second()); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_fade); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), TRUE, layer_x, layer_y, layer_width, layer_height); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), FALSE, layer_x, layer_y, layer_width, layer_height - 1); // Draw the fully visible duration layer_x = left_border + ((layer_data->start_time + layer_data->transition_in_duration) * time_line_get_pixels_per_second()) + 1; layer_width = (layer_data->duration * time_line_get_pixels_per_second()); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_fully_visible); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), TRUE, layer_x, layer_y, layer_width, layer_height); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), FALSE, layer_x - 1, layer_y, layer_width, layer_height -1); } else { // There's no fade in transition for this layer layer_x = left_border + (layer_data->start_time * time_line_get_pixels_per_second()) + 1; layer_width = (layer_data->duration * time_line_get_pixels_per_second()); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_fully_visible); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), TRUE, layer_x, layer_y, layer_width, layer_height); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), FALSE, layer_x, layer_y, layer_width - 1, layer_height - 1); } // Check if there's a fade out transition for this layer if (TRANS_LAYER_FADE == layer_data->transition_out_type) { // Draw the fade out layer_x += (layer_data->duration * time_line_get_pixels_per_second()); layer_width = (layer_data->transition_out_duration * time_line_get_pixels_per_second()); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_fade); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), TRUE, layer_x, layer_y, layer_width, layer_height); gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black); gdk_draw_rectangle(GDK_DRAWABLE(priv->display_buffer_bot_right), GDK_GC(display_buffer_gc), FALSE, layer_x - 1, layer_y, layer_width, layer_height - 1); } return TRUE; }
gboolean working_area_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) { // Local variables gint box_height; // Height of the bounding box gint box_width; // Width of the bounding box GList *collision_list = NULL; guint count_int; gint finish_x; // X position at the layer objects finish time gint finish_y; // Y position at the layer objects finish time GList *layer_pointer; GString *message; // Used to construct message strings guint num_collisions; gint onscreen_bottom; // Y coordinate of bounding box bottom gint onscreen_left; // X coordinate of bounding box left gint onscreen_right; // X coordinate of bounding box right gint onscreen_top; // Y coordinate of bounding box top gint pixmap_height; // Height of the front store gint pixmap_width; // Width of the front store gfloat scaled_height_ratio; // Used to calculate a vertical scaling ratio gfloat scaled_width_ratio; // Used to calculate a horizontal scaling ratio gint selected_row; // Holds the number of the row that is selected gint start_x; // X position at the layer objects start time gint start_y; // Y position at the layer objects start time layer *this_layer_data; // Pointer to the data for the selected layer slide *this_slide_data; // Alias to make things easier guint tmp_int; // Temporary integer // Only do this function if we have a front store available and a project loaded if ((NULL == get_front_store()) || (FALSE == get_project_active())) { return TRUE; } // Set the delete key focus to be layers set_delete_focus(FOCUS_LAYER); // Change the focus of the window to be this widget gtk_widget_grab_focus(GTK_WIDGET(widget)); // Initialise some things this_slide_data = get_current_slide_data(); gdk_drawable_get_size(GDK_PIXMAP(get_front_store()), &pixmap_width, &pixmap_height); // Check for primary mouse button click if (1 != event->button) { // Not a primary mouse click, so return return TRUE; } // Reset the mouse drag toggle set_mouse_dragging(FALSE); // Check if this was a double mouse click. If it was, open an edit dialog if (GDK_2BUTTON_PRESS == event->type) { // Open an edit dialog layer_edit(); return TRUE; } // Check if this was a triple mouse click. If it was, ignore it if (GDK_3BUTTON_PRESS == event->type) { return TRUE; } // If we're presently creating a new highlight layer, store the mouse coordinates if (TYPE_HIGHLIGHT == get_new_layer_selected()) { // Save the mouse coordinates set_stored_x(event->x); set_stored_y(event->y); // Reset the invalidation area set_invalidation_end_x(event->x); set_invalidation_end_y(event->y); set_invalidation_start_x(event->x - 1); set_invalidation_start_y(event->y - 1); return TRUE; } // If the user has clicked on the start or end points for the selected layer, we // don't want to do the collision detection below that changes layers if (END_POINTS_INACTIVE == get_end_point_status()) { // * Check if the user is clicking on the layer start or end points * // Calculate the height and width scaling values for the main drawing area at its present size scaled_height_ratio = (gfloat) get_project_height() / (gfloat) pixmap_height; scaled_width_ratio = (gfloat) get_project_width() / (gfloat) pixmap_width; // Determine which row is selected in the time line selected_row = time_line_get_selected_layer_num(this_slide_data->timeline_widget); layer_pointer = g_list_first(this_slide_data->layers); this_layer_data = g_list_nth_data(layer_pointer, selected_row); // If the layer data isn't accessible, then don't run this function if (NULL == this_layer_data) { return TRUE; } // Calculate start and end points finish_x = (this_layer_data->x_offset_finish / scaled_width_ratio) + END_POINT_HORIZONTAL_OFFSET; finish_y = (this_layer_data->y_offset_finish / scaled_height_ratio) + END_POINT_VERTICAL_OFFSET; start_x = (this_layer_data->x_offset_start / scaled_width_ratio) + END_POINT_HORIZONTAL_OFFSET; start_y = (this_layer_data->y_offset_start / scaled_height_ratio) + END_POINT_VERTICAL_OFFSET; // Is the user clicking on an end point? if (((event->x >= start_x) // Start point && (event->x <= start_x + END_POINT_WIDTH) && (event->y >= start_y) && (event->y <= start_y + END_POINT_HEIGHT)) || ((event->x >= finish_x) // End point && (event->x <= finish_x + END_POINT_WIDTH) && (event->y >= finish_y) && (event->y <= finish_y + END_POINT_HEIGHT))) { // Retrieve the layer size information switch (this_layer_data->object_type) { case TYPE_EMPTY: // We can't drag an empty layer, so reset things and return set_mouse_dragging(FALSE); set_end_point_status(END_POINTS_INACTIVE); set_stored_x(-1); set_stored_y(-1); return TRUE; case TYPE_HIGHLIGHT: box_width = ((layer_highlight *) this_layer_data->object_data)->width; box_height = ((layer_highlight *) this_layer_data->object_data)->height; break; case TYPE_GDK_PIXBUF: // If this is the background layer, then we ignore it if (TRUE == this_layer_data->background) { set_mouse_dragging(FALSE); set_end_point_status(END_POINTS_INACTIVE); set_stored_x(-1); set_stored_y(-1); return TRUE; } // No it's not, so process it box_width = ((layer_image *) this_layer_data->object_data)->width; box_height = ((layer_image *) this_layer_data->object_data)->height; break; case TYPE_MOUSE_CURSOR: box_width = ((layer_mouse *) this_layer_data->object_data)->width; box_height = ((layer_mouse *) this_layer_data->object_data)->height; break; case TYPE_TEXT: box_width = ((layer_text *) this_layer_data->object_data)->rendered_width; box_height = ((layer_text *) this_layer_data->object_data)->rendered_height; break; default: message = g_string_new(NULL); g_string_printf(message, "%s ED377: %s", _("Error"), _("Unknown layer type.")); display_warning(message->str); g_string_free(message, TRUE); return TRUE; // Unknown layer type, so no idea how to extract the needed data for the next code } // Work out the bounding box boundaries (scaled) if ((event->x >= start_x) // Left && (event->x <= start_x + END_POINT_WIDTH) // Right && (event->y >= start_y) // Top && (event->y <= start_y + END_POINT_HEIGHT)) // Bottom { // Start point clicked onscreen_left = this_layer_data->x_offset_start / scaled_width_ratio; onscreen_top = this_layer_data->y_offset_start / scaled_width_ratio;; onscreen_right = (this_layer_data->x_offset_start + box_width) / scaled_height_ratio; onscreen_bottom = (this_layer_data->y_offset_start + box_height) / scaled_height_ratio; } else { // End point clicked onscreen_left = this_layer_data->x_offset_finish / scaled_width_ratio; onscreen_top = this_layer_data->y_offset_finish / scaled_width_ratio;; onscreen_right = (this_layer_data->x_offset_finish + box_width) / scaled_height_ratio; onscreen_bottom = (this_layer_data->y_offset_finish + box_height) / scaled_height_ratio; } // Ensure the bounding box doesn't go out of bounds onscreen_left = CLAMP(onscreen_left, 2, pixmap_width - 2); onscreen_top = CLAMP(onscreen_top, 2, pixmap_height - 2); onscreen_right = CLAMP(onscreen_right, 2, pixmap_width - 2); onscreen_bottom = CLAMP(onscreen_bottom, 2, pixmap_height - 2); // Draw a bounding box onscreen draw_bounding_box(onscreen_left, onscreen_top, onscreen_right, onscreen_bottom); // End point clicked, so we return in order to avoid the collision detection return TRUE; } } // * Do collision detection here to determine if the user has clicked on a layer's object * this_slide_data = get_current_slide_data(); calculate_object_boundaries(); collision_list = detect_collisions(collision_list, event->x, event->y); if (NULL == collision_list) { // If there was no collision, then select the background layer time_line_set_selected_layer_num(this_slide_data->timeline_widget, this_slide_data->num_layers - 1); // *Needs* the -1, don't remove // Clear any existing handle box gdk_draw_drawable(GDK_DRAWABLE(get_main_drawing_area()->window), GDK_GC(get_main_drawing_area()->style->fg_gc[GTK_WIDGET_STATE(get_main_drawing_area())]), GDK_PIXMAP(get_front_store()), 0, 0, 0, 0, -1, -1); // Reset the stored mouse coordinates set_stored_x(-1); set_stored_y(-1); // Free the memory allocated during the collision detection g_list_free(collision_list); collision_list = NULL; return TRUE; } // * To get here there must have been at least one collision * // Save the mouse coordinates set_stored_x(event->x); set_stored_y(event->y); // Determine which layer the user has selected in the timeline selected_row = time_line_get_selected_layer_num(this_slide_data->timeline_widget); // Is the presently selected layer in the collision list? collision_list = g_list_first(collision_list); num_collisions = g_list_length(collision_list); for (count_int = 0; count_int < num_collisions; count_int++) { collision_list = g_list_first(collision_list); collision_list = g_list_nth(collision_list, count_int); layer_pointer = g_list_first(this_slide_data->layers); tmp_int = g_list_position(layer_pointer, ((boundary_box *) collision_list->data)->layer_ptr); if (tmp_int == selected_row) { // Return if the presently selected row is in the collision list, as we don't want to change our selected layer return TRUE; } } // * To get here, the presently selected layer wasn't in the collision list * // The presently selected row is not in the collision list, so move the selection row to the first collision collision_list = g_list_first(collision_list); selected_row = g_list_position(this_slide_data->layers, ((boundary_box *) collision_list->data)->layer_ptr); time_line_set_selected_layer_num(this_slide_data->timeline_widget, selected_row); // Draw a handle box around the new selected object draw_handle_box(); // Free the memory allocated during the collision detection g_list_free(collision_list); collision_list = NULL; return TRUE; }