]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / mBarRange.cxx
1 //----------------------------------------------------------------------------
2 #include "mBarRange.h"
3
4
5 //const wxEventType wxEVT_TSBAR = wxNewEventType();
6
7 DEFINE_EVENT_TYPE(wxEVT_TSBAR)
8 DEFINE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL)
9 DEFINE_EVENT_TYPE(wxEVT_TSBAR_START)
10 DEFINE_EVENT_TYPE(wxEVT_TSBAR_END)
11 DEFINE_EVENT_TYPE(wxEVT_TSBAR_MOVED)
12 DEFINE_EVENT_TYPE(wxEVT_SELECTION_END)
13
14
15
16 //----------------------------------------------------------------------------
17 //EVENT TABLE
18 //----------------------------------------------------------------------------
19
20 IMPLEMENT_CLASS(mBarRange, wxScrolledWindow)
21 BEGIN_EVENT_TABLE(mBarRange, wxScrolledWindow)
22         EVT_PAINT (mBarRange::OnPaint)
23         EVT_SIZE  (mBarRange::OnSize)
24         EVT_MOTION (mBarRange::OnMouseMove)
25         EVT_RIGHT_DOWN (mBarRange :: onShowPopupMenu)
26         EVT_MENU(cntID_CHANGE_COLOR, mBarRange :: onChangePartColor)
27         EVT_MENU(cntID_ENABLE_ACTUAL, mBarRange :: onEnableRange_Actual)
28         EVT_MENU(cntID_MOVABLE_ACTUAL_BAR, mBarRange :: onMovable_ActualWithBar)
29
30         //
31         EVT_LEFT_DOWN( mBarRange :: onLeftClicDown)
32         EVT_LEFT_UP( mBarRange :: onLeftClickUp)
33
34         //how to catch the new event (our event)
35         //EVT_COMMAND  (ID_MY_WINDOW, wxEVT_MY_EVENT, MyFrame::OnMyEvent)
36 END_EVENT_TABLE()
37
38
39 //----------------------------------------------------------------------------
40 //CONSTRUCTOR
41 //----------------------------------------------------------------------------
42
43 mBarRange::mBarRange(wxWindow *parent, int w, int h)
44 :wxScrolledWindow(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL)
45 {
46         acceptedClick = true;
47         _bitmap_bar                     =       NULL;
48         SetWidth (w);
49         SetHeight(h);
50         _initialPoint           =       0;
51         trianglesHalfWidth = 5;
52         
53         wxColour start_Colour;
54
55         // Setting the default parts colors
56         start_Colour            =       wxColour(0,0,255);
57         actual_Colour           =       wxColour(255,255,202);
58         end_Colour                      =       wxColour(0,0,255);
59         bar_Colour                      =       wxColour(255,0,255);
60         backgroundColor     =   parent ->GetBackgroundColour();
61         guideLineColor          =   wxColour(255,0,0);
62
63         //actual is in _start and end
64         //false means that it could be anywhere
65         _moveActualWithBar      =       false;
66         _in_rangeProperty       =       false;
67         _selectionMoveId        =       -1;
68         realX_vertical_line =   -1;
69         activeState                     =       false;
70         _actual=0;
71         deviceEndMargin = 0;
72
73         SetOrientation(true);
74         setIfWithActualDrawed(true);
75
76         b_popmenu.Append (cntID_CHANGE_COLOR, _("Change Color"), _("Changes the color of the selected part"));
77         b_popmenu.Append (cntID_ENABLE_ACTUAL, _("Enable actual in range"), _("Enables/Disables the actual triangle to be or not in range"));
78         b_popmenu.Append (cntID_MOVABLE_ACTUAL_BAR, _("Move actual-bar simultaneously"), _("Disables the actual triangle to move with the bar"));
79
80         SetSize(w,h);
81 }
82
83 //----------------------------------------------------------------------------
84 //DESTRUCTOR
85 //----------------------------------------------------------------------------
86
87 mBarRange::~mBarRange()
88 {
89 }
90 //---------------------------------------------------------------------------
91 //Draw bar: vertical or Horizontal
92 //---------------------------------------------------------------------------
93 void mBarRange::DrawBar()
94 {
95         //Horizontal
96         if(_orientation)
97         {
98                 SetWindowStyle(wxNO_FULL_REPAINT_ON_RESIZE);
99                 _bitmap_bar             = new wxBitmap(_w+1280,_h+100);
100                 //SIL//_bitmap_info     = new wxBitmap(_w+100+1280, _h+100);
101         }
102         //vertical
103         else
104         {
105                 SetWindowStyle(wxNO_FULL_REPAINT_ON_RESIZE);
106                 _bitmap_bar = new wxBitmap(_h+deviceStart_y+100,_w+1280);
107                 _bitmap_info = new wxBitmap(_h+deviceStart_y+100, _w+1280);
108         }
109 }
110 //----------------------------------------------------------------------------
111 //Getters & Setters
112 //----------------------------------------------------------------------------
113 //----------------------------------------------------------------------------
114 //the property condition on actual triangle
115 //----------------------------------------------------------------------------
116 bool mBarRange::GetInRangeProperty()
117 {
118         return _in_rangeProperty;
119 }
120 //----------------------------------------------------------------------------
121 void mBarRange::SetInRangeProperty(bool in)
122 {
123         _in_rangeProperty=in;
124 }
125 //----------------------------------------------------------------------------
126 //the information about the actual triangle in range or not, true if is between start and end
127 //----------------------------------------------------------------------------
128 bool mBarRange::IsActualInRange()
129 {
130         return ( _actual <= _end && _actual >= _start );
131 }
132
133 //----------------------------------------------------------------------------
134 // the position of the rectangle, vertical or horizontal
135 //----------------------------------------------------------------------------
136 bool mBarRange::GetOrientation()
137 {
138         return _orientation;
139 }
140 //-----------------------------------------------------------------------------
141 void mBarRange::SetOrientation(bool orientation)
142 {
143         if(_orientation)
144         {
145                 SetSize(_h,_w);
146         }
147         _orientation=orientation;
148
149 }
150 //----------------------------------------------------------------------------
151 // _start of the pixel rectangle
152 //----------------------------------------------------------------------------
153
154 int mBarRange::GetPixelStart()
155 {
156         return ((_start - _min)*(_w-deviceEndMargin))/(_max - _min);    
157 }
158 //----------------------------------------------------------------------------
159 // param i: value in pixels
160 //----------------------------------------------------------------------------
161 void mBarRange::SetPixelStart(int i)
162 {
163         _start = _min+((i - deviceStart_x)*( _max - _min))/(_w-deviceEndMargin);
164         
165 }
166 //----------------------------------------------------------------------------
167 // _actual of the pixel rectangle
168 //----------------------------------------------------------------------------
169 int mBarRange::GetPixelActual()
170 {
171         return ((_actual - _min)*(_w-deviceEndMargin))/(_max - _min);
172 }
173 //----------------------------------------------------------------------------
174 // param i: value in pixels
175 //----------------------------------------------------------------------------
176 void mBarRange::SetPixelActual(int i)
177 {
178         _actual = _min + (i-deviceStart_x)*(_max-_min)/(_w-deviceEndMargin);
179 }
180 //----------------------------------------------------------------------------
181 // _end of the pixel rectangle
182 //----------------------------------------------------------------------------
183 int mBarRange::GetPixelEnd()
184 {
185         return ((_end - _min)*(_w-deviceEndMargin))/(_max - _min);
186 }
187 //----------------------------------------------------------------------------
188 // param i: value in pixels to be converted to real logical value
189 //----------------------------------------------------------------------------
190 void mBarRange::SetPixelEnd(int i)
191 {
192         _end = _min + (i-deviceStart_x)*(_max-_min)/(_w-deviceEndMargin);
193 }
194 //----------------------------------------------------------------------------
195 // Logical max of the triangle
196 //----------------------------------------------------------------------------
197
198 double mBarRange::GetMax()
199 {
200         return _max;
201 }
202
203 //----------------------------------------------------------------------------
204 void mBarRange::SetMax(double i)
205 {
206         _max=i;
207 }
208 //----------------------------------------------------------------------------
209 // Logical min of the triangle
210 //----------------------------------------------------------------------------
211
212 double mBarRange::GetMin()
213 {
214         return _min;
215 }
216
217 //----------------------------------------------------------------------------
218 void mBarRange::SetMin(double i)
219 {
220         _min=i;
221 }
222
223 //----------------------------------------------------------------------------
224 // pixel dimensions of the rectangle
225 //----------------------------------------------------------------------------
226
227 int mBarRange::GetWidth()
228 {
229         return _w;
230 }
231 //----------------------------------------------------------------------------
232 void mBarRange::SetWidth(int w)
233 {
234         _w=w;
235 }
236 //----------------------------------------------------------------------------
237 int mBarRange::GetHeight()
238 {
239         return _h;
240 }
241
242 //----------------------------------------------------------------------------
243 void mBarRange::SetHeight(int h)
244 {
245         _h=h;   
246 }
247
248 //----------------------------------------------------------------------------
249 // Logical  Start of the rectangle
250 //----------------------------------------------------------------------------
251
252 int mBarRange::GetStart()
253 {
254         return _start;
255
256 }
257 //----------------------------------------------------------------------------
258 // param start: value real units
259 //----------------------------------------------------------------------------
260 void mBarRange::SetStart(int newstart)
261 {
262         if(newstart<_min)
263                 newstart = _min;
264         _start = newstart;
265         RefreshForce(); 
266 }
267 //----------------------------------------------------------------------------
268 // Logical End of the rectangle
269 //----------------------------------------------------------------------------
270
271 int mBarRange::GetEnd()
272 {
273         return _end;
274 }
275 //----------------------------------------------------------------------------
276 // param end: value pixel units
277 //----------------------------------------------------------------------------
278 void mBarRange::SetEnd(int nwend)
279 {
280         if(nwend>_max)
281                 _end = _max;
282         _end=nwend;
283         RefreshForce(); 
284 }
285 //----------------------------------------------------------------------------
286 // logical  Actual of the rectangle
287 //----------------------------------------------------------------------------
288 int mBarRange::GetActual()
289 {
290         return _actual;
291 }
292 //----------------------------------------------------------------------------
293 void mBarRange::SetActual(int actual)
294 {
295         if(actual<_min)
296                 _actual = _min;
297         else if (actual>_max)
298                 _actual = _max;
299         _actual=actual;
300         RefreshForce();
301 }
302
303 //----------------------------------------------------------------------------
304 //
305 //----------------------------------------------------------------------------
306 int mBarRange::GetTrianglesHalfWidth()
307 {
308         return trianglesHalfWidth;
309 }
310 //----------------------------------------------------------------------------
311 void mBarRange::SetTrianglesHalfWidth(int nwTriHalfWidth)
312 {
313         trianglesHalfWidth = nwTriHalfWidth;
314 }
315
316 void mBarRange::OnSize( wxSizeEvent &WXUNUSED(event) )
317 {
318         wxRect rectTotal = GetClientRect(); 
319         if(_orientation)
320         {               
321                 SetWidth( rectTotal.GetWidth() - deviceEndMargin );                     
322         } 
323         else 
324         {
325                 SetWidth( rectTotal.GetHeight() - deviceEndMargin);                             
326         }
327         _selectionMoveId = -1;
328         Refresh();              
329 }
330
331 //----------------------------------------------------------------------------
332
333 void mBarRange::Refresh(bool eraseBackground, const wxRect* rect)
334 {
335 // EED Borrame
336 //FILE *ff;
337 //ff=fopen ("c:/temp/xxx.txt", "a+");
338 //fprintf( ff , "mBarRange :: Refresh 01\n" );
339 //fclose(ff);
340
341         wxScrolledWindow::Refresh(false);
342
343
344 // EED Borrame
345 //ff=fopen ("c:/temp/xx.txt", "a+");
346 //fprintf( ff , "mBarRange :: Refresh 02\n" );
347 //fclose(ff);
348 }
349
350
351 //----------------------------------------------------------------------------
352 //Bar Methods
353 //----------------------------------------------------------------------------
354 void mBarRange::OnPaint( wxPaintEvent &WXUNUSED(event) )
355 {
356
357 // EED Borrame
358 //FILE *ff;
359 //ff=fopen ("c:/temp/xx.txt", "a+");
360 //fprintf( ff , "pColorBar :: OnPaint 01\n" );
361 //fclose(ff);
362
363         if (_bitmap_bar!=NULL){
364                 //repaint rectangle
365                 if(_orientation)
366                 {
367                         RefreshHorizontalView();
368                         wxMemoryDC temp_dc;
369                         temp_dc.SelectObject( *_bitmap_bar );
370                         wxPaintDC dc( this );
371                         dc.Blit(deviceStart_x-(trianglesHalfWidth+2), deviceStart_y, _w-deviceEndMargin+2*(trianglesHalfWidth+2), _h, &temp_dc, 0, 0);
372                         //repaint info
373 //                      if (_visibleLables)
374 //                      {
375 //                              temp_dc.SelectObject( *_bitmap_info );                          
376 //                              dc.Blit(deviceStart_x,deviceStart_y+_h, _w+deviceStart_x-deviceEndMargin, _h+deviceStart_y+200, &temp_dc, deviceStart_x, deviceStart_y);
377 //                              //dc.Blit(deviceStart_x,deviceStart_y+_h, _w+deviceStart_x-deviceEndMargin, _h+deviceStart_y+60, &temp_dc, 0, 0);
378 //                      }
379         
380                 } else {
381                         RefreshVerticalView();
382                         wxMemoryDC temp_dc;
383                         temp_dc.SelectObject( *_bitmap_bar );
384                         wxPaintDC dc( this );                   
385 //                      dc.Blit(deviceStart_y,deviceStart_x, _h+deviceStart_y-deviceEndMargin,_w+deviceStart_x-deviceEndMargin, &temp_dc, 0, 0);        
386                         dc.Blit(deviceStart_y,deviceStart_x-(trianglesHalfWidth+2), _h,_w-deviceEndMargin+2*(trianglesHalfWidth+2), &temp_dc, 0, 0);    
387                         
388                         //repaint info
389 //                      if (_visibleLables)
390 //                      {
391 //                              temp_dc.SelectObject( *_bitmap_info );
392 //                              dc.Blit(0,_w, _h+deviceStart_y+200, _w+deviceStart_x+200-deviceEndMargin, &temp_dc, deviceStart_y,_w+deviceStart_x);
393 //                      }
394
395
396                 } 
397         } 
398
399 // EED Borrame
400 //ff=fopen ("c:/temp/xx.txt", "a+");
401 //fprintf( ff , "pColorBar :: OnPaint 02\n" );
402 //fclose(ff);
403
404
405 }
406 //----------------------------------------------------------------------------
407 //Repaint the bar if it is horizontal
408 //----------------------------------------------------------------------------
409 void mBarRange::RefreshHorizontalView()
410 {
411
412 // EED Borrame
413 //FILE *ff;
414 //ff=fopen ("c:/temp/xxx.txt", "a+");
415 //fprintf( ff , "mBarRange :: RefreshHorizontalView 01\n" );
416 //fclose(ff);
417
418         wxPoint points[3];
419
420         //int largestNumberWidthInPixels = 15; // JPRx
421         int pxStart=GetPixelStart();
422         int pxEnd=GetPixelEnd();
423         int pxActual=GetPixelActual();
424
425         
426         int letterHeight = 9;
427         int barHeight = 2*letterHeight;
428         int tempHeight = _h-(6*letterHeight);
429         
430         
431         if (_visibleLables)
432         {
433                 barHeight = (tempHeight>0)  ? tempHeight : (int) _h/2;
434         }
435         else
436                 barHeight = _h; 
437
438         wxMemoryDC temp_dc;
439         temp_dc.SelectObject( *_bitmap_bar );
440
441         
442         // Background of this widget
443         
444         
445         temp_dc.SetPen(wxPen( backgroundColor ));
446         temp_dc.SetBrush(wxBrush( backgroundColor ,wxSOLID  ));
447         
448         temp_dc.DrawRectangle(0,0,_w+2*trianglesHalfWidth,_h);
449         
450
451         temp_dc.SetPen(wxPen( wxColour(167,165,191) ,1,wxSOLID  ));
452         temp_dc.DrawLine(trianglesHalfWidth+2, 0, _w-deviceEndMargin, 0);
453         temp_dc.DrawLine(trianglesHalfWidth+2, barHeight, (_w-deviceEndMargin-trianglesHalfWidth-2), barHeight);
454         temp_dc.SetDeviceOrigin(trianglesHalfWidth+2,0);
455
456
457         // Filling the bar
458         temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
459         temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
460         temp_dc.DrawRectangle( pxStart , 0, pxEnd-pxStart, barHeight);
461
462
463         //  The Bar
464         if( _selectionMoveId==4 )
465         {
466                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
467                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
468         }
469         else
470         {
471                 temp_dc.SetBrush(wxBrush( bar_Colour,wxSOLID  ));
472                 temp_dc.SetPen(wxPen( wxColour(164,0,164),1,wxSOLID  ));
473         }
474         temp_dc.DrawRectangle( pxStart,1, pxEnd-pxStart, barHeight );
475
476         // 2 Shadow Triangles: Start and End 
477         temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
478         temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
479         points[0].x= 0;
480         points[0].y= barHeight;
481         points[1].x= -trianglesHalfWidth-1;
482         points[1].y= 0;
483         points[2].x= trianglesHalfWidth+2;
484         points[2].y= 0;
485         temp_dc.DrawPolygon(3,points,pxStart,0);
486         temp_dc.DrawPolygon(3,points,pxEnd,0);
487
488         // 2 Triangles: Start and End 
489         points[1].x = -trianglesHalfWidth;      
490         points[2].x = trianglesHalfWidth;
491         
492         //first triangle (start)
493         if( _selectionMoveId == 1 )
494         {
495                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
496                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
497         }
498         else
499         {
500                 temp_dc.SetBrush(wxBrush( start_Colour,wxSOLID  ));
501                 temp_dc.SetPen(wxPen( wxColour(0,51,204),1,wxSOLID  ));
502         }
503         temp_dc.DrawPolygon(3,points,pxStart,0);
504         //second triangle (end)
505         if( _selectionMoveId == 2 )
506         {
507                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
508                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
509         }
510         else
511         {
512                 temp_dc.SetBrush(wxBrush( end_Colour,wxSOLID  ));
513                 temp_dc.SetPen(wxPen( wxColour(0,0,255),1,wxSOLID  ));
514         }
515         temp_dc.DrawPolygon(3,points,pxEnd,0);
516
517         if( withActualDrawed )
518         {
519                 // 1 Shadow Triangle: Actual
520                 temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
521                 temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
522                 points[1].x = -trianglesHalfWidth-1;
523                 points[2].x = trianglesHalfWidth+2;
524                 
525                 temp_dc.DrawPolygon(3,points,pxActual,0);
526
527                 // 1 Triangle: Actual (red)
528                 if( _selectionMoveId==3 )
529                 {
530                         temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
531                         temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
532                 }
533                 else
534                 {
535                         temp_dc.SetBrush(wxBrush( actual_Colour,wxSOLID  ));
536                         temp_dc.SetPen(wxPen( wxColour(205,160,5),1,wxSOLID  ));
537                 }
538                 points[1].x = -trianglesHalfWidth;
539                 points[2].x = trianglesHalfWidth;
540                 temp_dc.DrawPolygon(3,points,pxActual,0);
541         }
542
543         if (realX_vertical_line!=-1)
544         {
545                 temp_dc.SetPen(wxPen(  guideLineColor,1,wxDOT ));
546                 int pixelX_guide = ((realX_vertical_line - _min)*(_w-deviceEndMargin))/(_max - _min) ; 
547                 temp_dc.DrawLine(pixelX_guide, 0, pixelX_guide, barHeight);
548         }
549
550         //Information Device drawing
551
552         if (_visibleLables)
553         {
554                 //temp_dc.SelectObject( *_bitmap_info );
555                 /*temp_dc.SetBrush(wxBrush( colourParent ,wxSOLID  ));
556                 temp_dc.SetPen(wxPen( colourParent ,1,wxSOLID  ));*/
557                 //temp_dc.DrawRectangle(deviceStart_x,_h+deviceStart_y,_w+deviceStart_x+40,_h+deviceStart_y+40);
558                 //temp_dc.DrawRectangle(0,_h,_w+40-deviceEndMargin,_h+40);
559
560                 wxFont font(letterHeight-1, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL);
561                 temp_dc.SetFont(font);
562                 temp_dc.SetTextForeground(*wxBLACK);
563
564
565                 //the **MIN** value, always at the same y level that corresponds to barHeight+1
566                 wxString text_min;
567 //              text_min<< GetMin();
568                 text_min.Printf(_T("%d"), (int)GetMin() );
569                 
570                 temp_dc.DrawText(text_min,0,barHeight+1);
571
572                 //the **MAX** value always at the same place
573                 wxString text_max;
574 //              text_max << GetMax();
575                 text_max.Printf(_T("%d"), (int)GetMax() );
576
577                 //As there is a margin of 40 extra most numbers (max) should be visibles
578 //              stringSize = temp_dc.GetTextExtent(text_max);
579         wxCoord tmpX,tmpY;
580                 temp_dc.GetTextExtent(text_max,&tmpX,&tmpY);
581                 wxSize stringSize(tmpX,tmpY);
582                 
583                 temp_dc.DrawText(text_max,_w-deviceEndMargin -(stringSize.GetWidth())/*2*trianglesHalfWidth*/,barHeight+1);     
584                 
585                 //show logical values
586                 //show the **START TRIANGLE** value 
587                 wxString text_start;
588 //              text_start << GetStart();               
589                 text_start.Printf(_T("%d"), (int)GetStart() );
590
591                 temp_dc.DrawText(text_start, pxStart,barHeight+2*letterHeight);
592                 //show the **END TRIANGLE** value
593                 wxString text_end;
594 //              text_end << GetEnd();
595                 text_end.Printf(_T("%d"), (int)GetEnd() );
596
597 //              stringSize = temp_dc.GetTextExtent(text_end);
598                 temp_dc.GetTextExtent(text_end,&tmpX,&tmpY);
599                 stringSize.SetHeight(tmpY);
600                 stringSize.SetWidth(tmpX);
601                 temp_dc.DrawText(text_end, pxEnd-stringSize.GetWidth(),barHeight+3*letterHeight);
602                 if( withActualDrawed )
603                 {
604                         //show the actual value of actual
605                         wxString text_actual;
606 //                      text_actual << GetActual();
607                         text_actual.Printf(_T("%d"), (int)GetActual() );
608 //                      stringSize = temp_dc.GetTextExtent(text_actual);
609                         temp_dc.GetTextExtent(text_actual,&tmpX,&tmpY);
610                     stringSize.SetHeight(tmpY);
611                     stringSize.SetWidth(tmpX);
612                         temp_dc.DrawText(text_actual, pxActual-(stringSize.GetWidth()/2),barHeight+letterHeight);                       
613                 }                       
614         }
615
616 // EED Borrame
617 //ff=fopen ("c:/temp/xxx.txt", "a+");
618 //fprintf( ff , "mBarRange :: RefreshHorizontalView 02\n" );
619 //fclose(ff);
620 }
621
622 //----------------------------------------------------------------------------
623 //Repaint the bar if it is vertical
624 //----------------------------------------------------------------------------
625
626 void mBarRange::RefreshVerticalView()
627 {
628
629 // EED Borrame
630 //FILE *ff;
631 //ff=fopen ("c:/temp/xxx.txt", "a+");
632 //fprintf( ff , "mBarRange :: RefreshVerticalView 01\n" );
633 //fclose(ff);
634         wxPoint points[3];
635
636         int px1=GetPixelStart();
637         int px2=GetPixelEnd();
638         int px3=GetPixelActual();
639         int letterHeight = 9;
640         int panelHeight = 9*3+_w;
641
642         int barWidth;
643         if (_visibleLables)
644         {
645                 barWidth = (_w-30)>0 ? _w-30 : (int) _w/2;
646         }
647         else
648                 barWidth = _w;  
649
650         wxMemoryDC temp_dc;
651         temp_dc.SelectObject( *_bitmap_bar );
652
653         // Background
654         temp_dc.SetBrush(wxBrush( backgroundColor ,wxSOLID  ));
655         temp_dc.SetPen(wxPen( backgroundColor ));
656
657         temp_dc.DrawRectangle(0,0,_h,_w+2*trianglesHalfWidth);
658         
659
660         temp_dc.SetPen(wxPen( wxColour(167,165,191) ,1,wxSOLID  ));
661         temp_dc.DrawLine(0,trianglesHalfWidth+2, 0, _w-deviceEndMargin);
662         temp_dc.DrawLine(barWidth, trianglesHalfWidth+2, barWidth, (_w-deviceEndMargin-trianglesHalfWidth-2));
663         temp_dc.SetDeviceOrigin(0,trianglesHalfWidth+2);
664
665         // Filling the bar
666         temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
667         temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
668         temp_dc.DrawRectangle( 0,px1 ,_h, px2-px1 );
669
670
671         //  The Bar
672                 if( _selectionMoveId==4 )
673         {
674                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
675                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
676         }
677         else
678         {
679                 temp_dc.SetBrush(wxBrush( bar_Colour,wxSOLID  ));
680                 temp_dc.SetPen(wxPen( wxColour(164,0,164),1,wxSOLID  ));
681         }
682         temp_dc.DrawRectangle( 1,px1,_h, px2-px1);
683
684
685         // 2 Shadow Triangles: Start and End 
686         points[0].x=_h;
687         points[0].y=0;
688         points[1].x=0;
689         points[1].y=-trianglesHalfWidth-1;
690         points[2].x=0;
691         points[2].y=trianglesHalfWidth+2;
692         temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
693         temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
694         temp_dc.DrawPolygon(3,points,0,px1);
695         temp_dc.DrawPolygon(3,points,0,px2);
696
697         // 2 Triangles: Start and End 
698         points[0].x=_h;
699         points[0].y=0;
700         points[1].x=0;
701         points[1].y=-trianglesHalfWidth;
702         points[2].x=0;
703         points[2].y=trianglesHalfWidth;
704         //first triangle (start)
705         if( _selectionMoveId==1 )
706         {
707                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
708                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
709         }
710         else
711         {
712                 temp_dc.SetBrush(wxBrush( start_Colour,wxSOLID  ));
713                 temp_dc.SetPen(wxPen( wxColour(0,51,204),1,wxSOLID  ));
714         }
715         temp_dc.DrawPolygon(3,points,0,px1);
716         //second triangle (end)
717         if( _selectionMoveId==2 )
718         {
719                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
720                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
721         }
722         else
723         {
724                 temp_dc.SetBrush(wxBrush( end_Colour,wxSOLID  ));
725                 temp_dc.SetPen(wxPen( wxColour(0,0,255),1,wxSOLID  ));
726         }
727         temp_dc.DrawPolygon(3,points,0,px2);
728
729         if( withActualDrawed )
730         {
731                 // 1 Shadow Triangle: Actual
732                 temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
733                 temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
734                 points[0].x=_h;
735                 points[0].y=0;
736                 points[1].x=0;
737                 points[1].y=-trianglesHalfWidth-1;
738                 points[2].x=0;
739                 points[2].y=trianglesHalfWidth+2;
740                 temp_dc.DrawPolygon(3,points,0,px3);
741
742                 // 1 Triangle: Actual (red)
743                 points[0].x = _h;
744                 points[0].y = 0;
745                 points[1].x = 0;
746                 points[1].y = -trianglesHalfWidth;
747                 points[2].x = 0;
748                 points[2].y = trianglesHalfWidth;
749                 if( _selectionMoveId==3 )
750                 {
751                         temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
752                         temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
753                 }
754                 else
755                 {
756                         temp_dc.SetBrush(wxBrush( actual_Colour,wxSOLID  ));
757                         temp_dc.SetPen(wxPen( wxColour(205,160,5),1,wxSOLID  ));
758                 }
759                 temp_dc.DrawPolygon(3,points,0,px3);
760         }
761
762         if (realX_vertical_line!=-1)
763         {
764                 temp_dc.SetPen(wxPen(  guideLineColor,1,wxDOT  ));
765                 int pixelX_guide = realX_vertical_line*_w/(_max-_min)+deviceStart_x; 
766                 temp_dc.DrawLine(0,pixelX_guide, _h, pixelX_guide);
767         }
768
769         //Information Device drawing
770         if (_visibleLables)
771         {
772                 /*temp_dc.SelectObject( *_bitmap_info );
773
774                 temp_dc.SetBrush(wxBrush( backgroundColor ,wxSOLID  ));
775                 temp_dc.SetPen(wxPen( backgroundColor ,1,wxSOLID  ));
776                 temp_dc.DrawRectangle(deviceStart_y,_w+deviceStart_x,_h+deviceStart_y+200,_w+deviceStart_x+200);
777 */
778
779                 temp_dc.SetBackgroundMode(wxTRANSPARENT);
780                 wxFont font(letterHeight-1, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL);
781                 temp_dc.SetFont(font);
782                 temp_dc.SetTextForeground(*wxBLACK);
783
784                 //show logical values
785                 //show the actual value of start
786                 wxString text_start;
787 //              text_start<<"Start:"<< GetStart();
788                 text_start.Printf(_T("%s %d"),_T("Start: "), (int)GetStart() );
789                 temp_dc.DrawText( text_start ,deviceStart_y, _w+deviceStart_x+letterHeight+1);
790                 //show the actual value of end
791                 wxString text_end;
792 //              text_end <<"End: "<<GetEnd();
793                 text_end.Printf(_T("%s %d"),_T("End: "), (int)GetEnd() );
794                 temp_dc.DrawText( text_end ,deviceStart_y,_w+deviceStart_x+letterHeight*2 );
795                 if( withActualDrawed )
796                 {
797                         //show the actual value of actual
798                         wxString text_actual;
799 //                      text_actual <<"Actual: " <<GetActual();
800                         text_actual.Printf(_T("%s %d"),_T("Actual: "), (int)GetActual() );
801                         temp_dc.DrawText( text_actual ,deviceStart_y,_w+deviceStart_x+letterHeight*3);
802                 }
803                 //the min value, always at the same place
804                 wxString text_min;
805 //              text_min<<"Min: " << GetMin();
806                 text_min.Printf(_T("%s %d"),_T("Min: "), (int)GetMin() );
807                 temp_dc.DrawText( text_min ,deviceStart_y,_w+deviceStart_x+3);
808                 //the max value always at the samen place
809                 wxString text_max;
810 //              text_max <<"Max: "<< GetMax();
811                 text_max.Printf(_T("%s %d"),_T("Max: "), (int)GetMax() );
812                 //toca calcular cuantol lo corremos
813                 temp_dc.DrawText(text_max,deviceStart_y,_w+deviceStart_x+43);           
814         }
815
816 }
817
818 //----------------------------------------------------------------------------
819 void mBarRange::RefreshForce()
820 {
821         Refresh();
822         Update();
823 }
824 //----------------------------------------------------------------------------
825 void mBarRange::OnMouseMove(wxMouseEvent& event )
826 {
827 // EED Borrame
828 //FILE *ff;
829 //ff=fopen ("c:/temp/xxx.txt", "a+");
830 //fprintf( ff , "mBarRange :: OnMouseMove 01\n" );
831 //fclose(ff);
832
833         //int px1=GetPixelStart(); // JPRx
834         //int px2=GetPixelEnd(); // JPRx
835         //int px3=GetPixelActual(); // JPRx
836         if (activeState)
837         {
838                 wxPoint point = event.GetPosition();
839                 int barHeight;
840                 if (_orientation)
841                 {
842                         setClickedX(point.x);
843                         barHeight = point.y;
844                 }
845                 else
846                 {
847                         setClickedX(point.y);
848                         barHeight = point.x;
849                 }
850                 int logicClick = getLogicValueofPixel(clickedX);
851                         
852                 if( _selectionMoveId==-1 )
853                 {
854                         if (barHeight <=_h)
855                         {
856                                 bool in_StartTri = (clickedX>=GetPixelStart()-5+ deviceStart_x) && (clickedX<=GetPixelStart()+5+ deviceStart_x);
857                                 bool in_EndTri = (clickedX>=GetPixelEnd()-5+ deviceStart_x) && (clickedX<=GetPixelEnd()+5+ deviceStart_x);
858                                 bool in_actualT= withActualDrawed && (clickedX>=GetPixelActual()-5+ deviceStart_x) && (clickedX<=GetPixelActual()+5+ deviceStart_x);
859                                 bool in_movingBar = (clickedX>GetPixelStart()+5+ deviceStart_x) && (clickedX<GetPixelEnd()-5+ deviceStart_x);
860
861                                 if( in_actualT )
862                                         _selectionMoveId = 3;
863                                 else if(in_StartTri)
864                                         _selectionMoveId = 1;  
865                                 else if( in_EndTri )
866                                         _selectionMoveId = 2;
867                                 else if( in_movingBar )
868                                         _selectionMoveId = 4;
869                         }
870                 }
871                 else
872                 {
873                         if(acceptedClick)
874                         {
875                                 //is in start triagle
876                                 if( _selectionMoveId ==1 && event.LeftIsDown())
877                                 {
878                                         bool validPos_StartTri = (logicClick<GetEnd() && logicClick >=_min);
879                                         if( validPos_StartTri && !_in_rangeProperty)
880                                         {       
881                                                 SetPixelStart(clickedX);
882                                                 RefreshForce();
883                                                 RefreshHorizontalView();
884                                                 //-------------------------------------------
885                                                 // Sending the event of start triangle moved
886                                                 //-------------------------------------------
887                                                 createAndSendEvent( wxEVT_TSBAR_START );
888                                         }
889                                         //start has to be less than actual
890                                         else if (validPos_StartTri && _in_rangeProperty)
891                                         {
892                                                 if(logicClick<=GetActual())
893                                                 {
894                                                         SetPixelStart(clickedX);
895                                                         RefreshForce();
896                                                 //      RefreshHorizontalView();
897                                                         //-------------------------------------------
898                                                         // Sending the event of start triangle moved
899                                                         //-------------------------------------------
900                                                 createAndSendEvent( wxEVT_TSBAR_START );
901                                                 }
902                                         }
903                                 } // _selectionMoveId == 1
904                                 //is in end triangle
905                                 else if( _selectionMoveId == 2 && event.LeftIsDown() )
906                                 {
907                                         bool validPos_EndTri = logicClick>GetStart()&& logicClick<=_max;  
908                                         if( validPos_EndTri && !_in_rangeProperty )
909                                         {                                       
910                                                 SetPixelEnd(clickedX);
911                                                 RefreshForce();
912         //                                      RefreshHorizontalView();        
913                                                 //-------------------------------------------
914                                                 //Sending the event of end triangle moved
915                                                 //-------------------------------------------
916                                                 createAndSendEvent( wxEVT_TSBAR_END );
917                                         }
918                                         //the end triangle cant be less than actual
919                                         else if( validPos_EndTri && _in_rangeProperty )
920                                         {
921                                                 if(logicClick>=GetActual())
922                                                 {
923                                                         SetPixelEnd(clickedX);
924                                                         RefreshForce();
925                                                 //      RefreshHorizontalView();
926                                                         //-------------------------------------------
927                                                         //Sending the event of end triangle moved
928                                                         //-------------------------------------------
929                                                         createAndSendEvent( wxEVT_TSBAR_END );
930                                                 }
931                                         }
932                                 } 
933                                 //is the actual triangle
934                                 else if( _selectionMoveId == 3 && event.LeftIsDown())
935                                 {
936                                         bool validPos_ActualTri=(logicClick<=_max) && (logicClick>=_min);
937                                         //is in actual triangle but it could be anywhere
938                                         if( validPos_ActualTri && !_in_rangeProperty )
939                                         {
940                                                 SetPixelActual(clickedX);
941                                                 RefreshForce();
942                                                 RefreshHorizontalView();
943                                                 //-------------------------------------------
944                                                 //Sending the event of actual triangle moved
945                                                 //-------------------------------------------
946                                                 createAndSendEvent( wxEVT_TSBAR_ACTUAL );       
947 //                                              createAndSendEvent( 98765 );
948
949 //printf("EED creaMaracasVisu mBarRange::OnMouseMove XXXXXXX \n");
950
951                                         }
952                                         else if( validPos_ActualTri && _in_rangeProperty )
953                                         // the tringle in between start and end
954                                         {
955                                                 if( logicClick>=GetStart() && logicClick<=GetEnd())
956                                                 {
957                                                         SetPixelActual(clickedX);
958                                                         RefreshForce();
959                                                         RefreshHorizontalView();
960                                                         //-------------------------------------------
961                                                         //Sending the event of actual triangle moved
962                                                         //-------------------------------------------
963                                                         createAndSendEvent( wxEVT_TSBAR_ACTUAL );
964                                                 }
965                                         } 
966                                 } 
967                                 //is the bar
968                                 else if ( _selectionMoveId == 4 &&  event.LeftIsDown() )
969                                 {       
970                                         //FILE * f=fopen("E:/borrar/file.txt","a+");
971                                         if(_initialPoint == 0)
972                                         {
973                                                 _initialPoint = logicClick;
974                                                 logicInitial_start = GetStart(); 
975                                                 logicInitial_end = GetEnd();
976                                                 logicInitial_actual = GetActual();
977                                                 //SIL//fprintf(f,"\n\n---- Inicia draggin:\n  logicInitial_start:%d, logicInitial_end:%d,logicInitial_actual:%d \n", _initialPoint,logicInitial_start,logicInitial_end,logicInitial_actual);
978                                         }
979                                         int difference = logicClick -_initialPoint;
980                                         int next_end = difference + logicInitial_end;
981                                         int next_start = difference + logicInitial_start;
982                                         int next_actual = difference + logicInitial_actual;
983                                         
984                                         /*SIL//fprintf(f,"diff:%d, next_end%d, next_start%d, next_actual%d \n", difference,next_end,next_start,next_actual);
985                                         fclose(f);*/
986                                         
987                                         //if actual is not fixed to be in the middle
988                                         if( ((logicClick>next_start) && (logicClick<next_end)&& (next_end<=_max)&& (next_start>=_min)) && !_in_rangeProperty)
989                                         {
990                                                 SetStart(next_start);
991                                                 SetEnd(next_end);
992                                                 if( _moveActualWithBar )
993                                                 {
994                                                         SetActual (next_actual);
995                                                         //-------------------------------------------
996                                                         //Sending the event of actual triangle moved
997                                                         //-------------------------------------------
998                                                         createAndSendEvent( wxEVT_TSBAR_ACTUAL );
999                                                 }
1000                                                 RefreshForce();
1001                                                 RefreshHorizontalView();        
1002                                                                                         
1003                                                 //-------------------------------------------
1004                                                 // Sending the event that the bar ahs being moved
1005                                                 //-------------------------------------------
1006                                                 createAndSendEvent( wxEVT_TSBAR_MOVED );
1007                                         }
1008                                         //if actual has to be between start and end
1009                                         else if(_in_rangeProperty && ((next_start<=GetActual()) && (next_end>=GetActual()) && (next_end<=_max)&& (next_start>=_min)) )
1010                                         {
1011                                                 SetStart(next_start);
1012                                                 SetEnd(next_end);
1013                                                 if( _moveActualWithBar )
1014                                                 {
1015                                                         SetActual (next_actual);
1016                                                         //-------------------------------------------
1017                                                         //Sending the event of actual triangle moved
1018                                                         //-------------------------------------------
1019                                                         createAndSendEvent( wxEVT_TSBAR_ACTUAL );
1020                                                 }
1021                                                 RefreshForce();
1022                                                 RefreshHorizontalView();        
1023                                                 
1024                                                 //-------------------------------------------
1025                                                 // Sending the event that the bar ahs being moved
1026                                                 //-------------------------------------------
1027                                                 createAndSendEvent( wxEVT_TSBAR_MOVED );
1028                                         }
1029                                 }                       
1030                         }
1031                         if( !event.LeftIsDown())
1032                         {
1033                                 _initialPoint=0;
1034                                 _selectionMoveId = -1;
1035                                 RefreshForce();
1036                                 //-------------------------------------------
1037                                 //Sending a general event just because
1038                                 //-------------------------------------------
1039                                 //SIL//createAndSendEvent( wxEVT_TSBAR );
1040                                 createAndSendEvent(wxEVT_SELECTION_END);
1041                         }
1042                 }                               
1043         }       
1044
1045 // EED Borrame
1046 //ff=fopen ("c:/temp/xxx.txt", "a+");
1047 //fprintf( ff , "  mBarRange :: OnMouseMove 02\n" );
1048 //fclose(ff);
1049
1050 }
1051 /*
1052 * Sets the represented minimum and maximunm values
1053 * param minRealValue The minimum represented value (real value)
1054 * param maxRealValue The maximum represented value (real value)
1055 */
1056 void mBarRange :: setRepresentedValues ( double minRealValue, double maxRealValue)
1057 {
1058         _min = minRealValue;
1059         _max = maxRealValue;
1060         _start=_min;
1061         _end=_max;
1062 }
1063
1064 /*
1065 * Sets the property for viewing or not the bar labels information
1066 */
1067 void mBarRange :: setVisibleLabels ( bool setVisibleLB )
1068 {
1069         _visibleLables = setVisibleLB;
1070 }
1071
1072 /*
1073         * Sets the property for viewing or not the bar labels information
1074         * return _visibleLables The state of visible labels or not 
1075         */
1076         bool mBarRange ::getIfVisibleLabels ()
1077         {
1078                 return _visibleLables;
1079         }
1080
1081         /**
1082         * Sets the device start drawing left-superior (pixel) start point 
1083         * param deviceStart_x Pixel start for x-coord
1084         * param deviceStart_y Pixel start for y-coord
1085         */
1086         void mBarRange :: setDeviceBlitStart ( wxCoord devStart_x, wxCoord devStart_y )
1087         {
1088                 deviceStart_x = devStart_x;
1089                 deviceStart_y = devStart_y;
1090                 // For the initialization case
1091                 if (GetPixelEnd()<0)
1092                 {
1093                         if (_orientation)
1094                         {
1095                                 SetPixelStart(deviceStart_x);
1096                                 SetPixelEnd(_w+deviceStart_x);
1097                                 SetPixelActual(deviceStart_x);
1098                         }
1099                         else
1100                         {
1101                                 SetPixelStart(deviceStart_x);
1102                                 SetPixelEnd(_h+deviceStart_x);
1103                                 SetPixelActual(deviceStart_x);
1104                         }
1105                 }
1106                 DrawBar();
1107         }
1108         
1109         /**
1110         * Shows the popup menu 
1111         */
1112         void mBarRange :: onShowPopupMenu (wxMouseEvent& event)
1113         {
1114                 if (activeState)
1115                 {
1116                         bool validClic = false;
1117                         if (_orientation)
1118                         {
1119                                 validClic = event.GetX() >= deviceStart_x && event.GetY()<= (_h + deviceStart_y);
1120                         }
1121                         else
1122                         {
1123                                 validClic = event.GetX()>=deviceStart_y && event.GetX()<= (_h+deviceStart_y) && event.GetY()>deviceStart_x;
1124                         }
1125                         if (validClic)
1126                         {
1127                                 if(_orientation)
1128                                         setClickedX(event.GetX());
1129                                 else
1130                                         setClickedX(event.GetY());
1131
1132                                 if (getClickedX()<=_h)
1133                                 {                                               
1134                                         bool in_StartTri = (clickedX>=GetPixelStart()-5+ deviceStart_x) && (clickedX<=GetPixelStart()+5+ deviceStart_x);
1135                                         bool in_EndTri = (clickedX>=GetPixelEnd()-5+ deviceStart_x) && (clickedX<=GetPixelEnd()+5+ deviceStart_x);
1136                                         bool in_actualT= (clickedX>=GetPixelActual()-5+ deviceStart_x) && (clickedX<=GetPixelActual()+5+ deviceStart_x);
1137                                         bool in_movingBar = (clickedX>GetPixelStart()+5+ deviceStart_x) && (clickedX<GetPixelEnd()-5+ deviceStart_x);
1138
1139                                         if(in_StartTri)
1140                                                 _selectionMoveId = 1;
1141                                         else if( in_EndTri )
1142                                                 _selectionMoveId = 2;
1143                                         else if( in_actualT )
1144                                                 _selectionMoveId = 3;
1145                                         else if( in_movingBar )
1146                                                 _selectionMoveId = 4;
1147                                 }                               
1148                                 PopupMenu( &b_popmenu, event.GetX(), event.GetY());
1149                         }               
1150                 }
1151         }
1152         
1153         /**
1154         * Reacts to the cntID_ADD_COLOR_POINT wxCommandEvent and adds a color degrade point to the color bar.
1155         * param & anEvent The wxCommandEvent actioned event 
1156         */
1157         void mBarRange :: onChangePartColor ( wxCommandEvent& anEvent )
1158         {
1159                 bool okSelectedColor = false;
1160                 wxColour selectedColour;
1161                 wxColourData data;
1162                 wxColourDialog dialog( GetParent(), &data);
1163
1164                 if ( dialog.ShowModal() == wxID_OK )
1165                 {
1166                         selectedColour = dialog.GetColourData().GetColour();
1167                         okSelectedColor = true;
1168                 }
1169                 if( okSelectedColor )
1170                 {
1171                         if (_selectionMoveId==1 )
1172                                 start_Colour = selectedColour;
1173                         else if (_selectionMoveId==2 )
1174                                 end_Colour = selectedColour;
1175                         else if( _selectionMoveId==3 )
1176                                 actual_Colour = selectedColour;
1177                         else if( _selectionMoveId==4 )
1178                                 bar_Colour = selectedColour;            
1179                 }
1180                 _selectionMoveId = -1;
1181         RefreshForce();
1182                 
1183         }
1184         
1185         /**
1186         * Reacts to the cntID_ENABLE_ACTUAL (false) wxCommandEvent enables the actual to be between the the range.
1187         * param & anEvent The wxCommandEvent actioned event 
1188         */
1189         void mBarRange :: onEnableRange_Actual ( wxCommandEvent& anEvent )
1190         {
1191                 if (!_in_rangeProperty)
1192                 {
1193                         if(IsActualInRange())
1194                         {
1195                                 SetInRangeProperty (true);
1196                                 b_popmenu.SetLabel (cntID_ENABLE_ACTUAL, _T("Disable actual in range"));
1197                         }
1198                 }
1199                 else
1200                 {
1201                         SetInRangeProperty (false);
1202                         b_popmenu.SetLabel (cntID_ENABLE_ACTUAL, _T("Enable actual in range"));                 
1203                 }
1204         }
1205
1206         /**
1207         * Reacts to the cntID_MOVABLE_ACTUAL_BAR wxCommandEvent by enabling or disabling the property of moving the actual triangle with the bar, just when it is inside of it.
1208         * param & anEvent The wxCommandEvent actioned event 
1209         */
1210         void  mBarRange :: onMovable_ActualWithBar ( wxCommandEvent& anEvent )
1211         {
1212                 if (_moveActualWithBar )
1213                 {
1214                         _moveActualWithBar = false;
1215                         b_popmenu.SetLabel (cntID_MOVABLE_ACTUAL_BAR, _T("Move actual+bar simultaneously"));
1216                 }
1217                 else
1218                 {
1219                         if(IsActualInRange())
1220                         {
1221                                 _moveActualWithBar = true;
1222                                 b_popmenu.SetLabel (cntID_MOVABLE_ACTUAL_BAR, _T("Move actual-bar independent"));
1223                         }
1224                 }
1225         }
1226
1227                 /*
1228         * Set active state 
1229         * param activeNow The new state
1230         */
1231         void mBarRange :: setActiveStateTo (bool activeNow)
1232         {
1233                 activeState = activeNow;
1234         }
1235         
1236         /*
1237         * Gets the active state of the bar
1238         *  return activeState The actual state
1239         */
1240         bool mBarRange :: isActive()
1241         {
1242                 return activeState;
1243         }
1244
1245         /*
1246         * Gets the real-x value to draw a vertical line
1247         * return realX_vertical_line The real x value for the vertical line
1248         */
1249         int     mBarRange :: getRealX_vertical_line()
1250         {
1251                 return realX_vertical_line;
1252         }
1253
1254         /*
1255         * Sets the real-x value to draw a vertical line
1256         * param newReal_x The new real x value for the vertical line
1257         */
1258         void mBarRange :: setRealX_vertical_line(int newReal_x)
1259         {
1260                 realX_vertical_line = newReal_x;
1261         }
1262
1263         /*
1264         * Gets the device value form the end of this panel to the end of the drawing area in the device in pixels
1265         * return deviceEndMargin The value asigned to the right margin
1266         */
1267         int     mBarRange :: getDeviceEndX()
1268         {
1269                 return deviceEndMargin;
1270         }
1271
1272         /*
1273         * Sets the new device (deviceEndMargin) value form the end of this panel to the end of the drawing area in the device
1274         * param newDeviceEnd_pixels The new pixel value to asign to the right(horizontal view), underneath(vertical view) margin in pixels
1275         */
1276         void mBarRange :: setDeviceEndMargin(int newDeviceEnd_pixels)
1277         {
1278                 deviceEndMargin = newDeviceEnd_pixels;
1279         }
1280
1281         /*
1282         * Gets the last clickedX pixel coord inside the bar with respect to the container panel.
1283         * return clickedX The x-coord pixel value
1284         */
1285         int mBarRange :: getClickedX()
1286         {
1287                 return clickedX;
1288         }
1289
1290         /*
1291         * Sets the last clickedX pixel coord inside the bar with respect to the container panel.
1292         * param nwClickX The x-coord pixel value
1293         */
1294         void mBarRange :: setClickedX(int nwClickX)
1295         {
1296                 clickedX = nwClickX;
1297         }
1298
1299
1300                 /*
1301         * Gets the start porcentage with respect to the represented values of the bar
1302         * return The porcentage represented by the start  showing point
1303         */
1304         float mBarRange :: getStartShowPorcentage()
1305         {
1306                 return (float)( 1+(_start - _max)/(_max-_min));
1307         }
1308
1309         /*
1310         * Gets the end porcentage with respect to the represented values of the bar
1311         * return The porcentage represented by the end showing point
1312         */
1313         float mBarRange :: getEndShowPorcentage()
1314         {
1315                 return (float) (1+(_end - _max)/(_max-_min));
1316         }
1317
1318         /*
1319         * Gets the actual porcentage with respect to the represented values of the bar
1320         * return The porcentage represented by the actual  showing point
1321         */
1322         float mBarRange :: getActualShowPorcentage()
1323         {
1324                 return (float) (1+(_actual - _max)/(_max-_min));
1325         }
1326
1327         int mBarRange :: getLogicValueofPixel(int thePixel)
1328         {
1329                 return _min+((thePixel - deviceStart_x)*( _max - _min))/(_w-deviceEndMargin);
1330         }
1331
1332         /*
1333         * Sets the condition for knowing if the actual triangle is being drawed or not
1334         * param drawActual The condition to set for drawing or not the actual control (true for drawing)
1335         */
1336         void mBarRange :: setIfWithActualDrawed(bool drawActual)
1337         {
1338                 if(!withActualDrawed && drawActual)
1339                 {       
1340                         b_popmenu.Append (cntID_ENABLE_ACTUAL, _("Enable actual in range"), _("Enables/Disables the actual triangle to be or not in range"));
1341                         b_popmenu.Append (cntID_MOVABLE_ACTUAL_BAR, _("Move actual-bar simultaneously"), _("Disables the actual triangle to move with the bar"));               
1342                 }
1343                 else if (withActualDrawed && !drawActual)
1344                 {
1345                         b_popmenu.Remove(cntID_ENABLE_ACTUAL);
1346                         b_popmenu.Remove(cntID_MOVABLE_ACTUAL_BAR);
1347                 }
1348                 withActualDrawed = drawActual;
1349                 Refresh();      
1350         }
1351
1352         /*
1353         * Gets the condition for knowing if the actual triangle is being drawed or not
1354         * return withActualDrawed The condition for drawing or not the actual control
1355         */
1356         bool mBarRange :: getIfWithActualDrawed()
1357         {
1358                 return withActualDrawed;
1359         }
1360
1361         void mBarRange::createAndSendEvent(WXTYPE theEventType)
1362         {
1363                 wxCommandEvent cevent( theEventType, GetId() );
1364                 cevent.SetEventObject( this );
1365                 GetEventHandler()->ProcessEvent( cevent );
1366         }
1367
1368         /*
1369         * Sets the background color od the bar
1370         * theColor The color to set to the backgroundColor
1371         */
1372         void mBarRange :: setBackgroundColor(wxColour theColor)
1373         {
1374                 backgroundColor = theColor;
1375         }
1376
1377         /*
1378         * Sets the guide line color
1379         * param theNwGuideLineColor The color to set to the guideLineColor
1380         */
1381         void mBarRange :: setGuideLineColour(wxColour theNwGuideLineColor)
1382         {
1383                 guideLineColor = theNwGuideLineColor;
1384         }
1385
1386         /*
1387         * Gets the guide line color
1388         * return guideLineColor The color of the guideLine
1389         */
1390         wxColour mBarRange :: getGuideLineColour()
1391         {
1392                 return guideLineColor;
1393         }
1394
1395         void  mBarRange ::onLeftClicDown(wxMouseEvent& event )
1396         {
1397                 acceptedClick = true;           
1398         }
1399
1400         void  mBarRange ::onLeftClickUp(wxMouseEvent& event )
1401         {       
1402                 acceptedClick = false;
1403         }
1404
1405