matthiasm wrote:
> The code insode this function will certainly not draw into the
> windows. You see, the idea of using windows as children of groups is
> to create a new graphics context. Having a new coordinate system is
> just one of the side effects. If any drawing os visible on the child
> windows at all depends on the underlying platform. Generally, it is
> not recomendable to draw over child windows, but instead let the
> windows do their own drawing.
>
> So the solution here would be to derive your own window class and give
> it another draw() function.
>
> Oh, and another thing. You choose doublebuffered windows as children,
> which adds yet another layer of buffering, so drawing into the window
> from any other part of the code than the window's draw function is
> unpredictable.
Thanks for that explanation. It helped me to modified my code and get more or
less what I need.
But there's still one pb I just can't fixe.
The drawing in the second container doesn't works on the whole area of the
widget.
Actually the undrawing area correspond to the first container widget area.
I first thought it was a trivial offset pb, but it wasn't.
Could you take a look at my code ?
Thanks
class Container : public Fl_Double_Window
{
int border, xPos;
bool bSplit;
void Container::draw()
{
Fl_Double_Window::draw();
fl_color(FL_BLACK);
fl_line_style( FL_DOT, 1);
if(bSplit)
{
fl_push_clip(x(), y(), w(), h());
fl_line(xPos - 1, y() + border, xPos - 1, y() + h() - (border * 2));
fl_line(xPos, y() + border, xPos, y() + h() - (border * 2));
fl_line(xPos + 1, y() + border, xPos + 1, y() + h() - (border * 2));
fl_pop_clip();
}
else
{
fl_push_clip(x(), y(), w(), h());
fl_pop_clip();
}
}
public:
Container(int x, int y, int w, int h, char *l = 0)
: Fl_Double_Window(x, y, w, h, l)
{
set_non_modal();
box(FL_DOWN_BOX);
bSplit = false;
border = Fl::box_dx(FL_DOWN_BOX);
}
inline void setSplit(bool split){bSplit = split;}
inline void setXPos(int x){xPos = x;}
};
class VrtSplitter : public Fl_Group
{
Container *container1, *container2;
int splitPos, oldXPos;
bool bSplit;
void setSplitCtnr(bool split)
{
container1->setSplit(split);
container2->setSplit(split);
}
int VrtSplitter::handle(int e)
{
int ret = Fl_Group::handle(e);
switch(e)
{
case FL_MOVE:
if(Fl::event_x() > container1->w() - border && Fl::event_x() <
container1->w() + border)
{
fl_cursor(FL_CURSOR_WE);
bSplit = true;
}
else
{
fl_cursor(FL_CURSOR_DEFAULT);
bSplit = false;
}
return 1;
case FL_PUSH:
if(Fl::event_button() == FL_LEFT_MOUSE && bSplit)
{
setSplitCtnr(true);
oldXPos = Fl::event_x();
container1->setXPos(container1->w());
container2->setXPos(0);
container1->redraw();
container2->redraw();
}
return 1;
case FL_RELEASE:
if(Fl::event_button() == FL_LEFT_MOUSE && bSplit)
{
splitPos = Fl::event_x
setSplitCtnr(false);
container1->resize(x(), y(), splitPos, h());
container2->resize(x() + splitPos, y(), w() - splitPos, h());
bSplit = false;
container1->redraw();
container2->redraw();
}
return 1;
case FL_DRAG:
if(bSplit && Fl::event_state(FL_BUTTON1) != 0)
{
splitPos = Fl::event_x();
if(splitPos < oldXPos)
{
container1->setXPos(splitPos);
container1->redraw();
}
else
{
container2->setXPos(splitPos - oldXPos);
container2->redraw();
}
}
return 1;
}
return(ret);
}
public:
VrtSplitter(int x, int y, int w, int h, const char *l = 0)
: Fl_Group(x, y, w, h, l)
{
begin();
container1 = new Container(x, y, w / 2, h);
container1->color((Fl_Color) FL_RED);
end();
begin();
container2 = new Container(x + (w / 2), y, w / 2, h);
container2->color((Fl_Color) FL_BLUE);
end();
bSplit = false;
}
};
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk