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,
Odd white frame in wxCombobox
-
- Earned some good credits
- Posts: 108
- Joined: Mon Feb 07, 2022 11:53 am
Re: Odd white frame in wxCombobox
Hi,
Can you show some code?
Can you reproduce it in the widgets sample?
Thank you.
Can you show some code?
Can you reproduce it in the widgets sample?
Thank you.
-
- Earned some good credits
- Posts: 108
- Joined: Mon Feb 07, 2022 11:53 am
Re: Odd white frame in wxCombobox
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);
}
- doublemax@work
- Super wx Problem Solver
- Posts: 474
- Joined: Wed Jul 29, 2020 6:06 pm
- Location: NRW, Germany
Re: Odd white frame in wxCombobox
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.
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.
-
- Earned some good credits
- Posts: 108
- Joined: Mon Feb 07, 2022 11:53 am
Re: Odd white frame in wxCombobox
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?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.
- doublemax@work
- Super wx Problem Solver
- Posts: 474
- Joined: Wed Jul 29, 2020 6:06 pm
- Location: NRW, Germany
Re: Odd white frame in wxCombobox
This feature is not implemented in wxWidgets. You can only check if the system is in dark more or not, using wxSystemSettings::GetAppearance: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?
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.
-
- Earned some good credits
- Posts: 108
- Joined: Mon Feb 07, 2022 11:53 am
Re: Odd white frame in wxCombobox
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 !
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 !