Skip to content

Commit

Permalink
Merge pull request #138 from NREL/SAM_896
Browse files Browse the repository at this point in the history
fixes sam issue 896
  • Loading branch information
sjanzou authored Feb 10, 2022
2 parents 8b14424 + 868c0ab commit 7230c8b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 3 additions & 1 deletion include/wex/dview/dvstatisticstablectrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class dvStatisticsTreeModelNode {
~dvStatisticsTreeModelNode();

bool IsContainer() const;

dvStatisticsTreeModelNode *GetParent();

std::vector<dvStatisticsTreeModelNode *> GetChildren();
Expand Down Expand Up @@ -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;

private:

dvStatisticsTreeModelNode *m_root;
Expand Down
20 changes: 16 additions & 4 deletions src/dview/dvstatisticstablectrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -407,7 +418,8 @@ wxDVStatisticsTableCtrl::wxDVStatisticsTableCtrl(wxWindow *parent, wxWindowID id
m_showMonths = false;

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->Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &wxDVStatisticsTableCtrl::OnContextMenu, this);

m_StatisticsModel = new dvStatisticsTreeModel();
Expand Down Expand Up @@ -478,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);
Expand All @@ -496,11 +508,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);

Expand Down
2 changes: 2 additions & 0 deletions src/extgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7230c8b

Please sign in to comment.