
There also some changes to the insertion and extraction operators that are
Insertion and
necessary to handle the revised TLine class.
extraction operators
The insertion operator is modified to write out the P nSize and Colore
member It then writes out the points just as it did before..
The extraction operator reads in the data and uses the P nSize and Colore
data in the SetP n function. Each point is read in from the file and added toe
the object.
There are a few fairly minor changes to the TMyWindow class to
Changes to the
accommodate the revised TLine class:
TMyWindow class
■ The P n data member is constructed from the size and color of thee
current line.
■ The SetP nSize function is removed. The function GetP nSize opens ae e
TInputDialog for the user to enter a new pen size in. GetP nSize then callse
the function Line->SetP n to actually set the pen size.e
■ The CmP nColor function is added to handle the CM_PENCOLOR event.e
This event is sent from the new T ols menu choice P n Coloro e .
The CmP nColor function opens a TChooseColorDialog for the user to select ae
CmP nColore
color from. Like TFileOpenDialog and TFileSaveDialog, TChooseColorDialog is
function
an encapsulation of one of the Windows common dialog boxes.
Also like TFileOpenDialog and TFileSaveDialog, the TChooseColorDialog
constructor can take up to five parameters, but in this case you need only
two. The last three all have default values. The two parameters you need to
provide are a pointer to the parent window and a reference to a
TChooseColorDialog::TData object. In this case, the pointer to the parent
window is simply the this pointer The TChooseColorDialog::TData object is.
provided by colors.
Setting the Color member of colors to a particular color makes that color (or
its closest equivalent displayed in the dialog box) the default color in the
dialog box. By setting Color to the color of the current pen, you ensure that
the Color dialog box reflects the current state of the application.
Setting the CustColors member of the colors object to some array of TColor
objects sets those colors in the Custom Colors section of the Color dialog
box. Y u can use whatever colors you want for the CustColors array Theo .
values that are used in the tutorial produce a range of monochrome colors
that goes from black to white.
68
OWL P ogrammer’ Guider s