I wish to draw a line using mouseevents on Gtk::DrawableArea
.
What I want is something like:
- Click on Line Button to activate line event
- Select first point(already drawn) in the drawingarea
- Now Select second point(again already drawn) in the drawingarea
- line should be drawn between two points
What I already have:
Gtk::DrawingArea
- 2 points(manual circles) drawn using cairo, needed to create the line
The follwing is my constructor that calls the on_draw function.
drawingArea:: drawingArea()
{
signal_draw().connect(sigc::mem_fun(*this, &drawingArea::on_draw), false);
}
And the on_draw function draws the background:
bool drawingArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
cr->set_source_rgb(1.0, 1.0, 1.0); // white background
cr->paint();
cr->save();
cr->arc(10.0, 10.0, 1.0, 0.0, 2 * M_PI); // full circle
cr->set_source_rgba(0.0, 0.0, 0.8, 0.6); // partially translucent
cr->fill_preserve();
cr->restore();
cr->stroke();
return true;
}
P.S: I can easily add two points in this on_draw function. I'm a newbie in Gtkmm so kindly help shed some light on it.