Minimum height of notebook page too small at high DPI (Issue #24606)

44 views
Skip to first unread message

taler21

unread,
Jun 13, 2024, 3:36:57 AMJun 13
to wx-...@googlegroups.com, Subscribed

Description

The minimum height of a wxNotebook page calculated by a wxSizer is too small at high DPI.

The issue can be reproduced with the following changes to the minimal sample:

Patch for minimal sample
diff --git "a/samples/minimal/minimal.cpp" "b/samples/minimal/minimal.cpp"
index 5f32257c6b..d1c8492950 100644
--- "a/samples/minimal/minimal.cpp"
+++ "b/samples/minimal/minimal.cpp"
@@ -26,6 +26,8 @@
     #include "wx/wx.h"
 #endif
 
+#include "wx/notebook.h"
+
 // ----------------------------------------------------------------------------
 // resources
 // ----------------------------------------------------------------------------
@@ -69,6 +71,58 @@ private:
     wxDECLARE_EVENT_TABLE();
 };
 
+class MyDialog : public wxDialog
+{
+public:
+    MyDialog( wxWindow *parent )
+    {
+        wxDialog::Create( parent, wxID_ANY, "MyDialog" );
+
+        CreateControls();
+        GetSizer()->SetSizeHints(this);
+        Centre();
+    }
+
+private:
+    void CreateControls();
+};
+
+void MyDialog::CreateControls()
+{
+    wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
+    SetSizer( topSizer );
+
+#if 1
+
+    wxNotebook *nb = new wxNotebook( this, wxID_ANY );
+    topSizer->Add( nb, 1, wxGROW|wxALL, 5 );
+
+    for ( int i = 1; i <= 2; ++i )
+    {
+        wxPanel *page = new wxPanel( nb, wxID_ANY );
+        nb->AddPage( page, wxString::Format("Page %d", i) );
+
+        wxBoxSizer *pageSizer = new wxBoxSizer( wxVERTICAL );
+        page->SetSizer( pageSizer );
+
+        wxWindow *check = new wxCheckBox( page, wxID_ANY, "A g j" );
+        wxWindow *combo = new wxComboBox( page, wxID_ANY, "A g j" );
+
+        pageSizer->Add( (i == 1) ? check : combo );
+        pageSizer->Add( (i == 1) ? combo : check );
+    }
+
+#else
+
+    wxCheckBox *check = new wxCheckBox( this, wxID_ANY, "A g j" );
+    topSizer->Add( check, 0, wxALL, 0 );
+
+    wxComboBox *combo = new wxComboBox( this, wxID_ANY, "A g j" );
+    topSizer->Add( combo, 0, wxALL, 0 );
+
+#endif
+}
+
 // ----------------------------------------------------------------------------
 // constants
 // ----------------------------------------------------------------------------
@@ -188,6 +242,10 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
 {
+    MyDialog dlg(this);
+    dlg.ShowModal();
+    return;
+
     wxMessageBox(wxString::Format
                  (
                     "Welcome to %s!\n"

To Reproduce:

  1. Start the minimal sample.
  2. Press the F1 key to show the dialog with a notebook.

At a DPI scaling of 100%, the calculated minimum height is correct.
myDialog-dpi-scale-100.png (view on web)

At a DPI scaling of 200%, the calculated minimum height is a bit too small.
The bottom control on each notebook page is displayed a bit cut off.
myDialog-dpi-scale-200.png (view on web)

At a DPI scaling of 300%, the calculated minimum height is much too small.
The bottom control on each notebook page is displayed even more cut off.
myDialog-dpi-scale-300.png (view on web)

Platform and version information

  • wxWidgets version you use: 3.2.5 and master (7f5ca30)
  • wxWidgets port you use: wxMSW
  • OS and its version: Windows 10


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24606@github.com>

VZ

unread,
Jun 22, 2024, 2:04:53 PM (13 days ago) Jun 22
to wx-...@googlegroups.com, Subscribed

Would

diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp
index a0c11cd41a..9f0cbbd2d2 100644
--- a/src/msw/notebook.cpp
+++ b/src/msw/notebook.cpp
@@ -561,7 +561,7 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
     const int rows = GetRowCount();
 
     // add an extra margin in both directions
-    const int MARGIN = 8;
+    const int MARGIN = FromDIP(8);
     if ( IsVertical() )
     {
         sizeTotal.x += MARGIN;

help with this by chance?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24606/2184133658@github.com>

taler21

unread,
Jun 24, 2024, 2:11:38 AM (11 days ago) Jun 24
to wx-...@googlegroups.com, Subscribed

Yes, that fixes this issue. Many thanks!

Please also backport the fix to 3.2.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24606/2185689252@github.com>

VZ

unread,
Jul 3, 2024, 7:34:59 PM (2 days ago) Jul 3
to wx-...@googlegroups.com, Subscribed

Closed #24606 as completed via f43779d.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/24606/issue_event/13387415309@github.com>

Reply all
Reply to author
Forward
0 new messages