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