#15671 closed defect (fixed)

Generic InfoBar does not set its text colour

Reported by: matthew.ault Owned by:
Priority: normal Milestone: 3.0.1
Component: GUI-generic Version: 2.9.3
Keywords: InfoBar generic Cc:
Blocked By: Blocking:
Patch: yes

Description

When tooltip background is set to black and tooltip text is set to white then creating a generic non-native infobar and displaying a message will result in black text on a black background. Also calling SetForegroundColour on a generic info bar does not set its text colour.

I have attached a patch that resolves this bug and a script that can be used to replicate it.

Thanks,
Matt

Attachments (2)

generic_info_bar_demo.py download (442 bytes) - added by matthew.ault 11 months ago.
Demo that can be used to recreate bug
info_bar_set_foreground_colour.patch download (1.7 KB) - added by matthew.ault 11 months ago.
bug fix patch

Download all attachments as: .zip

Change History (12)

Changed 11 months ago by matthew.ault

Demo that can be used to recreate bug

Changed 11 months ago by matthew.ault

bug fix patch

comment:1 Changed 11 months ago by matthew.ault

  • Version set to 2.9.3

comment:2 Changed 11 months ago by vadz

  • Milestone set to 3.0.1
  • Status changed from new to confirmed

Sorry, I don't understand how can moving SetOwnForegroundColour() call can change anything. Shouldn't we replace it with the call to m_text->SetForegroundColour() instead?

I.e. my proposed patch would be

  • src/generic/infobar.cpp

    diff --git a/src/generic/infobar.cpp b/src/generic/infobar.cpp
    index 49cdefc..d1edd70 100644
    a b bool wxInfoBarGeneric::Create(wxWindow *parent, wxWindowID winid) 
    7171    // use special, easy to notice, colours 
    7272    const wxColour colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK); 
    7373    SetBackgroundColour(colBg); 
    74     SetOwnForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOTEXT)); 
    7574 
    7675    // create the controls: icon, text and the button to dismiss the 
    7776    // message. 
    bool wxInfoBarGeneric::Create(wxWindow *parent, wxWindowID winid) 
    8079    m_icon = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap); 
    8180 
    8281    m_text = new wxStaticText(this, wxID_ANY, ""); 
     82    m_text->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOTEXT)); 
    8383 
    8484    m_button = wxBitmapButton::NewCloseButton(this, wxID_ANY); 
    8585    m_button->SetToolTip(_("Hide this notification message.")); 

Does this work for you?

comment:3 Changed 11 months ago by matthew.ault

Yes, your patch would set the text colour correctly on the creation of the infobar. However it would not resolve the bug whereby calling SetForegroundColour on an already created infobar does not change the text colour.

SetOwnForegroundColour actually calls SetForegroundColour in the definition in the base class. Thus SetOwnForegroundColour needs to be called after the text is created in order to work.

comment:4 Changed 11 months ago by vadz

Yes, overriding SetForegroundColour() still needs to be done, but this is another, lesser problem. The important one is the black-on-black text by default. And I still don't see how does SetOwnForegroundColour() helps here, the info bar own foreground colour doesn't seem to be used at all anywhere. What am I missing?

comment:5 Changed 11 months ago by matthew.ault

Your suggested change to my patch would result in the same visual effects yes.

The info bar would not have its foreground colour set but I also don't believe that this is used although I can't check atm. In this case the SetForegroundColour definition can be simplified to only set the text colour.

comment:6 Changed 11 months ago by VZ

(In [75207]) Set wxInfoBarGeneric text colour correctly.

For some reason SetOwnForegroundColour() was used, but we really need to set
the colour of the child text control and not our own colour here (which is not
used for anything).

This makes the text visible even when using non default tooltip colours, which
could previously result in black-on-black text.

See #15671.

comment:7 Changed 11 months ago by VZ

(In [75208]) Allow changing the colour of wxInfoBarGeneric text.

Override SetForegroundColour() to forward it to the text control.

See #15671.

comment:8 Changed 11 months ago by VZ

(In [75213]) Set wxInfoBarGeneric text colour correctly.

For some reason SetOwnForegroundColour() was used, but we really need to set
the colour of the child text control and not our own colour here (which is not
used for anything).

This makes the text visible even when using non default tooltip colours, which
could previously result in black-on-black text.

See #15671.

comment:9 Changed 11 months ago by VZ

(In [75214]) Allow changing the colour of wxInfoBarGeneric text.

Override SetForegroundColour() to forward it to the text control.

See #15671.

comment:10 Changed 11 months ago by vadz

  • Resolution set to fixed
  • Status changed from confirmed to closed
Note: See TracTickets for help on using tickets.