"Integration of the Standard Template Library and the Microsoft Foundation Class" - читать интересную книгу автора (Wolfgang Paul, Song Yang)2 Example – Scribble.2.1 Description of the ProblemThe MFC Tutorial [3] includes a simple graphics application known as Scribble. The purpose of Scribble is to let the user draw a set of strokes with the mouse. The result is saved in a file (called a document) which can be opened and updated by adding additional strokes. (There is no method for deleting a stroke.) The user also has the option of specifying the thickness and color of the pen. Scribble's data structure consists of one or more strokes. Each stroke is the record of the mouse position from the time when the user clicks on left mouse key to the time when the user releases the mouse button. In MFC approach, a new class CStroke, which is derived from class CObject, is defined. This contains a data member of CArray‹CPoint, CPoint› with other data members to record and work on each stroke. The document class, CScribbDoc, is derived from CDocument. It contains a list of stokes using the MFC template class CTypedPtrList‹CObList, CStroke*›. Figure 1 illustrates the document data structure.
Figure 1 Scribble Document Structure |
||
|