> I'm confused with the way fl_line works.
> In my own widget I redefined the draw method as follow:
>
> void MyWidget::draw()
> {
> Fl_Group::draw();
> fl_color(FL_BLACK);
> fl_line_style( FL_DOT, 1);
>
> fl_push_clip(x(), y(), w(), h());
>
> fl_line(20, 50, 20, 100);
>
> fl_pop_clip();
> }
>
> In that case the line drawn is 50px and not 100px, so I guess that
> the line actually starts at the top of the widget
> so the proper way to get a 100px line should be:
This is fltk-1 I think?
Probably you are caught out because drawing takes palce relative to the
parent window in fltk-1, *not* relative to the widget origin. (There are
complex reasons about why this is or is not a good idea, but moving
on...)
So, you maybe need to do like this:
void MyWidget::draw()
{
int xo = x();
int yo = y();
Fl_Group::draw();
fl_color(FL_BLACK);
fl_line_style( FL_DOT, 1);
fl_push_clip(x(), y(), w(), h());
fl_line(xo + 20, yo + 50, xo + 20, yo + 100);
fl_pop_clip();
}
As an alternative, you can probably use fl_translate() to shift the
drawing origin to your widget co-ordinates once you have pushed the
clip...
void MyWidget::draw()
{
int xo = x();
int yo = y();
Fl_Group::draw();
fl_color(FL_BLACK);
fl_line_style( FL_DOT, 1);
fl_push_clip(x(), y(), w(), h());
fl_push_matrix();
fl_translate(xo, yo);
fl_line(20, 50, 20, 100);
fl_pop_matrix();
fl_pop_clip();
}
Something like that, anyway.
NOTE: I just typed this up without checking the docs, so this may not
work - but the idea is right, so hopefully it will show you how to
proceed...
--
Ian
SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14
3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk