wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
6.14k stars 1.76k forks source link

Shouldn't the function wxControl::RemoveMarkup moved to public class functions? #24823

Open rossanoparis opened 1 month ago

rossanoparis commented 1 month ago

Description

I'm sorry, I'm not a wx library developer, and I'm not able to get my hands dirty in it, but I would like to propose this small modification I'm going to describe ...

Regarding wxStaticText there is the public static function wxControl::RemoveMnemonics which is very useful to get a text as it will appear, before applying it to the control.

In my opinion, even the static function wxControl::RemoveMarkup should be public instead of protected. The two function are similar in their purpose, aren't they? Is there a specific reason for keeping wxControl::RemoveMarkup as protected?

Thank you, regards

vadz commented 1 month ago

There is no need for a reason to make function protected or private, what we need is a reason to add it to the public API and I don't see one there. Markup used with wxControl is pretty specific to its use for labels and I don't see why would you use it anywhere else than in the implementation of the classes using these labels themselves.

What exactly do you want to use this function for and are you aware of the exact markup syntax this function recognizes?

rossanoparis commented 1 month ago

Thank you for your reply.

are you aware of the exact markup syntax this function recognizes?

yes, it should be described in wxStaticText documentation

What exactly do you want to use this function for

Mainly because it is very useful to get a text as it will appear, before applying it to the control. Reasons for using the function in that way could be different, but perhaps none of them are so important to give you a specific one. I use the function wxControl::RemoveMnemonics for the reason I've written, and stupidly, I would have espected to be able to use wxControl::RemoveMarkup in the same way.

Thank you, regards

vadz commented 1 month ago

To be honest, I find this pretty unconvincing, i.e. I still don't see why would it be very useful.

Let's see if anybody else thinks we should make this part of the public API, but if not, I don't think this passes the bar for inclusion, sorry.

rossanoparis commented 1 month ago

I understand this isn't a critical issue, and I can certainly find a workaround for my code. However, it would be nice if you could consider adding some symmetry to the function RemoveMnemonics. Anyway, thank you ... in the meantime, I'll keep my fingers crossed :)

regards

KeyWorksRW commented 1 month ago

The following works (result == "Here be italic"), though of course it does mean you are using a private class which is not guaranteed to always be available:

#include <wx/private/markupparser.h>

wxString markup_test("Here be <span fgcolor=\'red\'><i>italic</i></span>");
auto result = wxMarkupParser::Strip(markup_test);
rossanoparis commented 1 month ago

@Thank you @KeyWorksRW it was very kind of you