Enable text wrapping inside a vertical sizer for wxStaticText (PR #25753)

104 views
Skip to first unread message

RobertRoeb

unread,
Sep 2, 2025, 10:58:12 AMSep 2
to wx-...@googlegroups.com, Subscribed

Changed the wxWrapSizer code from using a variable "m_usedLast" to two different functions
CalcMinFirstPass() and CalcMin() for the two step min size calculation.
Added the same logic and naming to controls using GetEffectiveMinSizeFirstPass()
Implemented this for the generic code in wxStaticTextBase.
Added test to wrapsizer sample.


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

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

Commit Summary

  • 45906cc Enable text wrapping inside a vertical size for wxStaticText similar to wxWrapSizer

File Changes

(9 files)

Patch Links:


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/pull/25753@github.com>

RobertRoeb

unread,
Sep 2, 2025, 11:00:58 AMSep 2
to wx-...@googlegroups.com, Subscribed
RobertRoeb left a comment (wxWidgets/wxWidgets#25753)

So far only tested on GTK+. Will test on OSX later the week. I would appreciate testing on MSW.


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/pull/25753/c3245720953@github.com>

VZ

unread,
Sep 2, 2025, 11:03:40 AMSep 2
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25753)

Before looking at it, could you please explain the relationship between this and wxWrapSizer? I mean, they do conceptually similar things, but other than that, there is none, right?

Also, I don't know if we want to do this unconditionally or if some flag is specified. While people probably don't want their labels being truncated, they may not want them to take more than one line too... And the interaction of this with ellipsize flags is not clear at all.


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/pull/25753/c3245731821@github.com>

VZ

unread,
Sep 2, 2025, 11:14:10 AMSep 2
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.

Sorry, there are a number of things to fix here, but more importantly I see 2 changes here that should ideally correspond to 2 commits:

  1. Addition of GetEffectiveMinSizeFirstPass() and changing wxWrapSizer to use it.
  2. Changes to wxStaticText.

(1) is probably fine, but it really needs to be documented.

For (2) I'm still not sure if we want to do it unconditionally or depending on a flag. If nothing else, this almost certainly shouldn't override explicit calls to Wrap() in the user code as it, I believe, does now.


In include/wx/sizer.h:

> +    // Can be overidden for two step process, e.g. by wxWrapSizer
+    virtual wxSize CalcMinFirstPass() { return CalcMin(); }

It would be nice to explain what the two step process is, because this is really not obvious.

Also, wxWrapSizer doesn't really need it, as it worked before adding it, so this makes things even more confusing.


In include/wx/window.h:

> @@ -411,6 +411,7 @@ class WXDLLIMPEXP_CORE wxWindowBase : public wxEvtHandler
         // minimum size, giving priority to the min size components, and
         // returns the results.
     virtual wxSize GetEffectiveMinSize() const;
+    virtual wxSize GetEffectiveMinSizeFirstPass() const { return  GetEffectiveMinSize(); }

This should really be documented (in a comment here and in interface/wx/window.h) because I just have no idea how to use it right now.


In include/wx/stattext.h:

> @@ -72,6 +77,12 @@ class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl
     // display.
     void UpdateLabel();
 
+    // save unwrapped label to allow to call Wrap() several times and 
+    // always starting from the original, unwrapped label
+    wxString m_unwrappedLabel;

Is this different from wxControl::m_labelOrig?


In include/wx/stattext.h:

> @@ -72,6 +77,12 @@ class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl
     // display.
     void UpdateLabel();
 
+    // save unwrapped label to allow to call Wrap() several times and 
+    // always starting from the original, unwrapped label
+    wxString m_unwrappedLabel;
+    int m_currentWrap = 0;

What is the value of this? Wrap width? With 0 meaning "none"? Please comment it too.


In samples/wrapsizer/wrapsizer.cpp:

> @@ -118,10 +118,13 @@ WrapSizerFrame::WrapSizerFrame()
 
         sizerMidWrap->Add(chk, wxSizerFlags().Centre().Border());
     }
-

Please avoid mixing whitespace-only changes with significant ones if possible.


In samples/wrapsizer/wrapsizer.cpp:

>      sizerMid->Add(sizerMidWrap, wxSizerFlags(100).Expand());
     sizerRoot->Add(sizerMid, wxSizerFlags(100).Expand().Border());
 
+    // A long wxStaticText that wraps like a wxWrapSizer

Really not sure this belongs to this sample anyhow. I'd rather add a button setting a long label to the "widgets" sample.


In src/common/stattextcmn.cpp:

> @@ -213,8 +213,46 @@ class wxLabelWrapper : public wxTextWrapper
 
 void wxStaticTextBase::Wrap(int width)
 {
+    if (width == m_currentWrap) return;

Please don't do this:

⬇️ Suggested change
-    if (width == m_currentWrap) return;
+    if (width == m_currentWrap)
+        return;

In src/common/stattextcmn.cpp:

> @@ -213,8 +213,46 @@ class wxLabelWrapper : public wxTextWrapper
 
 void wxStaticTextBase::Wrap(int width)
 {
+    if (width == m_currentWrap) return;
+    m_currentWrap = width;
+
+    // Allow for repeated calls to Wrap with different values
+    if (m_unwrappedLabel.IsNull()) 

Please use standard functions instead of wx 1.x ones

⬇️ Suggested change
-    if (m_unwrappedLabel.IsNull()) 
+    if (m_unwrappedLabel.empty()) 

In src/common/stattextcmn.cpp:

>      wxLabelWrapper wrapper;
     wrapper.WrapLabel(this, width);
+    InvalidateBestSize();
+}
+
+wxSize wxStaticTextBase::GetEffectiveMinSizeFirstPass() const
+{
+    // While wxWrapSizer can only wrap entire controls, a text paragraph
+    // could theoretically wrap at a few letters, so we start with
+    // requesting very little space in the first pass
+    return wxSize( 10, 10 );

Could we avoid hardcoding magic numbers please? It would make sense to use GetCharWidth() or something else based it.


In src/common/stattextcmn.cpp:

> +
+wxSize wxStaticTextBase::GetEffectiveMinSizeFirstPass() const
+{
+    // While wxWrapSizer can only wrap entire controls, a text paragraph
+    // could theoretically wrap at a few letters, so we start with
+    // requesting very little space in the first pass
+    return wxSize( 10, 10 );
+}
+
+bool wxStaticTextBase::InformFirstDirection(int direction, int size, int WXUNUSED(availableOtherDir))
+{
+    // In the second pass, this control has been given "size" amount of
+    // space in the horizontal direction. Wrap there and report a new
+    // GetEffectiveMinSize() from then on.
+
+    if (direction != wxHORIZONTAL) return false;
⬇️ Suggested change
-    if (direction != wxHORIZONTAL) return false;
+    if (direction != wxHORIZONTAL)
+        return false;

In src/common/stattextcmn.cpp:

> +    // While wxWrapSizer can only wrap entire controls, a text paragraph
+    // could theoretically wrap at a few letters, so we start with
+    // requesting very little space in the first pass
+    return wxSize( 10, 10 );
+}
+
+bool wxStaticTextBase::InformFirstDirection(int direction, int size, int WXUNUSED(availableOtherDir))
+{
+    // In the second pass, this control has been given "size" amount of
+    // space in the horizontal direction. Wrap there and report a new
+    // GetEffectiveMinSize() from then on.
+
+    if (direction != wxHORIZONTAL) return false;
+
+    int style = GetWindowStyleFlag();
+    SetWindowStyleFlag( style | wxST_NO_AUTORESIZE );

It looks like we could avoid calling it unnecessarily (and also below):

⬇️ Suggested change
-    SetWindowStyleFlag( style | wxST_NO_AUTORESIZE );
+    if ( !(style & wxST_NO_AUTORESIZE) )
+        SetWindowStyleFlag( style | wxST_NO_AUTORESIZE );

In src/common/wincmn.cpp:

> @@ -859,21 +859,39 @@ wxSize wxWindowBase::GetEffectiveMinSize() const
     // merge the best size with the min size, giving priority to the min size
     wxSize min = GetMinSize();
 
+    const wxStaticText *text = dynamic_cast<const wxStaticText*>(this);

Please remove this and all the other changes to this file.


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/pull/25753/review/3176982057@github.com>

RobertRoeb

unread,
Sep 2, 2025, 1:54:37 PMSep 2
to wx-...@googlegroups.com, Subscribed

@RobertRoeb commented on this pull request.


In include/wx/sizer.h:

> +    // Can be overidden for two step process, e.g. by wxWrapSizer
+    virtual wxSize CalcMinFirstPass() { return CalcMin(); }

wxWrapSizer called CalcMin() several times, but with different behaviour, but instead of using either a flag or two different calls, it set a flag in wxSizer::InformFirstDirection() which altered the behaviour of CalcMin(). I tried to use CalcMinFirstPass() or CalcMin( bool firstpass = false ); for both wrapsizer and a wrapped control, but there sizers and controls are handled differently in wxSizer::Layout()


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/pull/25753/review/3177583041@github.com>

RobertRoeb

unread,
Sep 2, 2025, 2:01:05 PMSep 2
to wx-...@googlegroups.com, Subscribed
RobertRoeb left a comment (wxWidgets/wxWidgets#25753)

Before looking at it, could you please explain the relationship between this and wxWrapSizer?
I mean, they do conceptually similar things, but other than that, there is none, right?

The code in wxSizer() always assumed this behaviour for wxWrapSizer and wxStaticText. It just
didn't work until now. This is even documented for probably 10 years:

https://docs.wxwidgets.org/3.2/classwx_window.html#a9fd5b6520c1b30eb8e82bb5d56bc24c0

Also, I don't know if we want to do this unconditionally or if some flag is specified. While
people probably don't want their labels being truncated, they may not want them to take
more than one line too... And the interaction of this with ellipsize flags is not clear at all.

This only happens inside of a vertical sizer, which calls InformsFirstDirection() to for the sole
purpose of wrapping the text. This change makes multiline text usable in sizers and should
not have an effect otherwise.


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/pull/25753/c3246301207@github.com>

RobertRoeb

unread,
Sep 2, 2025, 2:04:23 PMSep 2
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/45906cc1f583b28b734393dd6e064c364e417ed3/after/ac68407fb7a522f9498044d33fb9ffbdd1018a54@github.com>

RobertRoeb

unread,
Sep 2, 2025, 2:04:58 PMSep 2
to wx-...@googlegroups.com, Subscribed

@RobertRoeb commented on this pull request.


In include/wx/window.h:

> @@ -411,6 +411,7 @@ class WXDLLIMPEXP_CORE wxWindowBase : public wxEvtHandler
         // minimum size, giving priority to the min size components, and
         // returns the results.
     virtual wxSize GetEffectiveMinSize() const;
+    virtual wxSize GetEffectiveMinSizeFirstPass() const { return  GetEffectiveMinSize(); }

Right, will do


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/pull/25753/review/3177610609@github.com>

RobertRoeb

unread,
Sep 2, 2025, 2:07:44 PMSep 2
to wx-...@googlegroups.com, Subscribed

@RobertRoeb commented on this pull request.


In include/wx/stattext.h:

> @@ -72,6 +77,12 @@ class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl
     // display.
     void UpdateLabel();
 
+    // save unwrapped label to allow to call Wrap() several times and 
+    // always starting from the original, unwrapped label
+    wxString m_unwrappedLabel;

I could not figure out of the stripping of markup and/or mnemonics and/or the ellipsis code would alter m_labelOrig. I think m_labelOrig is the before any change, and m_unwrappedLabel is after the other changes, but before wrapping.


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/pull/25753/review/3177618535@github.com>

RobertRoeb

unread,
Sep 2, 2025, 2:10:55 PMSep 2
to wx-...@googlegroups.com, Subscribed

@RobertRoeb commented on this pull request.


In include/wx/stattext.h:

> @@ -72,6 +77,12 @@ class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl
     // display.
     void UpdateLabel();
 
+    // save unwrapped label to allow to call Wrap() several times and 
+    // always starting from the original, unwrapped label
+    wxString m_unwrappedLabel;
+    int m_currentWrap = 0;

0 means no wrapping (will add comment). The current value needs to be saved to prevent uncountable recalculations of the wrapping code during the wxSizer Layout() process (as you probably guessed).


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/pull/25753/review/3177626872@github.com>

RobertRoeb

unread,
Sep 2, 2025, 2:12:39 PMSep 2
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/ac68407fb7a522f9498044d33fb9ffbdd1018a54/after/752ece6f3f588ea120f99d9e8e1de154d52ca7c1@github.com>

RobertRoeb

unread,
Sep 2, 2025, 4:04:57 PMSep 2
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.

  • bd0c8e8 Avoid unnecessary call of setting flag


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/752ece6f3f588ea120f99d9e8e1de154d52ca7c1/after/bd0c8e84796d8df38ffc0803a9fa271e67785a98@github.com>

VZ

unread,
Sep 2, 2025, 5:34:57 PMSep 2
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.


In include/wx/sizer.h:

> +    // Can be overidden for two step process, e.g. by wxWrapSizer
+    virtual wxSize CalcMinFirstPass() { return CalcMin(); }

wxWrapSizer was, AFAIR, somewhat of a hack and it's great to replace it with something better but this something should be documented/explained.

Maybe documenting it would also give some idea for a better name because, frankly, "first pass" is not great: it doesn't mean anything per se and implies the existence of "second pass" which doesn't actually exist.


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/pull/25753/review/3178199506@github.com>

VZ

unread,
Sep 2, 2025, 5:36:22 PMSep 2
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.


In include/wx/stattext.h:

> @@ -72,6 +77,12 @@ class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl
     // display.
     void UpdateLabel();
 
+    // save unwrapped label to allow to call Wrap() several times and 
+    // always starting from the original, unwrapped label
+    wxString m_unwrappedLabel;

I think you're right, but is it really worth storing it separately instead of just stripping the other stuff from m_labelOrig?

It's not just about optimizing memory usage but also, in more places we store redundant information, more places we need to remember to update later.


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/pull/25753/review/3178202327@github.com>

VZ

unread,
Sep 2, 2025, 5:39:45 PMSep 2
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25753)

This only happens inside of a vertical sizer, which calls InformsFirstDirection() to for the sole purpose of wrapping the text.

Wait, does this mean that wrapping still won't work in a wxFlexGridSizer? This makes it significantly less useful and potentially very, very confusing: there are no other examples of controls (AFAIK) that appear differently depending on the sizer they're placed in.

Can we make it work for 2D sizers too?


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/pull/25753/c3246887197@github.com>

RobertRoeb

unread,
Sep 3, 2025, 10:27:37 AMSep 3
to wx-...@googlegroups.com, Subscribed
RobertRoeb left a comment (wxWidgets/wxWidgets#25753)

Wait, does this mean that wrapping still won't work
in a wxFlexGridSizer?

It should work there as well. I meant any vertical compartment in any sizer. And with my code it works for controls as well, although I cannot think of any apart from display of text. Well, a text editor or a HTML window, maybe.


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/pull/25753/c3249497493@github.com>

RobertRoeb

unread,
Sep 7, 2025, 8:51:19 AMSep 7
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 2 commits.

  • bd21c4c Added documentation for new xxx FirstPass() methods
  • 15e9d67 Document the new behaviour in wxStaticText


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/bd0c8e84796d8df38ffc0803a9fa271e67785a98/after/15e9d672f72720e0bba074387f407b4cfe356263@github.com>

RobertRoeb

unread,
Sep 7, 2025, 11:52:50 AMSep 7
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.

  • 73c86c6 Added missing override statement


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/15e9d672f72720e0bba074387f407b4cfe356263/after/73c86c6a1b28b3fe2613dfba0587f1d3bf03a3e3@github.com>

RobertRoeb

unread,
Sep 7, 2025, 12:37:39 PMSep 7
to wx-...@googlegroups.com, Subscribed
RobertRoeb left a comment (wxWidgets/wxWidgets#25753)

I can confirm that the PR works on GTK, OSX and MSW. Thanks for the technical and mental support from VZ for setting git up and making this possible.


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/pull/25753/c3263893796@github.com>

VZ

unread,
Sep 7, 2025, 1:38:29 PMSep 7
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25753)

Could you please check the CI failures? There are some trivial to fix compile errors, but this also broke wxWrapSizer unit tests.


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/pull/25753/c3263929361@github.com>

RobertRoeb

unread,
Sep 7, 2025, 3:24:10 PMSep 7
to wx-...@googlegroups.com, Subscribed
RobertRoeb left a comment (wxWidgets/wxWidgets#25753)

I will look at the compile errors, but doing further test scenarios I encountered a situation that might constitute an unexpected change of behaviour. If you put a vertical wxStaticBoxSizer in a dialog and you add two wxStaticText elements into it, the previous code stretched the wxStaticBoxSizer horizontally until the wxStaticText would fit it using a single line each. Previously, there was no way to make the wxStaticText wrap elegantly if the text was too long - you could just set a hard wrap at a e.g. 200px. But the point is: if your dialog layout relied on an expectation that the text would force the owning sizer to stretch, then that layout will be broken with the new code. Here is my artistic explanation
Before
+--wxStaticBox--------------------------
| This is a long text that stretches the box
| This is short text
| ( ) wxCheckBox
| What ever else here
+----------------------------------------

Now
+--wxStaticBox----------
| This is a long text
| that wraps in the box
| This is short text
| ( ) wxCheckBox
| What ever else here
+------------------------

I need to think if we need a wxST_WRAP_IN_SIZER or a wxWrapStaticText in order not to break anything.


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/pull/25753/c3263988123@github.com>

VZ

unread,
Sep 7, 2025, 5:00:10 PMSep 7
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25753)

FWIW, I didn't have time to really think about this yet, but since the very beginning I thought we would add a style (wxST_WRAP) or a function (AllowWrap()?) instead of making the new behaviour unconditional.


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/pull/25753/c3264038151@github.com>

RobertRoeb

unread,
Sep 9, 2025, 4:41:33 AMSep 9
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/73c86c6a1b28b3fe2613dfba0587f1d3bf03a3e3/after/df9a9be67ccc16bd639ce8192c1bdc67517f0bf3@github.com>

RobertRoeb

unread,
Sep 9, 2025, 5:36:20 AMSep 9
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/df9a9be67ccc16bd639ce8192c1bdc67517f0bf3/after/d07482af90173c51bbbc50efbd423ff86a67ada0@github.com>

RobertRoeb

unread,
Sep 9, 2025, 1:05:05 PMSep 9
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.

  • 212f1bb Converted tests to use new CalcMinFirstPass()


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/d07482af90173c51bbbc50efbd423ff86a67ada0/after/212f1bbf16cde44deaf95c1118238a4a6d983e80@github.com>

RobertRoeb

unread,
Sep 9, 2025, 1:21:14 PMSep 9
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/212f1bbf16cde44deaf95c1118238a4a6d983e80/after/5f2f5abf27bdc0ee3cb86f96d28e3e8283ef3ff9@github.com>

RobertRoeb

unread,
Sep 9, 2025, 2:05:30 PMSep 9
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.

  • 5ec6de1 Fix spelling and trailing white spaces

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/5f2f5abf27bdc0ee3cb86f96d28e3e8283ef3ff9/after/5ec6de114e2f6f4353f182cf9737aa2fa407c2fa@github.com>

RobertRoeb

unread,
Sep 9, 2025, 3:00:27 PMSep 9
to wx-...@googlegroups.com, Subscribed
RobertRoeb left a comment (wxWidgets/wxWidgets#25753)

Added wxST_WRAP, fixed tests and spelling mistakes


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/pull/25753/c3271927338@github.com>

RobertRoeb

unread,
Sep 23, 2025, 12:20:29 PM (13 days ago) Sep 23
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.

  • 9d7c647 Incorporated PR #751 to work with zero width spaces


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/5ec6de114e2f6f4353f182cf9737aa2fa407c2fa/after/9d7c647f00a0a419b7a1d99755b29e7d22f91c3c@github.com>

RobertRoeb

unread,
Sep 23, 2025, 3:24:38 PM (13 days ago) Sep 23
to wx-...@googlegroups.com, Push

@RobertRoeb pushed 1 commit.

  • 6f03759 Replaced the code with one that works in UTF8 mode

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/9d7c647f00a0a419b7a1d99755b29e7d22f91c3c/after/6f0375926859a5bdd259ccdaff82dda124f7ab5c@github.com>

VZ

unread,
Sep 27, 2025, 5:03:48 PM (9 days ago) Sep 27
to wx-...@googlegroups.com, Push

@vadz pushed 17 commits.

  • ab1abd8 Merge remote-tracking branch 'origin/master' into stattext-wrap
  • bed939a Update comments in wxWrapSizer code to make more sense
  • 3c0af77 Improve documentation of the new "first pass" functions
  • 35dd0ff Make wxWindow::GetEffectiveMinSize() code a bit more clear
  • 3077b5b Rationalize the new added "first pass" functions
  • 8be3003 Don't make "Static" page in the widgets sample so wide
  • f60de85 Disable "Ellipsize" checkbox on the "static" widgets sample page
  • 3b37a1a Test wxST_WRAP in the "Static" page of the widgets sample too
  • 909380b Rename variable with a nonsensical name in the widgets sample
  • b41d245 fixup! Enable text wrapping inside a vertical size for wxStaticText similar to wxWrapSizer
  • b0abba3 Return correct min size for wrapped wxStaticText
  • ec6f493 fixup! Added documentation for new xxx FirstPass() methods
  • abe8a3a fixup! Added wxST_WRAP flag
  • 9611d38 fixup! Enable text wrapping inside a vertical size for wxStaticText similar to wxWrapSizer
  • 90da7cb fixup! Enable text wrapping inside a vertical size for wxStaticText similar to wxWrapSizer
  • bcb5f04 Revert support for ZWSP in wxTextWrapper
  • cd24a29 Add support for wrapping on non-ASCII space characters

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25753/before/6f0375926859a5bdd259ccdaff82dda124f7ab5c/after/cd24a290df51486af9c76bd060c07f2179face49@github.com>

VZ

unread,
Sep 27, 2025, 5:35:06 PM (9 days ago) Sep 27
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25753)

I've done some changes here to make this more or less mergeable. Not counting minor corrections (including those needed to make CI builds pass), they are:

  1. Rename the new functions to make them make at least some sense to wxWidgets users.
  2. Actually made wxStaticText wrapping work in normal use, which wasn't at all the case before because GetMinSizeUsingLayoutDirection() always returned enough vertical space for just one line.
  3. Added demonstration of this to the widgets sample where you can actually see how it works instead of seeing... something? I am still not sure what... in the wrap sizer sample (BTW, I'd like to revert all changes to it, I still don't see what they have to do with wrap sizer and absolutely nobody would think to look for wxStaticText wrapping there).
  4. Provided more reasonable support for Unicode spaces in wxTextWrapper.

I'm still unhappy about several things but I don't have time to work on them myself:

  1. Current API for layout direction-dependent layout is really bad, you have to override 2 functions (InformFirstDirection() and GetMinSizeUsingLayoutDirection()) and store the parameters of the first one in order to use them in the second one. This is clearly suboptinal and we should, ideally, have something superseding them both, i.e. providing them the size available in the minor layout direction and returning the actual size required. This would make things much simpler and make more sense and I think we could make this backwards compatible by just calling InformFirstDirection() and then GetMinSize() from the new function. I'd really like to do this...
  2. There are no tests for the new behaviour, which is really a pity as it makes me hesitate to make more improvements, such as changing the above.
  3. wxST_WRAP should really work even if the object is not inside the sizer, it looks like it could be implemented by simply rewrapping the string with the current width on resize.
  4. Storing "original" string and "unwrapped" string is necessary now (as the comment I added explains), but this is clearly not ideal. Ideal would be to avoid changing the internal label from Wrap(), i.e. change just the label used by the underlying control (of course, the generic one would have to store it then).


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/pull/25753/c3342061802@github.com>

RobertRoeb

unread,
Oct 5, 2025, 12:00:00 PM (18 hours ago) Oct 5
to wx-...@googlegroups.com, Subscribed
RobertRoeb left a comment (wxWidgets/wxWidgets#25753)

Hi again, what is the current plan on this PR? I read your comments that not everything is perfect, but I always get nervous if a PR is waiting in queue. Further improvements could also be in later PR and the current PR does solve the issue it is supposed to solve (and the code was actually planning to solve 15 years ago).


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/pull/25753/c3369149308@github.com>

VZ

unread,
Oct 5, 2025, 1:06:26 PM (17 hours ago) Oct 5
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25753)

I hoped to work on (1) this weekend but I unfortunately couldn't find time to do it for unrelated reasons. Thinking more about this, we really shouldn't build more bad API on the existing bad InformFirstDirection() and adding a new GetMinSizeForKnownSizeInDirection() or maybe, following GTK, GetMinWidthForHeight() and GetMinHeightForWidth(), seems like a much better idea so I'd really like to do it before merging the new function into master.


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/pull/25753/c3369188467@github.com>

Reply all
Reply to author
Forward
0 new messages