Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

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