Opened 3 years ago

Closed 3 years ago

Last modified 13 months ago

#13745 closed defect (wontfix)

wxNotebook: Background Colour does not show

Reported by: BarrRobot Owned by:
Priority: normal Milestone:
Component: wxMSW Version: 2.8.12
Keywords: wxNotebook SetBackgroundColour Cc:
Blocked By: Blocking:
Patch: no

Description

The Background Colour when set to a solid colour (at least) does not show on the notebook background, but it is inherited and shown on child pages.

Version 2.8.9 is also affected.
OS: Windows XP SP3, Windows 7 X64 (at least: believed Vista also)

Code to demonstrate (using wxDev-C++ IDE):

GUI Items Creation Start

WxPanel1 = new wxPanel(this, ID_WXPANEL1, wxPoint(10, 9), wxSize(282, 321));
WxPanel1->SetBackgroundColour(wxColour(wxT("CYAN")));

WxNotebook1 = new wxNotebook(WxPanel1, ID_WXNOTEBOOK1, wxPoint(15, 22), wxSize(245, 189), wxNB_DEFAULT);
WxNotebook1->SetBackgroundColour(wxColour(wxT("BLUE")));

WxNoteBookPage1 = new wxPanel(WxNotebook1, ID_WXNOTEBOOKPAGE1, wxPoint(4, 24), wxSize(237, 161));
WxNotebook1->AddPage(WxNoteBookPage1, wxT("WxNoteBookPage1"));

WxNoteBookPage2 = new wxPanel(WxNotebook1, ID_WXNOTEBOOKPAGE2, wxPoint(4, 24), wxSize(237, 161));
WxNotebook1->AddPage(WxNoteBookPage2, wxT("WxNoteBookPage2"));

SetTitle(wxT("Project1"));
SetIcon(wxNullIcon);
SetSize(8,8,320,377);
Center();

GUI Items Creation End

The above shows a default Grey notebook background upon which are two pages both with an inherited blue background. I believe the Notebook background should be blue. The cyan background of the Panel is not inherited (which I believe to be correct).

This has been discussed at http://forums.wxwidgets.org/viewtopic.php?f=28&t=32923#p137208
That thread also has screenshots demonstrating the issue.

Attachments (1)

minimal.diff download (1.3 KB) - added by RedTide 3 years ago.

Download all attachments as: .zip

Change History (12)

Changed 3 years ago by RedTide

comment:1 Changed 3 years ago by RedTide

  • Patch set

I can confirm that this issue affect also wxGTK (this in 2.9 trunk BTW), the attached diff to the minimal sample demonstrate the problem,
also it shows the case that the bug doesn't happen when the notebook background has itself been set
(using both SetBackgroundColour() or SetOwnBackgroundColour() give same result).

comment:2 Changed 3 years ago by RedTide

  • Milestone set to 2.9.4

comment:3 Changed 3 years ago by vadz

  • Milestone 2.9.4 deleted
  • Patch unset
  • Status changed from new to infoneeded_new

The sample works fine for me with 2.9.3-rc1 under both MSW and GTK. What exactly is wrong in your case?

P.S. Resetting "patch" as we reserve this for the patches fixing the problem, not just reproducing it.

comment:4 Changed 3 years ago by BarrRobot

  • Status changed from infoneeded_new to new

@vadz: "The sample works fine for me" Which sample are you referring to - the original or minimal.diff?

This is the issue. Code to produce this appeared in the original ticket above:

http://forums.wxwidgets.org/download/file.php

The bug is quite simply that it is not possible to apply a background colour to a notebook.

I contend that

WxNotebook1->SetBackgroundColour(wxColour(wxT("BLUE")));

should set the notebook background colour to blue.
The fact that the pages of the notebook inherit the background colour shows that the colour is being read and enters the class hierarchy, but either is not applied to the notebook, or it is applied but immediately overwritten by the default colour / theme.
It is possible to apply a background colour to the pages individually, this is not the issue.

wxWidgets 2.9.* is not yet generally available for wxDev-C++. If you are able to backtrack to version 2.8.9 or 2.8.12 and still do not see the original problem, then it looks to be a platform-specific issue. If you do see the problem, then it is a reasonable indication that the bug is fixed in 2.9.3.

comment:5 Changed 3 years ago by ericj

My guess is that the native control just doesn't support this.

On Windows XP, with the Windows "classic" theme (Windows 2000 look) you get the blue background in the tab-area.

With the XP standard theme, or e.g. under Windows 7 standard theme, you don't get the blue background.

comment:6 follow-up: Changed 3 years ago by vadz

  • Resolution set to wontfix
  • Status changed from new to closed

Yes, exactly what ericj wrote. This is just how the native control behaves and I think it's fine. You do get predominant blue colour and if not absolutely everything is blue it's not really a problem is it?

Changing this -- assuming it's possible at all -- really wouldn't be worth the effort.

comment:7 in reply to: ↑ 6 Changed 3 years ago by BarrRobot

Replying to vadz:

Yes, exactly what ericj wrote. This is just how the native control behaves and I think it's fine. You do get predominant blue colour and if not absolutely everything is blue it's not really a problem is it?

Changing this -- assuming it's possible at all -- really wouldn't be worth the effort.

In that case, the documentation should make it clear that SetBackgroundColour has no effect under Windows.

comment:8 follow-up: Changed 3 years ago by vadz

That's not true, it does have an effect as the pages take this colour by default. And the tabs do too in some versions.

comment:9 in reply to: ↑ 8 Changed 3 years ago by BarrRobot

Replying to vadz:

That's not true, it does have an effect as the pages take this colour by default. And the tabs do too in some versions.

I must say you are making a pretty fine distinction there. Is it not a method that sets a Notebook property? I think it is reasonable to expect it to have a visible effect on the Notebook, not just on the Pages.
It may be a characteristic of Windows that you can do nothing about, but if it does not do in some versions that which is implied by the name, then a note in the documentation to make it clear that depending on the version it may or may not set the Notebook colour and/or the tab colour but it will set the default page colour would be the quickest and simplest way of warning users that the effect might not be what they expect.

comment:10 Changed 3 years ago by VZ

(In [69986]) Document that setting colours for native controls might not work.

Changing colours of the native controls can't be relied on.

See #13745.

comment:11 Changed 13 months ago by VZ

(In [74505]) Use wxNotebook background colour for the tab row background in wxMSW.

The free space near the tabs was always filled with the default light grey
colour, use wxNotebook background colour itself to fill it now.

Do it by changing the code in wxNotebook::OnPaint() to use the background
colour brush and ExtFloodFill() to paint over the default grey, instead of the
patterned background brush which is supposed to be used for the pages area
only and not for the tabs and which was not even taken into account anyhow as
the default window proc erases the entire contents of the DC we pass to it
anyhow (at least in the default top-aligned tabs case).

Also inherit the background colour from parent by default now, this ensures
that wxNotebook blends with its parent when its background colour has been
explicitly set by default, without the need to call its SetBackgroundColour()
explicitly.

See #13745.

Note: See TracTickets for help on using tickets.