Creating your own text class
If you want to implement your own text storage mechanism, you can derive your own class from TText. Your class must:
- Define a storage mechanism.
- Override the streaming operators and default constructor.
- Implement all TText pure virtual functions. These include functions for:
- Accessing and copying character and style data, separately or simultaneously
- Applying or modifying style information for ranges of characters
- Comparing text, character, and style data
- Inserting, deleting, and replacing characters
See the TText.h
file and the online class and member function documentation for a complete list of virtual functions and their descriptions.
Note that you should not override the TText Insert, Delete, or Replace functions. Instead, you implement protected functions that are broken down to handle the operations on character and style data separately, as shown in this figure:
The HandleInsertCharacterGap and HandleInsertStylesGap functions should be implemented to manipulate storage as necessary so that character or style data can be copied into the text object.
The TText Insert, Delete, and Replace functions are implemented to call the protected functions as follows:
Insert makes the following calls:
- HandleInsertCharacterGap
- HandleCopyCharacters
- HandleInsertStylesGap
- HandleCopyStyles--when the text to insert is a text object and not a UniChar array
Delete makes the following calls:
- HandleDeleteStyles
- HandleDeleteCharacters
Replace makes the following calls:
- HandleDeleteStyles
- HandleInsertCharacterGap--when the text to insert is longer than the text being replaced; or
HandleDeleteCharacters--when the text to insert is shorter than the text being replaced
- HandleCopyCharacters
- HandleInsertStylesGap
- HandleCopyStyles-- when the replacement text is a text object and not a UniChar array
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.
Generated with WebMaker