OpenCPN Partial API docs
Loading...
Searching...
No Matches
custom_grid.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2010 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 ***************************************************************************/
17
42#ifndef CUSTOmGRID_H_
43#define CUSTOmGRID_H_
44
45#include <vector>
46
47#include <wx/wxprec.h>
48
49#ifndef WX_PRECOMP
50#include <wx/wx.h>
51#endif
52
53#include <wx/grid.h>
54#include <wx/graphics.h>
55
56#include "ocpn_plugin.h"
57
58class GRIBUICtrlBar;
59class CustomRenderer;
60class GRIBTable;
61
62//------------------------------------------------------------------------------------
63// A derived class from wxGrid
64//----------------------------------------------------------------------------------------------------------
65class CustomGrid : public wxGrid {
66public:
67 CustomGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos,
68 const wxSize& size, long style, const wxString& name);
69
70 ~CustomGrid() override;
71
72 void GetFirstVisibleCell(int& frow, int& fcol);
73 void GetLastVisibleCell(int& lrow, int& lcol);
74 void SetNumericalRow(int row, int col, int datatype, double value);
75 void DrawColLabel(wxDC& dc, int col) override;
76 void DrawRowLabel(wxDC& dc, int row) override;
77 void DrawCornerLabel(wxDC& dc) override;
78
79 GRIBTable* m_gParent;
80
81private:
82 void OnScroll(wxScrollEvent& event);
83 void OnMouseEvent(wxMouseEvent& event);
84 void OnResize(wxSizeEvent& event);
85 void OnLabeClick(wxGridEvent& event);
86 void OnRefreshTimer(wxTimerEvent& event);
87 bool IsRowVisible(int row);
88 int GetRowIndex(int row);
89
90 wxTimer m_tRefreshTimer;
91 wxColour m_greenColour;
92 wxColour m_greyColour;
93
94 std::vector<std::vector<double> > m_NumRowVal;
95 std::vector<int> m_NumRow;
96 wxString m_IsDigit;
97
98#ifdef __WXOSX__
99 bool m_bLeftDown;
100#endif
101};
102
103//----------------------------------------------------------------------------------------------------------
104// A derived class from wxGridCellRenderer
105//----------------------------------------------------------------------------------------------------------
106class CustomRenderer : public wxGridCellRenderer {
107public:
108 CustomRenderer(double dir, bool isdigit)
109 : wxGridCellRenderer(), m_dDir(dir), m_IsDigit(isdigit) {}
110
111 void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect,
112 int row, int col, bool isSelected) override;
113
114 wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row,
115 int col) override {
116 return {-1, -1};
117 }
118 [[nodiscard]] wxGridCellRenderer* Clone() const override {
119 return new CustomRenderer(m_dDir, m_IsDigit);
120 }
121
122private:
123 void GetArrowsPoints(double si, double co, int di, int dj, int i, int j,
124 int k, int l, double& ii, double& jj, double& kk,
125 double& ll);
126
127 double m_dDir;
128 bool m_IsDigit;
129};
130
131#endif // CUSTOmGRID_H_
Dialog showing GRIB data in a table format.
Definition grib_table.h:70
PlugIn Object Definition/API.