Course list http://www.c-jump.com/bcc/
Your assignment is to improve the Scratch Pad App developed in Lab 16 by enhancing its features as described below.
Add C++ classes for three more drawing primitives - text label, filled circle, and filled rectangle:
CPrimitiveText CPrimitiveCircleFilled CPrimitiveRectangleFilled
A text label is a very attractive detail on a drawing. Add "Text Label" radio button to the group of the radio buttons. Also, add a text input field where the user can enter the text. The label should be created as soon as the user selects the "Text Label" and clicks in the drawing area of the window.
The following code will draw the text on the screen:
// CDrawBox.cpp #include "FL/fl_draw.H" //... void CPrimitiveText::draw() { Fl_Color orig_color = fl_color(); // preserve color fl_color( color ); // set color const char* text = "Hello"; // sample text to draw fl_font( FL_TIMES, 18 ); // font and font size fl_draw( text, x1, y1 ); // display text at the specified location fl_color( orig_color ); // restore original color }
The text field should be activated in "Text Label" mode and deactivated for all other types of shapes.
Implement filled circle and filled rectangle shapes. Use check box to alternate between the filled and unfilled shapes. Research FLTK 1.3.2 Programming Manual for appropriate FLTK library functions to use.
How would you add a unique, sequential number (identity code) to a drwaing shape?
When would you display the identity codes? Hint: The user could use a check box to turn on the identify display for all objects.
Where would you display the shape identity codes? Hint: calculate the center point of an object and create a CPrimitiveText to display the identity.
How would you implement a single object selection by mouse clicking? Hint: add a member function to calculate the center point of an object and use "mouse down" coordinate to search for the object in question. Once found, the object should be shown in alternative color. A "mouse down" combined with the SHIFT key may allow a multiple object selection.
How would you move an object to a different location? Hint: use the keyboard to move the selected object.
How would you scale an object, i.e. enlarge or decrease its size? Hint: calculate the center of the object and move it so the center ends up at the origin of the coordinate system (the point where x=0, y=0.) Multiply all coordinates by a factor to scale, then move the object back to its original position.
You must submit the entire project in a single ZIP file.
Importtant! Before creating your ZIP archive:
Delete Debug, Release, and ipch subfolders.
Delete the .SDF file.
Log on to CIS-255 online
On the Main Menu, follow the link to Submit Homework, click Project 5: Advanced Scratch Pad, and upload your file.
Note: the system will display an 8-digit confirmation number once the file is successfully uploaded. You can save the confirmation number for your own records, but this is not a required step and no further action is needed on your part.