Fit wrapsizer sample after initial wrapping (PR #27036)

14 views
Skip to first unread message

Richard Thomson

unread,
Sep 20, 2026, 12:59:09 AM (2 days ago) Sep 20
to wx-...@googlegroups.com, Subscribed

The wrapsizer sample used the panel best size before wxWrapSizer had been laid out at the initial width. On MSW this could leave wrapped rows clipped and hide lower controls.

Size once from the initial best width, lay out the panel so wrapping updates its required height, then keep that width and apply the new height before showing the frame.

Fixes #10852


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/27036

Commit Summary

  • 59442ba Fit wrapsizer sample after initial wrapping

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27036@github.com>

VZ

unread,
Sep 20, 2026, 12:36:22 PM (2 days ago) Sep 20
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.


In samples/wrapsizer/wrapsizer.cpp:

> @@ -167,7 +167,13 @@ WrapSizerFrame::WrapSizerFrame()
     // Set sizer for the panel
     m_panel->SetSizer(sizerRoot);
 
-    SetClientSize(m_panel->GetBestSize());
+    // Let wxWrapSizer calculate its height for the initial width.

Is this really the only way to make this work correctly? It looks like something is missing in the API if we need all this to get the right layout...


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27036/review/5261078618@github.com>

Richard Thomson

unread,
Sep 21, 2026, 11:11:35 AM (17 hours ago) Sep 21
to wx-...@googlegroups.com, Subscribed

@LegalizeAdulthood commented on this pull request.


In samples/wrapsizer/wrapsizer.cpp:

> @@ -167,7 +167,13 @@ WrapSizerFrame::WrapSizerFrame()
     // Set sizer for the panel
     m_panel->SetSizer(sizerRoot);
 
-    SetClientSize(m_panel->GetBestSize());
+    // Let wxWrapSizer calculate its height for the initial width.

You're right, this is probably addressing the symptom rather than the underlying awkwardness.

The problem is that wxWrapSizer's required height depends on the width it is given, so the initial unconstrained GetBestSize() can't really answer the question the sample is asking. This patch forces the answer by doing an initial size/layout pass and then asking again, but that does make the sample depend on layout side effects.

There does seem to already be an API for this: wxWindow::GetMinSizeFromKnownDirection() forwards to the window's sizer, and wxWrapSizer::CalcMinSizeFromKnownDirection() implements the width-known calculation. So I think the better direction is to use that path directly for the sample's initial width, instead of doing the extra SetClientSize()/Layout() cycle. I'll rework it that way.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27036/review/5268308376@github.com>

Richard Thomson

unread,
Sep 21, 2026, 7:44:04 PM (8 hours ago) Sep 21
to wx-...@googlegroups.com, Push

@LegalizeAdulthood pushed 1 commit.

  • e072e6c Use width-aware sizing in wrapsizer sample


View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27036/before/be934c675ea881ebc947baf1aab16f5fde40c888/after/e072e6cd1fdb9e54ac1f750939cc2f6d80459e99@github.com>

Reply all
Reply to author
Forward
0 new messages