]>
Commit | Line | Data |
---|---|---|
981b2508 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: plot.h | |
3 | // Purpose: wxPlotWindow | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
6 | // Created: 12/1/2000 | |
7 | // Copyright: (c) Robert Roebling | |
8 | // RCS-ID: $Id$ | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_PLOT_H_ | |
13 | #define _WX_PLOT_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "plot.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/scrolwin.h" | |
279ababf | 20 | #include "wx/event.h" |
981b2508 RR |
21 | |
22 | //----------------------------------------------------------------------------- | |
23 | // classes | |
24 | //----------------------------------------------------------------------------- | |
25 | ||
279ababf RR |
26 | class WXDLLEXPORT wxPlotEvent; |
27 | class WXDLLEXPORT wxPlotCurve; | |
28 | class WXDLLEXPORT wxPlotArea; | |
29 | class WXDLLEXPORT wxPlotXAxisArea; | |
30 | class WXDLLEXPORT wxPlotYAxisArea; | |
31 | class WXDLLEXPORT wxPlotWindow; | |
32 | ||
33 | //----------------------------------------------------------------------------- | |
34 | // consts | |
35 | //----------------------------------------------------------------------------- | |
36 | ||
37 | #define wxPLOT_X_AXIS 0x0004 | |
38 | #define wxPLOT_Y_AXIS 0x0008 | |
39 | #define wxPLOT_BUTTON_MOVE 0x0010 | |
40 | #define wxPLOT_BUTTON_ZOOM 0x0020 | |
41 | #define wxPLOT_BUTTON_ENLARGE 0x0040 | |
42 | ||
43 | #define wxPLOT_BUTTON_ALL (wxPLOT_BUTTON_MOVE|wxPLOT_BUTTON_ZOOM|wxPLOT_BUTTON_ENLARGE) | |
44 | #define wxPLOT_DEFAULT (wxPLOT_X_AXIS|wxPLOT_Y_AXIS | wxPLOT_BUTTON_ALL) | |
45 | ||
46 | //----------------------------------------------------------------------------- | |
47 | // wxPlotEvent | |
48 | //----------------------------------------------------------------------------- | |
49 | ||
50 | class WXDLLEXPORT wxPlotEvent: public wxNotifyEvent | |
51 | { | |
52 | public: | |
53 | wxPlotEvent( wxEventType commandType = wxEVT_NULL, int id = 0 ); | |
54 | ||
55 | wxPlotCurve *GetCurve() | |
56 | { return m_curve; } | |
57 | void SetCurve( wxPlotCurve *curve ) | |
58 | { m_curve = curve; } | |
59 | ||
60 | double GetZoom() | |
61 | { return m_zoom; } | |
62 | void SetZoom( double zoom ) | |
63 | { m_zoom = zoom; } | |
64 | ||
65 | wxInt32 GetPosition() | |
66 | { return m_position; } | |
67 | void SetPosition( wxInt32 pos ) | |
68 | { m_position = pos; } | |
69 | ||
70 | private: | |
71 | wxPlotCurve *m_curve; | |
72 | double m_zoom; | |
73 | wxInt32 m_position; | |
74 | }; | |
981b2508 RR |
75 | |
76 | //----------------------------------------------------------------------------- | |
77 | // wxPlotCurve | |
78 | //----------------------------------------------------------------------------- | |
79 | ||
80 | class WXDLLEXPORT wxPlotCurve: public wxObject | |
81 | { | |
82 | public: | |
846e1424 | 83 | wxPlotCurve( int offsetY, double startY, double endY ); |
981b2508 RR |
84 | |
85 | virtual wxInt32 GetStartX() = 0; | |
86 | virtual wxInt32 GetEndX() = 0; | |
846e1424 RR |
87 | |
88 | virtual double GetY( wxInt32 x ) = 0; | |
89 | ||
90 | void SetStartY( double startY ) | |
91 | { m_startY = startY; } | |
92 | double GetStartY() | |
93 | { return m_startY; } | |
94 | void SetEndY( double endY ) | |
95 | { m_endY = endY; } | |
96 | double GetEndY() | |
97 | { return m_endY; } | |
98 | void SetOffsetY( int offsetY ) | |
99 | { m_offsetY = offsetY; } | |
981b2508 RR |
100 | int GetOffsetY() |
101 | { return m_offsetY; } | |
102 | ||
981b2508 RR |
103 | private: |
104 | int m_offsetY; | |
846e1424 RR |
105 | double m_startY; |
106 | double m_endY; | |
981b2508 RR |
107 | |
108 | DECLARE_ABSTRACT_CLASS(wxPlotCurve) | |
109 | }; | |
110 | ||
111 | //----------------------------------------------------------------------------- | |
112 | // wxPlotArea | |
113 | //----------------------------------------------------------------------------- | |
114 | ||
115 | class WXDLLEXPORT wxPlotArea: public wxWindow | |
116 | { | |
117 | public: | |
118 | wxPlotArea() {} | |
119 | wxPlotArea( wxPlotWindow *parent ); | |
120 | ||
121 | void OnPaint( wxPaintEvent &event ); | |
122 | void OnMouse( wxMouseEvent &event ); | |
d3a809c7 RR |
123 | |
124 | void DrawCurve( wxDC *dc, wxPlotCurve *curve, int from = -1, int to = -1 ); | |
125 | void DeleteCurve( wxPlotCurve *curve, int from = -1, int to = -1 ); | |
981b2508 | 126 | |
279ababf RR |
127 | virtual void ScrollWindow( int dx, int dy, const wxRect *rect ); |
128 | ||
981b2508 | 129 | private: |
279ababf RR |
130 | wxPlotWindow *m_owner; |
131 | bool m_zooming; | |
981b2508 RR |
132 | |
133 | DECLARE_CLASS(wxPlotArea) | |
134 | DECLARE_EVENT_TABLE() | |
135 | }; | |
136 | ||
279ababf RR |
137 | //----------------------------------------------------------------------------- |
138 | // wxPlotXAxisArea | |
139 | //----------------------------------------------------------------------------- | |
140 | ||
141 | class WXDLLEXPORT wxPlotXAxisArea: public wxWindow | |
142 | { | |
143 | public: | |
144 | wxPlotXAxisArea() {} | |
145 | wxPlotXAxisArea( wxPlotWindow *parent ); | |
146 | ||
147 | void OnPaint( wxPaintEvent &event ); | |
148 | void OnMouse( wxMouseEvent &event ); | |
149 | ||
150 | private: | |
151 | wxPlotWindow *m_owner; | |
152 | ||
153 | DECLARE_CLASS(wxPlotXAxisArea) | |
154 | DECLARE_EVENT_TABLE() | |
155 | }; | |
156 | ||
157 | //----------------------------------------------------------------------------- | |
158 | // wxPlotYAxisArea | |
159 | //----------------------------------------------------------------------------- | |
160 | ||
161 | class WXDLLEXPORT wxPlotYAxisArea: public wxWindow | |
162 | { | |
163 | public: | |
164 | wxPlotYAxisArea() {} | |
165 | wxPlotYAxisArea( wxPlotWindow *parent ); | |
166 | ||
167 | void OnPaint( wxPaintEvent &event ); | |
168 | void OnMouse( wxMouseEvent &event ); | |
169 | ||
170 | private: | |
171 | wxPlotWindow *m_owner; | |
172 | ||
173 | DECLARE_CLASS(wxPlotYAxisArea) | |
174 | DECLARE_EVENT_TABLE() | |
175 | }; | |
176 | ||
981b2508 RR |
177 | //----------------------------------------------------------------------------- |
178 | // wxPlotWindow | |
179 | //----------------------------------------------------------------------------- | |
180 | ||
181 | class WXDLLEXPORT wxPlotWindow: public wxScrolledWindow | |
182 | { | |
183 | public: | |
184 | wxPlotWindow() {} | |
279ababf | 185 | wxPlotWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flags = wxPLOT_DEFAULT ); |
981b2508 RR |
186 | ~wxPlotWindow(); |
187 | ||
279ababf RR |
188 | // curve accessors |
189 | // --------------- | |
190 | ||
981b2508 RR |
191 | void Add( wxPlotCurve *curve ); |
192 | size_t GetCount(); | |
193 | wxPlotCurve *GetAt( size_t n ); | |
194 | ||
195 | void SetCurrent( wxPlotCurve* current ); | |
196 | wxPlotCurve *GetCurrent(); | |
197 | ||
279ababf RR |
198 | // vertical representation |
199 | // ----------------------- | |
200 | ||
d3a809c7 RR |
201 | void Move( wxPlotCurve* curve, int pixels_up ); |
202 | void Enlarge( wxPlotCurve *curve, double factor ); | |
203 | ||
279ababf RR |
204 | // horizontal representation |
205 | // ------------------------- | |
206 | ||
207 | void SetUnitsPerValue( double upv ); | |
208 | double GetUnitsPerValue() | |
209 | { return m_xUnitsPerValue; } | |
210 | ||
211 | void SetZoom( double zoom ); | |
212 | double GetZoom() | |
213 | { return m_xZoom; } | |
214 | ||
215 | // events (may be overridden) | |
216 | // -------------------------- | |
217 | ||
d3a809c7 RR |
218 | void OnMoveUp( wxCommandEvent& event ); |
219 | void OnMoveDown( wxCommandEvent& event ); | |
220 | ||
279ababf RR |
221 | void OnEnlarge( wxCommandEvent& event ); |
222 | void OnShrink( wxCommandEvent& event ); | |
223 | void OnZoomIn( wxCommandEvent& event ); | |
224 | void OnZoomOut( wxCommandEvent& event ); | |
d3a809c7 | 225 | |
279ababf RR |
226 | void OnScroll2( wxScrollWinEvent& event ); |
227 | ||
228 | // utilities | |
229 | // --------- | |
230 | ||
231 | void RedrawEverything(); | |
232 | void RedrawXAxis(); | |
d3a809c7 | 233 | void RedrawYAxis(); |
981b2508 | 234 | |
279ababf RR |
235 | void ResetScrollbar(); |
236 | ||
981b2508 RR |
237 | private: |
238 | friend wxPlotArea; | |
279ababf RR |
239 | friend wxPlotXAxisArea; |
240 | friend wxPlotYAxisArea; | |
d3a809c7 | 241 | |
279ababf RR |
242 | double m_xUnitsPerValue; |
243 | double m_xZoom; | |
244 | ||
245 | wxList m_curves; | |
246 | wxPlotArea *m_area; | |
247 | wxPlotXAxisArea *m_xaxis; | |
248 | wxPlotYAxisArea *m_yaxis; | |
249 | wxPlotCurve *m_current; | |
981b2508 RR |
250 | |
251 | DECLARE_CLASS(wxPlotWindow) | |
252 | DECLARE_EVENT_TABLE() | |
253 | }; | |
254 | ||
279ababf RR |
255 | // ---------------------------------------------------------------------------- |
256 | // calendar events macros | |
257 | // ---------------------------------------------------------------------------- | |
258 | ||
259 | #define EVT_PLOT(id, fn) { wxEVT_PLOT_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
260 | #define EVT_PLOT_SEL_CHANGING(id, fn) { wxEVT_PLOT_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
261 | #define EVT_PLOT_SEL_CHANGED(id, fn) { wxEVT_PLOT_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
262 | #define EVT_PLOT_CLICKED(id, fn) { wxEVT_PLOT_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
263 | #define EVT_PLOT_DOUBLECLICKED(id, fn) { wxEVT_PLOT_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
264 | #define EVT_PLOT_ZOOM_IN(id, fn) { wxEVT_PLOT_ZOOM_IN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
265 | #define EVT_PLOT_ZOOM_OUT(id, fn) { wxEVT_PLOT_ZOOM_OUT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
266 | #define EVT_PLOT_VALUE_SEL_CREATING(id, fn) { wxEVT_PLOT_VALUE_SEL_CREATING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
267 | #define EVT_PLOT_VALUE_SEL_CREATED(id, fn) { wxEVT_PLOT_VALUE_SEL_CREATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
268 | #define EVT_PLOT_VALUE_SEL_CHANGING(id, fn) { wxEVT_PLOT_VALUE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
269 | #define EVT_PLOT_VALUE_SEL_CHANGED(id, fn) { wxEVT_PLOT_VALUE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
270 | #define EVT_PLOT_AREA_SEL_CREATING(id, fn) { wxEVT_PLOT_AREA_SEL_CREATING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
271 | #define EVT_PLOT_AREA_SEL_CREATED(id, fn) { wxEVT_PLOT_AREA_SEL_CREATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
272 | #define EVT_PLOT_AREA_SEL_CHANGING(id, fn) { wxEVT_PLOT_AREA_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
273 | #define EVT_PLOT_AREA_SEL_CHANGED(id, fn) { wxEVT_PLOT_AREA_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
274 | #define EVT_PLOT_BEGIN_X_LABEL_EDIT(id, fn) { wxEVT_PLOT_BEGIN_X_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
275 | #define EVT_PLOT_END_X_LABEL_EDIT(id, fn) { wxEVT_PLOT_END_X_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
276 | #define EVT_PLOT_BEGIN_Y_LABEL_EDIT(id, fn) { wxEVT_PLOT_BEGIN_Y_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
277 | #define EVT_PLOT_END_Y_LABEL_EDIT(id, fn) { wxEVT_PLOT_END_Y_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
278 | #define EVT_PLOT_BEGIN_TITLE_EDIT(id, fn) { wxEVT_PLOT_BEGIN_TITLE_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
279 | #define EVT_PLOT_END_TITLE_EDIT(id, fn) { wxEVT_PLOT_END_TITLE_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
280 | ||
981b2508 RR |
281 | #endif |
282 | // _WX_PLOT_H_ |