21
edits
Changes
Created page with ''''Under Construction''' =CFrame= The code for this class is provided the repository of your team. You must understand and use it to develop your core classes in your repository.…'
'''Under Construction'''
=CFrame=
The code for this class is provided the repository of your team. You must understand and use it to develop your core classes in your repository.
CFrame class is responsible to create a frame or structure in which all user interface classes contain themselves. It can draw a border around it self or be border-less.
CFrame also, before displaying itself on the screen, will save the area it is about to cover, so it can re-display them to hide itself.
CFrame is base of all objects in our user interface system.
<big><syntaxhighlight lang="cpp">
/*
Add your names under fardad's name:
Reviewed by: (Team member names and date of review)
Full Name, Github id, date
Fardad Soleimanloo, fardad, Oct 03 2013 - 22:34
*/
#include "ciogh.h"
namespace cio{
class CFrame{
int _row;
int _col;
int _height;
int _width;
char _border[9];
bool _visible;
CFrame* _frame;
char* _covered;
void setLine(char* line, char left, char fill, char right)const;
void capture();
void free();
protected:
int absRow()const;
int absCol()const;
public:
CFrame(int Row=-1, int Col=-1, int Width=-1,int Height=-1,
bool Visible = false,
const char* Border=C_BORDER_CHARS,
CFrame* Frame = (CFrame*)0);
virtual void draw(int fn=C_FULL_FRAME);
virtual void move(CDirection dir);
virtual void move();
virtual void hide();
virtual ~CFrame();
/* setters and getters: */
bool fullscreen()const;
void visible(bool val);
bool visible()const;
void frame(CFrame* theContainer);
CFrame* frame();
void row(int val);
int row()const;
void col(int val);
int col()const;
void height(int val);
int height()const;
void width(int val);
int width()const;
void refresh();
};
}
</syntaxhighlight></big>
==Properties==
int _row, holds the relative coordinate of top row of this border with respect to its container.<br />
int _col, same as _row, but for _col. <br />
int _height, height of the entity. <br />
int _width, width of the entity. <br />
char _border[9], characters used to draw the border: <br />
: _border[0], left top
: _border[1], top side
: _border[2], right top
: _border[3], right side
: _border[4], right bottom
: _border[5], bottom side
: _border[6], bottom left
: _border[7], left side
bool _visible; Indicates if the border surrounding the entity is to be drawn or not. <br />
CFrame* _frame; holds the container (another CFrame) which has opened this one (owner or container of the current CFrame). '''_frame''' will be NULL if this CFrame does not have a container, in which case, it will be full screen and no matter what the values of row, col, width and height are, CFrame will be '''Full Screen''' (no border will be drawn)<br />
char* _covered; is a pointer to a character array that hold what was under this frame before being drawn. When the CFrame wants to hide itself, it simple copies the content of this array back on the screen on its own coordinates.
==Methods and Constructors==
===Private Methods===
<big><syntaxhighlight lang="cpp">
void capture();
</syntaxhighlight></big>
:if _covered pointer is not pointing to any allocated memory, it will call the iol_capture function to capture the area that is going to be covered by this frame and keeps its address in _covered.
===Protected Methods===
*int absRow()const; calculates the absolute row (relative to the left top corner of the screen) and returns it.
*:it returns the sum of '''row()''' of this border plus all the '''row()'''s of the '''_frame'''s
*int absCol()const; calculates the absolute column(relative to the left top corner of the screen) and returns it.
*:it returns the sum of '''col()''' of this border plus all the '''col()'''s of the '''_frame'''s
===Public Methods===
<big><syntaxhighlight lang="cpp">
CFrame(int Row=-1, int Col=-1, int Width=-1,int Height=-1,
bool Visible = false,
const char* Border=C_BORDER_CHARS,
CFrame* Frame = (CFrame*)0);
</syntaxhighlight></big>
:Sets the corresponding attributes to the incoming values in the argument list and set _covered to null
<big><syntaxhighlight lang="cpp">
virtual void draw(int fn=C_FULL_FRAME);
</syntaxhighlight></big>
* First it will '''capture()''' the coordinates it is supposed to cover
* If frame is '''fullscreen()''' then it just clears the screen and exits. <br />
Otherwise:<br />
*If the _visible flag is true, it will draw a box at _row and _col, with size of _width and _height using the _border characters and fills it with spaces. Otherwise it will just draw a box using spaces at the same location and same size.
<big><syntaxhighlight lang="cpp">
virtual void move(CDirection dir);
</syntaxhighlight></big>
First it will hide the Frame, then adjust the row and col to move to the "dir" direction and then draws the Frame back on screen.
<big><syntaxhighlight lang="cpp">
virtual void hide();
</syntaxhighlight></big>
using iol_restore()it restores the characters behind the Frame back on screen. It will also free the memory pointed by _covered;
<big><syntaxhighlight lang="cpp">
virtual ~CFrame();
</syntaxhighlight></big>
It will make sure allocated memories are freed.
<big><syntaxhighlight lang="cpp">
bool fullscreen()const;
void visible(bool val);
bool visible()const;
void frame(CFrame* theContainer);
CFrame* frame();
void row(int val);
int row()const;
void col(int val);
int col()const;
void height(int val);
int height()const;
void width(int val);
int width()const;
</syntaxhighlight></big>
These functions set and get the attributes of the CFrame.
==CFrame Student Resources==
===CFrame Help/Questions Blogs===
===CFrame Blog Posts===
=To Do=
No coding is involved in this release.
==task==
All team members must clone the repository and test the execution of CFrame:
# Branch the master for your review with a propoer name.
# Compile, run and test the execution
# Add your name, github id and date and time to the top of '''cframe.h''' header file.
# Merge the branch back into the master branch.
# Push the changes to github
==Due Date==
TBA
=Tester Program=
Test1Frame.cpp (is located in the repository)
=CFrame=
The code for this class is provided the repository of your team. You must understand and use it to develop your core classes in your repository.
CFrame class is responsible to create a frame or structure in which all user interface classes contain themselves. It can draw a border around it self or be border-less.
CFrame also, before displaying itself on the screen, will save the area it is about to cover, so it can re-display them to hide itself.
CFrame is base of all objects in our user interface system.
<big><syntaxhighlight lang="cpp">
/*
Add your names under fardad's name:
Reviewed by: (Team member names and date of review)
Full Name, Github id, date
Fardad Soleimanloo, fardad, Oct 03 2013 - 22:34
*/
#include "ciogh.h"
namespace cio{
class CFrame{
int _row;
int _col;
int _height;
int _width;
char _border[9];
bool _visible;
CFrame* _frame;
char* _covered;
void setLine(char* line, char left, char fill, char right)const;
void capture();
void free();
protected:
int absRow()const;
int absCol()const;
public:
CFrame(int Row=-1, int Col=-1, int Width=-1,int Height=-1,
bool Visible = false,
const char* Border=C_BORDER_CHARS,
CFrame* Frame = (CFrame*)0);
virtual void draw(int fn=C_FULL_FRAME);
virtual void move(CDirection dir);
virtual void move();
virtual void hide();
virtual ~CFrame();
/* setters and getters: */
bool fullscreen()const;
void visible(bool val);
bool visible()const;
void frame(CFrame* theContainer);
CFrame* frame();
void row(int val);
int row()const;
void col(int val);
int col()const;
void height(int val);
int height()const;
void width(int val);
int width()const;
void refresh();
};
}
</syntaxhighlight></big>
==Properties==
int _row, holds the relative coordinate of top row of this border with respect to its container.<br />
int _col, same as _row, but for _col. <br />
int _height, height of the entity. <br />
int _width, width of the entity. <br />
char _border[9], characters used to draw the border: <br />
: _border[0], left top
: _border[1], top side
: _border[2], right top
: _border[3], right side
: _border[4], right bottom
: _border[5], bottom side
: _border[6], bottom left
: _border[7], left side
bool _visible; Indicates if the border surrounding the entity is to be drawn or not. <br />
CFrame* _frame; holds the container (another CFrame) which has opened this one (owner or container of the current CFrame). '''_frame''' will be NULL if this CFrame does not have a container, in which case, it will be full screen and no matter what the values of row, col, width and height are, CFrame will be '''Full Screen''' (no border will be drawn)<br />
char* _covered; is a pointer to a character array that hold what was under this frame before being drawn. When the CFrame wants to hide itself, it simple copies the content of this array back on the screen on its own coordinates.
==Methods and Constructors==
===Private Methods===
<big><syntaxhighlight lang="cpp">
void capture();
</syntaxhighlight></big>
:if _covered pointer is not pointing to any allocated memory, it will call the iol_capture function to capture the area that is going to be covered by this frame and keeps its address in _covered.
===Protected Methods===
*int absRow()const; calculates the absolute row (relative to the left top corner of the screen) and returns it.
*:it returns the sum of '''row()''' of this border plus all the '''row()'''s of the '''_frame'''s
*int absCol()const; calculates the absolute column(relative to the left top corner of the screen) and returns it.
*:it returns the sum of '''col()''' of this border plus all the '''col()'''s of the '''_frame'''s
===Public Methods===
<big><syntaxhighlight lang="cpp">
CFrame(int Row=-1, int Col=-1, int Width=-1,int Height=-1,
bool Visible = false,
const char* Border=C_BORDER_CHARS,
CFrame* Frame = (CFrame*)0);
</syntaxhighlight></big>
:Sets the corresponding attributes to the incoming values in the argument list and set _covered to null
<big><syntaxhighlight lang="cpp">
virtual void draw(int fn=C_FULL_FRAME);
</syntaxhighlight></big>
* First it will '''capture()''' the coordinates it is supposed to cover
* If frame is '''fullscreen()''' then it just clears the screen and exits. <br />
Otherwise:<br />
*If the _visible flag is true, it will draw a box at _row and _col, with size of _width and _height using the _border characters and fills it with spaces. Otherwise it will just draw a box using spaces at the same location and same size.
<big><syntaxhighlight lang="cpp">
virtual void move(CDirection dir);
</syntaxhighlight></big>
First it will hide the Frame, then adjust the row and col to move to the "dir" direction and then draws the Frame back on screen.
<big><syntaxhighlight lang="cpp">
virtual void hide();
</syntaxhighlight></big>
using iol_restore()it restores the characters behind the Frame back on screen. It will also free the memory pointed by _covered;
<big><syntaxhighlight lang="cpp">
virtual ~CFrame();
</syntaxhighlight></big>
It will make sure allocated memories are freed.
<big><syntaxhighlight lang="cpp">
bool fullscreen()const;
void visible(bool val);
bool visible()const;
void frame(CFrame* theContainer);
CFrame* frame();
void row(int val);
int row()const;
void col(int val);
int col()const;
void height(int val);
int height()const;
void width(int val);
int width()const;
</syntaxhighlight></big>
These functions set and get the attributes of the CFrame.
==CFrame Student Resources==
===CFrame Help/Questions Blogs===
===CFrame Blog Posts===
=To Do=
No coding is involved in this release.
==task==
All team members must clone the repository and test the execution of CFrame:
# Branch the master for your review with a propoer name.
# Compile, run and test the execution
# Add your name, github id and date and time to the top of '''cframe.h''' header file.
# Merge the branch back into the master branch.
# Push the changes to github
==Due Date==
TBA
=Tester Program=
Test1Frame.cpp (is located in the repository)