Re: Pixmap (II)



Hi,

1) gtk_pixmap_new() is old and should not be used; I think you want to be using gtk_image_new_from_pixmap() instead. 2) though that said, if the image is going to be changing during the course of the program, you might want to do it differently (depending):
	2.1) create the image widget at app startup with gtk_image_new()
2.2) then, in your drawing routine, once you've got your pixmap, set the image widget with gtk_image_set_from_pixmap() 3) and I believe, in the case of using an image widget, you do not need to manage configure and expose events yourself, they are internally managed, so this part of my explanation is not relevant/ valid; you can execute your drawing routine (to get the pixmap and then place it in the image) and be done.

(I do not use the Gtk image myself, so if any of the above is wrong, would someone else please correct me?)

Rather, the paradigm I laid out below I use for DrawingArea widgets and displaying pixmaps therein; drawing area widgets require the user manage the configure() and expose() events themselves.

richard

On Aug 9, 2006, at 10:13 AM, Roses Roses wrote:

Hi!

I've read your solution, but I haven't obtained the correct answer.

My drawable routine is the next:

  GdkBitmap *masc; // Mascara de bits
  GtkStyle *stile; // Estilo
  stile = gtk_widget_get_style(window);
pixmap=gdk_pixmap_create_from_xpm(window->window,&masc,&stile->bg [GTK_STATE_NORMAL],"gtk.xpm");
//pixmap is a GdkPixmap and gtk.xpm is the new path of the new image
  pixmapwid= gtk_pixmap_new (pixmap, masc); //pixmapwid is a GtkWidget
  gtk_widget_queue_draw_area(pixmapwid,0,0,900,400);
  gtk_widget_show(pixmapwid);

But seems it's not correct. Have I any erro?

Thanks!!

============================================

hi,

one possible paradigm is to adhere to the following guidelines:

1) the configure event callback is responsible for calling all routines responsible for "drawing" the pixmap for ultimate display, but does NOT do
the actual display to the screen;

2) the expose event callback is responsible for rendering the current
pixmap to be displayed to the screen, but does NO "drawing" here, only render the pixmap to the screen via gdk_draw_drawable() or equivalent;

3.1) the drawing routine(s) are responsible for creating the pixmap for
ultimate display;

3.2) store the address of the pixmap in a variable that the expose event
callback also has access to (global or otherwise)

3.3) the last command as part of the drawing routine is to call
gtk_widget_queue_draw_area() on the widget used to display
the pixmap; this will force an expose event

in this manner, your drawing routine is called on all configure events
followed immediately by the expose event rendering the pixmap  to the
screen. while calling your drawing routine via a user-event, or some other event internal to the program, will also result in the expose event being
called to render the newly made pixmap to the screen.

so, in your case, you would attach the button-click to a callback
ultimately calling your pixmap drawing routine. the drawing routine will then be called on button-click and your new pixmap will be rendered via the
expose event.

cheers,

richard

On Aug 2, 2006, at 11:43 AM, Roses Roses wrote:

	 	Hi!!!

I'm programming a little interface but I have a prblem. The objective of this program is shows a pixmap qhich must ghange qhen the user clicks on a
button. How the fuction of the button can change the pixmap assigned?

One idea I've is declare the GtkPixmap as a global variable, but I'm not
sure if this plan can run.

Thank you very much

_________________________________________________________________
Horóscopo, tarot, numerología... Escucha lo que te dicen los astros.
http://astrocentro.msn.es/

_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list






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