Changes

Jump to: navigation, search

Console UI Core Classes - OOP344 20112

2,320 bytes added, 10:21, 20 July 2011
no edit summary
These functions set and get the attributes of the CFrame.
==CField==
The code for this class is provided. You must understand and use it to develop your core classes.
 
CField is an abstract base class that encapsulates the commonalities of all Input Outputs Console Fields which are placeable on a CDialog. All Fields could be Framed, therefore a CField is int
<big><syntaxhighlight lang="cpp">
#include "cframe.h"
class CDialog;
class CField : public CFrame{
protected:
void* _data;
public:
CField(int Row = 0, int Col = 0,
int Width = 0, int Height =0,
void* Data = (void*) 0,
bool Bordered = false,
const char* Border=C_BORDER_CHARS);
~CField();
virtual int edit() = 0;
virtual bool editable() const = 0;
virtual void set(const void* data) = 0;
virtual void* data();
void container(CDialog* theContainer);
CDialog* container();
};
</syntaxhighlight></big>
===Attributes===
<big><syntaxhighlight lang="cpp">
void* _data;
</syntaxhighlight></big>
Will hold the address of any type of data a CField can hold.
===Constructors and Methods===
<big><syntaxhighlight lang="cpp">
CField(int Row = 0, int Col = 0,
int Width = 0, int Height =0,
void* Data = (void*) 0,
bool Bordered = false,
const char* Border=C_BORDER_CHARS);
</syntaxhighlight></big>
Passes the corresponding attributes to it's parents constructor and then sets the _data attribute to the incoming Data argument.
<big><syntaxhighlight lang="cpp">
~CField();
</syntaxhighlight></big>
Empty Destructor
<big><syntaxhighlight lang="cpp">
virtual int edit() = 0;
virtual bool editable() const = 0;
virtual void set(const void* data) = 0;
</syntaxhighlight></big>
Enforce the children to implement;
* an edit() method
* an editable() method that returns true if the class is to edit data and false if the class is to only display data.
* a set() method to set the _data attribute to the data the class is to work with.
<big><syntaxhighlight lang="cpp">
virtual void* data();
</syntaxhighlight></big>
Returns _data.
<big><syntaxhighlight lang="cpp">
void container(CDialog* theContainer);
CDialog* container();
</syntaxhighlight></big>
Sets and Gets the _frame attribute of CFrame by calling CFrame::frame() method. Make sure to cast The CDialog to CFrame when setting and cast CFrame to CDialog when getting!

Navigation menu