Chapter 17. Creating the Document and Improving the View
WHAT YOU WILL LEARN IN THIS CHAPTER
How to use an STL list container and an STL/CLR list container to store sketch data
How to implement drawing a sketch in the MFC and CLR versions of Sketcher
How to implement scrolling in a view in MFC Sketcher
How to create a context menu at the cursor
How to highlight the element nearest the cursor to provide feedback to the user for moving and deleting elements
How to program the mouse to move and delete elements
In this chapter, you'll extend the MFC version of Sketcher to make the document view more flexible, introducing several new techniques in the process. You'll also extend the MFC and CLR versions of Sketcher to store elements in an object that encapsulates a complete sketch.
CREATING THE SKETCH DOCUMENT
The document in the Sketcher application needs to be able to store a sketch consisting of an arbitrary collection of lines, rectangles, circles, and curves in any sequence, and an excellent vehicle for handling this is a list. Using a list will also enable you to change an element's position in the list or to delete an element easily if it becomes necessary to do so. Because all the element classes that you've defined include the capability for the objects to draw themselves, the user will be able to a draw a sketch easily by stepping through the list.
Using a list<T> Container for the Sketch
You can define an STL list<CElement*>
container that stores pointers to instances of the shape classes ...
Get Ivor Horton's Beginning Visual C++® 2010 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.