Difference between revisions of "CIO 20133 Release 0.2 - OOP344"

From CDOT Wiki
Jump to: navigation, search
(Due Date)
(Tester Program)
Line 176: Line 176:
  
 
=Tester Program=
 
=Tester Program=
Test1Frame.cpp (is located in the repository)
+
Test1Frame.cpp (is in your team's repository)

Revision as of 08:17, 15 October 2013


OOP344 | Weekly Schedule | Student List | Teams | Project | Student Resources
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 the base of all the classes in our user interface system.

/* 
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();
  };

}

Properties

int _row, holds the relative coordinate of top row of this border with respect to its container.
int _col, same as _row, but for _col.
int _height, height of the entity.
int _width, width of the entity.
char _border[9], characters used to draw the border:

_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.
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)
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

void capture();
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 _frames
  • 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 _frames

Public Methods

  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);
Sets the corresponding attributes to the incoming values in the argument list and set _covered to null
  virtual void draw(int fn=C_FULL_FRAME);
  • First it will capture() the coordinates it is supposed to cover
  • If frame is fullscreen() then it just clears the screen and exits.

Otherwise:

  • 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.


  virtual void move(CDirection dir);

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.

  virtual void hide();

using iol_restore()it restores the characters behind the Frame back on screen. It will also free the memory pointed by _covered;

  virtual ~CFrame();

It will make sure allocated memories are freed.

  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;

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

  1. Select one of the team member's console.cpp and console.h
    That team member should branch and clone the repository, add console.cpp and console.h to the files in the repository, compile, run and test the execution. When done this team member should add her/his name, github id and the date and time of the completion (as a comment) to cframe.h and merge the branch back to the master repo and push the changes up to github.
  2. All other team members must clone the repository and test the execution of CFrame:
    1. Branch the master for review with a proper name.
    2. Compile, run and test the execution.
    3. Add a comment with your, github id and date and time to the top of cframe.h header file.
    4. Merge the branch back into the master branch.
    5. Push the changes to github.

Due Date

All branches must be merged back to master by Sunday Oct 20th, 23:59 and master repository should be fully compiled and the execution tested.

Tester Program

Test1Frame.cpp (is in your team's repository)