On 31.03.2018 23:31 Will B:
>
> For internet searchers, this is a simple example of overriding
> resize(). When running this myself, width and height seem to be
> accurate when resizing, but when I move the window, the width and height
> appear to be wrong. They eventually display the default width and
> height if you move the window enough.
I can't confirm this (running under Linux).
Anyway, your example code is incomplete. You should *always* call the
base class' resize() method, otherwise child widgets won't be resized. I
don't know if this can have anything to do with the behavior observed by
you, but, as you wrote, "For internet searchers..." I wanted to mention it:
/* handle resize events */
void MyWin::resize (int X, int Y, int W, int H)
{
std::cout << "resize: "
<< X << ", "
<< Y << ", "
<< W << ", "
<< H << "\n";
Fl_Double_Window::resize(X, Y, W, H); // <-- ADD THIS !
}
Depending on what you want to achieve, it can be enough to call
Fl_Window::resize() or Fl_Group::resize() instead, but that is another
story.
OTOH, if you want to do the widget resizing yourself, you might want to
call only Fl_Widget::resize() which will update the widget (in this case
the window) coordinates and sizes, then resize the children yourself,
like so:
/* handle resize events */
void MyWin::resize (int X, int Y, int W, int H)
{
std::cout << "resize: "
<< X << ", "
<< Y << ", "
<< W << ", "
<< H << "\n";
Fl_Widget::resize(X, Y, W, H); // adjust widget coord's and sizes
if (children()) {
// Add code to resize child widgets here:
...
}
}