Step 13: Now that the Board's states array is being used I can describe the void Draw(CDC* pDC) function in better detail.
In the constructor create and specify 5 solid CBrush objects (Yes, they are variables of the Board class). Using black for all off and white for all one, the three other CBrush object's colours are red, green and blue.
- Is the Board instance still valid?
- Is the supplied pDC valid?
- Is the states array still valid?
- Is the places array still valid?
For each cell of the Board,
- - if the state of that cell is the Board's cycle -1 (all on), select the white CBrush
- - else if the state of that cell is 3, select a colour CBrush.
- - else if the state of that cell is 2, select a colour CBrush.
- - else if the state of that cell is 1, select a colour CBrush.
- - else the state of that cell is 0 (all off), select the black CBrush.
- - Draw the cell. Note, not specifying the CPen of the current drawing area (the pDC) will cause an 1 pixel black outline to be drawn. It would have been better to assume that the user would have chosen the window background and a contrasting text colour and gone with that text colour to outline the cells.
- The Board instance is still valid.
- The same can be assumed about the places and states arrays.