21
edits
Changes
→IO_Label
<hr width="50%" />
<hr width="50%" />
===IO_Label===
'''IO_Label''' class mostly, encapsulates the '''[[OOP344_Assignment_One#void_io_display.28const_char_.2Astr.2C_int_row.2C_int_col.2C_int_len.29|io_display()]]''' function.
Inherit a new class called IO_Label from IO_Field to Display a text message on IO_Form. In addition to the attributes of its parent IO_Field, IO_Label has a private integer attribute called _len. _len is used to hold the length of Field in which the text is to be displayed.
IO_Label could hold holds its data dynamically or simply and will never point to an external one. Because of this IO_Label also has a boolean attribute called _dynamic that will hold the type of data within; being dynamic memory (value true), or external memory (value false)
'''IO_Label''' can be created in two ways;
<big><pre>
IO_Label(int row, int col, int len);
</pre></big>
This constructor will create an empty (blank) IO_Label with capacity of len characters.
In this case '''row''' and '''col''' are passed to the parent for initialisation and '''_len''' (the attribute) is set to the incoming argument '''len'''.
''Note that '''data''' is a void pointer; to use it here, you must cast it to a character pointer!''<br />
IO_Label(char* str, int row, int col, int len = -1);
</pre></big>
====Public Methods====
<big><pre>
void Display(void);
</pre></big>
<big><pre>
void Set(const void* str);
</pre></big>
'''Set()''' will copy the content of '''str''' into '''IO_Field::_data''' up to '''_len''' characters, if '''_len''' is not negative.
<big><pre>
bool IO_Label::Editable(void)const;
</pre></big>
'''Editable()''' returns false!.
<big><pre>
int Edit(IO_Form* Owner=(IO_Form*)0);
</pre></big>
<big><pre>
~IO_Label(void);
</pre></big>
The destructor, delete[]s the '''_data''' only if . (make sure '''_dynamic_data''' is truecasted to char* before deleting.
<big><pre>
IO_Label &operator=(const char* str);
</pre></big>