Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/wex/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ class wxMatrix {
wxMatrix<T> old(*this);
Resize(nr, nc);
Fill(val);
for (size_t r = 0; r < nr && r < old.nrows(); r++)
for (size_t c = 0; c < nc && c < old.ncols(); c++)
for (size_t r = 0; r < nr && r < old.Rows(); r++)
for (size_t c = 0; c < nc && c < old.Cols(); c++)
At(r, c) = old(r, c);
}

Expand Down
9 changes: 9 additions & 0 deletions src/dview/dvdcctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <wx/app.h>
#include <wx/busyinfo.h>
#include <wx/config.h>
#include <wx/settings.h>
#include <wx/tokenzr.h>

#include "wx/srchctrl.h"
Expand All @@ -56,16 +57,24 @@ enum {
wxDVDCCtrl::wxDVDCCtrl(wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name)
: wxPanel(parent, id, pos, size, style, name) {
wxColour bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
wxColour fgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
SetBackgroundColour(bgColour);
SetForegroundColour(fgColour);

wxBoxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL);
SetSizer(topSizer);
m_srchCtrl = NULL;
m_plotSurface = new wxPLPlotCtrl(this, wxID_ANY);
m_plotSurface->SetBackgroundColour(*wxWHITE);
m_plotSurface->SetForegroundColour(*wxBLACK);
m_plotSurface->ShowTitle(false);
m_plotSurface->ShowLegend(false);
topSizer->Add(m_plotSurface, 1, wxEXPAND | wxALL, 10);

m_srchCtrl = new wxSearchCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0);
m_srchCtrl->SetBackgroundColour(bgColour);
m_srchCtrl->SetForegroundColour(fgColour);
m_dataSelector = new wxDVSelectionListCtrl(this, wxID_DC_DATA_SELECTOR, 1);
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(m_srchCtrl, 0, wxALL | wxEXPAND, 0);
Expand Down
31 changes: 27 additions & 4 deletions src/dview/dvdmapctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <wx/choice.h>
#include <wx/config.h>
#include <wx/scrolbar.h>
#include <wx/settings.h>
#include "wx/srchctrl.h"
#include <wx/textctrl.h>
#include <wx/tokenzr.h>
Expand Down Expand Up @@ -210,12 +211,18 @@ wxDVDMapCtrl::wxDVDMapCtrl(wxWindow *parent,
m_timer(nullptr),
m_xAxixWorldMin(0),
m_xAxixWorldMax(0) {
wxColour bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
wxColour fgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
SetBackgroundColour(bgColour);
SetForegroundColour(fgColour);

m_currentlyShownDataSet = 0;
m_srchCtrl = NULL;
m_colourMap = new wxPLJetColourMap(0, 24);

m_plotSurface = new wxPLPlotCtrl(this, ID_DMAP_SURFACE);
m_plotSurface->SetBackgroundColour(*wxWHITE);
m_plotSurface->SetForegroundColour(*wxBLACK);
m_plotSurface->SetHighlightMode(wxPLPlotCtrl::HIGHLIGHT_SPAN);
m_plotSurface->ShowGrid(false, false);
m_plotSurface->ShowTitle(false);
Expand All @@ -235,15 +242,23 @@ wxDVDMapCtrl::wxDVDMapCtrl(wxWindow *parent,

m_minTextBox = new wxTextCtrl(this, ID_MIN_Z_INPUT, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxTE_PROCESS_ENTER);
m_minTextBox->SetBackgroundColour(bgColour);
m_minTextBox->SetForegroundColour(fgColour);
m_maxTextBox = new wxTextCtrl(this, ID_MAX_Z_INPUT, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxTE_PROCESS_ENTER);
m_maxTextBox->SetBackgroundColour(bgColour);
m_maxTextBox->SetForegroundColour(fgColour);

wxString choices[5] = {"Jet", "Parula", "Grayscale", "Coarse Rainbow", "Fine Rainbow"};
m_colourMapSelector = new wxChoice(this, ID_COLOURMAP_SELECTOR_CHOICE, wxDefaultPosition, wxDefaultSize, 5,
choices);
m_colourMapSelector->SetSelection(0);
m_colourMapSelector->SetBackgroundColour(bgColour);
m_colourMapSelector->SetForegroundColour(fgColour);

m_reverseColours = new wxCheckBox(this, ID_REVERSE_COLOURS, "Reverse colors");
m_reverseColours->SetBackgroundColour(bgColour);
m_reverseColours->SetForegroundColour(fgColour);

m_yGraphScroller = new wxScrollBar(this, ID_GRAPH_Y_SCROLLBAR, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL);
m_xGraphScroller = new wxScrollBar(this, ID_GRAPH_SCROLLBAR, wxDefaultPosition, wxDefaultSize, wxSB_HORIZONTAL);
Expand All @@ -264,6 +279,8 @@ wxDVDMapCtrl::wxDVDMapCtrl(wxWindow *parent,
scrollSizer->Add(zoom_fit, 0, wxALL | wxEXPAND, 1);

m_srchCtrl = new wxSearchCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0);
m_srchCtrl->SetBackgroundColour(bgColour);
m_srchCtrl->SetForegroundColour(fgColour);
m_selector = new wxDVSelectionListCtrl(this, ID_DATA_SELECTOR, 1, wxDefaultPosition, wxDefaultSize,
wxDVSEL_RADIO_FIRST_COL | wxDVSEL_NO_COLOURS);
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
Expand All @@ -280,13 +297,19 @@ wxDVDMapCtrl::wxDVDMapCtrl(wxWindow *parent,
optionsSizer->Add(m_colourMapSelector, 0, wxALL | wxEXPAND, 3);
optionsSizer->Add(m_reverseColours, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
optionsSizer->AddStretchSpacer();
optionsSizer->Add(new wxStaticText(this, wxID_ANY, "Min:"), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL, 4);
wxStaticText* minLabel = new wxStaticText(this, wxID_ANY, "Min:");
minLabel->SetForegroundColour(fgColour);
optionsSizer->Add(minLabel, 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL, 4);
optionsSizer->Add(m_minTextBox, 0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
optionsSizer->AddSpacer(6);
optionsSizer->Add(new wxStaticText(this, wxID_ANY, "Max:"), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL, 4);
wxStaticText* maxLabel = new wxStaticText(this, wxID_ANY, "Max:");
maxLabel->SetForegroundColour(fgColour);
optionsSizer->Add(maxLabel, 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL, 4);
optionsSizer->Add(m_maxTextBox, 0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
optionsSizer->Add(new wxButton(this, ID_RESET_MIN_MAX, "Reset", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT), 0,
wxALIGN_CENTER | wxRIGHT, 5);
wxButton* resetBtn = new wxButton(this, ID_RESET_MIN_MAX, "Reset", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
resetBtn->SetBackgroundColour(bgColour);
resetBtn->SetForegroundColour(fgColour);
optionsSizer->Add(resetBtn, 0, wxALIGN_CENTER | wxRIGHT, 5);

wxBoxSizer *leftSizer = new wxBoxSizer(wxVERTICAL);
leftSizer->Add(optionsSizer, 0, wxEXPAND, 2);
Expand Down
21 changes: 18 additions & 3 deletions src/dview/dvpncdfctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <wx/wx.h>
#include <wx/busyinfo.h>
#include <wx/settings.h>
#include "wx/srchctrl.h"
#include <wx/tokenzr.h>
#include <wx/config.h>
Expand Down Expand Up @@ -75,11 +76,17 @@ END_EVENT_TABLE()
wxDVPnCdfCtrl::wxDVPnCdfCtrl(wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name, const bool &bshowsearch, const bool &bshowselector, const bool& bshowpvalue, const bool& bshowhidezeros)
: wxPanel(parent, id, pos, size, style, name) {
wxColour bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
wxColour fgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
SetBackgroundColour(bgColour);
SetForegroundColour(fgColour);

m_bshowpvalue = bshowpvalue;
m_bshowhidezeros = bshowhidezeros;
m_srchCtrl = NULL;
m_plotSurface = new wxPLPlotCtrl(this, wxID_ANY);
m_plotSurface->SetBackgroundColour(*wxWHITE);
m_plotSurface->SetForegroundColour(*wxBLACK);
m_pdfPlot = new wxPLHistogramPlot();
m_cdfPlot = new wxPLLinePlot();
m_cdfPlot->SetColour(*wxBLACK);
Expand All @@ -94,12 +101,16 @@ wxDVPnCdfCtrl::wxDVPnCdfCtrl(wxWindow *parent, wxWindowID id, const wxPoint &pos
if (m_bshowpvalue) m_pValueTextBox = new wxTextCtrl(this, wxID_PVALUE_TB, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);

m_pValueResultLabel = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
m_pValueResultLabel->SetForegroundColour(fgColour);
m_pValueResultTextBox = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxTE_READONLY);
m_pValueResultTextBox->SetForegroundColour(UIColorCalculatedFore);
m_pValueResultTextBox->SetBackgroundColour(UIColorCalculatedBack);
m_pValueResultTextBox->SetForegroundColour(fgColour);
m_pValueResultTextBox->SetBackgroundColour(bgColour);
m_pValueResultUnits = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
m_pValueResultUnits->SetForegroundColour(fgColour);

m_srchCtrl = new wxSearchCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0);
m_srchCtrl->SetBackgroundColour(bgColour);
m_srchCtrl->SetForegroundColour(fgColour);
m_selector = new wxDVSelectionListCtrl(this, ID_DATA_SELECTOR, 1, wxDefaultPosition, wxDefaultSize,
wxDVSEL_RADIO_FIRST_COL | wxDVSEL_NO_COLOURS);
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
Expand All @@ -111,7 +122,11 @@ wxDVPnCdfCtrl::wxDVPnCdfCtrl(wxWindow *parent, wxWindowID id, const wxPoint &pos
if (!bshowselector)
m_selector->Hide();

if (m_bshowhidezeros) m_hideZeros = new wxCheckBox(this, wxID_ANY, "Exclude Zero Values", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
if (m_bshowhidezeros) {
m_hideZeros = new wxCheckBox(this, wxID_ANY, "Exclude Zero Values", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
m_hideZeros->SetBackgroundColour(bgColour);
m_hideZeros->SetForegroundColour(fgColour);
}
/*
m_PlotTypeDisplayed = new wxChoice(this, wxID_PLOT_TYPE);
m_PlotTypeDisplayed->Append(wxT("PDF and CDF"));
Expand Down
17 changes: 14 additions & 3 deletions src/dview/dvprofilectrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <wx/config.h>
#include <wx/dcbuffer.h>
#include <wx/fileconf.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include "wx/srchctrl.h"
#include <wx/tokenzr.h>
Expand Down Expand Up @@ -133,7 +134,6 @@ class wxDVProfileCtrl::VerticalLabelCtrl : public wxWindow {
VerticalLabelCtrl(wxWindow *parent, wxWindowID id)
: wxWindow(parent, id) {
SetBackgroundStyle(wxBG_STYLE_CUSTOM);
SetBackgroundColour(*wxWHITE);
}

virtual wxSize DoGetBestSize() const {
Expand Down Expand Up @@ -206,21 +206,31 @@ wxDVProfileCtrl::wxDVProfileCtrl(wxWindow *parent, wxWindowID id, const wxPoint
m_srchCtrl = NULL;
wxScrolledWindow *monthSelector = new wxScrolledWindow(this, wxID_ANY,
wxDefaultPosition, wxDefaultSize, wxHSCROLL);
wxColour bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
wxColour fgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
monthSelector->SetBackgroundColour(bgColour);
monthSelector->SetForegroundColour(fgColour);
wxBoxSizer *monthSizer = new wxBoxSizer(wxHORIZONTAL);
monthSelector->SetSizer(monthSizer);
monthSelector->SetScrollRate(10, 0);
for (int i = 0; i < 12; i++) {
m_monthCheckBoxes[i] = new wxCheckBox(monthSelector, ID_JAN_CHECK + i,
wxDateTime::GetMonthName(wxDateTime::Month(i), wxDateTime::Name_Abbr));
m_monthCheckBoxes[i]->SetValue(true);
m_monthCheckBoxes[i]->SetBackgroundColour(bgColour);
m_monthCheckBoxes[i]->SetForegroundColour(fgColour);
monthSizer->Add(m_monthCheckBoxes[i], 0, wxALL, 5);
}
m_numberOfPlotSurfacesShown = 12;
//Add an extra at the end for the annual profile.
m_monthCheckBoxes[12] = new wxCheckBox(monthSelector, ID_ANNUAL_CHECK, wxT("Annual"));
m_monthCheckBoxes[12]->SetBackgroundColour(bgColour);
m_monthCheckBoxes[12]->SetForegroundColour(fgColour);
monthSizer->Add(m_monthCheckBoxes[12], 0, wxALL, 5);
monthSizer->Add(new wxCheckBox(monthSelector, ID_SEL_ALL_CHECK,
wxT("Select All")), 0, wxALL, 5);
wxCheckBox* selAllCheck = new wxCheckBox(monthSelector, ID_SEL_ALL_CHECK, wxT("Select All"));
selAllCheck->SetBackgroundColour(bgColour);
selAllCheck->SetForegroundColour(fgColour);
monthSizer->Add(selAllCheck, 0, wxALL, 5);
for (int i = 0; i < 12; i++) {
m_plotSurfaces[i] = new wxPLPlotCtrl(this, wxID_ANY);
m_plotSurfaces[i]->SetIncludeLegendOnExport(true);
Expand All @@ -231,6 +241,7 @@ wxDVProfileCtrl::wxDVProfileCtrl(wxWindow *parent, wxWindowID id, const wxPoint
}
//Add annual profile:
m_plotSurfaces[12] = new wxPLPlotCtrl(this, wxID_ANY);
m_plotSurfaces[12]->SetBackgroundColour(*wxWHITE);
m_plotSurfaces[12]->SetTitle(wxT("Annual Profile"));
m_plotSurfaces[12]->ShowGrid(true, false);
m_plotSurfaces[12]->ShowLegend(false);
Expand Down
11 changes: 11 additions & 0 deletions src/dview/dvscatterplotctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <wx/wx.h>
#include <wx/config.h>
#include <wx/settings.h>
#include "wx/srchctrl.h"
#include <wx/tokenzr.h>

Expand Down Expand Up @@ -93,14 +94,22 @@ END_EVENT_TABLE()
wxDVScatterPlotCtrl::wxDVScatterPlotCtrl(wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name)
: wxPanel(parent, id, pos, size, style, name) {
wxColour bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
wxColour fgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
SetBackgroundColour(bgColour);
SetForegroundColour(fgColour);

m_srchCtrl = NULL;

m_plotSurface = new wxPLPlotCtrl(this, wxID_ANY);
m_plotSurface->ShowTitle(false);
m_plotSurface->SetBackgroundColour(*wxWHITE);
m_plotSurface->SetForegroundColour(*wxBLACK);
m_plotSurface->ShowLegend(false);

m_srchCtrl = new wxSearchCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0);
m_srchCtrl->SetBackgroundColour(bgColour);
m_srchCtrl->SetForegroundColour(fgColour);
m_dataSelectionList = new wxDVSelectionListCtrl(this, wxID_SCATTER_DATA_SELECTOR, 2, wxDefaultPosition,
wxDefaultSize, wxDVSEL_RADIO_FIRST_COL);
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
Expand All @@ -113,6 +122,8 @@ wxDVScatterPlotCtrl::wxDVScatterPlotCtrl(wxWindow *parent, wxWindowID id, const
wxBoxSizer *optionsSizer = new wxBoxSizer(wxHORIZONTAL);
m_showPerfAgreeLine = new wxCheckBox(this, wxID_PERFECT_AGREE_LINE, "Show Line of Perfect Agreement",
wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
m_showPerfAgreeLine->SetBackgroundColour(bgColour);
m_showPerfAgreeLine->SetForegroundColour(fgColour);
optionsSizer->Add(m_showPerfAgreeLine, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);

wxBoxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL);
Expand Down
18 changes: 13 additions & 5 deletions src/dview/dvselectionlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,14 @@ void wxDVSelectionListCtrl::OnPaint(wxPaintEvent &) {

// paint the background.
wxColour bg = GetBackgroundColour();

// Determine text color based on background luminance
// Standard relative luminance formula
double luminance = (0.299 * bg.Red() + 0.587 * bg.Green() + 0.114 * bg.Blue()) / 255.0;
wxColour fg = (luminance < 0.5) ? *wxWHITE : *wxBLACK;
wxColour dis_fg = (luminance < 0.5) ? wxColour(150, 150, 150) : *wxLIGHT_GREY;
fprintf(stderr, "DView: bg=(%d, %d, %d) luminance=%f fg=(%d, %d, %d)\n", bg.Red(), bg.Green(), bg.Blue(), luminance, fg.Red(), fg.Green(), fg.Blue()); fflush(stderr);

dc.SetBrush(wxBrush(bg));
dc.SetPen(wxPen(bg, 1));
wxRect windowRect(wxPoint(0, 0), GetClientSize());
Expand Down Expand Up @@ -507,10 +515,10 @@ void wxDVSelectionListCtrl::OnPaint(wxPaintEvent &) {
}

for (size_t c = 0; c < (size_t) m_numCols; c++) {
wxColour color = items[i]->enable[c] ? *wxBLACK : *wxLIGHT_GREY;
wxColour color = items[i]->enable[c] ? fg : dis_fg;
items[i]->geom[c] = wxRect(x, y + yoff, m_boxSize, m_boxSize); // save geometry to speed up mouse clicks

dc.SetBrush(*wxWHITE_BRUSH);
dc.SetBrush(wxBrush(bg));
dc.SetPen(wxPen(color, 1));

if (((m_style & wxDVSEL_RADIO_FIRST_COL) && c == 0) || (m_style == wxDVSEL_RADIO_ALL_COL))
Expand All @@ -519,8 +527,8 @@ void wxDVSelectionListCtrl::OnPaint(wxPaintEvent &) {
dc.DrawRectangle(x, y + yoff, m_boxSize, m_boxSize);

if (items[i]->value[c]) {
dc.SetBrush(*wxBLACK_BRUSH);
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(wxBrush(fg));
dc.SetPen(wxPen(fg));
if (((m_style & wxDVSEL_RADIO_FIRST_COL) && c == 0) || (m_style == wxDVSEL_RADIO_ALL_COL))
dc.DrawCircle(x + radius, y + radius + yoff, radius - 2);
else
Expand All @@ -531,7 +539,7 @@ void wxDVSelectionListCtrl::OnPaint(wxPaintEvent &) {
}

dc.SetFont(font_normal);
dc.SetTextForeground(*wxBLACK);
dc.SetTextForeground(fg);
dc.DrawText(items[i]->label, x + 2, y + m_itemHeight / 2 - dc.GetCharHeight() / 2 - 1);

y += m_itemHeight;
Expand Down
2 changes: 2 additions & 0 deletions src/dview/dvtimeseriesctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ wxDVTimeSeriesCtrl::wxDVTimeSeriesCtrl(wxWindow *parent, wxWindowID id, wxDVTime
m_xAxixWorldMin(0),
m_xAxixWorldMax(0) {
SetBackgroundColour(*wxWHITE);
SetForegroundColour(*wxBLACK);
m_srchCtrl = NULL;
m_stackingOnYLeft = false;
m_topAutoScale = false;
Expand All @@ -797,6 +798,7 @@ wxDVTimeSeriesCtrl::wxDVTimeSeriesCtrl(wxWindow *parent, wxWindowID id, wxDVTime

m_plotSurface = new wxPLPlotCtrl(this, ID_PLOT_SURFACE);
m_plotSurface->SetBackgroundColour(*wxWHITE);
m_plotSurface->SetForegroundColour(*wxBLACK);
m_plotSurface->SetHighlightMode(wxPLPlotCtrl::HIGHLIGHT_SPAN);
m_plotSurface->ShowTitle(false);
m_plotSurface->ShowLegend(false);
Expand Down
16 changes: 13 additions & 3 deletions src/metro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "wex/metro.h"
#include "wex/utils.h"

static wxColour GetContrastingTextColour(const wxColour& bg) {
double luminance = (0.299 * bg.Red() + 0.587 * bg.Green() + 0.114 * bg.Blue()) / 255.0;
return (luminance < 0.5) ? *wxWHITE : *wxBLACK;
}

#include "wex/icons/up_arrow_13.cpng"
#include "wex/icons/down_arrow_13.cpng"
#include "wex/icons/left_arrow_13.cpng"
Expand Down Expand Up @@ -635,13 +640,18 @@ void wxMetroTabList::OnPaint(wxPaintEvent &) {
}
}

wxColour text(*wxWHITE);
wxColour text;
if (light) {
wxColour bg = *wxWHITE;
text = ((int) i == m_selection
? wxMetroTheme::Colour(wxMT_FOREGROUND)
: ((int) i == m_hoverIdx
? wxMetroTheme::Colour(wxMT_SELECT)
: wxMetroTheme::Colour(wxMT_TEXT)));
text = GetContrastingTextColour(bg);
} else {
wxColour bg = wxMetroTheme::Colour(wxMT_FOREGROUND);
text = GetContrastingTextColour(bg);
}

dc.SetTextForeground(text);
Expand Down Expand Up @@ -1342,15 +1352,15 @@ void wxMetroListBox::OnPaint(wxPaintEvent &) {
&windowRect.x, &windowRect.y);
dc.DrawRectangle(windowRect);
dc.SetFont(GetFont());
dc.SetTextForeground(*wxBLACK);
dc.SetTextForeground(GetContrastingTextColour(bg));
int height = dc.GetCharHeight();
for (size_t i = 0; i < m_items.size(); i++) {
wxColour bcol = (m_selectedIdx == (int) i) ? wxColour(50, 50, 50) :
((m_hoverIdx == (int) i) ? wxColour(231, 231, 231) : GetBackgroundColour());
dc.SetPen(wxPen(bcol));
dc.SetBrush(wxBrush(bcol));
dc.DrawRectangle(m_items[i].geom);
dc.SetTextForeground((m_selectedIdx == (int) i) ? *wxWHITE : *wxBLACK);
dc.SetTextForeground(GetContrastingTextColour(bcol));
dc.DrawText(m_items[i].name, m_space / 2, m_items[i].geom.y + m_items[i].geom.height / 2 - height / 2);
}
}
Expand Down
Loading