CSC112 Spring 2016 Examples
// Functions for the widget class.1// Revision: $Revision: 1.1 $2// Change Log3// $Log: widget.cpp,v $4// Revision 1.1 2016/03/17 16:02:36 pngwen5// Initial revision6//78#include "widget.h"9#include "termmanip.h"10#include <iostream>1112using namespace std;1314Widget::Widget(int _x, int _y, int _width, int _height)15{16this->_x = _x;17this->_y = _y;18this->_width = _width;19this->_height = _height;20}212223Widget::Widget()24{25this->_x = 0;26this->_y = 0;27this->_width = 0;28this->_height = 0;29}303132void33Widget::clear()34{35//paint over the widget36for(int i=0; i<_height; i++) {37cout << cursorPosition(_x, _y+i);38for(int j=0; j<_width; j++) {39cout << ' ';40}41}4243cout.flush();44}4546int47Widget::x()48{49return _x;50}515253void54Widget::x(int _x)55{56this->_x = _x;57}585960int61Widget::y()62{63return _y;64}656667void68Widget::y(int _y)69{70this->_y = _y;71}727374int75Widget::width()76{77return _width;78}798081void82Widget::width(int _width)83{84this->_width = _width;85}868788int89Widget::height()90{91return _height;92}939495void96Widget::height(int _height)97{98this->_height = _height;99}100101102103