Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2370 views
1
#include "Widget.h"
2
#include "termmanip.h"
3
#include <iostream>
4
5
using namespace std;
6
7
Widget::Widget(int _x, int _y, int _width, int _height)
8
{
9
this->_x = _x;
10
this->_y = _y;
11
this->_width = _width;
12
this->_height = _height;
13
}
14
15
16
Widget::Widget()
17
{
18
this->_x = 0;
19
this->_y = 0;
20
this->_width = 0;
21
this->_height = 0;
22
}
23
24
25
void
26
Widget::clear()
27
{
28
//paint over the widget
29
for(int i=0; i<_height; i++) {
30
cout << cursorPosition(_x, _y+i);
31
for(int j=0; j<_width; j++) {
32
cout << ' ';
33
}
34
}
35
36
cout.flush();
37
}
38
39
int
40
Widget::x()
41
{
42
return _x;
43
}
44
45
46
void
47
Widget::x(int _x)
48
{
49
this->_x = _x;
50
}
51
52
53
int
54
Widget::y()
55
{
56
return _y;
57
}
58
59
60
void
61
Widget::y(int _y)
62
{
63
this->_y = _y;
64
}
65
66
67
int
68
Widget::width()
69
{
70
return _width;
71
}
72
73
74
void
75
Widget::width(int _width)
76
{
77
this->_width = _width;
78
}
79
80
81
int
82
Widget::height()
83
{
84
return _height;
85
}
86
87
88
void
89
Widget::height(int _height)
90
{
91
this->_height = _height;
92
}
93
94
95