Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
dbgrid.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_COMPONENT_DATAGRID_DBGRID_H__
22#define __ANTARES_TOOLBOX_COMPONENT_DATAGRID_DBGRID_H__
23
24#include <wx/grid.h>
25#include <yuni/yuni.h>
26
27namespace Antares
28{
29namespace Component
30{
31namespace Datagrid
32{
33// Forward declaration
34class Component;
35
36class DBGrid final : public wxGrid
37{
38public:
40
41
44 DBGrid(Component* parent);
46 virtual ~DBGrid();
48
49 const wxPoint& currentPosition() const
50 {
51 return pCurrentPosition;
52 }
53
54 Component* component() const
55 {
56 return pParentComponent;
57 }
58
59 void copyToClipboard();
60 void copyAllToClipboard();
61 void pasteFromClipboard();
62
63 void ensureDataAreLoaded();
64
65 void resizeAllHeaders(bool nodelay = false);
66
70 void enableRefresh(bool enabled)
71 {
72 pAllowRefresh = enabled;
73 }
74
75 bool canRefresh() const
76 {
77 return pAllowRefresh;
78 }
79
80 void DrawColLabel(wxDC& dc, int col, uint& offset);
81 void DrawRowLabel(wxDC& dc, int row, uint& offset);
82 void DrawCellHighlight(wxDC& dc, const wxGridCellAttr* attr);
83
84 void disableColorMappingForRowLabels()
85 {
86 pColorMappingRowLabels = false;
87 }
88
89 // For synchronizing scroll with another grid purpose
90 void setOtherGrid(DBGrid* otherGrid);
91
92private:
94 bool dataAreReady() const;
95
96 void ensureDataAreLoadedDelayed();
97
101 void onGridSelectCell(wxGridEvent& evt);
102
106 void onGridRangeSelect(wxGridRangeSelectEvent& evt);
107
111 void onGridLeave(wxFocusEvent& evt);
112
113 void onDraw(wxPaintEvent& evt);
114
115 void onKeyUp(wxKeyEvent& evt);
116
117 void evtOnResizeHeaders(wxCommandEvent& evt);
118
119 void evtCornerPaint(wxPaintEvent& evt);
120
121 void onEraseBackground(wxEraseEvent&)
122 {
123 }
124 void onDrawColLabels(wxPaintEvent&);
125 void onDrawRowLabels(wxPaintEvent&);
126
127 void onScroll(wxScrollWinEvent&);
128
129private:
131 Component* pParentComponent;
132 wxPoint pCurrentPosition;
133 bool pAllowRefresh;
134 bool pColorMappingRowLabels;
135 // The other grid we want scroll synchronously with
136 DBGrid* otherGrid_ = nullptr;
137
138 DECLARE_EVENT_TABLE();
139
140}; // class DBGrid
141
142} // namespace Datagrid
143} // namespace Component
144} // namespace Antares
145
146#endif // __ANTARES_TOOLBOX_COMPONENT_DATAGRID_DBGRID_H__
A datagrid with virtual values.
Definition component.h:84
void enableRefresh(bool enabled)
Allow refresh.
Definition dbgrid.h:70
virtual ~DBGrid()
Destructor.
Definition dbgrid.cpp:121
DBGrid(Component *parent)
Constructor.
Definition dbgrid.cpp:76