71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
#pragma once
|
|
|
|
// Include Graph_lib library files that holds declarations needed for Window,
|
|
// and Shape derivatives.
|
|
#include "Graph.h"
|
|
#include "GUI.h"
|
|
|
|
// This part is only relevant for non-Windows users in 2019.
|
|
// Windows users has Graph_lib::Arc, Mac don't.
|
|
#ifndef WIN32
|
|
#include "Graph_lib.h"
|
|
#endif
|
|
|
|
using namespace Graph_lib;
|
|
|
|
// An abstract class. Concrete classes derived from this base class
|
|
// has to implement the member function attach_to().
|
|
class Emoji
|
|
{
|
|
public:
|
|
// Disable copying. Disable slicing, etc.
|
|
Emoji(const Emoji&) = delete;
|
|
Emoji& operator=(const Emoji&) = delete;
|
|
|
|
// Deleting the copy constructor also deletes the default constructor.
|
|
// Emoji needs a default constructor.
|
|
Emoji() {}
|
|
// Emoji() = default; // is an alternative way of achieving the same.
|
|
|
|
// The pure virtual function that has to be overriden for a deriving class
|
|
// to be instantiable. Every class deriving from Emoji is supposed to
|
|
// attach all its Shapes to a window. This makes the class abstract.
|
|
virtual void attach_to(Graph_lib::Window&) = 0;
|
|
|
|
// Relevant because Vector_ref can own Emojis and automatically cleans up.
|
|
// Subject will be visited later in the course.
|
|
virtual ~Emoji() {}
|
|
};
|
|
|
|
// A yellow, empty face.
|
|
// An abstract class.
|
|
class Face : public Emoji
|
|
{
|
|
/* TODO:
|
|
* - add shapes (private)
|
|
* - make the class abstract
|
|
**/
|
|
|
|
Circle faceMask;
|
|
|
|
public:
|
|
Face(Point c, int r);
|
|
void attach_to(Graph_lib::Window& win) override;
|
|
};
|
|
|
|
/* TODO:
|
|
* - declare more emojis.
|
|
**/
|
|
|
|
class EmptyFace : public Face
|
|
{
|
|
public:
|
|
EmptyFace(Point p, int r, bool upSideDown = false);
|
|
void attach_to(Graph_lib::Window& win) override;
|
|
private:
|
|
int offset;
|
|
int eyeR;
|
|
Point left, right;
|
|
Vector_ref<Circle> eyes;
|
|
};
|