From 4e76d0cb196b9fa069cd4ae3dce50f5a9b2da203 Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Tue, 8 Feb 2022 04:44:26 -0700 Subject: [PATCH 1/2] Address statistic table issues with wx3.1.5 per SAM issue 896 --- include/wex/dview/dvstatisticstablectrl.h | 4 +++- src/dview/dvstatisticstablectrl.cpp | 25 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/wex/dview/dvstatisticstablectrl.h b/include/wex/dview/dvstatisticstablectrl.h index d10c2d22..32756732 100644 --- a/include/wex/dview/dvstatisticstablectrl.h +++ b/include/wex/dview/dvstatisticstablectrl.h @@ -88,7 +88,7 @@ class dvStatisticsTreeModelNode { ~dvStatisticsTreeModelNode(); bool IsContainer() const; - + dvStatisticsTreeModelNode *GetParent(); std::vector GetChildren(); @@ -167,6 +167,8 @@ class dvStatisticsTreeModel : public wxDataViewModel { virtual unsigned int GetChildren(const wxDataViewItem &parent, wxDataViewItemArray &array) const; + virtual bool GetAttr(const wxDataViewItem& item, unsigned int col, wxDataViewItemAttr& attr) const wxOVERRIDE; + private: dvStatisticsTreeModelNode *m_root; diff --git a/src/dview/dvstatisticstablectrl.cpp b/src/dview/dvstatisticstablectrl.cpp index 1eee8b92..3e47636b 100644 --- a/src/dview/dvstatisticstablectrl.cpp +++ b/src/dview/dvstatisticstablectrl.cpp @@ -260,6 +260,17 @@ bool dvStatisticsTreeModel::IsContainer(const wxDataViewItem &item) const { return node->IsContainer(); } +bool dvStatisticsTreeModel::GetAttr(const wxDataViewItem& item, unsigned int col, wxDataViewItemAttr& attr) const +{ + attr.SetColour(*wxRED); // fails + attr.SetBold(true); // works + //attr.SetBackgroundColour(clr); // works + // attr.SetStrikethrough(true); // works + return true; +} + + + unsigned int dvStatisticsTreeModel::GetChildren(const wxDataViewItem &parent, wxDataViewItemArray &array) const { dvStatisticsTreeModelNode *node = (dvStatisticsTreeModelNode *) parent.GetID(); @@ -405,9 +416,17 @@ END_EVENT_TABLE() wxDVStatisticsTableCtrl::wxDVStatisticsTableCtrl(wxWindow *parent, wxWindowID id) : wxPanel(parent, id) { m_showMonths = false; + // SetForegroundColour(*wxBLACK); m_ctrl = new wxDataViewCtrl(this, ID_STATISTICS_CTRL, wxDefaultPosition, wxSize(1040, 720), - wxDV_MULTIPLE | wxDV_ROW_LINES | wxDV_VERT_RULES | wxDV_HORIZ_RULES | wxBORDER_NONE); + wxDV_MULTIPLE | wxDV_ROW_LINES | wxDV_VERT_RULES | wxDV_HORIZ_RULES);// | wxBORDER_NONE); + + /* m_ctrl->SetForegroundColour(*wxBLACK); // supposed to set text color + auto fn = m_ctrl->GetFont(); + fn.set + fn.SetWeight(wxFONTWEIGHT_MEDIUM); + m_ctrl->SetFont(fn); +*/ m_ctrl->Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &wxDVStatisticsTableCtrl::OnContextMenu, this); m_StatisticsModel = new dvStatisticsTreeModel(); @@ -496,11 +515,11 @@ void wxDVStatisticsTableCtrl::RebuildDataViewCtrl() { wxDataViewColumn *column3 = new wxDataViewColumn("Max", tr, 3, 110, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE); m_ctrl->AppendColumn(column3); - tr = new wxDataViewTextRenderer("double", wxDATAVIEW_CELL_INERT, wxALIGN_RIGHT); + tr = new wxDataViewTextRenderer("double", wxDATAVIEW_CELL_ACTIVATABLE, wxALIGN_RIGHT); wxDataViewColumn *column4 = new wxDataViewColumn("Sum", tr, 4, 110, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE); m_ctrl->AppendColumn(column4); - tr = new wxDataViewTextRenderer("double", wxDATAVIEW_CELL_INERT, wxALIGN_RIGHT); + tr = new wxDataViewTextRenderer("double", wxDATAVIEW_CELL_EDITABLE, wxALIGN_RIGHT); wxDataViewColumn *column5 = new wxDataViewColumn("Std Dev", tr, 5, 110, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE); m_ctrl->AppendColumn(column5); From 868c0ab206243fab27ee81e9c197ebbf53fa508a Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Tue, 8 Feb 2022 05:14:23 -0700 Subject: [PATCH 2/2] Fix issues reported in SAM 896 https://github.com/NREL/SAM/issues/896 --- include/wex/dview/dvstatisticstablectrl.h | 2 +- src/dview/dvstatisticstablectrl.cpp | 11 ++--------- src/extgrid.cpp | 2 ++ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/include/wex/dview/dvstatisticstablectrl.h b/include/wex/dview/dvstatisticstablectrl.h index 32756732..d17b7834 100644 --- a/include/wex/dview/dvstatisticstablectrl.h +++ b/include/wex/dview/dvstatisticstablectrl.h @@ -167,7 +167,7 @@ class dvStatisticsTreeModel : public wxDataViewModel { virtual unsigned int GetChildren(const wxDataViewItem &parent, wxDataViewItemArray &array) const; - virtual bool GetAttr(const wxDataViewItem& item, unsigned int col, wxDataViewItemAttr& attr) const wxOVERRIDE; + virtual bool GetAttr(const wxDataViewItem& item, unsigned int col, wxDataViewItemAttr& attr) const; private: diff --git a/src/dview/dvstatisticstablectrl.cpp b/src/dview/dvstatisticstablectrl.cpp index 3e47636b..1d5683bc 100644 --- a/src/dview/dvstatisticstablectrl.cpp +++ b/src/dview/dvstatisticstablectrl.cpp @@ -262,7 +262,7 @@ bool dvStatisticsTreeModel::IsContainer(const wxDataViewItem &item) const { bool dvStatisticsTreeModel::GetAttr(const wxDataViewItem& item, unsigned int col, wxDataViewItemAttr& attr) const { - attr.SetColour(*wxRED); // fails + //attr.SetColour(*wxRED); // fails attr.SetBold(true); // works //attr.SetBackgroundColour(clr); // works // attr.SetStrikethrough(true); // works @@ -416,17 +416,10 @@ END_EVENT_TABLE() wxDVStatisticsTableCtrl::wxDVStatisticsTableCtrl(wxWindow *parent, wxWindowID id) : wxPanel(parent, id) { m_showMonths = false; - // SetForegroundColour(*wxBLACK); m_ctrl = new wxDataViewCtrl(this, ID_STATISTICS_CTRL, wxDefaultPosition, wxSize(1040, 720), wxDV_MULTIPLE | wxDV_ROW_LINES | wxDV_VERT_RULES | wxDV_HORIZ_RULES);// | wxBORDER_NONE); - /* m_ctrl->SetForegroundColour(*wxBLACK); // supposed to set text color - auto fn = m_ctrl->GetFont(); - fn.set - fn.SetWeight(wxFONTWEIGHT_MEDIUM); - m_ctrl->SetFont(fn); -*/ m_ctrl->Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &wxDVStatisticsTableCtrl::OnContextMenu, this); m_StatisticsModel = new dvStatisticsTreeModel(); @@ -497,7 +490,7 @@ void wxDVStatisticsTableCtrl::RebuildDataViewCtrl() { m_ctrl->ClearColumns(); m_ctrl->AssociateModel(m_StatisticsModel.get()); - //TODO: Is there a way to highlight "Total" nodes (i.e. bold, background color, etc...)? + //TODO: Is there a way to highlight "Total" nodes (i.e. bold, background color, etc...)? Use GetAttr in underlying model - howwever SetColour does not work in 3.1.5 tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT, wxALIGN_LEFT); wxDataViewColumn *column0 = new wxDataViewColumn("", tr, 0, 350, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE); diff --git a/src/extgrid.cpp b/src/extgrid.cpp index d48b3e08..6aa8bda9 100644 --- a/src/extgrid.cpp +++ b/src/extgrid.cpp @@ -194,6 +194,8 @@ wxExtGridCtrl::wxExtGridCtrl(wxWindow *parent, int id, m_lastSelBottomRow = -1; m_lastSelLeftCol = -1; m_lastSelRightCol = -1; + + SetGridLineColour(wxColor(99, 102, 106)); // darker cell lines for wx3.1.5 } void wxExtGridCtrl::EnablePasteEvent(bool b) {