Search code examples
wxwidgets

wxWidgets v2.9.4 dialog window needs more space when using aero theme


When I design a wxWidgets dialog window using the windows classic theme, everything looks OK.

But when I run the app on a machine using the aero theme, spaces become enlarged and items begin to vanish below the bottom of the window.

This is wxWidgets v2.9.4. The problem does not occur under wxWidgets v2.8.12

Here is a screenshot of the same dialog, aero on the left classic on the right. Notice how the OK button has vanished when using aero!

enter image description here

How can I solve this problem? I would like the spacing of dialog elements to be identical under all themes.

Calling GetSizer()->Fit() hides this problem, by resizing the entire window according to the space needed by the theme that happens to be used. However, I would like to understand this problem better. I specify the borders around the widgets in pixels ( 5, 10, whatever ) and the font size does not appear to change ( I think ) so how can one theme use more space than another? Something weird is going on!

Here is the code for a simple dialog that demonstrates the problem.

class cMyDialog : public wxDialog
{
public:
    cMyDialog()
        : wxDialog(NULL,-1,L"Test Dialog")
    {
        wxStaticText * text = new wxStaticText(this,-1,
            L"Lorem ipsum dolor sit amet,\n"
            L"consectetur adipiscing elit.\n"
            L"Nulla porta aliquam urna,\n"
            L"in aliquam massa mattis at.\n"
            L"Lorem ipsum dolor sit amet,\n"
            L"consectetur adipiscing elit.\n"
            L"Nunc ullamcorper euismod lacus vel condimentum.\n"
            L"Sed id magna ac nisl placerat tristique eu sit amet lorem.\n"
            );
        wxButton * button = new wxButton(this,-1,"OK");
        wxSizer * szr = new wxBoxSizer(wxVERTICAL);
        szr->Add( text, 0, wxALL, 20 );
        szr->Add( button, 0, wxALL, 20 );
        SetSizer( szr );

    }
};

This was designed using the windows classic them and linked with wxwidgets v2.9.3. It looks like this when run under the same theme:

enter image description here

However, if you stop the app, change the theme to aero, the run the app again it looks like this:

enter image description here

Notice how the OK button has almost vanished from the bottom of the dialog.

( Also note that you must stop the app, change the theme, and restart the app. Sinmply changing the theme while the app is running does not cause any problem. )


Solution

  • The default font size under wxWidgets v2.9.4 is 9 points when the theme is 'aero', but it is 8 points when the theme is 'windows classic'. In v2.8.12 the default font is 8 points, no matter what theme was used.

    The result is that if I design my dialog layouts under one theme but the user runs the app using a different theme, the dialogs are laid out differently. The widgets need more or less space, depending on the theme. The worst problem is that the OK/CANCEL buttons which I conventionally place at the bottom of the dialog will appear or disappear depending on which theme is selected. This upsets users!

    Explicitly setting the font size to 8 points fixes the problem.

    ( How this be!!!!!!!!!!!!!! I cannot imagine the justification for making such a change, breaking every dialog that is upgraded. )

    Apparently it is microsoft's fault - they changed the default font size 'to improve readability'. ( http://en.wikipedia.org/wiki/Windows_Aero#Font ) Idiots! Now I have to specify the font size in every application, so that the dialog's have the same layout no matter what theme the end user's select. Sigh!

    If it wasn't such a disaster, it might be funny. wxWidgets is supposed to be cross-platform, but now it isn't even cross-theme any more.