> Hi, I am writing a small problem to implement an algorithm
> in graphics.
> And I inherit Fl_Window to catch mouse click to draw some
> circle and lines on it. It works fine, but after I minimizing
> my window, those lines never appear, the draw() function I
> override is called (since I put some printf inside for
> debugging; it only appear after I use mouse to click on the window.
> int MyWindow::handle(int e)
> {
> int ret = Fl_Window::handle(e);
> switch (e)
> {
> case (FL_PUSH):
> point = new MyPoint(Fl::event_x(), Fl::event_y());
> draw();
> break; //exit switch case
> case (FL_SHOW):
> printf("FL_VISIBLE\n");
> draw(); /** <-- want to draw after the window is
> bring up from minimized in the toolbar, and it DOES call
> MyWindow::draw, but it just don't show up immediately, it
> shows only after the next FL_PUSH happens !
> }//end switch case
> return ret;
OK, there are a few things to think about;
- Firstly, as outlined in the docs, NEVER call the draw method directly.
Call redraw(), and allow the fltk rendering loop to manage the redraw
and expose events for you.
Also, a redraw will be scheduled after an expose event anyway, so what
you are doing in your handle method is unnecessary, it will be done
anyway.
- Secondly, Fl_Window is a container widget, not really a surface on
which you should draw directly. You would probably be better off
deriving your drawing surface from a simple widget like Fl_Box and
drawing on that, enclosing your box-derived widget in an Fl_Window
container.
This is all covered in the docs, and the worked examples in the "test"
directory show how to do this, so you should start by copying one of
those and extending it to your needs, to explore how this all works.
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