DrawBorder.cxx

Go to the documentation of this file.
00001 
00012 // for truncation warning
00013 #ifdef _MSC_VER
00014 #include "msdevstudio/MSconfig.h"
00015 #endif
00016 
00017 #include "DrawBorder.h"
00018 
00019 #include "graphics/Color.h"
00020 #include "graphics/ViewBase.h"
00021 
00022 #include <vector>
00023 
00024 using std::vector;
00025 
00026 using namespace hippodraw;
00027 
00028 DrawBorder * DrawBorder::s_instance = 0;
00029 
00030 DrawBorder::DrawBorder ()
00031 {
00032 }
00033 
00034 DrawBorder::DrawBorder ( const DrawBorder & )
00035 {
00036   // Left empty to avoid copying.
00037 }
00038 
00039 DrawBorder * DrawBorder::instance ()
00040 {
00041   if ( s_instance == 0 ) {
00042     s_instance = new DrawBorder ();
00043   }
00044   return s_instance;
00045 }
00046 
00047 void DrawBorder::setView (ViewBase * view)
00048 {
00049   m_view = view;
00050 }
00051 
00052 ViewBase * DrawBorder::getView ()
00053 {
00054   return m_view;
00055 }
00056 
00057 void DrawBorder::draw()
00058 {
00059 
00060   Rect rect = m_view->getDrawRect();
00061   double width = rect.getWidth();
00062   double height = rect.getHeight();
00063 
00064   width = width - 2;
00065   height = height - 2;
00066 
00067   vector <double> vx (8);
00068   vector <double> vy (8);
00069 
00070   vx [0] = 2;
00071   vy [0] = 2;
00072   vx [1] = width;
00073   vy [1] = 2;
00074 
00075   vx [2] = width;
00076   vy [2] = 2;
00077   vx [3] = width;
00078   vy [3] = height;
00079 
00080   vx [4] = width;
00081   vy [4] = height;
00082   vx [5] = 2;
00083   vy [5] = height;
00084 
00085   vx [6] = 2;
00086   vy [6] = height;
00087   vx [7] = 2;
00088   vy [7] = 2;
00089 
00090   m_view->drawViewLines ( vx, vy, Line::Solid, Color(180, 180, 180), 0 );
00091 
00092   // Now draw the knobs.
00093 
00094   drawKnob ( 2, 2);                 //Upper Right.
00095   drawKnob ( width / 2, 2);         //Upper Middle.
00096   drawKnob ( width, 2);             //Upper Left.
00097 
00098   drawKnob ( 2, height / 2);        //Middle Left.
00099   drawKnob ( width, height / 2);    //Middle Right.
00100 
00101   drawKnob ( 2, height);            //Lower left.
00102   drawKnob ( width / 2, height);    //Lower middle.
00103   drawKnob ( width, height);        //Lower right.
00104 
00105 }
00106 
00107 void DrawBorder::drawKnob( double x, double y)
00108 {
00109 
00110   int size = 2;
00111 
00112   vector <double> vx (8);
00113   vector <double> vy (8);
00114 
00115   vx [0] = x-size;
00116   vy [0] = y-size;
00117   vx [1] = x+size;
00118   vy [1] = y-size;
00119 
00120   vx [2] = x+size;
00121   vy [2] = y-size;
00122   vx [3] = x+size;
00123   vy [3] = y+size;
00124 
00125   vx [4] = x+size;
00126   vy [4] = y+size;
00127   vx [5] = x-size;
00128   vy [5] = y+size;
00129 
00130   vx [6] = x-size;
00131   vy [6] = y+size;
00132   vx [7] = x-size;
00133   vy [7] = y-size;
00134 
00135   m_view->drawViewLines ( vx, vy, Line::Solid, Color(180, 180, 180), 0 );
00136 }

Generated for HippoDraw Class Library by doxygen