Am Montag, den 25.04.2005, 20:11 +0200 schrieb Fopa1:
> >>2) I'd like to do something like that: fix the start point of my new
> >>line at some coordinates, and make the line follow the mouse pointer
> >>until I click. This "moving line" is not an object whitch redraws
> >>itself, and I can't figure how to manage that.
> >You can use the XOR Gdk::GC::Function. With this set, all simple drawing
> >operations will invert all drawn pixels in your scene.
> >So it would be done in this way:
> >>first click:
> > save start and end point
> >pointer move:
> > if its the first move simply draw a line from the saved point to
> > the actual one and save the endpoint.
> > else: draw a line with the saved start and end point and the old
> > line will disappear. then draw the line from the start point to
> > the new endpoint.
> >second click:
> > draw a line with the saved start and end point and the old line
> > will disappear. then draw the line from the start point to the
> > current location
> Ok, I tested that, with a 'motion_notify_event' proc like that ($x $y =
> 1st coordinates, $xx $yy = 2nd coordinates):
> def mne(w, e)
> w.window.draw_line(gc, $x, $y, $xx, $yy)
> w.window.draw_line(gc, $x, $y, e.x, e.y)
> $xx, $yy = e.x, e.y
> That doesn't work: it draws a lot of lines whitch follow the mouse
> pointer, but they are never deleted.
sure that they never got deleted. You have to use the XOR GC for drawing
_and_ for removing. Thats the clue. See this example
Bits in memory: 0111 0101
draw your line: XOR 1111 1111
New bits in mem: 1000 1010
remove line: XOR 1111 1111
New bits in mem: 0111 0101
> I tried to use a Pixmap, but there are 2 problems:
> 1) pixmap is "deprecated";
If you don't want to make very special things simply use the
Gtk::DrawingArea. This is a good starting point for own widgets.
> 2) when I draw some rectangle from pixmap to window, only 1 color is
all simple drawing oops are only with one color.
> and I don't know how to store color in pixmap.
> I tried Pixbuf too, but I don't know how to draw lines in a pixbuf :)
Thats simple, you can't. Pixbufs are only for displaying graphics, not
for drawing on it. The only thing you can do is to put single pixels in
a pixbuf, but you realy want to do this ;-)
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> ruby-gnome2-devel-en mailing list