Odd white frame in wxCombobox

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Odd white frame in wxCombobox

Post by giulio_seb »

Hello,
I am on OSx 12.2, using wxWidgets 3.1.5, and I am using wxWidgets with C++. When I create a wxComboBox on a wxFrame and change the background color of the wxComboBox and of the frame, I get these ugly white lines around the combobox. Do you know how to get rid of it ?

Thanks
Best,

Image
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Odd white frame in wxCombobox

Post by ONEEYEMAN »

Hi,
Can you show some code?
Can you reproduce it in the widgets sample?

Thank you.
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Re: Odd white frame in wxCombobox

Post by giulio_seb »

ONEEYEMAN wrote: Mon Sep 26, 2022 2:45 am Hi,
Can you show some code?
Can you reproduce it in the widgets sample?

Thank you.
Sure, here is the code

Code: Select all

#include <wx/wxprec.h>
#include <wx/combobox.h>

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

#include <iostream>
#include <cstdio>
#include <sstream>

using namespace std;

class MyApp: public wxApp{
public:
    virtual bool OnInit();
};

class MyFrame: public wxFrame{
    
public:
    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
        
};

wxIMPLEMENT_APP(MyApp);

bool MyApp::OnInit(){
     
    MyFrame *frame = new MyFrame( "My frame", wxDefaultPosition, wxDefaultSize);
    
    frame->Show( true );
    
    return true;
    
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame(NULL, wxID_ANY, title, pos, size){
    
    wxPanel* panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxT(""));
    
    wxComboBox* box = new wxComboBox(panel, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize);
    
    box->SetForegroundColour(*wxWHITE);
    box->SetBackgroundColour(*wxBLACK);
    
    SetForegroundColour(*wxWHITE);
    SetBackgroundColour(*wxBLACK);
    
}

and here is what I get as output on my OSX system Image

:roll: :?: #-o
User avatar
doublemax@work
Super wx Problem Solver
Super wx Problem Solver
Posts: 474
Joined: Wed Jul 29, 2020 6:06 pm
Location: NRW, Germany

Re: Odd white frame in wxCombobox

Post by doublemax@work »

OSX is very opinionated when it comes to gui design. I'd guess it's just not possible to change these colors.

And FWIW, personally i think you should never change the color of native controls on any platform. If you were trying to get a dark theme: If the user wanted a dark theme, he'd set a dark theme in the OS itself. And if he uses a light theme, you should not force your dark theme onto him.
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Re: Odd white frame in wxCombobox

Post by giulio_seb »

doublemax@work wrote: Mon Sep 26, 2022 11:36 am OSX is very opinionated when it comes to gui design. I'd guess it's just not possible to change these colors.

And FWIW, personally i think you should never change the color of native controls on any platform. If you were trying to get a dark theme: If the user wanted a dark theme, he'd set a dark theme in the OS itself. And if he uses a light theme, you should not force your dark theme onto him.
Thank you for your reply. Indeed, I did all this because I would like my app to be seen with a dark theme, so it is more easy to be used at night. How shall I achieve this? Is this functionality already implemented in wxWidgets?
User avatar
doublemax@work
Super wx Problem Solver
Super wx Problem Solver
Posts: 474
Joined: Wed Jul 29, 2020 6:06 pm
Location: NRW, Germany

Re: Odd white frame in wxCombobox

Post by doublemax@work »

giulio_seb wrote: Mon Sep 26, 2022 1:27 pm Indeed, I did all this because I would like my app to be seen with a dark theme, so it is more easy to be used at night. How shall I achieve this? Is this functionality already implemented in wxWidgets?
This feature is not implemented in wxWidgets. You can only check if the system is in dark more or not, using wxSystemSettings::GetAppearance:
https://docs.wxwidgets.org/trunk/classw ... aedbf43088

However, as i said before, personally i think the default colors should not be changed, so that all changes the user may have made on OS level also affect your application.
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Re: Odd white frame in wxCombobox

Post by giulio_seb »

I see, thank you.

Given an overall color configuration set by the operating system (dark or bright mode, or others), I would like to obtain the wxColour corresponding to the background color that the operating system uses to fill the rectangle of a wxComboBox. Do you know how to get it ? I tried with wxSystemSettings::GetColour(wxSystemColour index) by setting, for example index = wxSYS_COLOUR_LISTBOX, but I don't get the right color.

Thank you !
Post Reply