Re: Gtkmm draw line with mouse events
- From: Gurjot Singh <bhattigurjot gmail com>
- To: Chris Vine <chris cvine freeserve co uk>
- Cc: gtkmm-list gnome org
- Subject: Re: Gtkmm draw line with mouse events
- Date: Mon, 14 Jul 2014 21:27:50 +0530
On 14 July 2014 00:22, Chris Vine <chris cvine freeserve co uk> wrote:
If that is not possible only then I'd be forced to do everything in a
single on_draw().
You should draw in the on_draw() method or in a draw signal handler so
that the widget re-renders correctly when this is necessary by virtue of
other desktop activities. Obviously your overriding on_draw() method
can call whatever other drawing functions it wants. You can force a
draw when needed by calling Gtk::Widget::queue_draw_area() and cognates.
Pardon me, but I didn't get you.
Can you explain with some example?
Are you saying that everything that is to be drawn must be written in
on_draw function?
Suppose I have two functions that are called to draw point and line,
something like this:
http://pastebin.com/Ancx87EF
But if this is it, it'd re-draws the whole drawing area, so I'd be
unable to retain any previously drawn entity.
And that is why I was asking if it could be done something like,
void DrawingArea :: on_line_cb()
{
cr->set_source_rgb(0.0, 0.26, 0.26);
cr->save();
cr->move_to(0,0);
cr->line_to(100,100);
cr->restore();
cr->stroke();
queue_draw();
std::cout<<"Line created"<<std::endl;
}
But this doesn't work because it says that 'cr' is not declared in the
scope or something related to this.
P.S: I am unable to get any help from the documentation or even on
stackoverflow. :(
--
Gurjot Singh
Blog: http://bhattigurjot.wordpress.com
"It takes a person who is wide awake to make his dream come true." ~
Roger Babson
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]