markup in wxStaticText (Re: wxStaticText GTK woes)

Francesco Montorsi f18m_cpp217828 at yahoo.it
Thu Jan 11 06:14:31 PST 2007


Francesco Montorsi ha scritto:
>> FM> FM> I think that we could simply add a wxST_WITH_MARKUP style (and 
>> in future FM> a wxST_ELLIPSIZE) which define how the label passed to 
>> the wxStaticText FM> constructor should be handled...
>>
>>  Good idea! I'm definitely for using wxST_MARKUP style as you propose.
> good. Then I'll go with wxST_MARKUP.

Looking at  wxControl::GetLabelText()  I wonder if we couldn't just add 
markup support on by default...

Then we'd have the following public functions in wxStaticText:

   - SetLabel(): works as usual but recognizes not only mnemonics but 
also markup ('recognize' here means that when toolkit != GTK+2 the 
markup is stripped out)

   - GetLabel(): works as usual but returns the label not only with 
mnemonics, also with markup.


   - GetLabelText(): works as usual but not only strips out mnemonics; 
strips out also the markup. Both a static and non-static version of this 
function would be available.

   - [new] SetLabelText(): calls SetLabel() after escaping all 
occurrences of mnemonics and markup; could be used when the programmer 
wants to display e.g. HTML sources , i.e. does not want to have 
wxStaticText recognize mnemonics and markup.

   - eventually other static utility functions like
      - RemoveMarkup(const wxString &)
      - EscapeMarkup(const wxString &)
      - RemoveMnemonics(const wxString &)
      - EscapeMnemonics(const wxString &)

     The EscapeMarkup could be used to e.g. do:

       statText->SetLabel(wxStaticText::EscapeMarkup(wxT("2 > 1; this is 
a &mnemonic."));

      i.e. when the programmer needs mnemonics support _without_ markup 
support or viceversa.



The reasons why I'm proposing this change are:

  1) just like mnemonics-support is on by default (and cannot be 
disabled) it would be sensed to have markup support by default

  2) it would make wxWidgets sources less complicated.

  3) is we use wxST_MARKUP only a non-static version of GetLabelText() 
could be available (because it needs to check a wxStaticText object's 
style to understand if markup needs to be removed or not). This would be 
asymmetric with wxControl's GetLabelText.


The only drawback I see in adding markup support on by default is that 
some users will need to escape (double) quotes and < > symbols in their 
static labels (or switch to use SetLabelText)....

Thanks,
Francesco





More information about the wx-dev mailing list