OpenCPN Partial API docs
Loading...
Searching...
No Matches
CustomGrid.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, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
41#ifndef __CUSTOMGRID_H__
42#define __CUSTOMGRID_H__
43
44#include "wx/wxprec.h"
45
46#ifndef WX_PRECOMP
47#include "wx/wx.h"
48#endif // precompiled headers
49
50#include <wx/grid.h>
51#include "ocpn_plugin.h"
52#include <wx/graphics.h>
53#include <vector>
54
55class GRIBUICtrlBar;
56class CustomRenderer;
57class GRIBTable;
58
59//------------------------------------------------------------------------------------
60// A derived class from wxGrid
61//----------------------------------------------------------------------------------------------------------
62class CustomGrid : public wxGrid {
63public:
64 CustomGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos,
65 const wxSize& size, long style, const wxString& name);
66
68
69 void GetFirstVisibleCell(int& frow, int& fcol);
70 void GetLastVisibleCell(int& lrow, int& lcol);
71 void SetNumericalRow(int row, int col, int datatype, double value);
72
73 GRIBTable* m_gParent;
74
75private:
76 void DrawColLabel(wxDC& dc, int col);
77 void DrawRowLabel(wxDC& dc, int row);
78 void DrawCornerLabel(wxDC& dc);
79 void OnScroll(wxScrollEvent& event);
80 void OnMouseEvent(wxMouseEvent& event);
81 void OnResize(wxSizeEvent& event);
82 void OnLabeClick(wxGridEvent& event);
83 void OnRefreshTimer(wxTimerEvent& event);
84 bool IsRowVisible(int row);
85 int GetRowIndex(int row);
86
87 wxTimer m_tRefreshTimer;
88 wxColour m_greenColour;
89 wxColour m_greyColour;
90
91 std::vector<std::vector<double> > m_NumRowVal;
92 std::vector<int> m_NumRow;
93 wxString m_IsDigit;
94
95#ifdef __WXOSX__
96 bool m_bLeftDown;
97#endif
98};
99
100//----------------------------------------------------------------------------------------------------------
101// A derived class from wxGridCellRenderer
102//----------------------------------------------------------------------------------------------------------
103class CustomRenderer : public wxGridCellRenderer {
104public:
105 CustomRenderer(double dir, bool isdigit)
106 : wxGridCellRenderer(), m_dDir(dir), m_IsDigit(isdigit) {}
107
108 virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
109 const wxRect& rect, int row, int col, bool isSelected);
110
111 wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row,
112 int col) {
113 return wxSize(-1, -1);
114 }
115 wxGridCellRenderer* Clone() const {
116 return new CustomRenderer(m_dDir, m_IsDigit);
117 }
118
119private:
120 void GetArrowsPoints(double si, double co, int di, int dj, int i, int j,
121 int k, int l, double& ii, double& jj, double& kk,
122 double& ll);
123
124 double m_dDir;
125 bool m_IsDigit;
126};
127
128#endif //__CUSTOMGRID_H__
Dialog showing GRIB data in a table format.
Definition GribTable.h:71
PlugIn Object Definition/API.