Improve samples appearance in dark mode

- caret: Use the system color for window background instead of
  hard-coded white.

- image: Use hard-coded black for the text drawing since all other
  drawings on the image canvas use hard-coded colours too. The default
  text colour was barely readable in dark mode.

- joytest: Use wxCYAN_PEN instead of wxBLACK_PEN to ensure the line is
  visible both in light and dark colour system mode.

- ownerdrw: Use such background colour that there is good contrast
  between text and background both in light and dark colour system mode.

- popup: Use such background colour for the pop up so that there is a
  good contrast between text and background both in light and dark
  colour system mode.

Closes #23773.
This commit is contained in:
PB 2023-08-24 02:22:19 +02:00 committed by Vadim Zeitlin
parent 9e8ab658fe
commit 61bae154d3
5 changed files with 12 additions and 5 deletions

View file

@ -306,7 +306,7 @@ MyCanvas::MyCanvas( wxWindow *parent )
{
m_text = nullptr;
SetBackgroundColour(*wxWHITE);
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
SetFontSize(12);

View file

@ -401,6 +401,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
wxPaintDC dc( this );
PrepareDC( dc );
dc.SetTextForeground(*wxBLACK);
dc.DrawText( "Loaded image", 30, 10 );
if (my_square.IsOk())
dc.DrawBitmap( my_square, 30, 30 );

View file

@ -193,7 +193,7 @@ void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(evt))
else if (m_stick->GetButtonState(3))
dc.SetPen(*wxYELLOW_PEN);
else
dc.SetPen(*wxBLACK_PEN);
dc.SetPen(*wxCYAN_PEN);
dc.DrawLine(FromDIP(m_pos), FromDIP(pt));

View file

@ -297,7 +297,7 @@ OwnerDrawnFrame::OwnerDrawnFrame(wxFrame *frame, const wxString& title,
for ( ui = 0; ui < WXSIZEOF(aszChoices); ui += 2 )
{
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
m_pListBox->GetItem(ui)->SetBackgroundColour(wxColor(200, 200, 200));
m_pListBox->GetItem(ui)->SetBackgroundColour(*wxBLUE);
#endif
}
@ -345,6 +345,10 @@ OwnerDrawnFrame::OwnerDrawnFrame(wxFrame *frame, const wxString& title,
{
pListBox->GetItem(ui)->SetBackgroundColour(wxColor(0, 0, 0));
}
else if ( ui == 5 ) // black on dark grey is barely visible
{
pListBox->GetItem(ui)->SetBackgroundColour(*wxYELLOW);
}
}
#else

View file

@ -109,8 +109,10 @@ SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent, bool scrolled )
wxBORDER_NONE |
wxPU_CONTAINS_CONTROLS )
{
wxColour colour = wxSystemSettings::SelectLightDark(*wxLIGHT_GREY, wxColour(90, 90, 90));
m_panel = new wxScrolledWindow( this, wxID_ANY );
m_panel->SetBackgroundColour( *wxLIGHT_GREY );
m_panel->SetBackgroundColour(colour);
// Keep this code to verify if mouse events work, they're required if
// you're making a control like a combobox where the items are highlighted
@ -214,7 +216,7 @@ void SimpleTransientPopup::OnMouse(wxMouseEvent &event)
wxRect rect(m_mouseText->GetRect());
rect.SetX(-100000);
rect.SetWidth(1000000);
wxColour colour(*wxLIGHT_GREY);
wxColour colour = wxSystemSettings::SelectLightDark(*wxLIGHT_GREY, wxColour(90, 90, 90));
if (rect.Contains(event.GetPosition()))
{