Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2370 views
head	1.1;
access;
symbols;
locks; strict;
comment	@// @;


1.1
date	2016.03.17.16.02.36;	author pngwen;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@// Functions for the widget class.
// Revision: $Revision$
// Change Log
//   $Log$

#include "widget.h"
#include "termmanip.h"
#include <iostream>

using namespace std;

Widget::Widget(int _x, int _y, int _width, int _height)
{
  this->_x = _x;
  this->_y = _y;
  this->_width = _width;
  this->_height = _height;
}


Widget::Widget()
{
  this->_x = 0;
  this->_y = 0;
  this->_width = 0;
  this->_height = 0;
}


void
Widget::clear()
{
  //paint over the widget
  for(int i=0; i<_height; i++) {
    cout << cursorPosition(_x, _y+i);
    for(int j=0; j<_width; j++) {
      cout << ' ';
    }
  }

  cout.flush();
}

int
Widget::x()
{
  return _x;
}


void
Widget::x(int _x)
{
  this->_x = _x;
}


int
Widget::y()
{
  return _y;
}


void
Widget::y(int _y)
{
  this->_y = _y;
}


int
Widget::width()
{
  return _width;
}


void
Widget::width(int _width)
{
  this->_width = _width;
}


int
Widget::height()
{
  return _height;
}


void
Widget::height(int _height)
{
  this->_height = _height;
}

@