From 739f13adf97b141c3e7967f1bcaff1ac7274bc74 Mon Sep 17 00:00:00 2001 From: Epicalert Date: Mon, 19 Jul 2021 23:17:40 +0800 Subject: [PATCH] Fix gray window background on Windows --- src/fc2dconfig.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/fc2dconfig.cpp b/src/fc2dconfig.cpp index a9c077d..1186407 100644 --- a/src/fc2dconfig.cpp +++ b/src/fc2dconfig.cpp @@ -51,15 +51,16 @@ ConfigurationFrame::ConfigurationFrame() : wxFrame(NULL, wxID_ANY, "Configure " modelArray[i] = wxString(modelVec[i]); } + wxPanel* panel = new wxPanel(this); // define all controls and labels - useHaarCheckBox = new wxCheckBox(this , wxID_ANY, "Disable DNN face detection"); - showCameraCheckBox = new wxCheckBox(this , wxID_ANY, "Show camera feed"); - noEyesCheckBox = new wxCheckBox(this , wxID_ANY, "Disable eye tracking"); - wxStaticText* modelNameText = new wxStaticText(this, wxID_ANY, "Model name:"); - modelNameChoice = new wxChoice(this , wxID_ANY, wxDefaultPosition, wxDefaultSize, modelVec.size(), modelArray); - wxStaticText* cameraText = new wxStaticText(this , wxID_ANY, "Camera ID:"); - cameraSpinCtrl = new wxSpinCtrl(this); + useHaarCheckBox = new wxCheckBox(panel, wxID_ANY, "Disable DNN face detection"); + showCameraCheckBox = new wxCheckBox(panel, wxID_ANY, "Show camera feed"); + noEyesCheckBox = new wxCheckBox(panel, wxID_ANY, "Disable eye tracking"); + wxStaticText* modelNameText = new wxStaticText(panel, wxID_ANY, "Model name:"); + modelNameChoice = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, modelVec.size(), modelArray); + wxStaticText* cameraText = new wxStaticText(panel, wxID_ANY, "Camera ID:"); + cameraSpinCtrl = new wxSpinCtrl(panel); wxBoxSizer* modelSizer = new wxBoxSizer(wxHORIZONTAL); // need to put label next to dropdown modelSizer->Add(modelNameText, 0, wxALIGN_CENTER | wxALL, 5); @@ -79,19 +80,19 @@ ConfigurationFrame::ConfigurationFrame() : wxFrame(NULL, wxID_ANY, "Configure " // General section - wxStaticBoxSizer* generalBoxSizer = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, "General"), wxVERTICAL); + wxStaticBoxSizer* generalBoxSizer = new wxStaticBoxSizer(new wxStaticBox(panel, wxID_ANY, "General"), wxVERTICAL); generalBoxSizer->Add(modelSizer, 0, wxALL, 5); generalBoxSizer->Add(cameraSizer, 0, wxALL, 5); generalBoxSizer->Add(showCameraCheckBox, 0, wxALL, 5); // Performance section - wxStaticBoxSizer* performanceBoxSizer = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, "Performance"), wxVERTICAL); + wxStaticBoxSizer* performanceBoxSizer = new wxStaticBoxSizer(new wxStaticBox(panel, wxID_ANY, "Performance"), wxVERTICAL); performanceBoxSizer->Add(useHaarCheckBox, 0, wxALL, 5); performanceBoxSizer->Add(noEyesCheckBox, 0, wxALL, 5); // define bottom buttons (Cancel and Apply) and their sizer - wxButton* cancelButton = new wxButton(this, wxID_CANCEL, "Cancel"); - wxButton* applyButton = new wxButton(this, wxID_APPLY, "Apply settings"); + wxButton* cancelButton = new wxButton(panel, wxID_CANCEL, "Cancel"); + wxButton* applyButton = new wxButton(panel, wxID_APPLY, "Apply settings"); wxBoxSizer* bottomButtonSizer = new wxBoxSizer(wxHORIZONTAL); bottomButtonSizer->Add(cancelButton, 0, wxALL, 5); bottomButtonSizer->Add(applyButton, 0, wxALL, 5); @@ -103,7 +104,14 @@ ConfigurationFrame::ConfigurationFrame() : wxFrame(NULL, wxID_ANY, "Configure " sizer->AddStretchSpacer(1); sizer->Add(bottomButtonSizer, 0, wxALIGN_RIGHT | wxALL, 10); - SetSizerAndFit(sizer); + panel->SetSizer(sizer); + + // define top sizer which only contains the panel + // a panel is needed for proper background on Microsoft Windows + wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL); + topSizer->Add(panel, 1, wxEXPAND); + + SetSizerAndFit(topSizer); Bind(wxEVT_BUTTON, &ConfigurationFrame::OnApply, this, wxID_APPLY); Bind(wxEVT_BUTTON, &ConfigurationFrame::OnExit, this, wxID_CANCEL);