From 382404f0a7389a547aab5c3ecd7ee53b49679074 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 6 Oct 2018 16:12:48 +0200 Subject: [PATCH] Stop using wxColourDisplay() inside wxWidgets code This function always returns true in practice and it's completely useless to call it during each wxDC object construction, especially because wxDC::m_colour itself is not used anywhere. --- demos/poem/wxpoem.cpp | 31 +++++++++++++------------------ src/common/dcbase.cpp | 2 +- src/common/dcsvg.cpp | 1 - src/motif/dcclient.cpp | 1 - 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/demos/poem/wxpoem.cpp b/demos/poem/wxpoem.cpp index cfca656f6e..36206c8753 100644 --- a/demos/poem/wxpoem.cpp +++ b/demos/poem/wxpoem.cpp @@ -163,7 +163,7 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y) height = *max_y; } - if (DrawIt && wxColourDisplay()) + if (DrawIt) { dc->SetBrush(*wxLIGHT_GREY_BRUSH); dc->SetPen(*wxGREY_PEN); @@ -347,20 +347,18 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y) if (DrawIt) { // Draw dark grey thick border - if (wxColourDisplay()) - { - dc->SetBrush(*wxGREY_BRUSH); - dc->SetPen(*wxGREY_PEN); + dc->SetBrush(*wxGREY_BRUSH); + dc->SetPen(*wxGREY_PEN); + + // Left side + dc->DrawRectangle(0, 0, THIN_LINE_BORDER, height); + // Top side + dc->DrawRectangle(THIN_LINE_BORDER, 0, width-THIN_LINE_BORDER, THIN_LINE_BORDER); + // Right side + dc->DrawRectangle(width-THIN_LINE_BORDER, THIN_LINE_BORDER, width, height-THIN_LINE_BORDER); + // Bottom side + dc->DrawRectangle(THIN_LINE_BORDER, height-THIN_LINE_BORDER, width-THIN_LINE_BORDER, height); - // Left side - dc->DrawRectangle(0, 0, THIN_LINE_BORDER, height); - // Top side - dc->DrawRectangle(THIN_LINE_BORDER, 0, width-THIN_LINE_BORDER, THIN_LINE_BORDER); - // Right side - dc->DrawRectangle(width-THIN_LINE_BORDER, THIN_LINE_BORDER, width, height-THIN_LINE_BORDER); - // Bottom side - dc->DrawRectangle(THIN_LINE_BORDER, height-THIN_LINE_BORDER, width-THIN_LINE_BORDER, height); - } // Draw border // Have grey background, plus 3-d border - // One black rectangle. @@ -376,10 +374,7 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y) // Right and bottom white lines - 'grey' (black!) if // we're running on a mono display. - if (wxColourDisplay()) - dc->SetPen(*wxWHITE_PEN); - else - dc->SetPen(*wxBLACK_PEN); + dc->SetPen(*wxWHITE_PEN); dc->DrawLine(width-THICK_LINE_BORDER, THICK_LINE_BORDER, width-THICK_LINE_BORDER, height-THICK_LINE_BORDER); diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 1363984b7e..8b070995d8 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -318,7 +318,7 @@ wxIMPLEMENT_ABSTRACT_CLASS(wxDCImpl, wxObject); wxDCImpl::wxDCImpl( wxDC *owner ) : m_window(NULL) - , m_colour(wxColourDisplay()) + , m_colour(true) , m_ok(true) , m_clipping(false) , m_isInteractive(0) diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 7a02bebb4f..2913548a12 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -402,7 +402,6 @@ void wxSVGFileDCImpl::Init(const wxString &filename, int Width, int Height, m_backgroundBrush = *wxTRANSPARENT_BRUSH; m_textForegroundColour = *wxBLACK; m_textBackgroundColour = *wxWHITE; - m_colour = wxColourDisplay(); m_pen = *wxBLACK_PEN; m_font = *wxNORMAL_FONT; diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index 6bf809572f..a85f36bfc2 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -139,7 +139,6 @@ void wxWindowDCImpl::Init() m_currentPenDash = NULL; m_currentStyle = -1; m_currentFill = -1; - m_colour = wxColourDisplay(); m_display = NULL; m_pixmap = (WXPixmap) 0; m_autoSetting = 0;