OpenCPN Partial API docs
Loading...
Searching...
No Matches
piano.h
1/******************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: Chart Bar Window
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2010 by David S. Register *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24 ***************************************************************************
25 */
26
27#ifndef __statwin_H__
28#define __statwin_H__
29
30
31//----------------------------------------------------------------------------
32// constants
33//----------------------------------------------------------------------------
34
35#define PIANO_EVENT_TIMER 73566
36#define DEFERRED_KEY_CLICK_DOWN 1
37#define DEFERRED_KEY_CLICK_UP 2
38#define INFOWIN_TIMEOUT 3
39
40// Class declarations
41WX_DECLARE_OBJARRAY(wxRect, RectArray);
42
43class MyFrame;
44class ChartCanvas;
45
46//----------------------------------------------------------------------------
47// Piano
48//----------------------------------------------------------------------------
49class Piano : public wxEvtHandler {
50public:
51 Piano(ChartCanvas *parent);
52 ~Piano();
53
54 void Paint(int y, wxDC &dc, wxDC *shapeDC = NULL);
55 void Paint(int y, ocpnDC &dc, wxDC *shapeDC = NULL);
56 void DrawGL(int y);
57 void FormatKeys(void);
58 bool MouseEvent(wxMouseEvent &event);
59 void SetColorScheme(ColorScheme cs);
60 void SetKeyArray(std::vector<int> piano_chart_index_array);
61 void SetActiveKey(int iactive) { m_iactive = iactive; }
62 void SetActiveKeyArray(std::vector<int> array);
63 void SetNoshowIndexArray(std::vector<int> array);
64 void AddNoshowIndexArray(std::vector<int> array);
65 void SetEclipsedIndexArray(std::vector<int> array);
66 void SetSkewIndexArray(std::vector<int> array);
67 void SetTmercIndexArray(std::vector<int> array);
68 void SetPolyIndexArray(std::vector<int> array);
69
70 std::vector<int> GetActiveKeyArray() { return m_active_index_array; }
71
72 void SetVizIcon(wxBitmap *picon_bmp) {
73 if (m_pVizIconBmp) delete m_pVizIconBmp;
74 m_pVizIconBmp = picon_bmp;
75 }
76 void SetInVizIcon(wxBitmap *picon_bmp) {
77 if (m_pInVizIconBmp) delete m_pInVizIconBmp;
78 m_pInVizIconBmp = picon_bmp;
79 }
80 void SetSkewIcon(wxBitmap *picon_bmp) {
81 if (m_pSkewIconBmp) delete m_pSkewIconBmp;
82 m_pSkewIconBmp = picon_bmp;
83 }
84 void SetTMercIcon(wxBitmap *picon_bmp) {
85 if (m_pTmercIconBmp) delete m_pTmercIconBmp;
86 m_pTmercIconBmp = picon_bmp;
87 }
88 void SetPolyIcon(wxBitmap *picon_bmp) {
89 if (m_pPolyIconBmp) delete m_pPolyIconBmp;
90 m_pPolyIconBmp = picon_bmp;
91 }
92 void ShowBusy(bool busy);
93 void onTimerEvent(wxTimerEvent &event);
94
95 wxPoint GetKeyOrigin(int key_index);
96 void ResetRollover(void);
97 void SetRoundedRectangles(bool val) {
98 m_brounded = val;
99 m_hash.Clear();
100 }
101
102 int GetHeight();
103 int GetWidth();
104
105 wxString &GenerateAndStoreNewHash();
106 wxString &GetStoredHash();
107
108 int GetnKeys() { return m_nRegions; }
109
110private:
111 void BuildGLTexture();
112 bool InArray(std::vector<int> &array, int key);
113
114 wxString GetStateHash();
115 wxString m_hash;
116
117 ChartCanvas *m_parentCanvas;
118
119 int m_nRegions;
120 int m_index_last;
121 int m_hover_icon_last;
122 int m_hover_last;
123 bool m_gotPianoDown;
124
125 wxBrush m_backBrush;
126 wxBrush m_srBrush, m_rBrush;
127 wxBrush m_svBrush, m_vBrush;
128 wxBrush m_unavailableBrush;
129 wxBrush m_utileBrush, m_tileBrush;
130
131 wxBrush m_cBrush;
132 wxBrush m_scBrush;
133
134 std::vector<int> m_key_array;
135 std::vector<int> m_noshow_index_array;
136 std::vector<int> m_active_index_array;
137 std::vector<int> m_eclipsed_index_array;
138 std::vector<int> m_skew_index_array;
139 std::vector<int> m_tmerc_index_array;
140 std::vector<int> m_poly_index_array;
141 bool m_bBusy;
142 wxTimer m_eventTimer;
143 int m_click_sel_index;
144 int m_click_sel_dbindex;
145 int m_action;
146
147 // RectArray KeyRect;
148 std::vector<wxRect> KeyRect;
149
150 wxBitmap *m_pVizIconBmp;
151 wxBitmap *m_pInVizIconBmp;
152 wxBitmap *m_pTmercIconBmp;
153 wxBitmap *m_pSkewIconBmp;
154 wxBitmap *m_pPolyIconBmp;
155
156 int m_iactive;
157 bool m_brounded;
158 bool m_bleaving;
159
160 GLuint m_tex, m_texw, m_texh, m_tex_piano_height;
161 int m_ref, m_pad, m_radius, m_texPitch;
162
163 int m_width;
164
165 DECLARE_EVENT_TABLE()
166};
167
168//----------------------------------------------------------------------------
169// ChartBarWin
170//----------------------------------------------------------------------------
171class ChartBarWin : public wxDialog {
172public:
173 ChartBarWin(wxWindow *win);
174 ~ChartBarWin();
175 void OnSize(wxSizeEvent &event);
176 void OnPaint(wxPaintEvent &event);
177 void MouseEvent(wxMouseEvent &event);
178 int GetFontHeight();
179 void RePosition();
180 void ReSize();
181
182 DECLARE_EVENT_TABLE()
183};
184
185#endif
Definition: piano.h:49
Definition: ocpndc.h:55