Re: How to catch Pixmap widget x & y coordinates ?



Em 28 Feb 2002 13:03:38 -0500, Paul Davis escreveu:

Ok,

I want to use gdk_draw_pixmap to exchange one Gtk Pixmap with a file
pixmap, I made some experiences with this command as above :

int
troca_pixmap(gpointer user_data, char *nome_pixmap, char *filename,
gboolean use_pixmap_interno, GdkPixmap *pixmap_interno)
{

  GtkWidget *pixmap;
  GdkColormap *colormap;
  GdkPixmap *gdkpixmap;
  GdkBitmap *mask;
  gchar *pathname = NULL;

  pixmap = lookup_widget(user_data, nome_pixmap);

  if(use_pixmap_interno == FALSE)
    {
      if (!filename || !filename[0])
	return -1;

      pathname = gnome_pixmap_file (filename);
      if (!pathname)
	{
	  g_warning (_("Couldn't find pixmap file: %s"), filename);
	  return -1;
	}

      colormap = gtk_widget_get_colormap (user_data);

      gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap,
&mask, NULL, pathname);

      if (gdkpixmap == NULL)
	{
	  g_warning (_("Couldn't create pixmap from file: %s"), pathname);
	  g_free (pathname);
	  return -1;
	}
    }

   else
     {
      if (pixmap_interno == NULL)
	{
	  g_warning (_("Couldn't create pixmap from pixmap_interno"));
	  return -1;
	}

       gdkpixmap = pixmap_interno;
     }

  if(use_pixmap_interno == FALSE)
    {
      g_free (pathname);

       gdk_draw_pixmap (pixmap->window,
pixmap->style->fg_gc[GTK_WIDGET_STATE(pixmap)], gdkpixmap, -1, -1, -1,
-1, GTK_WIDGET (pixmap)->requisition.width, GTK_WIDGET
(pixmap)->requisition.height);

    }
  else
    {
      gtk_widget_hide(GTK_WIDGET(pixmap));
      gtk_pixmap_set(GTK_PIXMAP(pixmap), gdkpixmap, NULL);
      gtk_widget_show(GTK_WIDGET(pixmap));
    }
   if(use_pixmap_interno == FALSE)
     {
       gdk_pixmap_unref (gdkpixmap);
       gdk_bitmap_unref (mask);
     }

  return 1;
}

This works fine, but the position of pixmaps are allways in left up
corner I believe because the parameters -1, -1, -1, -1, but I don't know
what to put in these parameters, the gdk reference manual says that
these parameters are the x,y coordinates of source and destination, but
I don't know how  to obtain this information.

Any help to a newbie are Welcome

Thanks a lot 

Flavio Alberto


> >Hello all,
> >
> >I need to know how to catch the coordinates from a pixmap Widget;
> >Thanks for any help
> > your question is not clear. please be more specific.






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]