wxStaticText GTK woes

Francesco Montorsi f18m_cpp217828 at yahoo.it
Wed Jan 3 01:32:54 PST 2007


Hi Vadim,

Vadim Zeitlin ha scritto:
> On Tue, 02 Jan 2007 09:08:58 +0200 Peter Gordon <peter at pg-consultants.com> wrote:
> 
> PG> On Windows it works either way. On GTK2, I can detect movement, but
> PG> Entering and Leaving are always false, and I never get an ENTER or LEAVE
> PG> event.
> PG> 
> PG> Is there a workaround on GTK2?
> 
>  Only to create an extra wxWindow, make wxStaticText child of it and catch
> enter/leave for the outside window. wxStaticText itself doesn't have a real
> window under GTK and so there are no entering/leaving events generated for
> it. It would be nice to change wxGTK to create such container window
> automatically but so far nobody had time to do it.
I'd say however that such container window (as Paul suggested a 
GtkEventBox would be perfect) should be created only if it's needed: 
i.e. if the user calls some SetBackgroundColour or needs mouse events on 
it. Otherwise we would end up creating hundreds of additional windows in 
all those wxGTK programs which don't really need them making them a bit 
slower and a bit more memory hungry.


> PG> A second problem I have is that I want the text to appear underlined. I
> PG> use font.SetUnderlined(true) to set the font. Again, on Windows it works
> PG> but on GTK2 there is no underlining. Again, any advice would be
> PG> appreciated.
> 
>  GTK+ doesn't support underlined fonts natively so we have to deal with
> this at wx level. In this particular case, we should be using
> gtk_label_set_markup(wxString::Format("<u>%s</u>", label)) instead of
> gtk_label_set_text(label) if the current font is underlined probably. If
> you could make a patch (http://www.wxwidgets.org/technote/patches.htm)
> implementing this, it would be most welcome.
About this I wonder if we could add a

  wxStaticText::SetDecoratedLabel

or

  wxStaticText::SetLabelWithMarkup

which behaves as:

  1) on wxGTK just passes the text to gtk_label_set_markup()
  2) on other platforms strips aways all <u>, <i>, <b> tags and then 
calls SetLabel()

That would indeed very useful to take advantage of Pango capabilities on 
wxGTK port when needed. E.g. if I want a static text containing "Hello 
<b>world</b>" I currently can't do it now (unless I use two different 
static texts)...

Also, if the text being bold is not a feature-critical thing (I'd say it 
hardly is) then having this feature only on wxGTK would not be critical, 
too.

Francesco







More information about the wx-users mailing list