]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/plot/plot.cpp
don't use wxStaticCast to wxBookCtrlBase -- it doesn't work
[wxWidgets.git] / contrib / src / plot / plot.cpp
CommitLineData
8556b795
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: plot.cpp
3// Purpose: wxPlotWindow
4// Author: Robert Roebling
5// Modified by:
6// Created: 12/01/2000
7// RCS-ID: $Id$
8// Copyright: (c) Robert Roebling
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
8556b795
RR
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
20#include "wx/object.h"
21#include "wx/font.h"
22#include "wx/colour.h"
23#include "wx/settings.h"
24#include "wx/sizer.h"
25#include "wx/log.h"
26#include "wx/intl.h"
27#include "wx/dcclient.h"
8fb816ff 28#include "wx/stattext.h"
8556b795
RR
29#endif
30
31#include "wx/plot/plot.h"
32#include "wx/bmpbuttn.h"
27b1df43 33#include "wx/module.h"
8556b795
RR
34
35#include <math.h>
36
37// ----------------------------------------------------------------------------
38// XPMs
39// ----------------------------------------------------------------------------
40
41#if !defined(__WXMSW__) && !defined(__WXPM__)
42 #include "wx/plot/plot_enl.xpm"
43 #include "wx/plot/plot_shr.xpm"
44 #include "wx/plot/plot_zin.xpm"
45 #include "wx/plot/plot_zot.xpm"
46 #include "wx/plot/plot_up.xpm"
47 #include "wx/plot/plot_dwn.xpm"
48#endif
49
adb85931
RR
50//----------------------------------------------------------------------------
51// event types
52//----------------------------------------------------------------------------
53
97ee90ee
MB
54DEFINE_EVENT_TYPE(wxEVT_PLOT_SEL_CHANGING);
55DEFINE_EVENT_TYPE(wxEVT_PLOT_SEL_CHANGED);
56DEFINE_EVENT_TYPE(wxEVT_PLOT_CLICKED);
57DEFINE_EVENT_TYPE(wxEVT_PLOT_DOUBLECLICKED);
58DEFINE_EVENT_TYPE(wxEVT_PLOT_ZOOM_IN);
59DEFINE_EVENT_TYPE(wxEVT_PLOT_ZOOM_OUT);
60DEFINE_EVENT_TYPE(wxEVT_PLOT_VALUE_SEL_CREATING);
61DEFINE_EVENT_TYPE(wxEVT_PLOT_VALUE_SEL_CREATED);
62DEFINE_EVENT_TYPE(wxEVT_PLOT_VALUE_SEL_CHANGING);
63DEFINE_EVENT_TYPE(wxEVT_PLOT_VALUE_SEL_CHANGED);
64DEFINE_EVENT_TYPE(wxEVT_PLOT_AREA_SEL_CREATING);
65DEFINE_EVENT_TYPE(wxEVT_PLOT_AREA_SEL_CREATED);
66DEFINE_EVENT_TYPE(wxEVT_PLOT_AREA_SEL_CHANGING);
67DEFINE_EVENT_TYPE(wxEVT_PLOT_AREA_SEL_CHANGED);
68DEFINE_EVENT_TYPE(wxEVT_PLOT_BEGIN_X_LABEL_EDIT);
69DEFINE_EVENT_TYPE(wxEVT_PLOT_END_X_LABEL_EDIT);
70DEFINE_EVENT_TYPE(wxEVT_PLOT_BEGIN_Y_LABEL_EDIT);
71DEFINE_EVENT_TYPE(wxEVT_PLOT_END_Y_LABEL_EDIT);
72DEFINE_EVENT_TYPE(wxEVT_PLOT_BEGIN_TITLE_EDIT);
73DEFINE_EVENT_TYPE(wxEVT_PLOT_END_TITLE_EDIT);
74DEFINE_EVENT_TYPE(wxEVT_PLOT_AREA_CREATE);
adb85931 75
8556b795
RR
76//----------------------------------------------------------------------------
77// accessor functions for the bitmaps (may return NULL, check for it!)
78//----------------------------------------------------------------------------
79
80static wxBitmap *GetEnlargeBitmap();
81static wxBitmap *GetShrinkBitmap();
82static wxBitmap *GetZoomInBitmap();
83static wxBitmap *GetZoomOutBitmap();
84static wxBitmap *GetUpBitmap();
85static wxBitmap *GetDownBitmap();
86
8556b795
RR
87//-----------------------------------------------------------------------------
88// consts
89//-----------------------------------------------------------------------------
90
91#define wxPLOT_SCROLL_STEP 30
92
93//-----------------------------------------------------------------------------
94// wxPlotEvent
95//-----------------------------------------------------------------------------
96
97wxPlotEvent::wxPlotEvent( wxEventType commandType, int id )
98 : wxNotifyEvent( commandType, id )
298a3f2e 99{
8556b795
RR
100 m_curve = (wxPlotCurve*) NULL;
101 m_zoom = 1.0;
102 m_position = 0;
103}
298a3f2e 104
8556b795
RR
105//-----------------------------------------------------------------------------
106// wxPlotCurve
107//-----------------------------------------------------------------------------
108
109IMPLEMENT_ABSTRACT_CLASS(wxPlotCurve, wxObject)
110
111wxPlotCurve::wxPlotCurve( int offsetY, double startY, double endY )
8fb816ff 112: m_penNormal(*wxGREY_PEN), m_penSelected(*wxBLACK_PEN)
8556b795
RR
113{
114 m_offsetY = offsetY;
115 m_startY = startY;
116 m_endY = endY;
117}
118
119//-----------------------------------------------------------------------------
120// wxPlotOnOffCurve
121//-----------------------------------------------------------------------------
122
123IMPLEMENT_CLASS(wxPlotOnOffCurve, wxObject)
124
125#include "wx/arrimpl.cpp"
126WX_DEFINE_OBJARRAY(wxArrayPlotOnOff);
127
128wxPlotOnOffCurve::wxPlotOnOffCurve( int offsetY )
129{
130 m_offsetY = offsetY;
131 m_minX = -1;
132 m_maxX = -1;
133}
134
135void wxPlotOnOffCurve::Add( wxInt32 on, wxInt32 off, void *clientData )
136{
f7a8c129 137 wxASSERT_MSG( on > 0, _T("plot index < 0") );
8556b795
RR
138 wxASSERT( on <= off );
139
140 if (m_minX == -1)
141 m_minX = on;
142 if (off > m_maxX)
143 m_maxX = off;
298a3f2e 144
8556b795
RR
145 wxPlotOnOff *v = new wxPlotOnOff;
146 v->m_on = on;
147 v->m_off = off;
148 v->m_clientData = clientData;
149 m_marks.Add( v );
150}
151
152size_t wxPlotOnOffCurve::GetCount()
153{
154 return m_marks.GetCount();
155}
156
157wxInt32 wxPlotOnOffCurve::GetOn( size_t index )
158{
159 wxPlotOnOff *v = &m_marks.Item( index );
160 return v->m_on;
161}
162
163wxInt32 wxPlotOnOffCurve::GetOff( size_t index )
164{
165 wxPlotOnOff *v = &m_marks.Item( index );
166 return v->m_off;
167}
168
169void* wxPlotOnOffCurve::GetClientData( size_t index )
170{
171 wxPlotOnOff *v = &m_marks.Item( index );
172 return v->m_clientData;
173}
174
175wxPlotOnOff *wxPlotOnOffCurve::GetAt( size_t index )
176{
177 return &m_marks.Item( index );
178}
179
180void wxPlotOnOffCurve::DrawOnLine( wxDC &dc, wxCoord y, wxCoord start, wxCoord end, void *WXUNUSED(clientData) )
181{
182 dc.DrawLine( start, y, start, y-30 );
183 dc.DrawLine( start, y-30, end, y-30 );
184 dc.DrawLine( end, y-30, end, y );
185}
186
187void wxPlotOnOffCurve::DrawOffLine( wxDC &dc, wxCoord y, wxCoord start, wxCoord end )
188{
189 dc.DrawLine( start, y, end, y );
190}
191
192//-----------------------------------------------------------------------------
193// wxPlotArea
194//-----------------------------------------------------------------------------
195
196IMPLEMENT_DYNAMIC_CLASS(wxPlotArea, wxWindow)
197
198BEGIN_EVENT_TABLE(wxPlotArea, wxWindow)
298a3f2e
WS
199 EVT_PAINT( wxPlotArea::OnPaint)
200 EVT_LEFT_DOWN( wxPlotArea::OnMouse)
201 EVT_LEFT_DCLICK( wxPlotArea::OnMouse)
8556b795
RR
202END_EVENT_TABLE()
203
204wxPlotArea::wxPlotArea( wxPlotWindow *parent )
298a3f2e 205 : wxWindow( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER, _T("plotarea") )
8556b795
RR
206{
207 m_owner = parent;
298a3f2e
WS
208
209 m_zooming = false;
8556b795
RR
210
211 SetBackgroundColour( *wxWHITE );
212}
213
214void wxPlotArea::OnMouse( wxMouseEvent &event )
215{
216 int client_width;
217 int client_height;
218 GetClientSize( &client_width, &client_height);
219 int view_x;
220 int view_y;
221 m_owner->GetViewStart( &view_x, &view_y );
222 view_x *= wxPLOT_SCROLL_STEP;
223 view_y *= wxPLOT_SCROLL_STEP;
298a3f2e 224
8556b795
RR
225 wxCoord x = event.GetX();
226 wxCoord y = event.GetY();
227 x += view_x;
228 y += view_y;
298a3f2e 229
9c592b61 230 wxList::compatibility_iterator node = m_owner->m_curves.GetFirst();
8556b795
RR
231 while (node)
232 {
d301b8a2 233 wxPlotCurve *curve = (wxPlotCurve*)node->GetData();
298a3f2e 234
8556b795
RR
235 double double_client_height = (double)client_height;
236 double range = curve->GetEndY() - curve->GetStartY();
237 double end = curve->GetEndY();
238 wxCoord offset_y = curve->GetOffsetY();
298a3f2e 239
8556b795
RR
240 double dy = (end - curve->GetY( (wxInt32)(x/m_owner->GetZoom()) )) / range;
241 wxCoord curve_y = (wxCoord)(dy * double_client_height) - offset_y - 1;
298a3f2e 242
8556b795
RR
243 if ((y-curve_y < 4) && (y-curve_y > -4))
244 {
245 wxPlotEvent event1( event.ButtonDClick() ? wxEVT_PLOT_DOUBLECLICKED : wxEVT_PLOT_CLICKED, m_owner->GetId() );
246 event1.SetEventObject( m_owner );
247 event1.SetZoom( m_owner->GetZoom() );
248 event1.SetCurve( curve );
249 event1.SetPosition( (int)floor(x/m_owner->GetZoom()) );
250 m_owner->GetEventHandler()->ProcessEvent( event1 );
298a3f2e 251
6c43b66e 252 if (curve != m_owner->GetCurrentCurve())
8556b795
RR
253 {
254 wxPlotEvent event2( wxEVT_PLOT_SEL_CHANGING, m_owner->GetId() );
255 event2.SetEventObject( m_owner );
256 event2.SetZoom( m_owner->GetZoom() );
257 event2.SetCurve( curve );
258 if (!m_owner->GetEventHandler()->ProcessEvent( event2 ) || event2.IsAllowed())
259 {
6c43b66e 260 m_owner->SetCurrentCurve( curve );
8556b795
RR
261 }
262 }
263 return;
264 }
298a3f2e 265
d301b8a2 266 node = node->GetNext();
8556b795
RR
267 }
268}
269
270void wxPlotArea::DeleteCurve( wxPlotCurve *curve, int from, int to )
271{
272 wxClientDC dc(this);
273 m_owner->PrepareDC( dc );
274 dc.SetPen( *wxWHITE_PEN );
275 DrawCurve( &dc, curve, from, to );
276}
277
278void wxPlotArea::DrawCurve( wxDC *dc, wxPlotCurve *curve, int from, int to )
279{
280 int view_x;
281 int view_y;
282 m_owner->GetViewStart( &view_x, &view_y );
283 view_x *= wxPLOT_SCROLL_STEP;
298a3f2e 284
8556b795
RR
285 if (from == -1)
286 from = view_x;
287
288 int client_width;
289 int client_height;
290 GetClientSize( &client_width, &client_height);
298a3f2e 291
8556b795
RR
292 if (to == -1)
293 to = view_x + client_width;
298a3f2e 294
8556b795
RR
295 double zoom = m_owner->GetZoom();
296
297 int start_x = wxMax( from, (int)floor(curve->GetStartX()*zoom) );
298 int end_x = wxMin( to, (int)floor(curve->GetEndX()*zoom) );
299
300 start_x = wxMax( view_x, start_x );
301 end_x = wxMin( view_x + client_width, end_x );
298a3f2e 302
8556b795
RR
303 end_x++;
304
305 double double_client_height = (double)client_height;
306 double range = curve->GetEndY() - curve->GetStartY();
307 double end = curve->GetEndY();
308 wxCoord offset_y = curve->GetOffsetY();
298a3f2e 309
d301b8a2 310 wxCoord last_y=0;
8556b795
RR
311 for (int x = start_x; x < end_x; x++)
312 {
313 double dy = (end - curve->GetY( (wxInt32)(x/zoom) )) / range;
d301b8a2 314 wxCoord y = (wxCoord)(dy * double_client_height) - offset_y - 1;
298a3f2e 315
8556b795
RR
316 if (x != start_x)
317 dc->DrawLine( x-1, last_y, x, y );
298a3f2e 318
8556b795
RR
319 last_y = y;
320 }
321}
322
323void wxPlotArea::DrawOnOffCurve( wxDC *dc, wxPlotOnOffCurve *curve, int from, int to )
324{
325 int view_x;
326 int view_y;
327 m_owner->GetViewStart( &view_x, &view_y );
328 view_x *= wxPLOT_SCROLL_STEP;
298a3f2e 329
8556b795
RR
330 if (from == -1)
331 from = view_x;
332
333 int client_width;
334 int client_height;
335 GetClientSize( &client_width, &client_height);
298a3f2e 336
8556b795
RR
337 if (to == -1)
338 to = view_x + client_width;
298a3f2e 339
8556b795
RR
340 double zoom = m_owner->GetZoom();
341
342 int start_x = wxMax( from, (int)floor(curve->GetStartX()*zoom) );
343 int end_x = wxMin( to, (int)floor(curve->GetEndX()*zoom) );
344
345 start_x = wxMax( view_x, start_x );
346 end_x = wxMin( view_x + client_width, end_x );
298a3f2e 347
8556b795
RR
348 end_x++;
349
350 wxCoord offset_y = curve->GetOffsetY();
351 wxCoord last_off = -5;
298a3f2e 352
8556b795
RR
353 if (curve->GetCount() == 0)
354 return;
298a3f2e 355
8556b795
RR
356 for (size_t index = 0; index < curve->GetCount(); index++)
357 {
358 wxPlotOnOff *p = curve->GetAt( index );
298a3f2e 359
8556b795
RR
360 wxCoord on = (wxCoord)(p->m_on*zoom);
361 wxCoord off = (wxCoord)(p->m_off*zoom);
362
363 if (end_x < on)
364 {
365 curve->DrawOffLine( *dc, client_height-offset_y, last_off, on );
366 break;
367 }
298a3f2e 368
8556b795
RR
369 if (off >= start_x)
370 {
371 curve->DrawOffLine( *dc, client_height-offset_y, last_off, on );
372 curve->DrawOnLine( *dc, client_height-offset_y, on, off, p->m_clientData );
373 }
374 last_off = off;
375 }
298a3f2e 376
8556b795
RR
377 wxPlotOnOff *p = curve->GetAt( curve->GetCount()-1 );
378 wxCoord off = (wxCoord)(p->m_off*zoom);
379 if (off < end_x)
380 curve->DrawOffLine( *dc, client_height-offset_y, off, to );
381}
382
383void wxPlotArea::OnPaint( wxPaintEvent &WXUNUSED(event) )
384{
385 int view_x;
386 int view_y;
387 m_owner->GetViewStart( &view_x, &view_y );
388 view_x *= wxPLOT_SCROLL_STEP;
389 view_y *= wxPLOT_SCROLL_STEP;
390
391 wxPaintDC dc( this );
392 m_owner->PrepareDC( dc );
393
394 wxRegionIterator upd( GetUpdateRegion() );
298a3f2e 395
8556b795
RR
396 while (upd)
397 {
d301b8a2 398 int update_x = upd.GetX() + view_x;
8556b795 399 int update_width = upd.GetWidth();
298a3f2e 400
8556b795
RR
401/*
402 if (m_owner->m_current)
403 {
404 dc.SetPen( *wxLIGHT_GREY_PEN );
405 int base_line = client_height - m_owner->m_current->GetOffsetY();
406 dc.DrawLine( update_x-1, base_line-1, update_x+update_width+2, base_line-1 );
407 }
408*/
298a3f2e 409
9c592b61 410 wxList::compatibility_iterator node = m_owner->m_curves.GetFirst();
8556b795
RR
411 while (node)
412 {
d301b8a2 413 wxPlotCurve *curve = (wxPlotCurve*) node->GetData();
298a3f2e 414
6c43b66e 415 if (curve == m_owner->GetCurrentCurve())
8fb816ff 416 dc.SetPen( curve->GetPenSelected() );
8556b795 417 else
8fb816ff 418 dc.SetPen( curve->GetPenNormal() );
298a3f2e 419
8556b795
RR
420 DrawCurve( &dc, curve, update_x-1, update_x+update_width+2 );
421
d301b8a2 422 node = node->GetNext();
8556b795 423 }
298a3f2e 424
8556b795 425 dc.SetPen( *wxRED_PEN );
298a3f2e 426
d301b8a2 427 node = m_owner->m_onOffCurves.GetFirst();
8556b795
RR
428 while (node)
429 {
d301b8a2 430 wxPlotOnOffCurve *curve = (wxPlotOnOffCurve*) node->GetData();
298a3f2e 431
8556b795 432 DrawOnOffCurve( &dc, curve, update_x-1, update_x+update_width+2 );
298a3f2e 433
d301b8a2 434 node = node->GetNext();
8556b795 435 }
298a3f2e 436
8556b795
RR
437 upd ++;
438 }
439}
440
441void wxPlotArea::ScrollWindow( int dx, int dy, const wxRect *rect )
442{
443 wxWindow::ScrollWindow( dx, dy, rect );
444// m_owner->m_xaxis->ScrollWindow( dx, 0 );
445}
446
447//-----------------------------------------------------------------------------
448// wxPlotXAxisArea
449//-----------------------------------------------------------------------------
450
451IMPLEMENT_DYNAMIC_CLASS(wxPlotXAxisArea, wxWindow)
452
453BEGIN_EVENT_TABLE(wxPlotXAxisArea, wxWindow)
454 EVT_PAINT( wxPlotXAxisArea::OnPaint)
455 EVT_LEFT_DOWN( wxPlotXAxisArea::OnMouse)
456END_EVENT_TABLE()
457
458wxPlotXAxisArea::wxPlotXAxisArea( wxPlotWindow *parent )
298a3f2e 459 : wxWindow( parent, wxID_ANY, wxDefaultPosition, wxSize(wxDefaultCoord,40), 0, _T("plotxaxisarea") )
8556b795
RR
460{
461 m_owner = parent;
298a3f2e 462
8556b795
RR
463 SetBackgroundColour( *wxWHITE );
464 SetFont( *wxSMALL_FONT );
465}
466
467void wxPlotXAxisArea::OnMouse( wxMouseEvent &event )
468{
469 int client_width;
470 int client_height;
471 GetClientSize( &client_width, &client_height);
472 int view_x;
473 int view_y;
474 m_owner->GetViewStart( &view_x, &view_y );
475 view_x *= wxPLOT_SCROLL_STEP;
476 view_y *= wxPLOT_SCROLL_STEP;
298a3f2e 477
d301b8a2
DS
478 wxCoord x = event.GetX() + view_x;
479 wxCoord y = event.GetY() + view_y;
298a3f2e 480
d301b8a2
DS
481 /* TO DO: do something here */
482 wxUnusedVar(x);
483 wxUnusedVar(y);
8556b795
RR
484}
485
486void wxPlotXAxisArea::OnPaint( wxPaintEvent &WXUNUSED(event) )
487{
488 int view_x;
489 int view_y;
490 m_owner->GetViewStart( &view_x, &view_y );
491 view_x *= wxPLOT_SCROLL_STEP;
492 view_y *= wxPLOT_SCROLL_STEP;
493
494 wxPaintDC dc( this );
298a3f2e 495
8556b795
RR
496 int client_width;
497 int client_height;
498 GetClientSize( &client_width, &client_height);
298a3f2e 499
8556b795 500 double zoom = m_owner->GetZoom();
298a3f2e 501
8556b795 502 double ups = m_owner->GetUnitsPerValue() / zoom;
298a3f2e 503
8556b795
RR
504 double start = view_x * ups;
505 double end = (view_x + client_width) * ups;
506 double range = end - start;
298a3f2e 507
8556b795
RR
508 int int_log_range = (int)floor( log10( range ) );
509 double step = 1.0;
510 if (int_log_range > 0)
511 {
512 for (int i = 0; i < int_log_range; i++)
298a3f2e 513 step *= 10;
8556b795
RR
514 }
515 if (int_log_range < 0)
516 {
517 for (int i = 0; i < -int_log_range; i++)
298a3f2e 518 step /= 10;
8556b795
RR
519 }
520 double lower = ceil(start / step) * step;
521 double upper = floor(end / step) * step;
298a3f2e 522
8556b795
RR
523 // if too few values, shrink size
524 if ((range/step) < 4)
525 {
526 step /= 2;
527 if (lower-step > start) lower -= step;
528 if (upper+step < end) upper += step;
529 }
298a3f2e 530
8556b795
RR
531 // if still too few, again
532 if ((range/step) < 4)
533 {
534 step /= 2;
535 if (lower-step > start) lower -= step;
536 if (upper+step < end) upper += step;
537 }
298a3f2e 538
8556b795 539 dc.SetBrush( *wxWHITE_BRUSH );
d7313a61 540 dc.SetPen( *wxTRANSPARENT_PEN );
8556b795
RR
541 dc.DrawRectangle( 4, 5, client_width-14, 10 );
542 dc.DrawRectangle( 0, 20, client_width, 20 );
543 dc.SetPen( *wxBLACK_PEN );
298a3f2e 544
8556b795
RR
545 double current = lower;
546 while (current < upper+(step/2))
547 {
548 int x = (int)ceil((current-start) / range * (double)client_width) - 1;
549 if ((x > 4) && (x < client_width-25))
550 {
551 dc.DrawLine( x, 5, x, 15 );
552 wxString label;
553 if (range < 50)
554 {
f7a8c129 555 label.Printf( _T("%f"), current );
298a3f2e 556 while (label.Last() == _T('0'))
8556b795 557 label.RemoveLast();
f7a8c129
JS
558 if ((label.Last() == _T('.')) || (label.Last() == _T(',')))
559 label.Append( _T('0') );
8556b795
RR
560 }
561 else
f7a8c129 562 label.Printf( _T("%d"), (int)floor(current) );
8556b795
RR
563 dc.DrawText( label, x-4, 20 );
564 }
565
566 current += step;
567 }
298a3f2e 568
8556b795
RR
569 dc.DrawLine( 0, 15, client_width-8, 15 );
570 dc.DrawLine( client_width-4, 15, client_width-10, 10 );
571 dc.DrawLine( client_width-4, 15, client_width-10, 20 );
572}
573
574//-----------------------------------------------------------------------------
575// wxPlotYAxisArea
576//-----------------------------------------------------------------------------
577
578IMPLEMENT_DYNAMIC_CLASS(wxPlotYAxisArea, wxWindow)
579
580BEGIN_EVENT_TABLE(wxPlotYAxisArea, wxWindow)
581 EVT_PAINT( wxPlotYAxisArea::OnPaint)
582 EVT_LEFT_DOWN( wxPlotYAxisArea::OnMouse)
583END_EVENT_TABLE()
584
585wxPlotYAxisArea::wxPlotYAxisArea( wxPlotWindow *parent )
298a3f2e 586 : wxWindow( parent, wxID_ANY, wxDefaultPosition, wxSize(60,wxDefaultCoord), 0, _T("plotyaxisarea") )
8556b795
RR
587{
588 m_owner = parent;
298a3f2e 589
8556b795
RR
590 SetBackgroundColour( *wxWHITE );
591 SetFont( *wxSMALL_FONT );
592}
593
594void wxPlotYAxisArea::OnMouse( wxMouseEvent &WXUNUSED(event) )
595{
596 /* do something here */
597}
598
599void wxPlotYAxisArea::OnPaint( wxPaintEvent &WXUNUSED(event) )
600{
601 wxPaintDC dc( this );
298a3f2e 602
6c43b66e 603 wxPlotCurve *curve = m_owner->GetCurrentCurve();
298a3f2e 604
8556b795 605 if (!curve) return;
298a3f2e 606
8556b795
RR
607 int client_width;
608 int client_height;
609 GetClientSize( &client_width, &client_height);
610
298a3f2e 611
8556b795
RR
612 double range = curve->GetEndY() - curve->GetStartY();
613 double offset = ((double) curve->GetOffsetY() / (double)client_height ) * range;
614 double start = curve->GetStartY() - offset;
615 double end = curve->GetEndY() - offset;
298a3f2e 616
8556b795
RR
617 int int_log_range = (int)floor( log10( range ) );
618 double step = 1.0;
619 if (int_log_range > 0)
620 {
621 for (int i = 0; i < int_log_range; i++)
298a3f2e 622 step *= 10;
8556b795
RR
623 }
624 if (int_log_range < 0)
625 {
626 for (int i = 0; i < -int_log_range; i++)
298a3f2e 627 step /= 10;
8556b795
RR
628 }
629 double lower = ceil(start / step) * step;
630 double upper = floor(end / step) * step;
298a3f2e 631
8556b795
RR
632 // if too few values, shrink size
633 if ((range/step) < 4)
634 {
635 step /= 2;
636 if (lower-step > start) lower -= step;
637 if (upper+step < end) upper += step;
638 }
298a3f2e 639
8556b795
RR
640 // if still too few, again
641 if ((range/step) < 4)
642 {
643 step /= 2;
644 if (lower-step > start) lower -= step;
645 if (upper+step < end) upper += step;
646 }
647
648 dc.SetPen( *wxBLACK_PEN );
298a3f2e 649
8556b795
RR
650 double current = lower;
651 while (current < upper+(step/2))
652 {
653 int y = (int)((curve->GetEndY()-current) / range * (double)client_height) - 1;
654 y -= curve->GetOffsetY();
655 if ((y > 10) && (y < client_height-7))
656 {
657 dc.DrawLine( client_width-15, y, client_width-7, y );
658 wxString label;
659 if (range < 50)
660 {
f7a8c129 661 label.Printf( _T("%f"), current );
298a3f2e 662 while (label.Last() == _T('0'))
8556b795 663 label.RemoveLast();
f7a8c129
JS
664 if ((label.Last() == _T('.')) || (label.Last() == _T(',')))
665 label.Append( _T('0') );
8556b795
RR
666 }
667 else
f7a8c129 668 label.Printf( _T("%d"), (int)floor(current) );
8556b795
RR
669 dc.DrawText( label, 5, y-7 );
670 }
671
672 current += step;
673 }
298a3f2e 674
8556b795
RR
675 dc.DrawLine( client_width-15, 6, client_width-15, client_height );
676 dc.DrawLine( client_width-15, 2, client_width-20, 8 );
677 dc.DrawLine( client_width-15, 2, client_width-10, 8 );
678}
679
680//-----------------------------------------------------------------------------
681// wxPlotWindow
682//-----------------------------------------------------------------------------
683
684#define ID_ENLARGE 1000
685#define ID_SHRINK 1002
686
687#define ID_MOVE_UP 1006
688#define ID_MOVE_DOWN 1007
689
690#define ID_ZOOM_IN 1010
691#define ID_ZOOM_OUT 1011
692
693
694IMPLEMENT_DYNAMIC_CLASS(wxPlotWindow, wxScrolledWindow)
695
696BEGIN_EVENT_TABLE(wxPlotWindow, wxScrolledWindow)
298a3f2e
WS
697 EVT_BUTTON( ID_MOVE_UP, wxPlotWindow::OnMoveUp)
698 EVT_BUTTON( ID_MOVE_DOWN, wxPlotWindow::OnMoveDown)
699
700 EVT_BUTTON( ID_ENLARGE, wxPlotWindow::OnEnlarge)
701 EVT_BUTTON( ID_SHRINK, wxPlotWindow::OnShrink)
702
703 EVT_BUTTON( ID_ZOOM_IN, wxPlotWindow::OnZoomIn)
704 EVT_BUTTON( ID_ZOOM_OUT, wxPlotWindow::OnZoomOut)
705
706 EVT_SCROLLWIN( wxPlotWindow::OnScroll2)
8556b795
RR
707END_EVENT_TABLE()
708
709wxPlotWindow::wxPlotWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag )
8fb816ff
MW
710 : wxScrolledWindow( parent, id, pos, size, flag, _T("plotcanvas") ),
711 m_titleStaticText( NULL )
8556b795
RR
712{
713 m_xUnitsPerValue = 1.0;
714 m_xZoom = 1.0;
298a3f2e
WS
715
716 m_enlargeAroundWindowCentre = false;
717 m_scrollOnThumbRelease = false;
8556b795
RR
718
719 m_area = new wxPlotArea( this );
720 wxBoxSizer *mainsizer = new wxBoxSizer( wxHORIZONTAL );
298a3f2e 721
8556b795
RR
722 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ALL) != 0)
723 {
724 wxBoxSizer *buttonlist = new wxBoxSizer( wxVERTICAL );
725 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ENLARGE) != 0)
726 {
727 buttonlist->Add( new wxBitmapButton( this, ID_ENLARGE, *GetEnlargeBitmap() ), 0, wxEXPAND|wxALL, 2 );
728 buttonlist->Add( new wxBitmapButton( this, ID_SHRINK, *GetShrinkBitmap() ), 0, wxEXPAND|wxALL, 2 );
729 buttonlist->Add( 20,10, 0 );
730 }
731 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_MOVE) != 0)
732 {
733 buttonlist->Add( new wxBitmapButton( this, ID_MOVE_UP, *GetUpBitmap() ), 0, wxEXPAND|wxALL, 2 );
734 buttonlist->Add( new wxBitmapButton( this, ID_MOVE_DOWN, *GetDownBitmap() ), 0, wxEXPAND|wxALL, 2 );
735 buttonlist->Add( 20,10, 0 );
736 }
737 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ZOOM) != 0)
738 {
739 buttonlist->Add( new wxBitmapButton( this, ID_ZOOM_IN, *GetZoomInBitmap() ), 0, wxEXPAND|wxALL, 2 );
740 buttonlist->Add( new wxBitmapButton( this, ID_ZOOM_OUT, *GetZoomOutBitmap() ), 0, wxEXPAND|wxALL, 2 );
741 }
742 mainsizer->Add( buttonlist, 0, wxEXPAND|wxALL, 4 );
743 }
298a3f2e 744
8556b795 745 wxBoxSizer *plotsizer = new wxBoxSizer( wxHORIZONTAL );
298a3f2e 746
8fb816ff
MW
747 //Add sizer to hold the title and plot.
748 //Title to be added later.
749 m_plotAndTitleSizer = new wxBoxSizer( wxVERTICAL );
750 m_plotAndTitleSizer->Add( plotsizer, 1, wxEXPAND | wxTOP, 10 );
751
8556b795
RR
752 if ((GetWindowStyleFlag() & wxPLOT_Y_AXIS) != 0)
753 {
754 m_yaxis = new wxPlotYAxisArea( this );
298a3f2e 755
8556b795 756 wxBoxSizer *vert1 = new wxBoxSizer( wxVERTICAL );
298a3f2e 757 plotsizer->Add( vert1, 1, wxEXPAND|wxTOP,10 );
8556b795
RR
758 vert1->Add( m_yaxis, 1 );
759 if ((GetWindowStyleFlag() & wxPLOT_X_AXIS) != 0)
760 vert1->Add( 60, 40 );
761 }
762 else
763 {
764 m_yaxis = (wxPlotYAxisArea*) NULL;
765 }
298a3f2e 766
8556b795
RR
767 if ((GetWindowStyleFlag() & wxPLOT_X_AXIS) != 0)
768 {
769 m_xaxis = new wxPlotXAxisArea( this );
298a3f2e 770
8556b795 771 wxBoxSizer *vert2 = new wxBoxSizer( wxVERTICAL );
298a3f2e
WS
772 plotsizer->Add( vert2, 5, wxEXPAND);
773 vert2->Add( m_area, 1, wxEXPAND|wxTOP,10 );
8556b795
RR
774 vert2->Add( m_xaxis, 0, wxEXPAND );
775 }
776 else
777 {
778 plotsizer->Add( m_area, 1, wxEXPAND );
779 m_xaxis = (wxPlotXAxisArea*) NULL;
780 }
781
8fb816ff 782 mainsizer->Add( m_plotAndTitleSizer, 1, wxEXPAND );
298a3f2e
WS
783
784 SetAutoLayout( true );
8556b795 785 SetSizer( mainsizer );
298a3f2e
WS
786 mainsizer->Fit(this);
787 mainsizer->SetSizeHints(this);
8556b795
RR
788
789 SetTargetWindow( m_area );
790
791 SetBackgroundColour( *wxWHITE );
298a3f2e 792
8556b795
RR
793 m_current = (wxPlotCurve*) NULL;
794}
795
796wxPlotWindow::~wxPlotWindow()
797{
798}
799
800void wxPlotWindow::Add( wxPlotCurve *curve )
801{
802 m_curves.Append( curve );
803 if (!m_current) m_current = curve;
298a3f2e 804
8556b795
RR
805 ResetScrollbar();
806}
807
808size_t wxPlotWindow::GetCount()
809{
810 return m_curves.GetCount();
811}
812
813wxPlotCurve *wxPlotWindow::GetAt( size_t n )
814{
9c592b61 815 wxList::compatibility_iterator node = m_curves.Item( n );
8556b795
RR
816 if (!node)
817 return (wxPlotCurve*) NULL;
298a3f2e 818
d301b8a2 819 return (wxPlotCurve*) node->GetData();
8556b795
RR
820}
821
6c43b66e 822void wxPlotWindow::SetCurrentCurve( wxPlotCurve* current )
8556b795
RR
823{
824 m_current = current;
298a3f2e
WS
825 m_area->Refresh( false );
826
8556b795 827 RedrawYAxis();
298a3f2e 828
8556b795
RR
829 wxPlotEvent event( wxEVT_PLOT_SEL_CHANGED, GetId() );
830 event.SetEventObject( this );
831 event.SetZoom( GetZoom() );
832 event.SetCurve( m_current );
833 GetEventHandler()->ProcessEvent( event );
834}
835
836void wxPlotWindow::Delete( wxPlotCurve* curve )
837{
9c592b61 838 wxList::compatibility_iterator node = m_curves.Find( curve );
8556b795 839 if (!node) return;
298a3f2e 840
8556b795 841 m_curves.DeleteObject( curve );
298a3f2e 842
8556b795 843 m_area->DeleteCurve( curve );
298a3f2e 844 m_area->Refresh( false );
08a80932
JS
845
846 if (curve == m_current) m_current = (wxPlotCurve *) NULL;
8556b795
RR
847}
848
6c43b66e 849wxPlotCurve *wxPlotWindow::GetCurrentCurve()
8556b795
RR
850{
851 return m_current;
852}
853
854void wxPlotWindow::Add( wxPlotOnOffCurve *curve )
855{
856 m_onOffCurves.Append( curve );
857}
858
859void wxPlotWindow::Delete( wxPlotOnOffCurve* curve )
860{
9c592b61 861 wxList::compatibility_iterator node = m_onOffCurves.Find( curve );
8556b795 862 if (!node) return;
298a3f2e 863
8556b795
RR
864 m_onOffCurves.DeleteObject( curve );
865}
866
867size_t wxPlotWindow::GetOnOffCurveCount()
868{
869 return m_onOffCurves.GetCount();
870}
871
872wxPlotOnOffCurve *wxPlotWindow::GetOnOffCurveAt( size_t n )
873{
9c592b61 874 wxList::compatibility_iterator node = m_onOffCurves.Item( n );
8556b795
RR
875 if (!node)
876 return (wxPlotOnOffCurve*) NULL;
298a3f2e 877
d301b8a2 878 return (wxPlotOnOffCurve*) node->GetData();
8556b795
RR
879}
880
881void wxPlotWindow::Move( wxPlotCurve* curve, int pixels_up )
882{
883 m_area->DeleteCurve( curve );
298a3f2e 884
8556b795 885 curve->SetOffsetY( curve->GetOffsetY() + pixels_up );
298a3f2e
WS
886
887 m_area->Refresh( false );
888
8556b795
RR
889 RedrawYAxis();
890}
891
892void wxPlotWindow::OnMoveUp( wxCommandEvent& WXUNUSED(event) )
893{
894 if (!m_current) return;
298a3f2e 895
8556b795
RR
896 Move( m_current, 25 );
897}
898
899void wxPlotWindow::OnMoveDown( wxCommandEvent& WXUNUSED(event) )
900{
901 if (!m_current) return;
298a3f2e 902
8556b795
RR
903 Move( m_current, -25 );
904}
905
906void wxPlotWindow::Enlarge( wxPlotCurve *curve, double factor )
907{
908 m_area->DeleteCurve( curve );
298a3f2e 909
8556b795
RR
910 int client_width;
911 int client_height;
912 m_area->GetClientSize( &client_width, &client_height);
913 double offset = (double)curve->GetOffsetY() / (double)client_height;
298a3f2e 914
8556b795
RR
915 double range = curve->GetEndY() - curve->GetStartY();
916 offset *= range;
298a3f2e 917
8556b795
RR
918 double new_range = range / factor;
919 double new_offset = offset / factor;
298a3f2e 920
8556b795
RR
921 if (m_enlargeAroundWindowCentre)
922 {
923 double middle = curve->GetStartY() - offset + range/2;
298a3f2e 924
8556b795
RR
925 curve->SetStartY( middle - new_range / 2 + new_offset );
926 curve->SetEndY( middle + new_range / 2 + new_offset );
927 }
928 else
929 {
930 curve->SetStartY( (curve->GetStartY() - offset)/factor + new_offset );
931 curve->SetEndY( (curve->GetEndY() - offset)/factor + new_offset );
932 }
298a3f2e
WS
933
934 m_area->Refresh( false );
8556b795
RR
935 RedrawYAxis();
936}
937
938void wxPlotWindow::SetUnitsPerValue( double upv )
939{
940 m_xUnitsPerValue = upv;
298a3f2e 941
8556b795
RR
942 RedrawXAxis();
943}
944
945void wxPlotWindow::SetZoom( double zoom )
946{
947 double old_zoom = m_xZoom;
948 m_xZoom = zoom;
298a3f2e 949
8556b795
RR
950 int view_x = 0;
951 int view_y = 0;
952 GetViewStart( &view_x, &view_y );
298a3f2e 953
8556b795 954 wxInt32 max = 0;
9c592b61 955 wxList::compatibility_iterator node = m_curves.GetFirst();
8556b795
RR
956 while (node)
957 {
d301b8a2 958 wxPlotCurve *curve = (wxPlotCurve*) node->GetData();
8556b795
RR
959 if (curve->GetEndX() > max)
960 max = curve->GetEndX();
d301b8a2 961 node = node->GetNext();
8556b795 962 }
298a3f2e
WS
963 SetScrollbars( wxPLOT_SCROLL_STEP, wxPLOT_SCROLL_STEP,
964 (int)((max*m_xZoom)/wxPLOT_SCROLL_STEP)+1, 0,
965 (int)(view_x*zoom/old_zoom), 0,
966 true );
8556b795
RR
967
968 RedrawXAxis();
298a3f2e 969 m_area->Refresh( true );
8556b795
RR
970}
971
972void wxPlotWindow::ResetScrollbar()
973{
974 wxInt32 max = 0;
9c592b61 975 wxList::compatibility_iterator node = m_curves.GetFirst();
8556b795
RR
976 while (node)
977 {
d301b8a2 978 wxPlotCurve *curve = (wxPlotCurve*) node->GetData();
8556b795
RR
979 if (curve->GetEndX() > max)
980 max = curve->GetEndX();
d301b8a2 981 node = node->GetNext();
8556b795 982 }
298a3f2e
WS
983
984 SetScrollbars( wxPLOT_SCROLL_STEP, wxPLOT_SCROLL_STEP,
8556b795
RR
985 (int)(((max*m_xZoom)/wxPLOT_SCROLL_STEP)+1), 0 );
986}
987
8fb816ff
MW
988void wxPlotWindow::AddChartTitle(const wxString& title, wxFont font,
989 wxColour colour)
990{
991 m_title = title;
992 m_titleFont = font;
993 m_titleColour = colour;
994 DrawChartTitle();
995}
996
997void wxPlotWindow::DrawChartTitle()
998{
999 if(m_title.size() != 0)
1000 {
1001 //If it is already added, remove child and delete
1002 if(m_titleStaticText)
1003 {
1004 RemoveChild( m_titleStaticText );
1005 m_titleStaticText->Destroy();
1006 }
1007
1008 //Create the text control and set the font, colour
1009 m_titleStaticText = new wxStaticText( this, -1, m_title );
1010 m_titleStaticText->SetFont( m_titleFont );
1011 m_titleStaticText->SetForegroundColour( m_titleColour );
1012
1013 //Create a sizer for the title. Prepend it to the Plot + Title sizer.
1014 wxBoxSizer* titleSizer = new wxBoxSizer( wxHORIZONTAL );
1015 titleSizer->Add( m_titleStaticText, 0, wxALIGN_CENTER | wxALL, 10 );
1016 m_plotAndTitleSizer->Prepend( titleSizer, 0, wxALIGN_CENTER_HORIZONTAL );
1017
1018 //Finally, force layout
1019 m_plotAndTitleSizer->Layout();
1020 }
1021}
1022
8556b795
RR
1023void wxPlotWindow::RedrawXAxis()
1024{
1025 if (m_xaxis)
8fb816ff 1026 m_xaxis->Refresh( true );
8556b795
RR
1027}
1028
1029void wxPlotWindow::RedrawYAxis()
1030{
1031 if (m_yaxis)
298a3f2e 1032 m_yaxis->Refresh( true );
8556b795
RR
1033}
1034
1035void wxPlotWindow::RedrawEverything()
1036{
1037 if (m_xaxis)
298a3f2e 1038 m_xaxis->Refresh( true );
8556b795 1039 if (m_yaxis)
298a3f2e
WS
1040 m_yaxis->Refresh( true );
1041 m_area->Refresh( true );
8fb816ff
MW
1042
1043 DrawChartTitle();
8556b795
RR
1044}
1045
1046void wxPlotWindow::OnZoomIn( wxCommandEvent& WXUNUSED(event) )
1047{
1048 SetZoom( m_xZoom * 1.5 );
1049}
1050
1051void wxPlotWindow::OnZoomOut( wxCommandEvent& WXUNUSED(event) )
1052{
1053 SetZoom( m_xZoom * 0.6666 );
1054}
1055
1056void wxPlotWindow::OnEnlarge( wxCommandEvent& WXUNUSED(event) )
1057{
1058 if (!m_current) return;
298a3f2e 1059
8556b795
RR
1060 Enlarge( m_current, 1.5 );
1061}
1062
1063void wxPlotWindow::OnShrink( wxCommandEvent& WXUNUSED(event) )
1064{
1065 if (!m_current) return;
298a3f2e 1066
8556b795
RR
1067 Enlarge( m_current, 0.6666666 );
1068}
1069
1070void wxPlotWindow::OnScroll2( wxScrollWinEvent& event )
1071{
1072 if ((!m_scrollOnThumbRelease) || (event.GetEventType() != wxEVT_SCROLLWIN_THUMBTRACK))
1073 {
1074 wxScrolledWindow::OnScroll( event );
1075 RedrawXAxis();
1076 }
1077}
1078
1079// ----------------------------------------------------------------------------
1080// global functions
1081// ----------------------------------------------------------------------------
1082
1083// FIXME MT-UNSAFE
1084static wxBitmap *GetEnlargeBitmap()
1085{
1086 static wxBitmap* s_bitmap = (wxBitmap *) NULL;
298a3f2e 1087 static bool s_loaded = false;
8556b795
RR
1088
1089 if ( !s_loaded )
1090 {
298a3f2e 1091 s_loaded = true; // set it to true anyhow, we won't try again
8556b795
RR
1092
1093 #if defined(__WXMSW__) || defined(__WXPM__)
f7a8c129 1094 s_bitmap = new wxBitmap(_T("plot_enl_bmp"), wxBITMAP_TYPE_RESOURCE);
8556b795
RR
1095 #else
1096 s_bitmap = new wxBitmap( plot_enl_xpm );
1097 #endif
1098 }
1099
1100 return s_bitmap;
1101}
1102
1103static wxBitmap *GetShrinkBitmap()
1104{
1105 static wxBitmap* s_bitmap = (wxBitmap *) NULL;
298a3f2e 1106 static bool s_loaded = false;
8556b795
RR
1107
1108 if ( !s_loaded )
1109 {
298a3f2e 1110 s_loaded = true; // set it to true anyhow, we won't try again
8556b795
RR
1111
1112 #if defined(__WXMSW__) || defined(__WXPM__)
f7a8c129 1113 s_bitmap = new wxBitmap(_T("plot_shr_bmp"), wxBITMAP_TYPE_RESOURCE);
8556b795
RR
1114 #else
1115 s_bitmap = new wxBitmap( plot_shr_xpm );
1116 #endif
1117 }
1118
1119 return s_bitmap;
1120}
1121
1122static wxBitmap *GetZoomInBitmap()
1123{
1124 static wxBitmap* s_bitmap = (wxBitmap *) NULL;
298a3f2e 1125 static bool s_loaded = false;
8556b795
RR
1126
1127 if ( !s_loaded )
1128 {
298a3f2e 1129 s_loaded = true; // set it to true anyhow, we won't try again
8556b795
RR
1130
1131 #if defined(__WXMSW__) || defined(__WXPM__)
f7a8c129 1132 s_bitmap = new wxBitmap(_T("plot_zin_bmp"), wxBITMAP_TYPE_RESOURCE);
8556b795
RR
1133 #else
1134 s_bitmap = new wxBitmap( plot_zin_xpm );
1135 #endif
1136 }
1137
1138 return s_bitmap;
1139}
1140
1141static wxBitmap *GetZoomOutBitmap()
1142{
1143 static wxBitmap* s_bitmap = (wxBitmap *) NULL;
298a3f2e 1144 static bool s_loaded = false;
8556b795
RR
1145
1146 if ( !s_loaded )
1147 {
298a3f2e 1148 s_loaded = true; // set it to true anyhow, we won't try again
8556b795
RR
1149
1150 #if defined(__WXMSW__) || defined(__WXPM__)
f7a8c129 1151 s_bitmap = new wxBitmap(_T("plot_zot_bmp"), wxBITMAP_TYPE_RESOURCE);
8556b795
RR
1152 #else
1153 s_bitmap = new wxBitmap( plot_zot_xpm );
1154 #endif
1155 }
1156
1157 return s_bitmap;
1158}
1159
1160static wxBitmap *GetUpBitmap()
1161{
1162 static wxBitmap* s_bitmap = (wxBitmap *) NULL;
298a3f2e 1163 static bool s_loaded = false;
8556b795
RR
1164
1165 if ( !s_loaded )
1166 {
298a3f2e 1167 s_loaded = true; // set it to true anyhow, we won't try again
8556b795
RR
1168
1169 #if defined(__WXMSW__) || defined(__WXPM__)
f7a8c129 1170 s_bitmap = new wxBitmap(_T("plot_up_bmp"), wxBITMAP_TYPE_RESOURCE);
8556b795
RR
1171 #else
1172 s_bitmap = new wxBitmap( plot_up_xpm );
1173 #endif
1174 }
1175
1176 return s_bitmap;
1177}
1178
1179static wxBitmap *GetDownBitmap()
1180{
1181 static wxBitmap* s_bitmap = (wxBitmap *) NULL;
298a3f2e 1182 static bool s_loaded = false;
8556b795
RR
1183
1184 if ( !s_loaded )
1185 {
298a3f2e 1186 s_loaded = true; // set it to true anyhow, we won't try again
8556b795
RR
1187
1188 #if defined(__WXMSW__) || defined(__WXPM__)
f7a8c129 1189 s_bitmap = new wxBitmap(_T("plot_dwn_bmp"), wxBITMAP_TYPE_RESOURCE);
8556b795
RR
1190 #else
1191 s_bitmap = new wxBitmap( plot_dwn_xpm );
1192 #endif
1193 }
1194
1195 return s_bitmap;
1196}
1197