Tuesday, February 22, 2011

Markup in control labels

As I'm hopelessly out of date with my planned updates anyhow, I've decided to write a brief post about a nice new feature that was recently added to wx instead:

This feature is the possibility to use Pango-like markup in some wxWidgets controls, notably wxButton and wxStaticText. This means that it is now possible to write
wxButton *b = new wxButton(parent, wxID_ANY, "");
b->SetLabelMarkup("<span size='x-large' color='blue'>Big</span> <b>bold</b> button");
and it will indeed behave as expected:
MSW button with markup OS X button with markup GTK+ button with markup

Currently this works for wxButton in all major ports and for the wxGTK and the generic versions of wxStaticText (that can be used under all platforms if this feature is important). The plan is to extend this to more controls later, e.g. wxCheckBox, wxRadioButton or wxStaticBox and maybe even allow using markup for the items of controls with multiple items such as wxListBox or wxComboBox. There is however no definite schedule for this so if anybody is interested in using markup with these controls, please consider helping with implementing it, it should be pretty simple to do by simply copying wxButton behaviour.

3 comments:

golfnut said...

Great! That is exactly what I have been looking for. Is it currently available and if so, which release is supporting it?

Thanks,
Alan

VZ said...

You need svn to use this currently but it will be part of 2.9.2 release which should be done Really Soon Now.

zooplah said...

It sounds cool, but don't you think it's a bit late in the 3.0 development cycle to add all these new features? I dig wanting to get as much as possible into 3.0, but it needs adequate testing and not this "2.9.2 will be released soon and will be the last beta before 3.0" thing.