mBarRange.cxx

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 #include "mBarRange.h"
00003 
00004 
00005 //const wxEventType wxEVT_TSBAR = wxNewEventType();
00006 
00007 DEFINE_EVENT_TYPE(wxEVT_TSBAR)
00008 DEFINE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL)
00009 DEFINE_EVENT_TYPE(wxEVT_TSBAR_START)
00010 DEFINE_EVENT_TYPE(wxEVT_TSBAR_END)
00011 DEFINE_EVENT_TYPE(wxEVT_TSBAR_MOVED)
00012 DEFINE_EVENT_TYPE(wxEVT_SELECTION_END)
00013 
00014 
00015 
00016 //----------------------------------------------------------------------------
00017 //EVENT TABLE
00018 //----------------------------------------------------------------------------
00019 
00020 IMPLEMENT_CLASS(mBarRange, wxScrolledWindow)
00021 BEGIN_EVENT_TABLE(mBarRange, wxScrolledWindow)
00022         EVT_PAINT (mBarRange::OnPaint)
00023         EVT_SIZE  (mBarRange::OnSize)
00024         EVT_MOTION (mBarRange::OnMouseMove)
00025         EVT_RIGHT_DOWN (mBarRange :: onShowPopupMenu)
00026         EVT_MENU(cntID_CHANGE_COLOR, mBarRange :: onChangePartColor)
00027         EVT_MENU(cntID_ENABLE_ACTUAL, mBarRange :: onEnableRange_Actual)
00028         EVT_MENU(cntID_MOVABLE_ACTUAL_BAR, mBarRange :: onMovable_ActualWithBar)
00029 
00030         //
00031         EVT_LEFT_DOWN( mBarRange :: onLeftClicDown)
00032         EVT_LEFT_UP( mBarRange :: onLeftClickUp)
00033 
00034         //how to catch the new event (our event)
00035         //EVT_COMMAND  (ID_MY_WINDOW, wxEVT_MY_EVENT, MyFrame::OnMyEvent)
00036 END_EVENT_TABLE()
00037 
00038 
00039 //----------------------------------------------------------------------------
00040 //CONSTRUCTOR
00041 //----------------------------------------------------------------------------
00042 
00043 mBarRange::mBarRange(wxWindow *parent, int w, int h)
00044 :wxScrolledWindow(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL)
00045 {
00046         acceptedClick = true;
00047         _bitmap_bar                     =       NULL;
00048         SetWidth (w);
00049         SetHeight(h);
00050         _initialPoint           =       0;
00051         trianglesHalfWidth = 5;
00052         
00053         wxColour start_Colour;
00054 
00055         // Setting the default parts colors
00056         start_Colour            =       wxColour(0,0,255);
00057         actual_Colour           =       wxColour(255,255,202);
00058         end_Colour                      =       wxColour(0,0,255);
00059         bar_Colour                      =       wxColour(255,0,255);
00060         backgroundColor     =   parent ->GetBackgroundColour();
00061         guideLineColor          =   wxColour(255,0,0);
00062 
00063         //actual is in _start and end
00064         //false means that it could be anywhere
00065         _moveActualWithBar      =       false;
00066         _in_rangeProperty       =       false;
00067         _selectionMoveId        =       -1;
00068         realX_vertical_line =   -1;
00069         activeState                     =       false;
00070         _actual=0;
00071         deviceEndMargin = 0;
00072 
00073         SetOrientation(true);
00074         setIfWithActualDrawed(true);
00075 
00076         b_popmenu.Append (cntID_CHANGE_COLOR, _("Change Color"), _("Changes the color of the selected part"));
00077         b_popmenu.Append (cntID_ENABLE_ACTUAL, _("Enable actual in range"), _("Enables/Disables the actual triangle to be or not in range"));
00078         b_popmenu.Append (cntID_MOVABLE_ACTUAL_BAR, _("Move actual-bar simultaneously"), _("Disables the actual triangle to move with the bar"));
00079 
00080         SetSize(w,h);
00081 }
00082 
00083 //----------------------------------------------------------------------------
00084 //DESTRUCTOR
00085 //----------------------------------------------------------------------------
00086 
00087 mBarRange::~mBarRange()
00088 {
00089 }
00090 //---------------------------------------------------------------------------
00091 //Draw bar: vertical or Horizontal
00092 //---------------------------------------------------------------------------
00093 void mBarRange::DrawBar()
00094 {
00095         //Horizontal
00096         if(_orientation)
00097         {
00098                 SetWindowStyle(wxNO_FULL_REPAINT_ON_RESIZE);
00099                 _bitmap_bar             = new wxBitmap(_w+1280,_h+100);
00100                 //SIL//_bitmap_info     = new wxBitmap(_w+100+1280, _h+100);
00101         }
00102         //vertical
00103         else
00104         {
00105                 SetWindowStyle(wxNO_FULL_REPAINT_ON_RESIZE);
00106                 _bitmap_bar = new wxBitmap(_h+deviceStart_y+100,_w+1280);
00107                 _bitmap_info = new wxBitmap(_h+deviceStart_y+100, _w+1280);
00108         }
00109 }
00110 //----------------------------------------------------------------------------
00111 //Getters & Setters
00112 //----------------------------------------------------------------------------
00113 //----------------------------------------------------------------------------
00114 //the property condition on actual triangle
00115 //----------------------------------------------------------------------------
00116 bool mBarRange::GetInRangeProperty()
00117 {
00118         return _in_rangeProperty;
00119 }
00120 //----------------------------------------------------------------------------
00121 void mBarRange::SetInRangeProperty(bool in)
00122 {
00123         _in_rangeProperty=in;
00124 }
00125 //----------------------------------------------------------------------------
00126 //the information about the actual triangle in range or not, true if is between start and end
00127 //----------------------------------------------------------------------------
00128 bool mBarRange::IsActualInRange()
00129 {
00130         return ( _actual <= _end && _actual >= _start );
00131 }
00132 
00133 //----------------------------------------------------------------------------
00134 // the position of the rectangle, vertical or horizontal
00135 //----------------------------------------------------------------------------
00136 bool mBarRange::GetOrientation()
00137 {
00138         return _orientation;
00139 }
00140 //-----------------------------------------------------------------------------
00141 void mBarRange::SetOrientation(bool orientation)
00142 {
00143         if(_orientation)
00144         {
00145                 SetSize(_h,_w);
00146         }
00147         _orientation=orientation;
00148 
00149 }
00150 //----------------------------------------------------------------------------
00151 // _start of the pixel rectangle
00152 //----------------------------------------------------------------------------
00153 
00154 int mBarRange::GetPixelStart()
00155 {
00156         return ((_start - _min)*(_w-deviceEndMargin))/(_max - _min);    
00157 }
00158 //----------------------------------------------------------------------------
00159 // param i: value in pixels
00160 //----------------------------------------------------------------------------
00161 void mBarRange::SetPixelStart(int i)
00162 {
00163         _start = _min+((i - deviceStart_x)*( _max - _min))/(_w-deviceEndMargin);
00164         
00165 }
00166 //----------------------------------------------------------------------------
00167 // _actual of the pixel rectangle
00168 //----------------------------------------------------------------------------
00169 int mBarRange::GetPixelActual()
00170 {
00171         return ((_actual - _min)*(_w-deviceEndMargin))/(_max - _min);
00172 }
00173 //----------------------------------------------------------------------------
00174 // param i: value in pixels
00175 //----------------------------------------------------------------------------
00176 void mBarRange::SetPixelActual(int i)
00177 {
00178         _actual = _min + (i-deviceStart_x)*(_max-_min)/(_w-deviceEndMargin);
00179 }
00180 //----------------------------------------------------------------------------
00181 // _end of the pixel rectangle
00182 //----------------------------------------------------------------------------
00183 int mBarRange::GetPixelEnd()
00184 {
00185         return ((_end - _min)*(_w-deviceEndMargin))/(_max - _min);
00186 }
00187 //----------------------------------------------------------------------------
00188 // param i: value in pixels to be converted to real logical value
00189 //----------------------------------------------------------------------------
00190 void mBarRange::SetPixelEnd(int i)
00191 {
00192         _end = _min + (i-deviceStart_x)*(_max-_min)/(_w-deviceEndMargin);
00193 }
00194 //----------------------------------------------------------------------------
00195 // Logical max of the triangle
00196 //----------------------------------------------------------------------------
00197 
00198 double mBarRange::GetMax()
00199 {
00200         return _max;
00201 }
00202 
00203 //----------------------------------------------------------------------------
00204 void mBarRange::SetMax(double i)
00205 {
00206         _max=i;
00207 }
00208 //----------------------------------------------------------------------------
00209 // Logical min of the triangle
00210 //----------------------------------------------------------------------------
00211 
00212 double mBarRange::GetMin()
00213 {
00214         return _min;
00215 }
00216 
00217 //----------------------------------------------------------------------------
00218 void mBarRange::SetMin(double i)
00219 {
00220         _min=i;
00221 }
00222 
00223 //----------------------------------------------------------------------------
00224 // pixel dimensions of the rectangle
00225 //----------------------------------------------------------------------------
00226 
00227 int mBarRange::GetWidth()
00228 {
00229         return _w;
00230 }
00231 //----------------------------------------------------------------------------
00232 void mBarRange::SetWidth(int w)
00233 {
00234         _w=w;
00235 }
00236 //----------------------------------------------------------------------------
00237 int mBarRange::GetHeight()
00238 {
00239         return _h;
00240 }
00241 
00242 //----------------------------------------------------------------------------
00243 void mBarRange::SetHeight(int h)
00244 {
00245         _h=h;   
00246 }
00247 
00248 //----------------------------------------------------------------------------
00249 // Logical  Start of the rectangle
00250 //----------------------------------------------------------------------------
00251 
00252 int mBarRange::GetStart()
00253 {
00254         return _start;
00255 
00256 }
00257 //----------------------------------------------------------------------------
00258 // param start: value real units
00259 //----------------------------------------------------------------------------
00260 void mBarRange::SetStart(int newstart)
00261 {
00262         if(newstart<_min)
00263                 newstart = _min;
00264         _start = newstart;
00265         RefreshForce(); 
00266 }
00267 //----------------------------------------------------------------------------
00268 // Logical End of the rectangle
00269 //----------------------------------------------------------------------------
00270 
00271 int mBarRange::GetEnd()
00272 {
00273         return _end;
00274 }
00275 //----------------------------------------------------------------------------
00276 // param end: value pixel units
00277 //----------------------------------------------------------------------------
00278 void mBarRange::SetEnd(int nwend)
00279 {
00280         if(nwend>_max)
00281                 _end = _max;
00282         _end=nwend;
00283         RefreshForce(); 
00284 }
00285 //----------------------------------------------------------------------------
00286 // logical  Actual of the rectangle
00287 //----------------------------------------------------------------------------
00288 int mBarRange::GetActual()
00289 {
00290         return _actual;
00291 }
00292 //----------------------------------------------------------------------------
00293 void mBarRange::SetActual(int actual)
00294 {
00295         if(actual<_min)
00296                 _actual = _min;
00297         else if (actual>_max)
00298                 _actual = _max;
00299         _actual=actual;
00300         RefreshForce();
00301 }
00302 
00303 //----------------------------------------------------------------------------
00304 //
00305 //----------------------------------------------------------------------------
00306 int mBarRange::GetTrianglesHalfWidth()
00307 {
00308         return trianglesHalfWidth;
00309 }
00310 //----------------------------------------------------------------------------
00311 void mBarRange::SetTrianglesHalfWidth(int nwTriHalfWidth)
00312 {
00313         trianglesHalfWidth = nwTriHalfWidth;
00314 }
00315 
00316 void mBarRange::OnSize( wxSizeEvent &WXUNUSED(event) )
00317 {
00318         wxRect rectTotal = GetClientRect(); 
00319         if(_orientation)
00320         {               
00321                 SetWidth( rectTotal.GetWidth() - deviceEndMargin );                     
00322         } 
00323         else 
00324         {
00325                 SetWidth( rectTotal.GetHeight() - deviceEndMargin);                             
00326         }
00327         _selectionMoveId = -1;
00328         Refresh();              
00329 }
00330 
00331 //----------------------------------------------------------------------------
00332 
00333 void mBarRange::Refresh(bool eraseBackground, const wxRect* rect)
00334 {
00335 // EED Borrame
00336 //FILE *ff;
00337 //ff=fopen ("c:/temp/xxx.txt", "a+");
00338 //fprintf( ff , "mBarRange :: Refresh 01\n" );
00339 //fclose(ff);
00340 
00341         wxScrolledWindow::Refresh(false);
00342 
00343 
00344 // EED Borrame
00345 //ff=fopen ("c:/temp/xx.txt", "a+");
00346 //fprintf( ff , "mBarRange :: Refresh 02\n" );
00347 //fclose(ff);
00348 }
00349 
00350 
00351 //----------------------------------------------------------------------------
00352 //Bar Methods
00353 //----------------------------------------------------------------------------
00354 void mBarRange::OnPaint( wxPaintEvent &WXUNUSED(event) )
00355 {
00356 
00357 // EED Borrame
00358 //FILE *ff;
00359 //ff=fopen ("c:/temp/xx.txt", "a+");
00360 //fprintf( ff , "pColorBar :: OnPaint 01\n" );
00361 //fclose(ff);
00362 
00363         if (_bitmap_bar!=NULL){
00364                 //repaint rectangle
00365                 if(_orientation)
00366                 {
00367                         RefreshHorizontalView();
00368                         wxMemoryDC temp_dc;
00369                         temp_dc.SelectObject( *_bitmap_bar );
00370                         wxPaintDC dc( this );
00371                         dc.Blit(deviceStart_x-(trianglesHalfWidth+2), deviceStart_y, _w-deviceEndMargin+2*(trianglesHalfWidth+2), _h, &temp_dc, 0, 0);
00372                         //repaint info
00373 //                      if (_visibleLables)
00374 //                      {
00375 //                              temp_dc.SelectObject( *_bitmap_info );                          
00376 //                              dc.Blit(deviceStart_x,deviceStart_y+_h, _w+deviceStart_x-deviceEndMargin, _h+deviceStart_y+200, &temp_dc, deviceStart_x, deviceStart_y);
00377 //                              //dc.Blit(deviceStart_x,deviceStart_y+_h, _w+deviceStart_x-deviceEndMargin, _h+deviceStart_y+60, &temp_dc, 0, 0);
00378 //                      }
00379         
00380                 } else {
00381                         RefreshVerticalView();
00382                         wxMemoryDC temp_dc;
00383                         temp_dc.SelectObject( *_bitmap_bar );
00384                         wxPaintDC dc( this );                   
00385 //                      dc.Blit(deviceStart_y,deviceStart_x, _h+deviceStart_y-deviceEndMargin,_w+deviceStart_x-deviceEndMargin, &temp_dc, 0, 0);        
00386                         dc.Blit(deviceStart_y,deviceStart_x-(trianglesHalfWidth+2), _h,_w-deviceEndMargin+2*(trianglesHalfWidth+2), &temp_dc, 0, 0);    
00387                         
00388                         //repaint info
00389 //                      if (_visibleLables)
00390 //                      {
00391 //                              temp_dc.SelectObject( *_bitmap_info );
00392 //                              dc.Blit(0,_w, _h+deviceStart_y+200, _w+deviceStart_x+200-deviceEndMargin, &temp_dc, deviceStart_y,_w+deviceStart_x);
00393 //                      }
00394 
00395 
00396                 } 
00397         } 
00398 
00399 // EED Borrame
00400 //ff=fopen ("c:/temp/xx.txt", "a+");
00401 //fprintf( ff , "pColorBar :: OnPaint 02\n" );
00402 //fclose(ff);
00403 
00404 
00405 }
00406 //----------------------------------------------------------------------------
00407 //Repaint the bar if it is horizontal
00408 //----------------------------------------------------------------------------
00409 void mBarRange::RefreshHorizontalView()
00410 {
00411 
00412 // EED Borrame
00413 //FILE *ff;
00414 //ff=fopen ("c:/temp/xxx.txt", "a+");
00415 //fprintf( ff , "mBarRange :: RefreshHorizontalView 01\n" );
00416 //fclose(ff);
00417 
00418         wxPoint points[3];
00419 
00420         //int largestNumberWidthInPixels = 15; // JPRx
00421         int pxStart=GetPixelStart();
00422         int pxEnd=GetPixelEnd();
00423         int pxActual=GetPixelActual();
00424 
00425         
00426         int letterHeight = 9;
00427         int barHeight = 2*letterHeight;
00428         int tempHeight = _h-(6*letterHeight);
00429         
00430         
00431         if (_visibleLables)
00432         {
00433                 barHeight = (tempHeight>0)  ? tempHeight : (int) _h/2;
00434         }
00435         else
00436                 barHeight = _h; 
00437 
00438         wxMemoryDC temp_dc;
00439         temp_dc.SelectObject( *_bitmap_bar );
00440 
00441         
00442         // Background of this widget
00443         
00444         
00445         temp_dc.SetPen(wxPen( backgroundColor ));
00446         temp_dc.SetBrush(wxBrush( backgroundColor ,wxSOLID  ));
00447         
00448         temp_dc.DrawRectangle(0,0,_w+2*trianglesHalfWidth,_h);
00449         
00450 
00451         temp_dc.SetPen(wxPen( wxColour(167,165,191) ,1,wxSOLID  ));
00452         temp_dc.DrawLine(trianglesHalfWidth+2, 0, _w-deviceEndMargin, 0);
00453         temp_dc.DrawLine(trianglesHalfWidth+2, barHeight, (_w-deviceEndMargin-trianglesHalfWidth-2), barHeight);
00454         temp_dc.SetDeviceOrigin(trianglesHalfWidth+2,0);
00455 
00456 
00457         // Filling the bar
00458         temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
00459         temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
00460         temp_dc.DrawRectangle( pxStart , 0, pxEnd-pxStart, barHeight);
00461 
00462 
00463         //  The Bar
00464         if( _selectionMoveId==4 )
00465         {
00466                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
00467                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
00468         }
00469         else
00470         {
00471                 temp_dc.SetBrush(wxBrush( bar_Colour,wxSOLID  ));
00472                 temp_dc.SetPen(wxPen( wxColour(164,0,164),1,wxSOLID  ));
00473         }
00474         temp_dc.DrawRectangle( pxStart,1, pxEnd-pxStart, barHeight );
00475 
00476         // 2 Shadow Triangles: Start and End 
00477         temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
00478         temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
00479         points[0].x= 0;
00480         points[0].y= barHeight;
00481         points[1].x= -trianglesHalfWidth-1;
00482         points[1].y= 0;
00483         points[2].x= trianglesHalfWidth+2;
00484         points[2].y= 0;
00485         temp_dc.DrawPolygon(3,points,pxStart,0);
00486         temp_dc.DrawPolygon(3,points,pxEnd,0);
00487 
00488         // 2 Triangles: Start and End 
00489         points[1].x = -trianglesHalfWidth;      
00490         points[2].x = trianglesHalfWidth;
00491         
00492         //first triangle (start)
00493         if( _selectionMoveId == 1 )
00494         {
00495                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
00496                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
00497         }
00498         else
00499         {
00500                 temp_dc.SetBrush(wxBrush( start_Colour,wxSOLID  ));
00501                 temp_dc.SetPen(wxPen( wxColour(0,51,204),1,wxSOLID  ));
00502         }
00503         temp_dc.DrawPolygon(3,points,pxStart,0);
00504         //second triangle (end)
00505         if( _selectionMoveId == 2 )
00506         {
00507                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
00508                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
00509         }
00510         else
00511         {
00512                 temp_dc.SetBrush(wxBrush( end_Colour,wxSOLID  ));
00513                 temp_dc.SetPen(wxPen( wxColour(0,0,255),1,wxSOLID  ));
00514         }
00515         temp_dc.DrawPolygon(3,points,pxEnd,0);
00516 
00517         if( withActualDrawed )
00518         {
00519                 // 1 Shadow Triangle: Actual
00520                 temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
00521                 temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
00522                 points[1].x = -trianglesHalfWidth-1;
00523                 points[2].x = trianglesHalfWidth+2;
00524                 
00525                 temp_dc.DrawPolygon(3,points,pxActual,0);
00526 
00527                 // 1 Triangle: Actual (red)
00528                 if( _selectionMoveId==3 )
00529                 {
00530                         temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
00531                         temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
00532                 }
00533                 else
00534                 {
00535                         temp_dc.SetBrush(wxBrush( actual_Colour,wxSOLID  ));
00536                         temp_dc.SetPen(wxPen( wxColour(205,160,5),1,wxSOLID  ));
00537                 }
00538                 points[1].x = -trianglesHalfWidth;
00539                 points[2].x = trianglesHalfWidth;
00540                 temp_dc.DrawPolygon(3,points,pxActual,0);
00541         }
00542 
00543         if (realX_vertical_line!=-1)
00544         {
00545                 temp_dc.SetPen(wxPen(  guideLineColor,1,wxDOT ));
00546                 int pixelX_guide = ((realX_vertical_line - _min)*(_w-deviceEndMargin))/(_max - _min) ; 
00547                 temp_dc.DrawLine(pixelX_guide, 0, pixelX_guide, barHeight);
00548         }
00549 
00550         //Information Device drawing
00551 
00552         if (_visibleLables)
00553         {
00554                 //temp_dc.SelectObject( *_bitmap_info );
00555                 /*temp_dc.SetBrush(wxBrush( colourParent ,wxSOLID  ));
00556                 temp_dc.SetPen(wxPen( colourParent ,1,wxSOLID  ));*/
00557                 //temp_dc.DrawRectangle(deviceStart_x,_h+deviceStart_y,_w+deviceStart_x+40,_h+deviceStart_y+40);
00558                 //temp_dc.DrawRectangle(0,_h,_w+40-deviceEndMargin,_h+40);
00559 
00560                 wxFont font(letterHeight-1, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL);
00561                 temp_dc.SetFont(font);
00562                 temp_dc.SetTextForeground(*wxBLACK);
00563 
00564 
00565                 //the **MIN** value, always at the same y level that corresponds to barHeight+1
00566                 wxString text_min;
00567 //              text_min<< GetMin();
00568                 text_min.Printf(_T("%d"), (int)GetMin() );
00569                 
00570                 temp_dc.DrawText(text_min,0,barHeight+1);
00571 
00572                 //the **MAX** value always at the same place
00573                 wxString text_max;
00574 //              text_max << GetMax();
00575                 text_max.Printf(_T("%d"), (int)GetMax() );
00576 
00577                 //As there is a margin of 40 extra most numbers (max) should be visibles
00578 //              stringSize = temp_dc.GetTextExtent(text_max);
00579         wxCoord tmpX,tmpY;
00580                 temp_dc.GetTextExtent(text_max,&tmpX,&tmpY);
00581                 wxSize stringSize(tmpX,tmpY);
00582                 
00583                 temp_dc.DrawText(text_max,_w-deviceEndMargin -(stringSize.GetWidth())/*2*trianglesHalfWidth*/,barHeight+1);     
00584                 
00585                 //show logical values
00586                 //show the **START TRIANGLE** value 
00587                 wxString text_start;
00588 //              text_start << GetStart();               
00589                 text_start.Printf(_T("%d"), (int)GetStart() );
00590 
00591                 temp_dc.DrawText(text_start, pxStart,barHeight+2*letterHeight);
00592                 //show the **END TRIANGLE** value
00593                 wxString text_end;
00594 //              text_end << GetEnd();
00595                 text_end.Printf(_T("%d"), (int)GetEnd() );
00596 
00597 //              stringSize = temp_dc.GetTextExtent(text_end);
00598                 temp_dc.GetTextExtent(text_end,&tmpX,&tmpY);
00599                 stringSize.SetHeight(tmpY);
00600                 stringSize.SetWidth(tmpX);
00601                 temp_dc.DrawText(text_end, pxEnd-stringSize.GetWidth(),barHeight+3*letterHeight);
00602                 if( withActualDrawed )
00603                 {
00604                         //show the actual value of actual
00605                         wxString text_actual;
00606 //                      text_actual << GetActual();
00607                         text_actual.Printf(_T("%d"), (int)GetActual() );
00608 //                      stringSize = temp_dc.GetTextExtent(text_actual);
00609                         temp_dc.GetTextExtent(text_actual,&tmpX,&tmpY);
00610                     stringSize.SetHeight(tmpY);
00611                     stringSize.SetWidth(tmpX);
00612                         temp_dc.DrawText(text_actual, pxActual-(stringSize.GetWidth()/2),barHeight+letterHeight);                       
00613                 }                       
00614         }
00615 
00616 // EED Borrame
00617 //ff=fopen ("c:/temp/xxx.txt", "a+");
00618 //fprintf( ff , "mBarRange :: RefreshHorizontalView 02\n" );
00619 //fclose(ff);
00620 }
00621 
00622 //----------------------------------------------------------------------------
00623 //Repaint the bar if it is vertical
00624 //----------------------------------------------------------------------------
00625 
00626 void mBarRange::RefreshVerticalView()
00627 {
00628 
00629 // EED Borrame
00630 //FILE *ff;
00631 //ff=fopen ("c:/temp/xxx.txt", "a+");
00632 //fprintf( ff , "mBarRange :: RefreshVerticalView 01\n" );
00633 //fclose(ff);
00634         wxPoint points[3];
00635 
00636         int px1=GetPixelStart();
00637         int px2=GetPixelEnd();
00638         int px3=GetPixelActual();
00639         int letterHeight = 9;
00640         int panelHeight = 9*3+_w;
00641 
00642         int barWidth;
00643         if (_visibleLables)
00644         {
00645                 barWidth = (_w-30)>0 ? _w-30 : (int) _w/2;
00646         }
00647         else
00648                 barWidth = _w;  
00649 
00650         wxMemoryDC temp_dc;
00651         temp_dc.SelectObject( *_bitmap_bar );
00652 
00653         // Background
00654         temp_dc.SetBrush(wxBrush( backgroundColor ,wxSOLID  ));
00655         temp_dc.SetPen(wxPen( backgroundColor ));
00656 
00657         temp_dc.DrawRectangle(0,0,_h,_w+2*trianglesHalfWidth);
00658         
00659 
00660         temp_dc.SetPen(wxPen( wxColour(167,165,191) ,1,wxSOLID  ));
00661         temp_dc.DrawLine(0,trianglesHalfWidth+2, 0, _w-deviceEndMargin);
00662         temp_dc.DrawLine(barWidth, trianglesHalfWidth+2, barWidth, (_w-deviceEndMargin-trianglesHalfWidth-2));
00663         temp_dc.SetDeviceOrigin(0,trianglesHalfWidth+2);
00664 
00665         // Filling the bar
00666         temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
00667         temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
00668         temp_dc.DrawRectangle( 0,px1 ,_h, px2-px1 );
00669 
00670 
00671         //  The Bar
00672                 if( _selectionMoveId==4 )
00673         {
00674                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
00675                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
00676         }
00677         else
00678         {
00679                 temp_dc.SetBrush(wxBrush( bar_Colour,wxSOLID  ));
00680                 temp_dc.SetPen(wxPen( wxColour(164,0,164),1,wxSOLID  ));
00681         }
00682         temp_dc.DrawRectangle( 1,px1,_h, px2-px1);
00683 
00684 
00685         // 2 Shadow Triangles: Start and End 
00686         points[0].x=_h;
00687         points[0].y=0;
00688         points[1].x=0;
00689         points[1].y=-trianglesHalfWidth-1;
00690         points[2].x=0;
00691         points[2].y=trianglesHalfWidth+2;
00692         temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
00693         temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
00694         temp_dc.DrawPolygon(3,points,0,px1);
00695         temp_dc.DrawPolygon(3,points,0,px2);
00696 
00697         // 2 Triangles: Start and End 
00698         points[0].x=_h;
00699         points[0].y=0;
00700         points[1].x=0;
00701         points[1].y=-trianglesHalfWidth;
00702         points[2].x=0;
00703         points[2].y=trianglesHalfWidth;
00704         //first triangle (start)
00705         if( _selectionMoveId==1 )
00706         {
00707                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
00708                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
00709         }
00710         else
00711         {
00712                 temp_dc.SetBrush(wxBrush( start_Colour,wxSOLID  ));
00713                 temp_dc.SetPen(wxPen( wxColour(0,51,204),1,wxSOLID  ));
00714         }
00715         temp_dc.DrawPolygon(3,points,0,px1);
00716         //second triangle (end)
00717         if( _selectionMoveId==2 )
00718         {
00719                 temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
00720                 temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
00721         }
00722         else
00723         {
00724                 temp_dc.SetBrush(wxBrush( end_Colour,wxSOLID  ));
00725                 temp_dc.SetPen(wxPen( wxColour(0,0,255),1,wxSOLID  ));
00726         }
00727         temp_dc.DrawPolygon(3,points,0,px2);
00728 
00729         if( withActualDrawed )
00730         {
00731                 // 1 Shadow Triangle: Actual
00732                 temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID  ));
00733                 temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID  ));
00734                 points[0].x=_h;
00735                 points[0].y=0;
00736                 points[1].x=0;
00737                 points[1].y=-trianglesHalfWidth-1;
00738                 points[2].x=0;
00739                 points[2].y=trianglesHalfWidth+2;
00740                 temp_dc.DrawPolygon(3,points,0,px3);
00741 
00742                 // 1 Triangle: Actual (red)
00743                 points[0].x = _h;
00744                 points[0].y = 0;
00745                 points[1].x = 0;
00746                 points[1].y = -trianglesHalfWidth;
00747                 points[2].x = 0;
00748                 points[2].y = trianglesHalfWidth;
00749                 if( _selectionMoveId==3 )
00750                 {
00751                         temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID  ));
00752                         temp_dc.SetPen(wxPen(  wxColour(0,128,0),1,wxSOLID  ));
00753                 }
00754                 else
00755                 {
00756                         temp_dc.SetBrush(wxBrush( actual_Colour,wxSOLID  ));
00757                         temp_dc.SetPen(wxPen( wxColour(205,160,5),1,wxSOLID  ));
00758                 }
00759                 temp_dc.DrawPolygon(3,points,0,px3);
00760         }
00761 
00762         if (realX_vertical_line!=-1)
00763         {
00764                 temp_dc.SetPen(wxPen(  guideLineColor,1,wxDOT  ));
00765                 int pixelX_guide = realX_vertical_line*_w/(_max-_min)+deviceStart_x; 
00766                 temp_dc.DrawLine(0,pixelX_guide, _h, pixelX_guide);
00767         }
00768 
00769         //Information Device drawing
00770         if (_visibleLables)
00771         {
00772                 /*temp_dc.SelectObject( *_bitmap_info );
00773 
00774                 temp_dc.SetBrush(wxBrush( backgroundColor ,wxSOLID  ));
00775                 temp_dc.SetPen(wxPen( backgroundColor ,1,wxSOLID  ));
00776                 temp_dc.DrawRectangle(deviceStart_y,_w+deviceStart_x,_h+deviceStart_y+200,_w+deviceStart_x+200);
00777 */
00778 
00779                 temp_dc.SetBackgroundMode(wxTRANSPARENT);
00780                 wxFont font(letterHeight-1, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL);
00781                 temp_dc.SetFont(font);
00782                 temp_dc.SetTextForeground(*wxBLACK);
00783 
00784                 //show logical values
00785                 //show the actual value of start
00786                 wxString text_start;
00787 //              text_start<<"Start:"<< GetStart();
00788                 text_start.Printf(_T("%s %d"),_T("Start: "), (int)GetStart() );
00789                 temp_dc.DrawText( text_start ,deviceStart_y, _w+deviceStart_x+letterHeight+1);
00790                 //show the actual value of end
00791                 wxString text_end;
00792 //              text_end <<"End: "<<GetEnd();
00793                 text_end.Printf(_T("%s %d"),_T("End: "), (int)GetEnd() );
00794                 temp_dc.DrawText( text_end ,deviceStart_y,_w+deviceStart_x+letterHeight*2 );
00795                 if( withActualDrawed )
00796                 {
00797                         //show the actual value of actual
00798                         wxString text_actual;
00799 //                      text_actual <<"Actual: " <<GetActual();
00800                         text_actual.Printf(_T("%s %d"),_T("Actual: "), (int)GetActual() );
00801                         temp_dc.DrawText( text_actual ,deviceStart_y,_w+deviceStart_x+letterHeight*3);
00802                 }
00803                 //the min value, always at the same place
00804                 wxString text_min;
00805 //              text_min<<"Min: " << GetMin();
00806                 text_min.Printf(_T("%s %d"),_T("Min: "), (int)GetMin() );
00807                 temp_dc.DrawText( text_min ,deviceStart_y,_w+deviceStart_x+3);
00808                 //the max value always at the samen place
00809                 wxString text_max;
00810 //              text_max <<"Max: "<< GetMax();
00811                 text_max.Printf(_T("%s %d"),_T("Max: "), (int)GetMax() );
00812                 //toca calcular cuantol lo corremos
00813                 temp_dc.DrawText(text_max,deviceStart_y,_w+deviceStart_x+43);           
00814         }
00815 
00816 }
00817 
00818 //----------------------------------------------------------------------------
00819 void mBarRange::RefreshForce()
00820 {
00821         Refresh();
00822         Update();
00823 }
00824 //----------------------------------------------------------------------------
00825 void mBarRange::OnMouseMove(wxMouseEvent& event )
00826 {
00827 // EED Borrame
00828 //FILE *ff;
00829 //ff=fopen ("c:/temp/xxx.txt", "a+");
00830 //fprintf( ff , "mBarRange :: OnMouseMove 01\n" );
00831 //fclose(ff);
00832 
00833         //int px1=GetPixelStart(); // JPRx
00834         //int px2=GetPixelEnd(); // JPRx
00835         //int px3=GetPixelActual(); // JPRx
00836         if (activeState)
00837         {
00838                 wxPoint point = event.GetPosition();
00839                 int barHeight;
00840                 if (_orientation)
00841                 {
00842                         setClickedX(point.x);
00843                         barHeight = point.y;
00844                 }
00845                 else
00846                 {
00847                         setClickedX(point.y);
00848                         barHeight = point.x;
00849                 }
00850                 int logicClick = getLogicValueofPixel(clickedX);
00851                         
00852                 if( _selectionMoveId==-1 )
00853                 {
00854                         if (barHeight <=_h)
00855                         {
00856                                 bool in_StartTri = (clickedX>=GetPixelStart()-5+ deviceStart_x) && (clickedX<=GetPixelStart()+5+ deviceStart_x);
00857                                 bool in_EndTri = (clickedX>=GetPixelEnd()-5+ deviceStart_x) && (clickedX<=GetPixelEnd()+5+ deviceStart_x);
00858                                 bool in_actualT= withActualDrawed && (clickedX>=GetPixelActual()-5+ deviceStart_x) && (clickedX<=GetPixelActual()+5+ deviceStart_x);
00859                                 bool in_movingBar = (clickedX>GetPixelStart()+5+ deviceStart_x) && (clickedX<GetPixelEnd()-5+ deviceStart_x);
00860 
00861                                 if( in_actualT )
00862                                         _selectionMoveId = 3;
00863                                 else if(in_StartTri)
00864                                         _selectionMoveId = 1;  
00865                                 else if( in_EndTri )
00866                                         _selectionMoveId = 2;
00867                                 else if( in_movingBar )
00868                                         _selectionMoveId = 4;
00869                         }
00870                 }
00871                 else
00872                 {
00873                         if(acceptedClick)
00874                         {
00875                                 //is in start triagle
00876                                 if( _selectionMoveId ==1 && event.LeftIsDown())
00877                                 {
00878                                         bool validPos_StartTri = (logicClick<GetEnd() && logicClick >=_min);
00879                                         if( validPos_StartTri && !_in_rangeProperty)
00880                                         {       
00881                                                 SetPixelStart(clickedX);
00882                                                 RefreshForce();
00883                                                 RefreshHorizontalView();
00884                                                 //-------------------------------------------
00885                                                 // Sending the event of start triangle moved
00886                                                 //-------------------------------------------
00887                                                 createAndSendEvent( wxEVT_TSBAR_START );
00888                                         }
00889                                         //start has to be less than actual
00890                                         else if (validPos_StartTri && _in_rangeProperty)
00891                                         {
00892                                                 if(logicClick<=GetActual())
00893                                                 {
00894                                                         SetPixelStart(clickedX);
00895                                                         RefreshForce();
00896                                                 //      RefreshHorizontalView();
00897                                                         //-------------------------------------------
00898                                                         // Sending the event of start triangle moved
00899                                                         //-------------------------------------------
00900                                                 createAndSendEvent( wxEVT_TSBAR_START );
00901                                                 }
00902                                         }
00903                                 } // _selectionMoveId == 1
00904                                 //is in end triangle
00905                                 else if( _selectionMoveId == 2 && event.LeftIsDown() )
00906                                 {
00907                                         bool validPos_EndTri = logicClick>GetStart()&& logicClick<=_max;  
00908                                         if( validPos_EndTri && !_in_rangeProperty )
00909                                         {                                       
00910                                                 SetPixelEnd(clickedX);
00911                                                 RefreshForce();
00912         //                                      RefreshHorizontalView();        
00913                                                 //-------------------------------------------
00914                                                 //Sending the event of end triangle moved
00915                                                 //-------------------------------------------
00916                                                 createAndSendEvent( wxEVT_TSBAR_END );
00917                                         }
00918                                         //the end triangle cant be less than actual
00919                                         else if( validPos_EndTri && _in_rangeProperty )
00920                                         {
00921                                                 if(logicClick>=GetActual())
00922                                                 {
00923                                                         SetPixelEnd(clickedX);
00924                                                         RefreshForce();
00925                                                 //      RefreshHorizontalView();
00926                                                         //-------------------------------------------
00927                                                         //Sending the event of end triangle moved
00928                                                         //-------------------------------------------
00929                                                         createAndSendEvent( wxEVT_TSBAR_END );
00930                                                 }
00931                                         }
00932                                 } 
00933                                 //is the actual triangle
00934                                 else if( _selectionMoveId == 3 && event.LeftIsDown())
00935                                 {
00936                                         bool validPos_ActualTri=(logicClick<=_max) && (logicClick>=_min);
00937                                         //is in actual triangle but it could be anywhere
00938                                         if( validPos_ActualTri && !_in_rangeProperty )
00939                                         {
00940                                                 SetPixelActual(clickedX);
00941                                                 RefreshForce();
00942                                                 RefreshHorizontalView();
00943                                                 //-------------------------------------------
00944                                                 //Sending the event of actual triangle moved
00945                                                 //-------------------------------------------
00946                                                 createAndSendEvent( wxEVT_TSBAR_ACTUAL );       
00947 //                                              createAndSendEvent( 98765 );
00948 
00949 //printf("EED creaMaracasVisu mBarRange::OnMouseMove XXXXXXX \n");
00950 
00951                                         }
00952                                         else if( validPos_ActualTri && _in_rangeProperty )
00953                                         // the tringle in between start and end
00954                                         {
00955                                                 if( logicClick>=GetStart() && logicClick<=GetEnd())
00956                                                 {
00957                                                         SetPixelActual(clickedX);
00958                                                         RefreshForce();
00959                                                         RefreshHorizontalView();
00960                                                         //-------------------------------------------
00961                                                         //Sending the event of actual triangle moved
00962                                                         //-------------------------------------------
00963                                                         createAndSendEvent( wxEVT_TSBAR_ACTUAL );
00964                                                 }
00965                                         } 
00966                                 } 
00967                                 //is the bar
00968                                 else if ( _selectionMoveId == 4 &&  event.LeftIsDown() )
00969                                 {       
00970                                         //FILE * f=fopen("E:/borrar/file.txt","a+");
00971                                         if(_initialPoint == 0)
00972                                         {
00973                                                 _initialPoint = logicClick;
00974                                                 logicInitial_start = GetStart(); 
00975                                                 logicInitial_end = GetEnd();
00976                                                 logicInitial_actual = GetActual();
00977                                                 //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);
00978                                         }
00979                                         int difference = logicClick -_initialPoint;
00980                                         int next_end = difference + logicInitial_end;
00981                                         int next_start = difference + logicInitial_start;
00982                                         int next_actual = difference + logicInitial_actual;
00983                                         
00984                                         /*SIL//fprintf(f,"diff:%d, next_end%d, next_start%d, next_actual%d \n", difference,next_end,next_start,next_actual);
00985                                         fclose(f);*/
00986                                         
00987                                         //if actual is not fixed to be in the middle
00988                                         if( ((logicClick>next_start) && (logicClick<next_end)&& (next_end<=_max)&& (next_start>=_min)) && !_in_rangeProperty)
00989                                         {
00990                                                 SetStart(next_start);
00991                                                 SetEnd(next_end);
00992                                                 if( _moveActualWithBar )
00993                                                 {
00994                                                         SetActual (next_actual);
00995                                                         //-------------------------------------------
00996                                                         //Sending the event of actual triangle moved
00997                                                         //-------------------------------------------
00998                                                         createAndSendEvent( wxEVT_TSBAR_ACTUAL );
00999                                                 }
01000                                                 RefreshForce();
01001                                                 RefreshHorizontalView();        
01002                                                                                         
01003                                                 //-------------------------------------------
01004                                                 // Sending the event that the bar ahs being moved
01005                                                 //-------------------------------------------
01006                                                 createAndSendEvent( wxEVT_TSBAR_MOVED );
01007                                         }
01008                                         //if actual has to be between start and end
01009                                         else if(_in_rangeProperty && ((next_start<=GetActual()) && (next_end>=GetActual()) && (next_end<=_max)&& (next_start>=_min)) )
01010                                         {
01011                                                 SetStart(next_start);
01012                                                 SetEnd(next_end);
01013                                                 if( _moveActualWithBar )
01014                                                 {
01015                                                         SetActual (next_actual);
01016                                                         //-------------------------------------------
01017                                                         //Sending the event of actual triangle moved
01018                                                         //-------------------------------------------
01019                                                         createAndSendEvent( wxEVT_TSBAR_ACTUAL );
01020                                                 }
01021                                                 RefreshForce();
01022                                                 RefreshHorizontalView();        
01023                                                 
01024                                                 //-------------------------------------------
01025                                                 // Sending the event that the bar ahs being moved
01026                                                 //-------------------------------------------
01027                                                 createAndSendEvent( wxEVT_TSBAR_MOVED );
01028                                         }
01029                                 }                       
01030                         }
01031                         if( !event.LeftIsDown())
01032                         {
01033                                 _initialPoint=0;
01034                                 _selectionMoveId = -1;
01035                                 RefreshForce();
01036                                 //-------------------------------------------
01037                                 //Sending a general event just because
01038                                 //-------------------------------------------
01039                                 //SIL//createAndSendEvent( wxEVT_TSBAR );
01040                                 createAndSendEvent(wxEVT_SELECTION_END);
01041                         }
01042                 }                               
01043         }       
01044 
01045 // EED Borrame
01046 //ff=fopen ("c:/temp/xxx.txt", "a+");
01047 //fprintf( ff , "  mBarRange :: OnMouseMove 02\n" );
01048 //fclose(ff);
01049 
01050 }
01051 /*
01052 * Sets the represented minimum and maximunm values
01053 * param minRealValue The minimum represented value (real value)
01054 * param maxRealValue The maximum represented value (real value)
01055 */
01056 void mBarRange :: setRepresentedValues ( double minRealValue, double maxRealValue)
01057 {
01058         _min = minRealValue;
01059         _max = maxRealValue;
01060         _start=_min;
01061         _end=_max;
01062 }
01063 
01064 /*
01065 * Sets the property for viewing or not the bar labels information
01066 */
01067 void mBarRange :: setVisibleLabels ( bool setVisibleLB )
01068 {
01069         _visibleLables = setVisibleLB;
01070 }
01071 
01072 /*
01073         * Sets the property for viewing or not the bar labels information
01074         * return _visibleLables The state of visible labels or not 
01075         */
01076         bool mBarRange ::getIfVisibleLabels ()
01077         {
01078                 return _visibleLables;
01079         }
01080 
01086         void mBarRange :: setDeviceBlitStart ( wxCoord devStart_x, wxCoord devStart_y )
01087         {
01088                 deviceStart_x = devStart_x;
01089                 deviceStart_y = devStart_y;
01090                 // For the initialization case
01091                 if (GetPixelEnd()<0)
01092                 {
01093                         if (_orientation)
01094                         {
01095                                 SetPixelStart(deviceStart_x);
01096                                 SetPixelEnd(_w+deviceStart_x);
01097                                 SetPixelActual(deviceStart_x);
01098                         }
01099                         else
01100                         {
01101                                 SetPixelStart(deviceStart_x);
01102                                 SetPixelEnd(_h+deviceStart_x);
01103                                 SetPixelActual(deviceStart_x);
01104                         }
01105                 }
01106                 DrawBar();
01107         }
01108         
01112         void mBarRange :: onShowPopupMenu (wxMouseEvent& event)
01113         {
01114                 if (activeState)
01115                 {
01116                         bool validClic = false;
01117                         if (_orientation)
01118                         {
01119                                 validClic = event.GetX() >= deviceStart_x && event.GetY()<= (_h + deviceStart_y);
01120                         }
01121                         else
01122                         {
01123                                 validClic = event.GetX()>=deviceStart_y && event.GetX()<= (_h+deviceStart_y) && event.GetY()>deviceStart_x;
01124                         }
01125                         if (validClic)
01126                         {
01127                                 if(_orientation)
01128                                         setClickedX(event.GetX());
01129                                 else
01130                                         setClickedX(event.GetY());
01131 
01132                                 if (getClickedX()<=_h)
01133                                 {                                               
01134                                         bool in_StartTri = (clickedX>=GetPixelStart()-5+ deviceStart_x) && (clickedX<=GetPixelStart()+5+ deviceStart_x);
01135                                         bool in_EndTri = (clickedX>=GetPixelEnd()-5+ deviceStart_x) && (clickedX<=GetPixelEnd()+5+ deviceStart_x);
01136                                         bool in_actualT= (clickedX>=GetPixelActual()-5+ deviceStart_x) && (clickedX<=GetPixelActual()+5+ deviceStart_x);
01137                                         bool in_movingBar = (clickedX>GetPixelStart()+5+ deviceStart_x) && (clickedX<GetPixelEnd()-5+ deviceStart_x);
01138 
01139                                         if(in_StartTri)
01140                                                 _selectionMoveId = 1;
01141                                         else if( in_EndTri )
01142                                                 _selectionMoveId = 2;
01143                                         else if( in_actualT )
01144                                                 _selectionMoveId = 3;
01145                                         else if( in_movingBar )
01146                                                 _selectionMoveId = 4;
01147                                 }                               
01148                                 PopupMenu( &b_popmenu, event.GetX(), event.GetY());
01149                         }               
01150                 }
01151         }
01152         
01157         void mBarRange :: onChangePartColor ( wxCommandEvent& anEvent )
01158         {
01159                 bool okSelectedColor = false;
01160                 wxColour selectedColour;
01161                 wxColourData data;
01162                 wxColourDialog dialog( GetParent(), &data);
01163 
01164                 if ( dialog.ShowModal() == wxID_OK )
01165                 {
01166                         selectedColour = dialog.GetColourData().GetColour();
01167                         okSelectedColor = true;
01168                 }
01169                 if( okSelectedColor )
01170                 {
01171                         if (_selectionMoveId==1 )
01172                                 start_Colour = selectedColour;
01173                         else if (_selectionMoveId==2 )
01174                                 end_Colour = selectedColour;
01175                         else if( _selectionMoveId==3 )
01176                                 actual_Colour = selectedColour;
01177                         else if( _selectionMoveId==4 )
01178                                 bar_Colour = selectedColour;            
01179                 }
01180                 _selectionMoveId = -1;
01181         RefreshForce();
01182                 
01183         }
01184         
01189         void mBarRange :: onEnableRange_Actual ( wxCommandEvent& anEvent )
01190         {
01191                 if (!_in_rangeProperty)
01192                 {
01193                         if(IsActualInRange())
01194                         {
01195                                 SetInRangeProperty (true);
01196                                 b_popmenu.SetLabel (cntID_ENABLE_ACTUAL, _T("Disable actual in range"));
01197                         }
01198                 }
01199                 else
01200                 {
01201                         SetInRangeProperty (false);
01202                         b_popmenu.SetLabel (cntID_ENABLE_ACTUAL, _T("Enable actual in range"));                 
01203                 }
01204         }
01205 
01210         void  mBarRange :: onMovable_ActualWithBar ( wxCommandEvent& anEvent )
01211         {
01212                 if (_moveActualWithBar )
01213                 {
01214                         _moveActualWithBar = false;
01215                         b_popmenu.SetLabel (cntID_MOVABLE_ACTUAL_BAR, _T("Move actual+bar simultaneously"));
01216                 }
01217                 else
01218                 {
01219                         if(IsActualInRange())
01220                         {
01221                                 _moveActualWithBar = true;
01222                                 b_popmenu.SetLabel (cntID_MOVABLE_ACTUAL_BAR, _T("Move actual-bar independent"));
01223                         }
01224                 }
01225         }
01226 
01227                 /*
01228         * Set active state 
01229         * param activeNow The new state
01230         */
01231         void mBarRange :: setActiveStateTo (bool activeNow)
01232         {
01233                 activeState = activeNow;
01234         }
01235         
01236         /*
01237         * Gets the active state of the bar
01238         *  return activeState The actual state
01239         */
01240         bool mBarRange :: isActive()
01241         {
01242                 return activeState;
01243         }
01244 
01245         /*
01246         * Gets the real-x value to draw a vertical line
01247         * return realX_vertical_line The real x value for the vertical line
01248         */
01249         int     mBarRange :: getRealX_vertical_line()
01250         {
01251                 return realX_vertical_line;
01252         }
01253 
01254         /*
01255         * Sets the real-x value to draw a vertical line
01256         * param newReal_x The new real x value for the vertical line
01257         */
01258         void mBarRange :: setRealX_vertical_line(int newReal_x)
01259         {
01260                 realX_vertical_line = newReal_x;
01261         }
01262 
01263         /*
01264         * Gets the device value form the end of this panel to the end of the drawing area in the device in pixels
01265         * return deviceEndMargin The value asigned to the right margin
01266         */
01267         int     mBarRange :: getDeviceEndX()
01268         {
01269                 return deviceEndMargin;
01270         }
01271 
01272         /*
01273         * Sets the new device (deviceEndMargin) value form the end of this panel to the end of the drawing area in the device
01274         * param newDeviceEnd_pixels The new pixel value to asign to the right(horizontal view), underneath(vertical view) margin in pixels
01275         */
01276         void mBarRange :: setDeviceEndMargin(int newDeviceEnd_pixels)
01277         {
01278                 deviceEndMargin = newDeviceEnd_pixels;
01279         }
01280 
01281         /*
01282         * Gets the last clickedX pixel coord inside the bar with respect to the container panel.
01283         * return clickedX The x-coord pixel value
01284         */
01285         int mBarRange :: getClickedX()
01286         {
01287                 return clickedX;
01288         }
01289 
01290         /*
01291         * Sets the last clickedX pixel coord inside the bar with respect to the container panel.
01292         * param nwClickX The x-coord pixel value
01293         */
01294         void mBarRange :: setClickedX(int nwClickX)
01295         {
01296                 clickedX = nwClickX;
01297         }
01298 
01299 
01300                 /*
01301         * Gets the start porcentage with respect to the represented values of the bar
01302         * return The porcentage represented by the start  showing point
01303         */
01304         float mBarRange :: getStartShowPorcentage()
01305         {
01306                 return (float)( 1+(_start - _max)/(_max-_min));
01307         }
01308 
01309         /*
01310         * Gets the end porcentage with respect to the represented values of the bar
01311         * return The porcentage represented by the end showing point
01312         */
01313         float mBarRange :: getEndShowPorcentage()
01314         {
01315                 return (float) (1+(_end - _max)/(_max-_min));
01316         }
01317 
01318         /*
01319         * Gets the actual porcentage with respect to the represented values of the bar
01320         * return The porcentage represented by the actual  showing point
01321         */
01322         float mBarRange :: getActualShowPorcentage()
01323         {
01324                 return (float) (1+(_actual - _max)/(_max-_min));
01325         }
01326 
01327         int mBarRange :: getLogicValueofPixel(int thePixel)
01328         {
01329                 return _min+((thePixel - deviceStart_x)*( _max - _min))/(_w-deviceEndMargin);
01330         }
01331 
01332         /*
01333         * Sets the condition for knowing if the actual triangle is being drawed or not
01334         * param drawActual The condition to set for drawing or not the actual control (true for drawing)
01335         */
01336         void mBarRange :: setIfWithActualDrawed(bool drawActual)
01337         {
01338                 if(!withActualDrawed && drawActual)
01339                 {       
01340                         b_popmenu.Append (cntID_ENABLE_ACTUAL, _("Enable actual in range"), _("Enables/Disables the actual triangle to be or not in range"));
01341                         b_popmenu.Append (cntID_MOVABLE_ACTUAL_BAR, _("Move actual-bar simultaneously"), _("Disables the actual triangle to move with the bar"));               
01342                 }
01343                 else if (withActualDrawed && !drawActual)
01344                 {
01345                         b_popmenu.Remove(cntID_ENABLE_ACTUAL);
01346                         b_popmenu.Remove(cntID_MOVABLE_ACTUAL_BAR);
01347                 }
01348                 withActualDrawed = drawActual;
01349                 Refresh();      
01350         }
01351 
01352         /*
01353         * Gets the condition for knowing if the actual triangle is being drawed or not
01354         * return withActualDrawed The condition for drawing or not the actual control
01355         */
01356         bool mBarRange :: getIfWithActualDrawed()
01357         {
01358                 return withActualDrawed;
01359         }
01360 
01361         void mBarRange::createAndSendEvent(WXTYPE theEventType)
01362         {
01363                 wxCommandEvent cevent( theEventType, GetId() );
01364                 cevent.SetEventObject( this );
01365                 GetEventHandler()->ProcessEvent( cevent );
01366         }
01367 
01368         /*
01369         * Sets the background color od the bar
01370         * theColor The color to set to the backgroundColor
01371         */
01372         void mBarRange :: setBackgroundColor(wxColour theColor)
01373         {
01374                 backgroundColor = theColor;
01375         }
01376 
01377         /*
01378         * Sets the guide line color
01379         * param theNwGuideLineColor The color to set to the guideLineColor
01380         */
01381         void mBarRange :: setGuideLineColour(wxColour theNwGuideLineColor)
01382         {
01383                 guideLineColor = theNwGuideLineColor;
01384         }
01385 
01386         /*
01387         * Gets the guide line color
01388         * return guideLineColor The color of the guideLine
01389         */
01390         wxColour mBarRange :: getGuideLineColour()
01391         {
01392                 return guideLineColor;
01393         }
01394 
01395         void  mBarRange ::onLeftClicDown(wxMouseEvent& event )
01396         {
01397                 acceptedClick = true;           
01398         }
01399 
01400         void  mBarRange ::onLeftClickUp(wxMouseEvent& event )
01401         {       
01402                 acceptedClick = false;
01403         }
01404 
01405 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1