+void wxPlotArea::ScrollWindow( int dx, int dy, const wxRect *rect )
+{
+ wxWindow::ScrollWindow( dx, dy, rect );
+// m_owner->m_xaxis->ScrollWindow( dx, 0 );
+}
+
+//-----------------------------------------------------------------------------
+// wxPlotXAxisArea
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxPlotXAxisArea, wxWindow)
+
+BEGIN_EVENT_TABLE(wxPlotXAxisArea, wxWindow)
+ EVT_PAINT( wxPlotXAxisArea::OnPaint)
+ EVT_LEFT_DOWN( wxPlotXAxisArea::OnMouse)
+END_EVENT_TABLE()
+
+wxPlotXAxisArea::wxPlotXAxisArea( wxPlotWindow *parent )
+ : wxWindow( parent, -1, wxDefaultPosition, wxSize(-1,40), 0, "plotxaxisarea" )
+{
+ m_owner = parent;
+
+ SetBackgroundColour( *wxWHITE );
+ SetFont( *wxSMALL_FONT );
+}
+
+void wxPlotXAxisArea::OnMouse( wxMouseEvent &event )
+{
+ int client_width;
+ int client_height;
+ GetClientSize( &client_width, &client_height);
+ int view_x;
+ int view_y;
+ m_owner->GetViewStart( &view_x, &view_y );
+ view_x *= wxPLOT_SCROLL_STEP;
+ view_y *= wxPLOT_SCROLL_STEP;
+
+ wxCoord x = event.GetX();
+ wxCoord y = event.GetY();
+ x += view_x;
+ y += view_y;
+
+ /* do something here */
+}
+
+void wxPlotXAxisArea::OnPaint( wxPaintEvent &WXUNUSED(event) )
+{
+ int view_x;
+ int view_y;
+ m_owner->GetViewStart( &view_x, &view_y );
+ view_x *= wxPLOT_SCROLL_STEP;
+ view_y *= wxPLOT_SCROLL_STEP;
+
+ wxPaintDC dc( this );
+
+ int client_width;
+ int client_height;
+ GetClientSize( &client_width, &client_height);
+
+ double zoom = m_owner->GetZoom();
+
+ double ups = m_owner->GetUnitsPerValue() / zoom;
+
+ double start = view_x * ups;
+ double end = (view_x + client_width) * ups;
+ double range = end - start;
+
+ int int_log_range = (int)floor( log10( range ) );
+ double step = 1.0;
+ if (int_log_range > 0)
+ {
+ for (int i = 0; i < int_log_range; i++)
+ step *= 10;
+ }
+ if (int_log_range < 0)
+ {
+ for (int i = 0; i < -int_log_range; i++)
+ step /= 10;
+ }
+ double lower = ceil(start / step) * step;
+ double upper = floor(end / step) * step;
+
+ // if too few values, shrink size
+ if ((range/step) < 4)
+ {
+ step /= 2;
+ if (lower-step > start) lower -= step;
+ if (upper+step < end) upper += step;
+ }
+
+ // if still too few, again
+ if ((range/step) < 4)
+ {
+ step /= 2;
+ if (lower-step > start) lower -= step;
+ if (upper+step < end) upper += step;
+ }
+
+ dc.SetBrush( *wxWHITE_BRUSH );
+ dc.SetPen( *wxTRANSPARENT_PEN );
+ dc.DrawRectangle( 4, 5, client_width-14, 10 );
+ dc.DrawRectangle( 0, 20, client_width, 20 );
+ dc.SetPen( *wxBLACK_PEN );
+
+ double current = lower;
+ while (current < upper+(step/2))
+ {
+ int x = (int)ceil((current-start) / range * (double)client_width) - 1;
+ if ((x > 4) && (x < client_width-25))
+ {
+ dc.DrawLine( x, 5, x, 15 );
+ wxString label;
+ if (range < 50)
+ {
+ label.Printf( wxT("%f"), current );
+ while (label.Last() == wxT('0'))
+ label.RemoveLast();
+ if ((label.Last() == wxT('.')) || (label.Last() == wxT(',')))
+ label.Append( wxT('0') );
+ }
+ else
+ label.Printf( wxT("%d"), (int)floor(current) );
+ dc.DrawText( label, x-4, 20 );
+ }
+
+ current += step;
+ }
+
+ dc.DrawLine( 0, 15, client_width-8, 15 );
+ dc.DrawLine( client_width-4, 15, client_width-10, 10 );
+ dc.DrawLine( client_width-4, 15, client_width-10, 20 );
+}
+
+//-----------------------------------------------------------------------------
+// wxPlotYAxisArea
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxPlotYAxisArea, wxWindow)
+
+BEGIN_EVENT_TABLE(wxPlotYAxisArea, wxWindow)
+ EVT_PAINT( wxPlotYAxisArea::OnPaint)
+ EVT_LEFT_DOWN( wxPlotYAxisArea::OnMouse)
+END_EVENT_TABLE()
+
+wxPlotYAxisArea::wxPlotYAxisArea( wxPlotWindow *parent )
+ : wxWindow( parent, -1, wxDefaultPosition, wxSize(60,-1), 0, "plotyaxisarea" )
+{
+ m_owner = parent;
+
+ SetBackgroundColour( *wxWHITE );
+ SetFont( *wxSMALL_FONT );
+}
+
+void wxPlotYAxisArea::OnMouse( wxMouseEvent &WXUNUSED(event) )
+{
+ /* do something here */
+}
+
+void wxPlotYAxisArea::OnPaint( wxPaintEvent &WXUNUSED(event) )
+{
+ wxPaintDC dc( this );
+
+ wxPlotCurve *curve = m_owner->GetCurrent();
+
+ if (!curve) return;
+
+ int client_width;
+ int client_height;
+ GetClientSize( &client_width, &client_height);
+
+
+ double range = curve->GetEndY() - curve->GetStartY();
+ double offset = ((double) curve->GetOffsetY() / (double)client_height ) * range;
+ double start = curve->GetStartY() - offset;
+ double end = curve->GetEndY() - offset;
+
+ int int_log_range = (int)floor( log10( range ) );
+ double step = 1.0;
+ if (int_log_range > 0)
+ {
+ for (int i = 0; i < int_log_range; i++)
+ step *= 10;
+ }
+ if (int_log_range < 0)
+ {
+ for (int i = 0; i < -int_log_range; i++)
+ step /= 10;
+ }
+ double lower = ceil(start / step) * step;
+ double upper = floor(end / step) * step;
+
+ // if too few values, shrink size
+ if ((range/step) < 4)
+ {
+ step /= 2;
+ if (lower-step > start) lower -= step;
+ if (upper+step < end) upper += step;
+ }
+
+ // if still too few, again
+ if ((range/step) < 4)
+ {
+ step /= 2;
+ if (lower-step > start) lower -= step;
+ if (upper+step < end) upper += step;
+ }
+
+ dc.SetPen( *wxBLACK_PEN );
+
+ double current = lower;
+ while (current < upper+(step/2))
+ {
+ int y = (int)((curve->GetEndY()-current) / range * (double)client_height) - 1;
+ y -= curve->GetOffsetY();
+ if ((y > 10) && (y < client_height-7))
+ {
+ dc.DrawLine( client_width-15, y, client_width-7, y );
+ wxString label;
+ if (range < 50)
+ {
+ label.Printf( wxT("%f"), current );
+ while (label.Last() == wxT('0'))
+ label.RemoveLast();
+ if ((label.Last() == wxT('.')) || (label.Last() == wxT(',')))
+ label.Append( wxT('0') );
+ }
+ else
+ label.Printf( wxT("%d"), (int)floor(current) );
+ dc.DrawText( label, 5, y-7 );
+ }
+
+ current += step;
+ }
+
+ dc.DrawLine( client_width-15, 6, client_width-15, client_height );
+ dc.DrawLine( client_width-15, 2, client_width-20, 8 );
+ dc.DrawLine( client_width-15, 2, client_width-10, 8 );
+}
+