Changes

Jump to: navigation, search

OOP344 Assignment Two

668 bytes added, 16:06, 19 December 2009
IO_Form
==IO_Form==
'''[[#IO_Frame| IO_Frame]]''' is inherited into a container class called '''IO_Form'''. '''IO_Form''' organizes the '''[[#IO_Field | IO_Field]]''' classes and give the user a panel to use them sequentially.
'''IO_Form''' should be able to hold unlimited number of '''[[#IO_Field | IO_Fields]]'''. (Use either a dynamic array, or linked list structure of '''[[#IO_Field | IO_Fields]]''' to implement this)
<hr width="50%" />
===Constructor===
int add(IO_Field* f, bool dynamic, bool submitter);
</pre></big>
'''IO_Form''' uses this private '''add''' method to provide means of adding fields through several public add methods. this method adds an '''[[#IO_Field | IO_Field]]''' to the end of the '''[[#IO_Field | IO_Fields ]]''' in the IO_Form;
*'''f''' : is Is the address of the '''[[#IO_Field | IO_Field]]''' begin added to the '''IO_Form'''*'''dynamic''' : if If set to true, it sets this '''[[#IO_Field | IO_Field]]''' to be deallocated by '''IO_Form''''s destructor at the end;*'''submitter''': if If set to true, it tags this '''[[#IO_Field | IO_Field]]''' to terminate the '''IO_Form''''s edit() if ENTER_KEY is hit. see the edit() method for more info.
'''add()''' also calls '''set(IO_Form* owner)''' of '''[[#IO_Field | IO_Field]]''' and passes its pointer ''(this)'' to it. By doing this, each '''[[#IO_Field | IO_Field]]''' will know who is its owner.
'''add()''' returns the number of fields currently in IO_FORM.
<hr width="50%" />
int add(IO_Field* f, bool submitter = false);
</pre></big>
Uses the private add() method to add a dynamic IO_field'''[[#IO_Field | IO_Field]]'''.
<hr width="50%" />
<big><pre>
int add(IO_Field& f, bool submitter = false);
</pre></big>
Uses the private add() method to add a non-dynamic IO_field'''[[#IO_Field | IO_Field]]'''.
<hr width="50%" />
<big><pre>
int addHelp(IO_Label* L);
</pre></big>
Uses the private add() method to add a dynamic IO_field '''[[#IO_Field | IO_Field]]''' and also saves its address for the general help message label of the Form.
<hr width="50%" />
<big><pre>
int addHelp(IO_Label& L);
</pre></big>
Uses the private add() method to add a non-dynamic IO_field '''[[#IO_Field | IO_Field]]''' and also saves its address for the general help message label of the Form.
<hr width="50%" />
<big><pre>
int addError(IO_Label* L);
</pre></big>
Uses the private add() method to add a dynamic IO_field '''[[#IO_Field | IO_Field]]''' and also saves its address for the general error message label of the Form.
<hr width="50%" />
<big><pre>
int addError(IO_Label& L);
</pre></big>
Uses the private add() method to add a non-dynamic IO_field '''[[#IO_Field | IO_Field]]''' and also saves its address for the general error message label of the Form.
<hr width="50%" />
<big><pre>
</pre></big>
Uses the private add() method to add a non-submitter, dynamic IO_field'''[[#IO_Field | IO_Field]]'''.
<hr width="50%" />
<big><pre>
IO_Form& operator<<(IO_Field& f);
</pre></big>
Uses the private add() method to add a non-submitter, non-dynamic IO_field'''[[#IO_Field | IO_Field]]'''.
<hr width="50%" />
void* data(unsigned int fieldnumber=0);
</pre></big>
Returns address of the data of "fieldnumber"th, '''[[#IO_Field | IO_Field]]''' in the IO_Form. If "fieldnumber" is zero, then it returns the data of the current '''[[#IO_Field | IO_Field]]'''.
====The index operator====
IO_Field& operator[](unsigned int index);
</pre></big>
Returns the reference of the '''[[#IO_Field| IO_Field]]''', number "fieldnumber-1". First Field has the index 0;
<hr width="50%" />
</pre></big>
If neither of the '''[[#IO_Field | IO_Fields]]''' is editable, it displays all the '''[[#IO_Field | IO_Fields]]''', then waits for a key entry and then ends the function by returning the key entered.
If the fieldnumber pointer is NULL, it should use a local variable’s address with the value of “0” zero instead.
Call the edit of each field and depending on the value returned, do the following:
* For '''TAB_KEY''' and '''DOWN_KEY''', go to next editable '''[[#IO_Field| IO_Field]]''', if this is the last editable '''[[#IO_Field| IO_Field]]''' then restart from '''[[#IO_Field | IO_Field]]''' number one.
* For '''UP_KEY''' go to the previous editable '''[[#IO_Field| IO_Field]]''', if there is no previous editable '''[[#IO_Field| IO_Field]]''', go to the last editable '''[[#IO_Field| IO_Field]]''' of the ''IO_Form'' and continue the search for an editable '''[[#IO_Field| IO_Field]]'''.
* For '''ENTER_KEY''' do exactly as '''TAB_KEY''', except that if the current '''[[#IO_Field| IO_Field]]''' is a submitter (is tagged to be a submitter when added), in which case terminate the edit function returning the '''ENTER_KEY'''.
* For any other key, terminate the edit function returning the character which caused the termination.
1
edit

Navigation menu