Course list http://www.c-jump.com/bcc/
Lab 9 is the prototype for this project. We are adding new features to allow interactive line drawing by clicking the mouse:
New class, CPrimitiveLine, encapsulates the line segment coordinates and provides a drawing operation.
Objects of CPrimitiveLine class are stored in an std::vector container.
Make a copy of Lab 9 subfolder
c255labs\labs\c255_lab09_fl_box
or download and unzip c255_lab09_fl_box.zip
Rename the new folder as c255_lab10_mouse.
Open solution file in Visual Studio and finish the usual steps to rename the project.
Download new version of CDrawBox.h and save it in
c255labs\labs\c255_lab10_mouse\fluid_project
Compile and test the program.
Open CDrawBox.h and examine the code. The new class CPrimitiveLine is responsible for storing and drawing individual line segments. Class CDrawBox has changed significantly:
The object draws its own border around the box. The color of border changes as the mouse enters/leaves the widget.
The object maintains the list of line segments in vect_primitives container
New function draw_clear() erases the content of the entire drawing area
The handle() is a virtual function that receives input events encoded in its parameter. The function controls only the mouse movement and clicks. In the future it can be extended to manage the keyboard input as well.
A line primitive is created when the following sequence of events is detected:
the mouse button is pressed down
the mouse is being dragged around the area of the box
the mouse button is released.
An instance of CPrimitiveLine class is created as soon as the first mouse drag event in the sequence is detected. The CPrimitiveLine object is inserted into vect_primitives container. This and every subsequent drag event forces the draw box to redraw itself to indicate the new line position.
This is a self-learning lab. There are no files to submit. Make sure to complete all required steps to build and test the project on your own home computer.