Book Image

Microsoft Visual C++ Windows Applications by Example

By : Stefan Bjornander, Stefan Björnander
Book Image

Microsoft Visual C++ Windows Applications by Example

By: Stefan Bjornander, Stefan Björnander

Overview of this book

Table of Contents (15 chapters)
Microsoft Visual C++ Windows Applications by Example
Credits
About the Author
About the Reviewer
Preface
Index

The TextFigure Class


TextFigure is a direct sub class of Figure. It manages the text. The users can move and edit the text, they can also change the font of the text.

The field m_ptText represents the upper left corner of the text, in logical units. m_szText is the size of the text, also in logical units. The field m_stText is the actual text; m_stPreviousText is used to resume the original text in case the user aborts the editing by pressing the Esc key. GenererateCaretArray is called every time the text is changed (change of font or addition or removal of a character) and calculates the size and position for each character in the text. The horizontal positions (x values) relative to the beginning of the text are stored in m_caretArray. The field m_font is the font of the text and m_iAverageWidth holds the average width of the font, roughly the width of the z character. It is used by the caret in the keyboard overwrite state. Finally, m_eDragMode is used to give the cursor the correct...