Hi,
I'm trying to make a typical mouse select box.
I suppose I should to use the fl_overlay_rect and
the fl_overlay_clear functions.
But, I don't really understand the way to do that.
Here's what I tried:
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/fl_draw.H>
class Application : public Fl_Double_Window
{
int xPos, yPos;
int Application::handle(int e)
{
int ret = Fl_Double_Window::handle(e);
switch(e)
{
case FL_PUSH:
make_current();
xPos = Fl::event_x();
yPos = Fl::event_y();
ret = 1;
case FL_DRAG:
fl_overlay_rect(xPos, yPos,
Fl::event_x() - xPos, Fl::event_y() - yPos);
ret = 1;
case FL_RELEASE:
fl_overlay_clear();
ret = 1;
}
return(ret);
}
void Application::draw()
{
fl_overlay_clear();
Fl_Double_Window::draw();
}
public:
Application(int w, int h, const char *l, int argc, char *argv[]);
};
Application::Application(int w, int h, const char *l, int argc, char *argv[])
: Fl_Double_Window(w, h, l)
{
begin();
box(FL_DOWN_BOX);
color((Fl_Color) FL_WHITE);
resizable(this);
end();
show(argc, argv);
}
int main (int argc, char ** argv)
{
Application myApp(500, 300, "Mouse Selection", argc, argv);
return(Fl::run());
}
I can see briefly a rectangle drawed when I drag the mouse while keeping a
button pressed but there's a clipping pb or something.
Can someone explain to me how to do that in a proper way ?
Thanks
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk