Search code examples
c++linuxdebianfltk

FLTK child window not redrawing on Linux


I'm working on a nice open-source project that I hope to release, however I'm having some trouble with a child window not redrawing after being damaged. Please see this image for details:

Child window redraw example

Here is the code I'm using to display this:

void showMessageWindow (std::string strMessage, std::string strTitle)
{
    Fl_Window* msgWin = new Fl_Window(400, 255, NULL);
    if (strTitle == "")
        msgWin->label("Window Title");
    msgWin->box(FL_BORDER_FRAME);
    msgWin->set_non_modal();

    Fl_PNG_Image* img = new Fl_PNG_Image("/home/obaker/Pictures/info-icon.png");
    Fl_Box* ibox = new Fl_Box(20, 20, 48, 48);
    ibox->image(img);

    Fl_Multiline_Output* mOut = new Fl_Multiline_Output(90, 20, 275, 175, NULL);    
    mOut->box(FL_NO_BOX);
    mOut->wrap(true);
    mOut->readonly(true);
    mOut->cursor_color(FL_BACKGROUND_COLOR);    
    mOut->value(strdup(strMessage.c_str()));

    Fl_Button* btn = new Fl_Button(150, 210, 100, 35, "OK");
    btn->box(FL_GTK_UP_BOX);
    btn->shortcut(FL_Enter);
    btn->callback(msgBoxClose, msgWin);

    msgWin->add(ibox);
    msgWin->add(mOut);
    msgWin->add(btn);

    msgWin->show();
}

I have tried using Fl_Double_Window instead of Fl_Window and it looks even worse:

Child window redraw example - Fl_Double_Window

As 'edgy' and 'cool' as that might look, it's not appropriate for my project. :-)

I'm developing and testing on Debian Linux 8, 64-bit, AMD Radeon HD 6670 video card, 8 GB RAM. The Debian-provided version of FLTK is 1.3 (1.3.2-6).

The parent window is an Fl_Double_Window and it redraws itself just fine.

Is there anything anyone could recommend to force this child window to redraw itself when it's damaged?

Thank you in advance! :-)


Solution

  • After guidance from Chris on the FLTK forums, I was able to resolve this issue.

    The changes necessary are:

    msgWin->box(FL_BORDER_BOX)

    instead of

    msgWin->box(FL_BORDER_FRAME)

    "FL_NO_BOX for output may also lead to drawing artifacts. Better set the outputs background color to the windows background color:"

    mOut->box(FL_FLAT_BOX);
    mOut->color(msgWin->color());
    

    Thank you for all of your help! :-)