Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
/**
 * gdk_gl_window_new:
 * @glconfig: a #GdkGLConfig.
 * @window: the #GdkWindow to be used as the rendering area.
 * @attrib_list: (array) (allow-none): this must be set to NULL or empty (first attribute of None).
 *
 * Creates an on-screen rendering area.
 * attrib_list is currently unused. This must be set to NULL or empty
 * (first attribute of None). See GLX 1.3 spec.
 *
 * Return value: the new #GdkGLWindow.
 **/
GdkGLWindow *
gdk_gl_window_new (GdkGLConfig *glconfig, GdkWindow *window, const int *attrib_list)
{
  GDK_GL_NOTE_FUNC ();

  g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), NULL);
  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);

  /*
   * Get X Window.
   */

  Window glxwindow = GDK_DRAWABLE_XID (GDK_DRAWABLE (window));

  /*
   * Instantiate the GdkGLWindowImplX11 object.
   */

  GdkGLWindow *glwindow = g_object_new (GDK_TYPE_GL_WINDOW, NULL);

  glwindow->drawable = GDK_DRAWABLE (window);
  g_object_add_weak_pointer (G_OBJECT (glwindow->drawable), (gpointer *) &(glwindow->drawable));

  glwindow->glxwindow = glxwindow;

  glwindow->glconfig = glconfig;
  g_object_ref (G_OBJECT (glwindow->glconfig));

  glwindow->is_destroyed = FALSE;

  return glwindow;
}
Ejemplo n.º 3
0
GdkPixbuf *
meta_ui_get_pixbuf_from_pixmap (Pixmap   pmap)
{
  GdkPixmap *gpmap;
  GdkScreen *screen;
  GdkPixbuf *pixbuf;
  GdkColormap *cmap;
  int width, height, depth;

  gpmap = gdk_pixmap_foreign_new (pmap);
  screen = gdk_drawable_get_screen (gpmap);

  gdk_drawable_get_size (GDK_DRAWABLE (gpmap), &width, &height);
  
  depth = gdk_drawable_get_depth (GDK_DRAWABLE (gpmap));
  if (depth <= 24)
    cmap = gdk_screen_get_rgb_colormap (screen);
  else
    cmap = gdk_screen_get_rgba_colormap (screen);
  
  pixbuf = gdk_pixbuf_get_from_drawable (NULL, gpmap, cmap, 0, 0, 0, 0,
                                         width, height);

  g_object_unref (gpmap);

  return pixbuf;
}
Ejemplo n.º 4
0
void WebBrowserObject::BrowserSnapshot(const char *fname)
{
    int width, height;
    char *c, *buf = 0;
    GdkColormap *cmap = gdk_colormap_get_system();
    gdk_drawable_get_size(GDK_DRAWABLE(mozilla->window), &width, &height);
    GdkPixbuf *pix = gdk_pixbuf_get_from_drawable(0, GDK_DRAWABLE(mozilla->window), cmap, 0, 0, 0, 0, width, height);
    if (pix) {
       if (!fname) {
           buf = strdup(location ? location : "lmboxweb");
           buf = (char*)realloc(buf, strlen(buf) + 16);
           fname = buf;
           if ((c = strrchr(buf, '/'))) {
               //fname = c + 1;
           }
           if ((c = strrchr(fname, '.'))) {
               *c = 0;
           }
           strcat((char*)fname, ".png");
       }
       gdk_pixbuf_save (pix, fname, "png", NULL, NULL);
       gdk_pixbuf_unref(pix);
       printf("Webbrowser snapshot %s\n",fname);
    }
    gdk_colormap_unref(cmap);
    lmbox_free(buf);
}
Ejemplo n.º 5
0
static gboolean
expose_callback (GtkWidget      *event_box,
                 GdkEventButton *,
                 TSignalData    *sigdata)
{
    cairo_t *cr;
    if (sigdata->event_box != NULL)
        cr = gdk_cairo_create (GDK_DRAWABLE (sigdata->event_box->window));
    else
    {
        cr = gdk_cairo_create (GDK_DRAWABLE (event_box->window));
        sigdata->event_box = event_box;
    }


    if (sigdata->image != NULL)
    {
        GdkPixbuf *pxbf = gtk_image_get_pixbuf(GTK_IMAGE(sigdata->image));

        gdk_cairo_set_source_pixbuf (cr, pxbf, 0,0);

        cairo_paint (cr);

        draw_grid(cr, sigdata->idata);
    }


    return TRUE;
}
Ejemplo n.º 6
0
static void
gdk_wmspec_change_state (gboolean add,
			 GdkWindow *window,
			 GdkAtom state1,
			 GdkAtom state2)
{
  GdkDisplay *display = 
    gdk_screen_get_display (gdk_drawable_get_screen (GDK_DRAWABLE (window)));
  XEvent xev;
  
#define _NET_WM_STATE_REMOVE        0    /* remove/unset property */
#define _NET_WM_STATE_ADD           1    /* add/set property */
#define _NET_WM_STATE_TOGGLE        2    /* toggle property  */  
  
  xev.xclient.type = ClientMessage;
  xev.xclient.serial = 0;
  xev.xclient.send_event = True;
  xev.xclient.window = GDK_WINDOW_XID (window);
  xev.xclient.message_type = 
    gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE");
  xev.xclient.format = 32;
  xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
  xev.xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);
  xev.xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);
  
  XSendEvent (GDK_WINDOW_XDISPLAY (window),
	      GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (gdk_drawable_get_screen (GDK_DRAWABLE (window)))),
	      False, SubstructureRedirectMask | SubstructureNotifyMask,
	      &xev);
}
Ejemplo n.º 7
0
gboolean
xfwmPixmapRenderGdkPixbuf (xfwmPixmap * pm, GdkPixbuf *pixbuf)
{
    GdkPixbuf *src;
    GdkPixmap *destw;
    GdkVisual *gvisual;
    GdkColormap *cmap;
    gint width, height;
    gint dest_x, dest_y;

    g_return_val_if_fail (pm != NULL, FALSE);
    g_return_val_if_fail (pm->pixmap != None, FALSE);
    g_return_val_if_fail (pm->mask != None, FALSE);

    destw = gdk_xid_table_lookup (pm->pixmap);
    if (destw)
    {
        g_object_ref (G_OBJECT (destw));
    }
    else
    {
        destw = gdk_pixmap_foreign_new (pm->pixmap);
    }

    if (!destw)
    {
        g_warning ("Cannot get pixmap");
        return FALSE;
    }

    gvisual = gdk_screen_get_system_visual (pm->screen_info->gscr);
    cmap = gdk_x11_colormap_foreign_new (gvisual, pm->screen_info->cmap);

    if (!cmap)
    {
        g_warning ("Cannot create colormap");
        g_object_unref (destw);
        return FALSE;
    }

    width = MIN (gdk_pixbuf_get_width (pixbuf), pm->width);
    height = MIN (gdk_pixbuf_get_height (pixbuf), pm->height);

    /* Add 1 for rounding */
    dest_x = (pm->width - width + 1) / 2;
    dest_y = (pm->height - height + 1) / 2;

    src = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE (destw), cmap,
                                       dest_x, dest_y, 0, 0, width, height);
    gdk_pixbuf_composite (pixbuf, src, 0, 0, width, height,
                          0, 0, 1.0, 1.0, GDK_INTERP_NEAREST, 0xFF);
    gdk_draw_pixbuf (GDK_DRAWABLE (destw), NULL, src, 0, 0, dest_x, dest_y,
                     width, height, GDK_RGB_DITHER_NONE, 0, 0);

    g_object_unref (cmap);
    g_object_unref (src);
    g_object_unref (destw);

    return TRUE;
}
Ejemplo n.º 8
0
void SetUpStatusBarStuff (GtkWidget* aWindow)
{
	_String			   fName = baseDirectory & "GTKResources/striped.xpm";
	statusBarLayout			 = pango_layout_new (screenPContext);
	statusBarFontDesc		 = pango_font_description_new ();
	stripedFill				 = gdk_pixmap_create_from_xpm (GDK_DRAWABLE(aWindow->window), NULL, NULL, fName.sData);
	stripedFillGC			 = gdk_gc_new (GDK_DRAWABLE(aWindow->window));
	if (stripedFill)
	{
		gdk_gc_set_fill (stripedFillGC,GDK_TILED);
		gdk_gc_set_tile	(stripedFillGC,stripedFill);
	}
	else
	{
		printf ("Failed to load a status bar .xpm from %s\n", fName.sData);
	}
	
	gdk_gc_set_line_attributes		  (stripedFillGC, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
	GdkColor saveFG = {0,0,0,0};
	gdk_gc_set_foreground			  (stripedFillGC, &saveFG);

	pango_font_description_set_family (statusBarFontDesc, statusBarFont.face.sData);
	pango_font_description_set_style  (statusBarFontDesc, (statusBarFont.style & HY_FONT_ITALIC) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
	pango_font_description_set_weight (statusBarFontDesc, (statusBarFont.style & HY_FONT_BOLD) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
	pango_font_description_set_size   (statusBarFontDesc, statusBarFont.size*PANGO_SCALE);
	pango_layout_set_font_description (statusBarLayout, statusBarFontDesc ); // ref ?
	pango_layout_set_width			  (statusBarLayout, -1);
	
	redButtonIcon = (GdkPixbuf*)ProcureIconResource(4000);
	yellowButtonIcon = (GdkPixbuf*)ProcureIconResource(4001);
	greenButtonIcon = (GdkPixbuf*)ProcureIconResource(4002);
	orangeButtonIcon = (GdkPixbuf*)ProcureIconResource(4003);
	
}
gboolean time_line_internal_draw_layer_name(TimeLinePrivate *priv, gint layer_number)
{
	// Local variables
	const GdkColor		colour_black = {0, 0, 0, 0 };
	static GdkColormap	*colourmap = NULL;			// Colourmap used for drawing
	static GdkGC		*display_buffer_gc = NULL;
	static PangoContext *font_context = NULL;
	static PangoFontDescription  *font_description = NULL;
	static PangoLayout	*font_layout = NULL;
	layer				*layer_data;
	GList				*layer_pointer;				// Points to the layers in the selected slide
	GString *message = NULL;

	message  = g_string_new(NULL);

	// Initialisation
	if (NULL == colourmap)
	{
		colourmap = gdk_colormap_get_system();
		gdk_drawable_set_colormap(GDK_DRAWABLE(priv->display_buffer_bot_left), GDK_COLORMAP(colourmap));
	}
	if (NULL == font_context)
	{
		font_context = gdk_pango_context_get();
	}
	if (NULL == font_layout)
	{
		font_layout = pango_layout_new(font_context);
	}
	if (NULL == display_buffer_gc)
	{
		display_buffer_gc = gdk_gc_new(GDK_DRAWABLE(priv->display_buffer_bot_left));
	}
	if (NULL == font_description)
	{
		font_description = pango_font_description_from_string("Sans , 15px");
		pango_layout_set_font_description(font_layout, font_description);
	}

	// Retrieve the layer name string
	layer_pointer = get_current_slide_layers_pointer();
	layer_pointer = g_list_first(layer_pointer);
	layer_data = g_list_nth_data(layer_pointer, layer_number);
//	g_string_printf(message, "%d  %s ",layer_number,layer_data->name->str);
	pango_layout_set_text(font_layout, layer_data->name->str, -1);

	// Set a clip mask
//	clip_region.x = 0;
//	clip_region.y = (layer_number <= 0)?0:(layer_number * priv->row_height);
//	clip_region.width = priv->left_border_width - 1;
//	clip_region.height = priv->row_height * 2;
//	gdk_gc_set_clip_rectangle(GDK_GC(display_buffer_gc), &clip_region);

	// Draw the text string
	gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black);
	gdk_draw_layout(GDK_DRAWABLE(priv->display_buffer_bot_left), GDK_GC(display_buffer_gc), 5, (layer_number * priv->row_height)+1,font_layout);

	return TRUE;
}
Ejemplo n.º 10
0
static gboolean
gdk_gl_pixmap_impl_x11_make_context_current (GdkGLDrawable *draw,
                                             GdkGLDrawable *read,
                                             GdkGLContext  *glcontext)
{
  GdkGLConfig *glconfig;
  GLXPixmap glxpixmap;
  GLXContext glxcontext;

  g_return_val_if_fail (GDK_IS_GL_PIXMAP_IMPL_X11 (draw), FALSE);
  g_return_val_if_fail (GDK_IS_GL_CONTEXT_IMPL_X11 (glcontext), FALSE);

  glconfig = GDK_GL_PIXMAP_IMPL_X11 (draw)->glconfig;
  glxpixmap = GDK_GL_PIXMAP_IMPL_X11 (draw)->glxpixmap;
  glxcontext = GDK_GL_CONTEXT_GLXCONTEXT (glcontext);

  if (glxpixmap == None || glxcontext == NULL)
    return FALSE;

#ifdef GDKGLEXT_MULTIHEAD_SUPPORT
  GDK_GL_NOTE (MISC,
    g_message (" -- Pixmap: screen number = %d",
      GDK_SCREEN_XNUMBER (gdk_drawable_get_screen (GDK_DRAWABLE (draw)))));
#endif /* GDKGLEXT_MULTIHEAD_SUPPORT */
  GDK_GL_NOTE (MISC,
    g_message (" -- Pixmap: visual id = 0x%lx",
      GDK_VISUAL_XVISUAL (gdk_drawable_get_visual (GDK_DRAWABLE (draw)))->visualid));

  GDK_GL_NOTE_FUNC_IMPL ("glXMakeCurrent");

  if (!glXMakeCurrent (GDK_GL_CONFIG_XDISPLAY (glconfig), glxpixmap, glxcontext))
    {
      g_warning ("glXMakeCurrent() failed");
      _gdk_gl_context_set_gl_drawable (glcontext, NULL);
      /* currently unused. */
      /* _gdk_gl_context_set_gl_drawable_read (glcontext, NULL); */
      return FALSE;
    }

  _gdk_gl_context_set_gl_drawable (glcontext, draw);
  /* currently unused. */
  /* _gdk_gl_context_set_gl_drawable_read (glcontext, read); */

  if (_GDK_GL_CONFIG_AS_SINGLE_MODE (glconfig))
    {
      /* We do this because we are treating a double-buffered frame
         buffer as a single-buffered frame buffer because the system
         does not appear to export any suitable single-buffered
         visuals (in which the following are necessary). */
      glDrawBuffer (GL_FRONT);
      glReadBuffer (GL_FRONT);
    }

  GDK_GL_NOTE (MISC, _gdk_gl_print_gl_info ());

  return TRUE;
}
Ejemplo n.º 11
0
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;
}
Ejemplo n.º 12
0
Archivo: gui_util.c Proyecto: bert/fped
void debug_save_widget(GtkWidget *widget)
{
	GdkPixmap *pixmap;
	GdkPixbuf *pixbuf;
	gint w, h;

	pixmap = gtk_widget_get_snapshot(widget, NULL);
	gdk_drawable_get_size(GDK_DRAWABLE(pixmap), &w, &h);
	pixbuf = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE(pixmap),
	    NULL, 0, 0, 0, 0, w, h);
	debug_save_pixbuf(pixbuf);
	gdk_pixmap_unref(pixmap);
	g_object_unref(pixbuf);
}
static gboolean
gtk_experiment_transcript_expose(GtkWidget *widget, GdkEventExpose *event)
{
	GtkExperimentTranscript *trans = GTK_EXPERIMENT_TRANSCRIPT(widget);

	gdk_draw_drawable(GDK_DRAWABLE(gtk_widget_get_window(widget)),
			  widget->style->fg_gc[gtk_widget_get_state(widget)],
			  GDK_DRAWABLE(trans->priv->layer_text),
			  event->area.x, event->area.y,
			  event->area.x, event->area.y,
			  event->area.width, event->area.height);

	return FALSE;
}
Ejemplo n.º 14
0
void UI_buildui(IBusHandwriteEngine * engine)
{
	GdkPixmap * pxmp;
	GdkGC * gc;
	GdkColor black, white;

	GdkColormap* colormap = gdk_colormap_get_system();

	gdk_color_black(colormap, &black);
	gdk_color_white(colormap, &white);

	g_object_unref(colormap);

	int R = 5;

	if (!engine->drawpanel)
	//建立绘图窗口, 建立空点
	{
		engine->drawpanel = gtk_window_new(GTK_WINDOW_POPUP);
		gtk_window_move((GtkWindow*) engine->drawpanel, 500, 550);
		gtk_widget_add_events(GTK_WIDGET(engine->drawpanel),
				GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK
						| GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK);
		g_signal_connect_after(G_OBJECT(engine->drawpanel),"motion_notify_event",G_CALLBACK(on_mouse_move),engine);
		g_signal_connect(G_OBJECT(engine->drawpanel),"expose-event",G_CALLBACK(paint_ui),engine);
		g_signal_connect(G_OBJECT(engine->drawpanel),"button-release-event",G_CALLBACK(on_button),engine);
		g_signal_connect(G_OBJECT(engine->drawpanel),"button-press-event",G_CALLBACK(on_button),engine);

		gtk_window_resize(GTK_WINDOW(engine->drawpanel), 200, 250);

		gtk_widget_show(engine->drawpanel);

		pxmp = gdk_pixmap_new(NULL, 200, 250, 1);
		gc = gdk_gc_new(GDK_DRAWABLE(pxmp));

		gdk_gc_set_foreground(gc, &black);

		gdk_draw_rectangle(GDK_DRAWABLE(pxmp), gc, 1, 0, 0, 200, 250);

		gdk_gc_set_foreground(gc, &white);

		gdk_draw_arc(GDK_DRAWABLE(pxmp), gc, 1, 0, 0, R*2, R*2, 0, 360 * 64);
		gdk_draw_arc(GDK_DRAWABLE(pxmp), gc, 1, 200 - R*2, 0, R*2, R*2, 0, 360
				* 64);
		gdk_draw_arc(GDK_DRAWABLE(pxmp), gc, 1, 200 - R*2, 250 - R*2, R*2, R*2, 0,
				360 * 64);
		gdk_draw_arc(GDK_DRAWABLE(pxmp), gc, 1, 0, 250 - R*2, R*2, R*2, 0, 360
				* 64);
		gdk_draw_rectangle(GDK_DRAWABLE(pxmp), gc, 1, 0, R, 200, 250 - R*2);
		gdk_draw_rectangle(GDK_DRAWABLE(pxmp), gc, 1, R, 0, 200 - R*2, 250);
		gdk_window_shape_combine_mask(engine->drawpanel->window, pxmp, 0, 0);
		g_object_unref(gc);
		g_object_unref(pxmp);
		gtk_window_set_opacity(GTK_WINDOW(engine->drawpanel), 0.62);
		//	engine->GdkPoints = NULL;
	}
	//	gtk_widget_show_all(engine->drawpanel);
}
Ejemplo n.º 15
0
void	_HYSequencePane::_Paint (Ptr p)
{
	_HYRect* 	destR = (_HYRect*)p;
	
	_HYRect 	srcRect,
				destRect = *destR;
				
	//printf ("Sequence Paint Called %d %d %d %d\n", destR->left, destR->top, destR->right, destR->bottom);
	
	if (HasHScroll())
		destRect.bottom-= HY_SCROLLER_WIDTH;
		
	if (HasVScroll())
		destRect.right -= HY_SCROLLER_WIDTH;
		
	//destRect.left 		= destR->left;
	//destRect.top 		= destR->top;
	_HYRect srcR 		= _VisibleContents (p);
	
	gdk_draw_drawable (GDK_DRAWABLE(parentWindow->window), theContext, thePane, 0, 0, 
						parentWindow->allocation.x+destRect.left, parentWindow->allocation.y+destRect.top, destRect.Width(), destRect.Height()); 

	long		saveBorder = settings.width & HY_COMPONENT_BORDER;
	settings.width -= saveBorder;
	_HYPlatformComponent::_Paint(p);
	settings.width += saveBorder;
}
Ejemplo n.º 16
0
static void
gdk_drawable_impl_x11_finalize (GObject *object)
{
  gdk_drawable_set_colormap (GDK_DRAWABLE (object), NULL);

  G_OBJECT_CLASS (_gdk_drawable_impl_x11_parent_class)->finalize (object);
}
Ejemplo n.º 17
0
static VALUE
rg_s_from_drawable(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
    VALUE cmap, src, src_x, src_y, width, height, dest, dest_x, dest_y;
    GdkPixbuf* buf;

    rb_scan_args(argc, argv, "63", &cmap, &src, &src_x, &src_y, &width, &height, 
                 &dest, &dest_x, &dest_y);

    buf = gdk_pixbuf_get_from_drawable(GDK_PIXBUF(RVAL2GOBJ(dest)),
                                       GDK_DRAWABLE(RVAL2GOBJ(src)),
                                       GDK_COLORMAP(RVAL2GOBJ(cmap)),
                                       NUM2INT(src_x), NUM2INT(src_y),
                                       NIL_P(dest_x) ? 0 : NUM2INT(dest_x),
                                       NIL_P(dest_y) ? 0 : NUM2INT(dest_y),
                                       NUM2INT(width), NUM2INT(height));
    if (NIL_P(dest)) {
        if (buf) {
            return GOBJ2RVALU(buf);
        } else {
            return Qnil;
        }
    } else {
        return dest;
    }
}
Ejemplo n.º 18
0
/* Copy selection */
void copy(GtkWidget *widget, gpointer data){//widget and data are useless
  if (!selection_is_on)
    show_error_message("No hay nada seleccionado para copiar");
  
  save_paste_positions();
  clipboard_pixbuf = gdk_pixbuf_get_from_drawable(NULL,GDK_DRAWABLE(canvas->window),gdk_colormap_get_system(),selection_x1,selection_y1,0,0,selection_x2-selection_x1,selection_y2-selection_y1);
}
Ejemplo n.º 19
0
static gboolean
piano_keyboard_expose(GtkWidget *widget, GdkEventExpose *event)
{
	int i;
	PianoKeyboard *pk = PIANO_KEYBOARD(widget);
	cairo_t* cr = gdk_cairo_create (GDK_DRAWABLE (GTK_WIDGET(pk)->window));

	gdk_cairo_region (cr, event->region);
	cairo_clip (cr);

	for (i = 0; i < NNOTES; i++) {
		GdkRectangle r;

		r.x = pk->notes[i].x;
		r.y = 0;
		r.width = pk->notes[i].w;
		r.height = pk->notes[i].h;

		switch (gdk_region_rect_in (event->region, &r)) {
		case GDK_OVERLAP_RECTANGLE_PART:
		case GDK_OVERLAP_RECTANGLE_IN:
			draw_note (pk, cr, i);
			break;
		default:
			break;
		}
	}

	cairo_destroy (cr);

	return TRUE;
}
Ejemplo n.º 20
0
static void
player_av_set_video_destination (Player *self, GtkWidget *dest)
{
    PlayerAVPrivate *priv = PLAYER_AV (self)->priv;

    if (priv->video_dest) {
        gdk_window_invalidate_rect (priv->video_dest->window, NULL, TRUE);
    }

    priv->video_dest = dest;

    if (dest) {
        player_av_change_gdk_window (PLAYER_AV (self), dest->window);
    } else {
        if (priv->fullscreen) {
            player_av_change_gdk_window (PLAYER_AV (self), priv->fs_da->window);
            priv->video_dest = priv->fs_da;
        } else {
            player_av_change_gdk_window (PLAYER_AV (self), priv->em_da->window);
            priv->video_dest = priv->em_da;
        }
    }

    g_signal_connect (priv->video_dest, "size-allocate", G_CALLBACK (on_alloc_event), self);

    gdk_drawable_get_size (GDK_DRAWABLE (priv->video_dest->window),
        &priv->win_width, &priv->win_height);
}
Ejemplo n.º 21
0
/* Redraw the screen from the backing pixmap */
static gboolean expose_event (GtkWidget      *widget,
                              GdkEventExpose *event)
{
	static GdkImage *image = NULL;
	GdkCursor *cursor;
	GdkPixbuf *pixbuf;

	if (framebuffer_allocated == FALSE) {

		rfbClientSetClientData (cl, gtk_init, widget);

		image = gdk_drawable_get_image (widget->window, 0, 0,
		                                widget->allocation.width,
		                                widget->allocation.height);

		cl->frameBuffer= image->mem;

		cl->width  = widget->allocation.width;
		cl->height = widget->allocation.height;

		cl->format.bitsPerPixel = image->bits_per_pixel;
		cl->format.redShift     = image->visual->red_shift;
		cl->format.greenShift   = image->visual->green_shift;
		cl->format.blueShift    = image->visual->blue_shift;

		cl->format.redMax   = (1 << image->visual->red_prec) - 1;
		cl->format.greenMax = (1 << image->visual->green_prec) - 1;
		cl->format.blueMax  = (1 << image->visual->blue_prec) - 1;

#ifdef LIBVNCSERVER_CONFIG_LIBVA
		/* Allow libvncclient to use a more efficient way
		 * of putting the framebuffer on the screen when
		 * using the H.264 format.
		 */
		cl->outputWindow = GDK_WINDOW_XID(widget->window);
#endif

		SetFormatAndEncodings (cl);

		framebuffer_allocated = TRUE;

		/* Also disable local cursor */
                pixbuf = gdk_pixbuf_new_from_xpm_data(dot_cursor_xpm);
	        cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, dot_cursor_x_hot, dot_cursor_y_hot);
		g_object_unref(pixbuf);	
		gdk_window_set_cursor (gtk_widget_get_window(GTK_WIDGET(window)), cursor);
		gdk_cursor_unref(cursor);
	}

#ifndef LIBVNCSERVER_CONFIG_LIBVA
	gdk_draw_image (GDK_DRAWABLE (widget->window),
	                widget->style->fg_gc[gtk_widget_get_state(widget)],
	                image,
	                event->area.x, event->area.y,
	                event->area.x, event->area.y,
	                event->area.width, event->area.height);
#endif

	return FALSE;
}
Ejemplo n.º 22
0
static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
{
	PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
	GdkPixmap *pixmap = gtkwb->pixmap;
	cairo_t *cr;

	if (pixmap) {
		cr = g_object_get_data(G_OBJECT(pixmap), "cairo-context");
		if (cr)
			cairo_destroy(cr);
		g_object_unref(pixmap);
	}

	pixmap = gdk_pixmap_new(widget->window,
							widget->allocation.width,
							widget->allocation.height,
							-1);
	gtkwb->pixmap = pixmap;

	cr = gdk_cairo_create(GDK_DRAWABLE(pixmap));
	g_object_set_data(G_OBJECT(pixmap), "cairo-context", cr);
	gdk_cairo_set_source_color(cr, &widget->style->white);
	cairo_rectangle(cr,
	                0, 0,
	                widget->allocation.width, widget->allocation.height);
	cairo_fill(cr);

	return TRUE;
}
Ejemplo n.º 23
0
static VALUE
rg_set_drawable(VALUE self, VALUE drawable)
{
    gdk_pango_renderer_set_drawable(_SELF(self), 
                                    GDK_DRAWABLE(RVAL2GOBJ(drawable)));
    return self;
}
Ejemplo n.º 24
0
gboolean
totem_ratio_fits_screen (GdkWindow * video_window, int video_width,
    int video_height, gfloat ratio)
{
  GdkRectangle fullscreen_rect;
  int new_w, new_h;
  GdkScreen *screen;

  if (video_width <= 0 || video_height <= 0)
    return TRUE;

  new_w = video_width * ratio;
  new_h = video_height * ratio;

  screen = gdk_drawable_get_screen (GDK_DRAWABLE (video_window));
  gdk_screen_get_monitor_geometry (screen,
      gdk_screen_get_monitor_at_window
      (screen, video_window), &fullscreen_rect);

  if (new_w > (fullscreen_rect.width - 128) ||
      new_h > (fullscreen_rect.height - 128)) {
    return FALSE;
  }

  return TRUE;
}
Ejemplo n.º 25
0
Archivo: maemo.c Proyecto: CSRedRat/vlc
static int ControlWindow (vout_window_t *p_wnd, int query, va_list args)
{
    intf_thread_t *p_intf = (intf_thread_t *)p_wnd->sys;

    switch( query )
    {
    case VOUT_WINDOW_SET_SIZE:
    {
        int i_width  = (int)va_arg( args, int );
        int i_height = (int)va_arg( args, int );

        int i_current_w, i_current_h;
        gdk_drawable_get_size( GDK_DRAWABLE( p_intf->p_sys->p_video_window ),
                               &i_current_w, &i_current_h );
        if( i_width != i_current_w || i_height != i_current_h )
            return VLC_EGENERIC;
        return VLC_SUCCESS;
    }
    case VOUT_WINDOW_SET_FULLSCREEN:
    {
        bool b_fs = va_arg( args, int );
        p_intf->p_sys->b_fullscreen = b_fs;
        g_idle_add( fullscreen_cb, p_intf );
        return VLC_SUCCESS;
    }
    default:
        return VLC_EGENERIC;
    }
}
Ejemplo n.º 26
0
void start_recording(GtkWidget *widget, gpointer data) {
    GdkNativeWindow native;
    GdkDisplay *display;
    GdkRectangle rect;

    if(is_recording)
        return;

    screen = gtk_widget_get_screen(widget);
    if (screen == NULL) {
        screen = gdk_screen_get_default ();
    }
    native = select_window(screen);
    display = gdk_screen_get_display (screen);
    window = gdk_window_foreign_new_for_display (display, native);

    gdk_drawable_get_size (GDK_DRAWABLE (window), &rect.width, &rect.height);

    /* creating flv und screenVideo instances */
    flv = newFLVStream(FLVVERSION_1, FLVFLAG_VIDEO);
    video = newScreenVideo(rect.width, rect.height, 64);
    printf("video width: %i, height: %i\n", rect.width, rect.height);

    /* capture timer */
    g_timeout_add ( 1000 / FRAMERATE,  next_capture, NULL);
    is_recording = 1;
}
Ejemplo n.º 27
0
static void
fill_pixel_rect(DiaRenderer *object,
		int x, int y,
		int width, int height,
		Color *color)
{
  DiaGdkRenderer *renderer = DIA_GDK_RENDERER (object);
  GdkGC *gc = renderer->gc;
  GdkColor gdkcolor;
  int target_width, target_height;
    
  gdk_drawable_get_size (GDK_DRAWABLE (renderer->pixmap), &target_width, &target_height);
    
  if (x + width < 0 || y + height < 0 || x > target_width || y > target_height)
    return; /* clip early rather than failing in Gdk */

  color_convert(color, &gdkcolor);
  gdk_gc_set_foreground(gc, &gdkcolor);
  /* reset stippling (alpha emulation) */
  gdk_gc_set_fill(gc, GDK_SOLID);
  renderer->current_alpha = 1.0;

  gdk_draw_rectangle (renderer->pixmap, gc, TRUE,
		      x, y,  width, height);
}
Ejemplo n.º 28
0
static void
draw_pixel_line(DiaRenderer *object,
		int x1, int y1,
		int x2, int y2,
		Color *color)
{
  DiaGdkRenderer *renderer = DIA_GDK_RENDERER (object);
  GdkGC *gc = renderer->gc;
  GdkColor gdkcolor;
  int target_width, target_height;
    
  dia_gdk_renderer_set_dashes(renderer, x1+y1);

  gdk_drawable_get_size (GDK_DRAWABLE (renderer->pixmap), &target_width, &target_height);

  if (   (x1 < 0 && x2 < 0)
      || (y1 < 0 && y2 < 0)
      || (x1 > target_width && x2 > target_width) 
      || (y1 > target_height && y2 > target_height))
    return; /* clip early rather than failing in Gdk */
  
  color_convert(color, &gdkcolor);
  gdk_gc_set_foreground(gc, &gdkcolor);
  /* reset stippling (alpha emulation) */
  gdk_gc_set_fill(gc, GDK_SOLID);
  renderer->current_alpha = 1.0;
  
  gdk_draw_line(renderer->pixmap, gc, x1, y1, x2, y2);
}
static gboolean
render_contribution_topdown(GtkExperimentTranscript *trans,
			    ExperimentReaderContrib *contrib,
			    gint64 current_time, gint64 current_time_px,
			    gint *last_contrib_y)
{
	GtkWidget *widget = GTK_WIDGET(trans);

	gint old_last_contrib_y = *last_contrib_y;
	int logical_height;

	*last_contrib_y = current_time_px - TIME_TO_PX(contrib->start_time);

	if (!configure_text_layout(trans, contrib, current_time,
				   *last_contrib_y, old_last_contrib_y,
				   &logical_height))
		return TRUE;

	if (*last_contrib_y - logical_height > widget->allocation.height)
		return FALSE;

	gdk_draw_layout(GDK_DRAWABLE(trans->priv->layer_text),
			widget->style->text_gc[gtk_widget_get_state(widget)],
			0, *last_contrib_y - logical_height,
			trans->priv->layer_text_layout);

	return *last_contrib_y < widget->allocation.height;
}
Ejemplo n.º 30
0
GdkCursor *
create_cursor(GdkWindow *window,
	      const guint8 *data,
	      int hot_x, int hot_y)
{
  GdkPixbuf *pixbuf;
  GdkCursor *cursor;
  GdkDisplay *display;

  g_return_val_if_fail(window != NULL, NULL);
#if GTK_CHECK_VERSION (2,24,0)
  display = gdk_window_get_display (window);
#else
  display = gdk_drawable_get_display (GDK_DRAWABLE (window));
#endif

  pixbuf = gdk_pixbuf_new_from_inline(-1, data, FALSE, NULL);

  cursor = gdk_cursor_new_from_pixbuf (display, pixbuf, hot_x,hot_y);
  g_assert(cursor != NULL);

  g_object_unref(pixbuf);

  return cursor;
}