#pragma once #include #include #include #include #include #include #include "VBWidgetType.h" class GPainter; class GWidget; class VBForm; class VBProperty; enum class Direction { None, Left, UpLeft, Up, UpRight, Right, DownRight, Down, DownLeft }; template inline void for_each_direction(Callback callback) { callback(Direction::Left); callback(Direction::UpLeft); callback(Direction::Up); callback(Direction::UpRight); callback(Direction::Right); callback(Direction::DownRight); callback(Direction::Down); callback(Direction::DownLeft); } class VBWidget : public Retainable, public Weakable { public: static Retained create(VBWidgetType type, VBForm& form) { return adopt(*new VBWidget(type, form)); } ~VBWidget(); bool is_selected() const; Rect rect() const; void set_rect(const Rect&); Rect grabber_rect(Direction) const; Direction grabber_at(const Point&) const; GWidget* gwidget() { return m_gwidget; } const VBProperty* property_by_name(const String&) const; VBProperty* property_by_name(const String&); void for_each_property(Function); protected: VBWidget(VBWidgetType, VBForm&); private: VBWidgetType m_type { VBWidgetType::None }; VBForm& m_form; GWidget* m_gwidget { nullptr }; HashMap> m_properties; };