Re: [gtk-list] Many novice GTK questions + a new Colormap rotation plug-in.




Pavel Greenfield <pavel@riskdevel.ml.com> writes:

> 1. How do I erase an arrow without having to redraw the preview (all of it
> or even part of it)? If that's impossible, how about a few suggestions how
> to make redrawing more efficient? (Something beyond "redraw the part
> covered by the arrow only.")

If redrawing the relevant portion of the preview isn't satisfactory,
you could investigate drawing your arrows in XOR mode. You need to
create a GC with the mode set to XOR - something like:

  GdkGCValues values;
  GdkGC xor_gc;

  values.foreground = widget->style->white;
  values.function = GDK_XOR;
  xor_gc = gdk_gc_new_with_values (widget->window,
	  		           &values,
				   GDK_GC_FOREGROUND |
				   GDK_GC_FUNCTION);

Then to erase it, all you have to do is draw it again. (But you have
to make sure it _is_ there ...)

> 2. How do I draw an arc centered at a certain point, of certain radius,
> from angle A to angle B? 

How about

void gdk_draw_arc        (GdkDrawable  *drawable,
			  GdkGC        *gc,
			  gint          filled,
			  gint          x,
			  gint          y,
			  gint          width,
			  gint          height,
			  gint          angle1,
			  gint          angle2);

(The angles are in units of degrees * 64 from the three-o'clock
position, ala XDrawArc)

> 3. Can someone write a definitive (-ish) tut on how to control colors of
> the gdk-objects. A few people tried to explain that to me (Thank you very
> much, BTW) but I still don't get it!

[ not right now, anyways ]

> 4. My preview captures all the mouse events. When I tried to make the
> frame the preview is in capture these events it didn't work (except for
> GTK_EXPOSE). Why?

The frame doesn't have it's own window (the preview does). Only things
with an X-window can receive events. So you need to put the frame
inside something with a window. The best choice might be the EventBox
widget that I posted to this list some while ago. I probably should
clean it up a little and post a new version with documentation, but
what I posted before should work. (Of course, it won't be useful for
a plug-in unless it becomes standard - but no current widget is really
suitable - the viewport widget might work in some circumstances.)

Hope this helps,
                                        Owen



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