Changes

Jump to: navigation, search

OOP344 Assignment Two

13 bytes removed, 21:37, 16 November 2009
m
Spelling Errors
[[ OOP344_Hasselhoff | Team Hasselhoff ]]
=General Definition Header file=
create a file called: '''io_def.h'''. This file will contain any nessecary necessary definitions or inclusions for the project.
for now add the following define statements in io_def.h
These are pure virtual methods enforcing the creation of the identical methods in the derived classes. This make the IO_Field class an abstract class.
Note: The purpose of passing a an IO_Form pointer to the Edit method, is to make the future Edit methods capable of sending a message (errors and help messages)to the Screen they are being Edited on.
==IO_Frame==
void display(int topOffset=0, int leftOffset=0)const;
</pre></big>
'''display()''', starts from top + topOffset and left + leftOffset and draws the frame to the width and hight height received form from the constructor.
====getLeft()====
int add(IO_Field& f, bool submitter = false);
</pre></big>
Uses the private add() method to add a non-dynamaic dynamic IO_field.
<hr width="50%" />
<big><pre>
int addHelp(IO_Label* L);
</pre></big>
Uses the private add() method to add a dynamaic dynamic 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-dynamaic dynamic 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 dynamaic dynamic 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-dynamaic dynamic IO_field and also saves its address for the general error message label of the Form.
<hr width="50%" />
<big><pre>
If neither of the IO_Fields is editable, it displays all the 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 addrss address with the value of “0” zero instead.
if *fieldnumber is (0) zero, then display all the fields before editing the fields and then set *fieldnumber to (1) one.
* For UP_KEY go to the previous editable IO_Field, if there is no previous editable IO_Field, go to the last editable IO_Field of the IO_Form. (continue the search from the last IO_Field in the IO_Form).
* for ENTER_KEY do exactly as TAB_KEY, except that if the current IO_Field is a submitter (is tagged to be a submitter when added), in which case terminate the eidt edit function returning the ENTER_KEY.
* for any other key, terminate the edit function returning the character which caused the termination.
Inherit IO_Field and IO_Frame into a new class called IO_Edit. (Read: Practical Programming Techniques Using C++, pages 94 to 96, ''Multiple Inheritance'' topic)
IO_Edit, encapsulates the io_edit() function of ciol library when isTextEditor is false. IO_Edit calls the io_edit function to edit a string that is either created dynamically by the IO_Edit itself, or a string that is external and is received through the constructor arugumentsarguments.
Also IO_Edit gives the user the option of surrounding the editing line with a frame.
This constructor dynamically creates an array of '''maxdatalen''' + 1 chars (an empty string) and sets IO_Field::_data to point to it.
'''row and col and frameChars''' will be passed directly to the Frame class's '''top and left and frameChars''', respectively. But since a an IO_Frame needs to surround the edit field, it has to have one char extra for each side. Therefore, (fieldlen + 2) should be passed to IO_Frame as width and 3 should be passed to IO_Frame as height.
On the other hand, the IO_Field class holds the actual coordinate at which, the editing should happen. So, depending on the value of the '''framed''' being false or true the values, '''(row and col)''' or '''(row+1 and col+1)''' will be passed to IO_Field's constructor respectively.
====Destructor====
The IO_Edit's destructor, checks to see if the object is marked to be dynamic. In this case it will delete[] the the character content of IO_Field's _data.
===Public Methods===
void IO_Edit::display()const;
</pre></big>
display, first checks to see if IO_Edit is framed. if it is it will call the IO_Frame's display(), using _owner->getTop() and _owner->getLeft() as its topOffset and leftOffset agrumentsarguments.Then it will makes a direct call to ciol's io_display() function passing IO_Field's data, getRow() and getCol() and also the fieldlen value form IO_Edit's attrubutesattributes.
<blockquote>
Passing _owner->getTop() and _owner->getLeft() to IO_Frame's display() and also, using getRow() and getCol() for extracting row and col from IO_Field, makes row and col of the IO_Edit, relative to top, left of the form it is on. (if IO_Edit belongs to an IO_Form, that is, if _owner is not NULL)
IO_Checklist can work in two modes:
*Radio mode; were the the selection is exclusive and each selection deselects the rest of the selections.
*CheckBox mode; where the selection is inclusive and many selections can be done at the same time.
*'''mode''' is one of the two selection of <big><code>enum CheckListMode{CheckBox, Radio}</code></big> that should be defined in io_def.h.
*'''row''' and '''col''' are the top, left corner of the frame surrounding the options.
*'''items''' is the a "newline" separated list of options in a string.
*'''format''' is a 3 char string that holds the shape of a checked option(i.e. "[X]" or "<@>"),if the format is zero, then depending of the value of '''mode''' being '''Radio''' or '''CheckBox''', frame will be defaulted to '''_RADIOLIST_CHARS''' or '''_CHECKLIST_CHARS''' respectively.
*'''frameChars''' is a string with the characters building the frame.
Inherit IO_Field and IO_Frame into a new class called IO_TextEdit. (Read: Practical Programming Techniques Using C++, pages 94 to 96, Multiple Inheritance topic)
IO_TextEdit, uses the io_edit() function of ciol library the if the isTextEditor flag set to true. IO_TextEdit calls the io_edit function repeatedly to edit series of strings that is created dynamically by the IO_TextEdit. If an intial initial newline ('\n') sepearted separated string is provided, IO_TextEdit will split the string into several strings and copy them into dynamically allocated series of strings.
IO_TextEdit will do the edit in a framed multiline text field. Editing begins with the cursor at the top left of the field or from the position the editing was terminated before.
Each line can be edited using the io_edit. If during the process of editing the string is shifted, make sure all lines are shifted together. If in overstrike mode hitting the enter key goes to next line. Otherwise (in insert mode) it should insert a new line after the current line and if there is any data after the current position, the data should be cut, and pasted to the newly created line. The cursor should stand at the beginning of the new line.
Up and Down arrows should focus the editing on previous and next lines respectfully and if needed, to accomodate accommodate this the lines should shift to up and down. How everHowever, However if UP and Down keys are hit on the first or last line of data, then the function will terminate returning those values.
Page up and down should scrole scroll the lines in the text field up and down "height-2" times, or better to say, scroll the text a page up or down if possible. if paging is not possible, then the keys are ignored.
Each line in the text can be the maximum of "_IO_TEXT_ALLOCATION_LINE_SIZE" characters, definded defined in io_def.h
==Constructors==
int maxLines = -1,const char* frameChars = (const char*)0);</pre></big>
This constructor set the class to dynamically create "sereies series of strings" to be edited by io_edit function in the edit method when needed.The arguments, row and column are top and left coordinates of the text feild field and width and hieght are the width and height of the text field.
insertMode is where the insert flag status is kept.
===Non-dynamic Data===
<big><pre>IIO_TextEditIO_TextEdit(char* str, int row, int col, int width, int height,int* insertmode,
int maxLines = -1,const char* frameChars = (const char*)0);</pre></big>
This constructor initially splits the newline seperated separated data from the "str" argument into series of lines that are created dynamically to be edited by the io_edit function in the edit method. The arguments, row and column are top and left coordinates of the text feild field and width and hieght height are the width and height of the text field.
insertMode is where the insert flag status is kept.
frameChars hold the optional characters to build the frame.
The "single dimension string" representation of the "series of the strings" holding the text will the be where str argument is pointing to. No dynamic memory is allocated for this.It is the caller program's responsibilty to accomodate accommodate enough space for the data;
maxLines argument will limit the number of the lines in text, unless it is set to -1.
===void display()const;===
Displays the frame, and in the fram frame it will display the text from the top left being the first character of the first line or othewise otherwise any position it was been right before the editing was terminated the last time.
===void *data();===
first converts back the series of string to a single dimenssion dimension newline seperated separated string of characters pointed by the IO_Field's data, and then returns it.
If object is dynamic (created by the first construcotrconstructor) then you may have to reallocate memory to make room for convertionconversion.
If object is not dynamic, (made by the second constructor) then the conversion's target will be the _data of IO_Field that was set by the construcotrconstructor. No dynamic memory allocation should be done for the conversion. It is the user program of the object's responsiblity responsibility to provide enough memory for this.
Make sure you modify void IO_Field::data(); method to virtual for this to work;
===void set(const void *str);===
splits the newline seperated separated data from the "str" argument into "series of stings" that are created dynamically to be edited by the io_edit function in the edit method.
===virtual ~IO_TextEdit();===
if( i < 1895 || i > 2010){
res = false;
F[4].set("InvlalidInvalid");
}
else{
if( d<0.0 || d>10 ){
res = false;
F[6].set("InvlalidInvalid");
}
else{
#In solution exp. rightclick on headerfiles, add / new item
#Added code/headerfile: "io_textedit.h"
#Now i am righclicking rightclicking on sourcefiles/newitem code/cpp file#Added inclusion guards code to the headerifle headerfile (#ifndef __IO_TEXTEDIT_H__.....)#Included general headerifle headerfile in io_textedit.h. It will have all necessary definitions and includes for the project#Adding io_textedit.h and io_textdit.cpp to working copy($svn add ..., this tags them to be added to repository the next time svn is commitedcommitted)
#Compiled and it was successful, so I will commit now
'''fardad:''' Done, you can now update you working copy and see what I did. You should do the same for all the other classes. It should not take you more than 30 minutes to do you your part, just pick a class and write it.
1
edit

Navigation menu