#include <Drawing.h>
Public Member Functions | |
Drawing () | |
~Drawing () | |
Shape * | get_selected_shape () |
color | get_background_color () |
void | set_background_color (color) |
void | add_shape (Shape *) |
void | select_shape_at_point (point2d) |
void | draw () |
void | delete_selected_shape () |
void | move_selected_shape_up () |
void | move_selected_shape_down () |
Private Attributes | |
std::vector< Shape * > | _shapes |
Shape * | _selected_shape |
color | _background_color |
The Drawing class holds references to all the shapes and can draw them all to the screen in order, as well as selecting, reordering and removing shapes on screen
Drawing::Drawing | ( | ) |
The constructor initialises the _selected_shape and _background_color data members
Drawing::~Drawing | ( | ) |
Upon destruction, memory for each shape the drawing holds is freed (ie. each shape is deleted)
void Drawing::add_shape | ( | Shape * | shape | ) |
Adds a Shape to the drawing
shape | the shape to add |
void Drawing::delete_selected_shape | ( | ) |
Deletes the selected shape from the drawing, freeing it's memory and removing it from _shapes
void Drawing::draw | ( | ) |
color Drawing::get_background_color | ( | ) |
Gets the background colour
Shape * Drawing::get_selected_shape | ( | ) |
Gets the selected shape
void Drawing::move_selected_shape_down | ( | ) |
Moves the selected shape down in the array, unless it is the first already
void Drawing::move_selected_shape_up | ( | ) |
Moves the selected shape up in the array, unless it is the last already
void Drawing::select_shape_at_point | ( | point2d | point | ) |
Selects the shape that is at the point point by checking if each Shape::is_at the point
point | the point to select the shape at |
void Drawing::set_background_color | ( | color | bg | ) |
Sets the background colour
bg | background colour |
|
private |
The background colour of the drawing canvas
|
private |
Pointer to the selected shape
|
private |
Vector array of the shape references, creates a "has many" relationship