Search code examples
c++wt

Wt WDialog content doesn't fill free area


I need to show a modal dialog with exact content and I can't set height of the content manually. It makes scrollable area of fixed height (400) and I cannot expand content to this area. By reading HTML code of generated page and found this div

<div id="omoz2q6" class="modal-body" style="box-sizing: border-box; position: absolute; width: 900px; left: 0px; height: 541px; top: 49px;"><div id="omoz2q3" style="height:540.0px;">

which is shown in browser with height 400px.

Here is the code of the dialog:

CHelpDialog::CHelpDialog( Wt::WString title, Wt::WString text )
{
    setWindowTitle( title );

    Wt::WText* helpText = new Wt::WText( text, Wt::XHTMLUnsafeText );
    contents()->addWidget( helpText );

    Wt::WPushButton* okButton = new Wt::WPushButton( L"OK" );
    okButton->clicked().connect( std::bind( [=] () {
        accept();
    } ) );
    footer()->addWidget( okButton );

    setMaximumSize( 900, 650 );
    setMinimumSize( 900, 650 );

    helpText->setHeight( 540 );

    std::cerr << "helpText height : " << helpText->height().value() << std::endl;
    std::cerr << "helpText maxHeight : " << helpText->maximumHeight().value() << std::endl;
    std::cerr << "contents maxHeight : " << contents()->maximumHeight().value() << std::endl;
    std::cerr << "dialog maxHeight : " << maximumHeight().value() << std::endl;
}

And here there is a screenshot with trouble region highlited by red.

Does smb know why it shows this way? I tried to use contents()->setHeight( ... ), Wt::WScrollArea but it didn't help.


Solution

  • It seems that you are using WBootstrapTheme for your application, and that theme sets max-height: 400px; for the dialog body. You can override that property using custom stylesheet:

    .my-dialog .modal-body
    {
      max-height: none;
    }
    

    Include it into your app and set your custom css class to the dialog:

    wApp->useStyleSheet("stylesheet.css");
    dialog = new MyDialog();
    dialog->addStyleClass("my-dialog");