Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
gridhelper.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __ANTARES_TOOLBOX_COMPONENTS_DATAGRID__GRID_HELPER_H__
22#define __ANTARES_TOOLBOX_COMPONENTS_DATAGRID__GRID_HELPER_H__
23
24#include <wx/panel.h>
25#include <wx/grid.h>
26#include <vector>
27#include <yuni/core/math.h>
28#include "renderer.h"
29
30namespace Antares
31{
32namespace Component
33{
34
35namespace Datagrid
36{
46class VGridHelper final : public wxGridTableBase
47{
48public:
50 using Indices = std::vector<int>;
51
52public:
54
55 VGridHelper(Renderer::IRenderer* renderer, bool markModified);
57 virtual ~VGridHelper()
58 {
59 }
61
65 virtual int GetNumberRows() override;
66
70 virtual int GetNumberCols() override;
71
76 virtual wxString GetRowLabelValue(int row) override;
77
82 virtual wxString GetColLabelValue(int col) override;
83
91 virtual wxString GetValue(int row, int col) override;
92
93 virtual double GetValueAsDouble(int row, int col) override;
94
95 virtual bool GetValueAsBool(int row, int col) override;
96
106 virtual double GetNumericValue(int row, int col) const; // override;
107
115 virtual void SetValue(int row, int col, const wxString& v) override;
116 virtual void SetValue(int row, int col, const Yuni::String& v); // override
117
121 bool IsEmptyCell(int, int) override;
122
131 int realCol(uint col) const;
132
141 int realRow(uint row) const;
142
143 virtual bool CanValueAs(int, int, const wxString&); // override
144
145 void resetIndicesToDefault();
146 void resetIndicesToDefaultWithoutInit();
147
148 void precision(const Date::Precision p);
149
150 void loadFromMatrix();
151
156
157 wxColour foregroundColorFromCellStyle(Renderer::IRenderer::CellStyle s) const;
158 wxColour backgroundColorFromCellStyle(Renderer::IRenderer::CellStyle s) const;
159
160 void appendCSSForAllCellStyles(wxString& s);
161 void appendCSSForAllCellStyles2(Yuni::String& s);
162
163 bool markTheStudyAsModified() const;
164
165public:
166 Indices indicesRows;
167 Indices indicesCols;
168 wxPoint virtualSize;
170 bool valid;
171
172private:
174 Renderer::IRenderer* pRenderer;
176 Date::Precision pDataGridPrecision;
177
178 bool pMarkStudyModifiedWhenModifyingCell;
179
180}; // class VGridHelper
181
182} // namespace Datagrid
183} // namespace Component
184} // namespace Antares
185
186#include "gridhelper.hxx"
187
188#endif // __ANTARES_TOOLBOX_COMPONENTS_DATAGRID__GRID_HELPER_H__
Data provider for Datagrids.
Definition renderer.h:53
Wrapper between a wxGridTableBase and a renderer
Definition gridhelper.h:47
virtual wxString GetRowLabelValue(int row) override
Get the label for a given row.
Definition gridhelper.cpp:517
std::vector< int > Indices
Indices.
Definition gridhelper.h:50
virtual int GetNumberCols() override
Get the number of columns that the wxGrid should display.
Definition gridhelper.hxx:35
int realRow(uint row) const
Get the real index used by the renderer of a given row index used by the wxGrid.
Definition gridhelper.hxx:61
bool IsEmptyCell(int, int) override
Get if a cell is empty or not (unused)
Definition gridhelper.hxx:50
Renderer::IRenderer * renderer() const
The renderer.
Definition gridhelper.hxx:72
virtual ~VGridHelper()
Destructor.
Definition gridhelper.h:57
virtual wxString GetColLabelValue(int col) override
Get the label for a given colum.
Definition gridhelper.cpp:524
virtual void SetValue(int row, int col, const wxString &v) override
Try to set the value of a given cell.
Definition gridhelper.cpp:541
int realCol(uint col) const
Get the real index used by the renderer of a given column index used by the wxGrid.
Definition gridhelper.hxx:55
virtual double GetNumericValue(int row, int col) const
Get the float value of the cell at a given position.
Definition gridhelper.cpp:536
virtual int GetNumberRows() override
Get the number of rows that the wxGrid should display.
Definition gridhelper.hxx:30
bool valid
Get if the grid is valid.
Definition gridhelper.h:170
virtual wxString GetValue(int row, int col) override
Get the string representation of the cell at a given position.
Definition gridhelper.cpp:529