Discussion:
wxTreeCtrl in wxNotebook has unexpected bgcolor
Jan Engelhardt
2014-03-28 20:12:11 UTC
Permalink
Normally, a wxTreeCtrl as a child of a wxFrame, wxDialog or wxPanel(!)
appears as a white area with a sunken border around it. (That is,
assuming that your system does not have a fancy theme set up.) This is
just the way I would expect it, and wxMSW and wxGTK exhibit this
behavior of course.

Now, if such a wxTreeCtrl is created as a direct child of a wxNotebook
and added to the notebook as a page, then, _under wxGTK_, the background
of the treectrl will be some gray.
That seems unexpected, but perhaps there is some reason you know of?

-- testcase --
#include <wx/wx.h>
#include <wx/notebook.h>
#include <wx/treectrl.h>
class Main : public wxFrame {
public: Main(void) : wxFrame(NULL, wxID_ANY, "Hi") {
auto nb1 = new wxNotebook(this, wxID_ANY);
auto tree1 = new wxTreeCtrl(nb1, wxID_ANY);
auto root1 = tree1->AddRoot("root");
tree1->AppendItem(root1, wxEmptyString);
nb1->AddPage(tree1, "tree", true);

auto nb2 = new wxNotebook(this, wxID_ANY);
auto panel2 = new wxPanel(nb2, wxID_ANY);
auto tree2 = new wxTreeCtrl(panel2, wxID_ANY);
auto root2 = tree2->AddRoot("root");
auto si2 = new wxBoxSizer(wxVERTICAL);
tree2->AppendItem(root2, wxEmptyString);
si2->Add(tree2, 1, wxEXPAND);
panel2->SetSizer(si2);
si2->SetSizeHints(panel2);
nb2->AddPage(panel2, "tree", true);

auto si0 = new wxBoxSizer(wxHORIZONTAL);
si0->Add(nb1, 1, wxEXPAND);
si0->Add(nb2, 1, wxEXPAND);
SetSizer(si0);
si0->SetSizeHints(this);
};
};
class App : public wxApp {
public: bool OnInit(void) {
(new Main)->Show();
return true;
};
};
IMPLEMENT_APP(App);
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-03-29 13:46:57 UTC
Permalink
On Fri, 28 Mar 2014 21:12:11 +0100 (CET) Jan Engelhardt wrote:

JE> Normally, a wxTreeCtrl as a child of a wxFrame, wxDialog or wxPanel(!)
JE> appears as a white area with a sunken border around it. (That is,
JE> assuming that your system does not have a fancy theme set up.) This is
JE> just the way I would expect it, and wxMSW and wxGTK exhibit this
JE> behavior of course.
JE>
JE> Now, if such a wxTreeCtrl is created as a direct child of a wxNotebook
JE> and added to the notebook as a page, then, _under wxGTK_, the background
JE> of the treectrl will be some gray.
JE> That seems unexpected, but perhaps there is some reason you know of?

I can confirm this behaviour but I have no idea about what causes it, so
the only thing I can say is that you should create a Trac ticket with this
example and hope somebody has time to debug this later. Of course, if you
can try to do it yourself, it'd be great, but I don't even know what advice
to give you, i.e. where to start debugging this...

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Loading...