Open main menu

CDOT Wiki β

Changes

OOP344 Assignment Two

2,015 bytes added, 13:06, 4 November 2009
IO_Edit
==IO_Edit==
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 aruguments. Also IO_Edit gives the user the option of surrounding the editing line with a frame. Editing without a frame at row:2 col:5<big><pre>0123456789012345678901234567890123456789012345678912 Hello! I am editing a text_345</pre></big>Editing with a frame at row:2 col:5 (the actual editing happens at row:2+1 and col: 5+1<big><pre>0123456789012345678901234567890123456789012345678912 +-------------------------------------+3 |Hello! I am editing a text_ |4 +-------------------------------------+5</pre></big>
IO_Edit can be created in two ways:
<big><pre>
IO_Edit::O_Edit(int row, int col, int fieldlen,
int maxdatalen, int* insertmode,
bool framed = false, const char* frameChars = (const char*)0);
</pre></big>
This constructor dynamically creates an array of '''maxdatalen''' + 1 chars (an empty string) and sets IO_Feild::_data to point to it.
IO_Edit::IO_Edit(int '''rowand col and frameChars''' will be passed directly to the Frame class's '''top and left and frameChars''', respectively. But since a IO_Frame needs to surround the edit field, int colit has to have one char extra for each side. Therefore, int (fieldlen,+ 2) should be passed to IO_Frame as width and 3 should be passed to IO_Frame as height.
int maxdatalenOn the other hand, int* insertmodethe IO_Field class holds the actual coordinate at which,bool the editing should happen. So, depending on the value of the '''framed''' being false or true the values,const char* frameChars'''(row and col)''' or '''(row+1 and col+1);''' will be passed to IO_Field's constructor respectively.
</pre></big>This constructor dynamically creates an array of '''maxdatalen''' + 1 chars and sets IO_Feild::_data The IO_Edit In this case is marked to point to itbe dynamic, so at destruction time, the memory is deallocated.
--- incomplete ---All the arguments needed for ciol's io_edit() function should be kept as attributes so they can be used at edit() time.
<big><pre>
 
IO_Edit::IO_Edit(char* str, int row, int col, int fieldlen,
  int maxdatalen, int* insertmode, bool framed= false,const char* frameChars= (const char*)0); 
</pre></big>
This constructor works exactly like the above constructor, with one exception. The data being edited is not dynamic here. So the IO_Fields::_data should point where the '''str''' argument is pointing to. Obviously, in this case IO_Edit should be marked as non--- incomplete ---dynamic so at destruction time, the memory is NOT deallocated.
==IO_CheckList==