]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/plot.h
Fix for VA 4.0
[wxWidgets.git] / include / wx / generic / plot.h
CommitLineData
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
26class WXDLLEXPORT wxPlotEvent;
27class WXDLLEXPORT wxPlotCurve;
28class WXDLLEXPORT wxPlotArea;
29class WXDLLEXPORT wxPlotXAxisArea;
30class WXDLLEXPORT wxPlotYAxisArea;
31class 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
50class WXDLLEXPORT wxPlotEvent: public wxNotifyEvent
51{
52public:
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
70private:
71 wxPlotCurve *m_curve;
72 double m_zoom;
73 wxInt32 m_position;
74};
981b2508
RR
75
76//-----------------------------------------------------------------------------
77// wxPlotCurve
78//-----------------------------------------------------------------------------
79
80class WXDLLEXPORT wxPlotCurve: public wxObject
81{
82public:
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
103private:
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
115class WXDLLEXPORT wxPlotArea: public wxWindow
116{
117public:
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 129private:
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
141class WXDLLEXPORT wxPlotXAxisArea: public wxWindow
142{
143public:
144 wxPlotXAxisArea() {}
145 wxPlotXAxisArea( wxPlotWindow *parent );
146
147 void OnPaint( wxPaintEvent &event );
148 void OnMouse( wxMouseEvent &event );
149
150private:
151 wxPlotWindow *m_owner;
152
153 DECLARE_CLASS(wxPlotXAxisArea)
154 DECLARE_EVENT_TABLE()
155};
156
157//-----------------------------------------------------------------------------
158// wxPlotYAxisArea
159//-----------------------------------------------------------------------------
160
161class WXDLLEXPORT wxPlotYAxisArea: public wxWindow
162{
163public:
164 wxPlotYAxisArea() {}
165 wxPlotYAxisArea( wxPlotWindow *parent );
166
167 void OnPaint( wxPaintEvent &event );
168 void OnMouse( wxMouseEvent &event );
169
170private:
171 wxPlotWindow *m_owner;
172
173 DECLARE_CLASS(wxPlotYAxisArea)
174 DECLARE_EVENT_TABLE()
175};
176
981b2508
RR
177//-----------------------------------------------------------------------------
178// wxPlotWindow
179//-----------------------------------------------------------------------------
180
181class WXDLLEXPORT wxPlotWindow: public wxScrolledWindow
182{
183public:
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
a5a0dd06
RR
198 void Delete( wxPlotCurve* curve );
199
279ababf
RR
200 // vertical representation
201 // -----------------------
202
d3a809c7
RR
203 void Move( wxPlotCurve* curve, int pixels_up );
204 void Enlarge( wxPlotCurve *curve, double factor );
205
279ababf
RR
206 // horizontal representation
207 // -------------------------
208
209 void SetUnitsPerValue( double upv );
210 double GetUnitsPerValue()
211 { return m_xUnitsPerValue; }
212
213 void SetZoom( double zoom );
214 double GetZoom()
215 { return m_xZoom; }
216
217 // events (may be overridden)
218 // --------------------------
219
d3a809c7
RR
220 void OnMoveUp( wxCommandEvent& event );
221 void OnMoveDown( wxCommandEvent& event );
222
279ababf
RR
223 void OnEnlarge( wxCommandEvent& event );
224 void OnShrink( wxCommandEvent& event );
225 void OnZoomIn( wxCommandEvent& event );
226 void OnZoomOut( wxCommandEvent& event );
d3a809c7 227
279ababf
RR
228 void OnScroll2( wxScrollWinEvent& event );
229
230 // utilities
231 // ---------
232
233 void RedrawEverything();
234 void RedrawXAxis();
d3a809c7 235 void RedrawYAxis();
981b2508 236
279ababf
RR
237 void ResetScrollbar();
238
981b2508
RR
239private:
240 friend wxPlotArea;
279ababf
RR
241 friend wxPlotXAxisArea;
242 friend wxPlotYAxisArea;
d3a809c7 243
279ababf
RR
244 double m_xUnitsPerValue;
245 double m_xZoom;
246
247 wxList m_curves;
248 wxPlotArea *m_area;
249 wxPlotXAxisArea *m_xaxis;
250 wxPlotYAxisArea *m_yaxis;
251 wxPlotCurve *m_current;
981b2508
RR
252
253 DECLARE_CLASS(wxPlotWindow)
254 DECLARE_EVENT_TABLE()
255};
256
279ababf
RR
257// ----------------------------------------------------------------------------
258// calendar events macros
259// ----------------------------------------------------------------------------
260
261#define EVT_PLOT(id, fn) { wxEVT_PLOT_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
262#define EVT_PLOT_SEL_CHANGING(id, fn) { wxEVT_PLOT_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
263#define EVT_PLOT_SEL_CHANGED(id, fn) { wxEVT_PLOT_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
264#define EVT_PLOT_CLICKED(id, fn) { wxEVT_PLOT_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
265#define EVT_PLOT_DOUBLECLICKED(id, fn) { wxEVT_PLOT_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
266#define EVT_PLOT_ZOOM_IN(id, fn) { wxEVT_PLOT_ZOOM_IN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
267#define EVT_PLOT_ZOOM_OUT(id, fn) { wxEVT_PLOT_ZOOM_OUT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
268#define EVT_PLOT_VALUE_SEL_CREATING(id, fn) { wxEVT_PLOT_VALUE_SEL_CREATING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
269#define EVT_PLOT_VALUE_SEL_CREATED(id, fn) { wxEVT_PLOT_VALUE_SEL_CREATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
270#define EVT_PLOT_VALUE_SEL_CHANGING(id, fn) { wxEVT_PLOT_VALUE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
271#define EVT_PLOT_VALUE_SEL_CHANGED(id, fn) { wxEVT_PLOT_VALUE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
272#define EVT_PLOT_AREA_SEL_CREATING(id, fn) { wxEVT_PLOT_AREA_SEL_CREATING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
273#define EVT_PLOT_AREA_SEL_CREATED(id, fn) { wxEVT_PLOT_AREA_SEL_CREATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
274#define EVT_PLOT_AREA_SEL_CHANGING(id, fn) { wxEVT_PLOT_AREA_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
275#define EVT_PLOT_AREA_SEL_CHANGED(id, fn) { wxEVT_PLOT_AREA_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
276#define EVT_PLOT_BEGIN_X_LABEL_EDIT(id, fn) { wxEVT_PLOT_BEGIN_X_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
277#define EVT_PLOT_END_X_LABEL_EDIT(id, fn) { wxEVT_PLOT_END_X_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
278#define EVT_PLOT_BEGIN_Y_LABEL_EDIT(id, fn) { wxEVT_PLOT_BEGIN_Y_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
279#define EVT_PLOT_END_Y_LABEL_EDIT(id, fn) { wxEVT_PLOT_END_Y_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
280#define EVT_PLOT_BEGIN_TITLE_EDIT(id, fn) { wxEVT_PLOT_BEGIN_TITLE_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
281#define EVT_PLOT_END_TITLE_EDIT(id, fn) { wxEVT_PLOT_END_TITLE_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
282
981b2508
RR
283#endif
284 // _WX_PLOT_H_