markup in wxStaticText (Re: wxStaticText GTK woes)
Francesco Montorsi
f18m_cpp217828 at yahoo.it
Thu Jan 11 09:40:49 PST 2007
Vadim Zeitlin ha scritto:
> On Thu, 11 Jan 2007 15:14:31 +0100 Francesco Montorsi <f18m_cpp217828 at yahoo.it> wrote:
>
> FM> Looking at wxControl::GetLabelText() I wonder if we couldn't just add
> FM> markup support on by default...
>
> Is it really needed? I.e. why complicate things, is it really so difficult
> to call SetLabelMarkup() or use wxST_MARKUP style?
not so difficult just sometimes tricky (because e.g. in wxGTK things
which handle mnemonics & => _ conversion and such are implemented in
wxControl and e.g. in wxMSW there's the SS_ENDELLIPSIS style which is
sometimes used and sometimes not, etc).
> FM> Then we'd have the following public functions in wxStaticText:
> FM>
> FM> - SetLabel(): works as usual but recognizes not only mnemonics but
> FM> also markup ('recognize' here means that when toolkit != GTK+2 the
> FM> markup is stripped out)
>
> While '<' symbols are not used often in static labels, it still risks to
> be quite surprising to people who do use them.
yes... but if we document (just finished doc part of the patch) it and
put a note in the changelog it shouldn't be so surprising ;)
> FM> - GetLabel(): works as usual but returns the label not only with
> FM> mnemonics, also with markup.
>
> And this could potentially be even more surprising...
why?
GetLabel() is currently documented to return the string with the
mnemonics. It seems clear to me that it's logical that, now that markup
support is being added, it should return the string also with the markup.
As wxControl's docs say clearly, if you don't want mnemonics you should
use GetLabelText(). In case of wxStaticText, if you want
markup/mnemonics you'll have to use the wxStaticText::GetLabelText function.
> FM> - GetLabelText(): works as usual but not only strips out mnemonics;
> FM> strips out also the markup. Both a static and non-static version of this
> FM> function would be available.
> FM>
> FM> - [new] SetLabelText(): calls SetLabel() after escaping all
> FM> occurrences of mnemonics and markup; could be used when the programmer
> FM> wants to display e.g. HTML sources , i.e. does not want to have
> FM> wxStaticText recognize mnemonics and markup.
>
> Both of these could be useful though.
SetLabelText() can be added also if we keep the wxST_MARKUP style...
however just like all other functions it will act differently when this
style is present.
> FM> The reasons why I'm proposing this change are:
> FM>
> FM> 1) just like mnemonics-support is on by default (and cannot be
> FM> disabled) it would be sensed to have markup support by default
>
> Mnemonics are supported by all ports (except wxGTK1 maybe) while markup is
> GTK2-only (for now) and is also much less wide spread: all static texts
> have mnemonics normally but not all of them use markup.
right...
> FM> 2) it would make wxWidgets sources less complicated.
>
> I can't really judge about this but I don't really understand why?
see above for a very brief description of tricky things encountered so far.
well, it turns out that the current size of the patch (with only wxGTK,
wxMSW and wxMotif correctly patched) is more than 2000 lines
(unfortunately).
I did not want to make such big patch but it turned out so... (but most
of the size is due to code move from dlgcmn.cpp to stattextcmn.cpp and
similar and to the Ellipsize algorithm).
> FM> 3) is we use wxST_MARKUP only a non-static version of GetLabelText()
> FM> could be available
>
> Not a big deal IMO.
yes, sure, it mainly disturbs me because I see it as an "asimmetry"
between the wxControl::GetLabelText functions and wxStaticText's one.
I'm not sure too that removing wxST_MARKUP will lead to big benefits
(and I'm sure someone will complain about the change in behaviour of
SetLabel if we do that) but I wanted to make sure this possibility is
contemplated, too.
Francesco
More information about the wx-dev
mailing list