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