DrawBorder.cxx
Go to the documentation of this file.
1 
12 // for truncation warning
13 #ifdef _MSC_VER
14 #include "msdevstudio/MSconfig.h"
15 #endif
16 
17 #include "DrawBorder.h"
18 
19 #include "graphics/Color.h"
20 #include "graphics/ViewBase.h"
21 
22 #include <vector>
23 
24 using std::vector;
25 
26 using namespace hippodraw;
27 
29 
31 {
32 }
33 
35 {
36  // Left empty to avoid copying.
37 }
38 
40 {
41  if ( s_instance == 0 ) {
42  s_instance = new DrawBorder ();
43  }
44  return s_instance;
45 }
46 
48 {
49  m_view = view;
50 }
51 
53 {
54  return m_view;
55 }
56 
58 {
59 
60  Rect rect = m_view->getDrawRect();
61  double width = rect.getWidth();
62  double height = rect.getHeight();
63 
64  width = width - 2;
65  height = height - 2;
66 
67  vector <double> vx (8);
68  vector <double> vy (8);
69 
70  vx [0] = 2;
71  vy [0] = 2;
72  vx [1] = width;
73  vy [1] = 2;
74 
75  vx [2] = width;
76  vy [2] = 2;
77  vx [3] = width;
78  vy [3] = height;
79 
80  vx [4] = width;
81  vy [4] = height;
82  vx [5] = 2;
83  vy [5] = height;
84 
85  vx [6] = 2;
86  vy [6] = height;
87  vx [7] = 2;
88  vy [7] = 2;
89 
90  m_view->drawViewLines ( vx, vy, Line::Solid, Color(180, 180, 180), 0 );
91 
92  // Now draw the knobs.
93 
94  drawKnob ( 2, 2); //Upper Right.
95  drawKnob ( width / 2, 2); //Upper Middle.
96  drawKnob ( width, 2); //Upper Left.
97 
98  drawKnob ( 2, height / 2); //Middle Left.
99  drawKnob ( width, height / 2); //Middle Right.
100 
101  drawKnob ( 2, height); //Lower left.
102  drawKnob ( width / 2, height); //Lower middle.
103  drawKnob ( width, height); //Lower right.
104 
105 }
106 
107 void DrawBorder::drawKnob( double x, double y)
108 {
109 
110  int size = 2;
111 
112  vector <double> vx (8);
113  vector <double> vy (8);
114 
115  vx [0] = x-size;
116  vy [0] = y-size;
117  vx [1] = x+size;
118  vy [1] = y-size;
119 
120  vx [2] = x+size;
121  vy [2] = y-size;
122  vx [3] = x+size;
123  vy [3] = y+size;
124 
125  vx [4] = x+size;
126  vy [4] = y+size;
127  vx [5] = x-size;
128  vy [5] = y+size;
129 
130  vx [6] = x-size;
131  vy [6] = y+size;
132  vx [7] = x-size;
133  vy [7] = y-size;
134 
135  m_view->drawViewLines ( vx, vy, Line::Solid, Color(180, 180, 180), 0 );
136 }

Generated for HippoDraw Class Library by doxygen