Difference between revisions of "Console UI Core Classes - OOP344 20111"

From CDOT Wiki
Jump to: navigation, search
(CFrame)
(CFrame)
Line 104: Line 104:
 
=Basic (BIO) Encapsulating Classes=
 
=Basic (BIO) Encapsulating Classes=
 
==CFrame==
 
==CFrame==
 +
The code for this class is provided. You must understand and use it to develop your core classes.
 
<big><syntaxhighlight lang="cpp">
 
<big><syntaxhighlight lang="cpp">
 
#pragma once
 
#pragma once
Line 117: Line 118:
 
   CFrame* _frame;
 
   CFrame* _frame;
 
   char* _covered;
 
   char* _covered;
  void setLine(char* line, char left, char fill, char right)const;
 
 
   void capture();
 
   void capture();
 
protected:
 
protected:
Line 157: Line 157:
 
};
 
};
 
</syntaxhighlight></big>
 
</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 hides itself, it simple copies the content of this array back on the screen on its own coordinates.
 +
===Methods and Constructors===

Revision as of 07:08, 8 March 2011


OOP344 | Weekly Schedule | Student List | Teams | Project | Student Resources
Under Construction!

Before anything, go to your repository/branches/fardad/bio_additions and open bio.c and bio.h, then copy and apply the additional functions and changes to your own bio.c and bio.h in trunk. Make sure it compiles and runs properly. These changes add buffering support to be able to prevent flickering. The functionalities added will not change the console behavior or the bio functions. After applying the changes, everything should work they way they worked before.

Your objective at this stage is to create series of core classes designed to interact with the user. These Core Classes then can be used in development of any interactive application.

Please note that the class definitions here are minimum requirement for the Core Classes and you are free to add any enhancements or features you find useful. However make sure that you discuss these enhancements with your professor to make sure they are feasible before implementation.

It is highly recommended to develop the classes in the order they are stated here. You must create your won tester programs fore each class (if possible); However, close to due date of each release, a tester program is provided to help you verify the functionality of your classes. Executables of the test programs are available on matrix to show you how it is supposed to run.

Start by creating mock-up classes (class declaration and definition with empty methods that only compiles and don't do anything). Each class MUST have its own header file to hold its declaration and "cpp" file to hold its implementation. To make sure you do not do circular includes follow these simple guidelines:

  • Add recompilation safeguards to all your header files.
  • Always use forward declaration if possible instead of including a class header-file.
  • Use includes only in files in which the actual header file code is used.
  • Avoid "just in case" includes.

General Internal Header file (ccgh.h R0.1)

The general header file holds the common setting and definition between all the Core Classes.

#ifndef ___CGH_H__
#define ___CGH_H__
 
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
 
#define C_MAX_NO_FIELDS 100
#define C_BUTTON_HIT 1
#define C_MAX_LINE_CHARS  (1024u)

#define C_FULL_FRAME -1
#define C_NO_FRAME 0

#define C_BORDER_CHARS  "/-\\|/-\\|"
enum CDirection {bio_centre, bio_left, bio_right, bio_up, bio_down};

extern "C"{
#include "bio.h"
};

enum MessageStatus{ClearMessage,SetMessage};


#ifdef NO_HELPFUNC
# undef NO_HELPFUNC
#endif
#define NO_HELPFUNC ((void(*)(MessageStatus, CDialog&))(0))
#ifdef NO_VALDFUNC
# undef NO_VALDFUNC
#endif
#define NO_VALDFUNC ((bool(*)(const char*, CDialog&))(0))


#define C_MAX_LINE_CHARS  (1024u)
#define C_INITIAL_NUM_OF_LINES (100u)

#endif

File Names

Use the following rules to create filenames for your class.

  • Each class MUST have its own header file and cpp file for implementation
  • Use the class name for the name of the file but make sure it is all lowercase.
    For example CFrame class should have cframe.h and cframe.cpp files for its implementation.

Hierarchy

CFrame
 |
 |---CDialog
 |
 |
 |---CField
       |
       |-------- CLabel
       |
       |
       |-------- CButton
       |
       |
       |-------- CLineEdit
       |         |
       |         |-------CValEdit
       |
       |-------- CText
       |
       |
       |-------- CCheck
       |
       |
       |-------- CCheckList
       |
       |
       |-------- CCMenuItem 
       |
       |
       |-------- CCMenu 

Basic (BIO) Encapsulating Classes

CFrame

The code for this class is provided. You must understand and use it to develop your core classes.

#pragma once
#include "cgh.h"

class CFrame{
  int _row;
  int _col;
  int _height;
  int _width;
  char _border[9];
  bool _visible;
  CFrame* _frame;
  char* _covered;
  void capture();
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 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;
};

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 hides itself, it simple copies the content of this array back on the screen on its own coordinates.

Methods and Constructors