Esempio n. 1
0
/**
 * gdk_gl_pixmap_get_pixmap:
 * @glpixmap: a #GdkGLPixmap.
 *
 * Returns the #GdkPixmap associated with @glpixmap.
 *
 * Notice that #GdkGLPixmap is not #GdkPixmap, but another
 * #GdkDrawable which have an associated #GdkPixmap.
 *
 * Return value: the #GdkPixmap associated with @glpixmap.
 **/
GdkPixmap *
gdk_gl_pixmap_get_pixmap (GdkGLPixmap *glpixmap)
{
  g_return_val_if_fail (GDK_IS_GL_PIXMAP (glpixmap), NULL);

  return GDK_PIXMAP (glpixmap->drawable);
}
Esempio n. 2
0
int
clip_GTK_DRAGSETICONPIXMAP(ClipMachine * cm)
{
        C_object  *ccontext = _fetch_co_arg(cm);
	C_object *ccolormap = _fetch_cobject(cm, _clip_spar(cm, 2));
        C_object   *cpixmap = _fetch_cobject(cm, _clip_spar(cm, 3));
        C_object     *cmask = _fetch_cobject(cm, _clip_spar(cm, 4));
        gint          hot_x = _clip_parni(cm, 5);
        gint          hot_y = _clip_parni(cm, 6);

	if (!ccontext || ccontext->type != GDK_TYPE_DRAG_CONTEXT)
        	goto err;
	CHECKCOBJ(ccolormap, GDK_IS_COLORMAP(ccolormap->object));
	CHECKCOBJ(cpixmap, GDK_IS_PIXMAP(cpixmap->object));
	CHECKCOBJ(cmask, GDK_IS_BITMAP(cmask));
	CHECKARG(5, NUMERIC_t);
	CHECKARG(6, NUMERIC_t);

        gtk_drag_set_icon_pixmap((GdkDragContext*)ccontext->object,
        	GDK_COLORMAP(ccolormap->object),
                GDK_PIXMAP(cpixmap->object),
                GDK_BITMAP(cmask->object),
        	hot_x, hot_y );

	return 0;
err:
	return 1;
}
gboolean expose_event_top_right(GtkWidget *widget,GdkEventExpose *event, gpointer user){

	static GdkGC		*this_gc = NULL;
	TimeLinePrivate		*priv;
	gint				new_cursor_pos;
	gint 				width;
	gint				height;
	priv = (TimeLinePrivate *)user;

	if(priv->top_right_evb->window == NULL || priv->display_buffer_top_right == NULL){

				return TRUE;
	}
	if (NULL == this_gc)
	{
		this_gc = gdk_gc_new(GDK_DRAWABLE(priv->top_right_evb->window));
	}
	width = ((get_current_slide_duration() +1)  * time_line_get_pixels_per_second());
	height = (get_current_slide_num_layers() *priv->row_height)+10;
	if(width<priv->main_table->allocation.width)
		 width = priv->main_table->allocation.width;
	if(height<priv->main_table->allocation.height)
			 height = priv->main_table->allocation.height;
	new_cursor_pos = round(time_line_get_cursor_position(priv->main_table->parent) * time_line_get_pixels_per_second());
	time_line_internal_draw_cursor(priv->main_table->parent, new_cursor_pos);

	gdk_draw_drawable(GDK_DRAWABLE(priv->top_right_evb->window), GDK_GC(this_gc),
	GDK_PIXMAP(priv->display_buffer_top_right),0,0,0,0,width, priv->top_border_height);

	return TRUE;
}
Esempio n. 4
0
static VALUE
rg_m_set_icon(int argc, VALUE *argv, VALUE self)
{
    VALUE context, obj, pixmap = Qnil, mask = Qnil, hot_x, hot_y;

    if (argc == 6) {
        rb_scan_args(argc, argv, "60", &context, &obj, &pixmap, &mask, &hot_x, &hot_y);
        gtk_drag_set_icon_pixmap(RVAL2DC(context),
                                 GDK_COLORMAP(RVAL2GOBJ(obj)), 
                                 GDK_PIXMAP(RVAL2GOBJ(pixmap)),
                                 GDK_BITMAP(RVAL2GOBJ(mask)), 
                                 NUM2INT(hot_x), NUM2INT(hot_y));
    } else {
        rb_scan_args(argc, argv, "40", &context, &obj, &hot_x, &hot_y);

        if (TYPE(obj) == T_SYMBOL){
            gtk_drag_set_icon_stock(RVAL2DC(context), rb_id2name(SYM2ID(obj)),
                                    NUM2INT(hot_x), NUM2INT(hot_y));
        } else if (rb_obj_is_kind_of(obj, GTYPE2CLASS(GTK_TYPE_WIDGET))){
            gtk_drag_set_icon_widget(RVAL2DC(context), RVAL2WIDGET(obj),
                                     NUM2INT(hot_x), NUM2INT(hot_y));
        } else if (rb_obj_is_kind_of(obj, GTYPE2CLASS(GDK_TYPE_PIXBUF))){
            gtk_drag_set_icon_pixbuf(RVAL2DC(context),
                                     GDK_PIXBUF(RVAL2GOBJ(obj)),
                                     NUM2INT(hot_x), NUM2INT(hot_y));
        } else {
            rb_raise(rb_eArgError, "invalid argument %s", rb_class2name(CLASS_OF(obj)));
        }
    }
    return self;
}
Esempio n. 5
0
static VALUE
gdkwin_set_icon(VALUE self, VALUE icon, VALUE pixmap, VALUE mask)
{
    gdk_window_set_icon(_SELF(self), NIL_P(icon) ? NULL :_SELF(icon),
                        NIL_P(pixmap) ? NULL : GDK_PIXMAP(RVAL2GOBJ(pixmap)),
                        NIL_P(mask) ? NULL : GDK_BITMAP(RVAL2GOBJ(mask)));
    return self;
}
Esempio n. 6
0
static VALUE
gdkwin_set_back_pixmap(VALUE self, VALUE pixmap, VALUE parent_relative)
{
    gdk_window_set_back_pixmap(_SELF(self), 
                               GDK_PIXMAP(RVAL2GOBJ(pixmap)),
                               RVAL2CBOOL(parent_relative));
    return self;
}
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;
}
Esempio n. 8
0
static VALUE
rg_m_source_set_icon(int argc, VALUE *argv, VALUE self)
{
    VALUE widget, obj, pixmap = Qnil, mask = Qnil;

    rb_scan_args(argc, argv, "22", &widget, &obj, &pixmap, &mask);
    if (argc == 4){
        gtk_drag_source_set_icon(RVAL2WIDGET(widget), GDK_COLORMAP(RVAL2GOBJ(obj)),
                                 GDK_PIXMAP(RVAL2GOBJ(pixmap)), 
                                 GDK_BITMAP(RVAL2GOBJ(mask)));
    } else if (argc == 2){
        if (TYPE(obj) == T_SYMBOL){
            gtk_drag_source_set_icon_stock(RVAL2WIDGET(widget), rb_id2name(SYM2ID(obj)));
        } else {
            gtk_drag_source_set_icon_pixbuf(RVAL2WIDGET(widget), GDK_PIXBUF(RVAL2GOBJ(obj)));
        }
    } else {
        rb_raise(rb_eArgError, "need 2 or 4 arguments");
    }
    return self;
}
Esempio n. 9
0
int
clip_GTK_DRAGSOURCESETICON(ClipMachine * cm)
{
        C_widget      *cwid = _fetch_cw_arg(cm);
	C_object *ccolormap = _fetch_cobject(cm, _clip_spar(cm, 2));
        C_object   *cpixmap = _fetch_cobject(cm, _clip_spar(cm, 3));
        C_object     *cmask = _fetch_cobject(cm, _clip_spar(cm, 4));

	CHECKCWID(cwid, GTK_IS_WIDGET);
	CHECKCOBJ(ccolormap, GDK_IS_COLORMAP(ccolormap->object));
	CHECKCOBJ(cpixmap, GDK_IS_PIXMAP(cpixmap->object));
	CHECKCOBJ(cmask, GDK_IS_BITMAP(cmask));

        gtk_drag_source_set_icon(GTK_WIDGET(cwid->widget),
        	GDK_COLORMAP(ccolormap->object),
                GDK_PIXMAP(cpixmap->object),
                GDK_BITMAP(cmask->object));

	return 0;
err:
	return 1;
}
Esempio n. 10
0
int
clip_GTK_DRAGSETDEFAULTICON(ClipMachine * cm)
{
        C_object *ccolormap = _fetch_co_arg(cm);
        C_object   *cpixmap = _fetch_cobject(cm, _clip_spar(cm, 2));
        C_object     *cmask = _fetch_cobject(cm, _clip_spar(cm, 3));
        gint          hot_x = _clip_parni(cm, 4);
        gint          hot_y = _clip_parni(cm, 5);

	CHECKCOBJ(ccolormap, GDK_IS_COLORMAP(ccolormap->object));
	CHECKCOBJ(cpixmap, GDK_IS_PIXMAP(cpixmap->object));
	CHECKCOBJ(cmask, GDK_IS_PIXMAP(cmask));
	CHECKARG(5, NUMERIC_t);
	CHECKARG(4, NUMERIC_t);

        gtk_drag_set_default_icon(GDK_COLORMAP(ccolormap->object),
                GDK_PIXMAP(cpixmap->object),
                GDK_BITMAP(cmask->object),
        	hot_x, hot_y );

	return 0;
err:
	return 1;
}
Esempio n. 11
0
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;
}
Esempio n. 12
0
static VALUE
rg_set_tile(VALUE self, VALUE tile)
{
    gdk_gc_set_tile(_SELF(self), GDK_PIXMAP(RVAL2GOBJ(tile)));
    return self;
}
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;
}