70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "DiscretePoint.h"
|
|
#include "VisualLayer.h"
|
|
#include "PaintEvent.h"
|
|
#include "Color.h"
|
|
#include "MouseEvent.h"
|
|
#include "KeyboardEvent.h"
|
|
|
|
class Widget
|
|
{
|
|
protected:
|
|
|
|
DiscretePoint mLocation;
|
|
unsigned mWidth;
|
|
unsigned mHeight;
|
|
std::vector<VisualLayerUPtr> mMyLayers;
|
|
std::vector<VisualLayer*> mLayers;
|
|
std::vector<std::unique_ptr<Widget> > mChildren;
|
|
ColorUPtr mBackgroundColor;
|
|
|
|
public:
|
|
|
|
Widget();
|
|
|
|
virtual ~Widget();
|
|
|
|
static std::unique_ptr<Widget> Create();
|
|
|
|
void AddWidget(std::unique_ptr<Widget> widget);
|
|
|
|
unsigned GetWidth() const;
|
|
|
|
unsigned GetHeight() const;
|
|
|
|
std::vector<VisualLayer*> GetLayers() const;
|
|
|
|
DiscretePoint GetLocation() const;
|
|
|
|
virtual void OnPaintEvent(const PaintEvent* event);
|
|
|
|
virtual bool OnMouseEvent(const MouseEvent* event);
|
|
|
|
virtual bool OnKeyboardEvent(const KeyboardEvent* event);
|
|
|
|
bool Contains(const DiscretePoint& loc) const;
|
|
|
|
void SetBackgroundColor(ColorUPtr color);
|
|
|
|
void SetSize(unsigned mWidth, unsigned mHeight);
|
|
|
|
void SetLocation(const DiscretePoint& loc);
|
|
|
|
protected:
|
|
|
|
virtual bool OnMyKeyboardEvent(const KeyboardEvent* event);
|
|
|
|
virtual void OnMyMouseEvent(const MouseEvent* event);
|
|
|
|
virtual void AddChildLayers(const PaintEvent* event);
|
|
|
|
virtual void AddBackground(const PaintEvent* event);
|
|
|
|
void CopyMyLayers();
|
|
};
|
|
|
|
using WidgetUPtr = std::unique_ptr<Widget>;
|