Repository navigation
Control
IControl - describes the minimum program interface for any control. This interface is implemented to some extent by any control or window (since a window is also a control). Let's look at the control interface
class i_control
{
public:
virtual void draw(graphic &gr) = 0;
virtual void set_position(const rect &position) = 0;
virtual rect position() const = 0;
virtual void set_parent(std::shared_ptr<window> window_) = 0;
virtual void clear_parent() = 0;
virtual bool topmost() const = 0;
virtual void set_focus() = 0;
virtual bool remove_focus() = 0; /// Returns false if the control changes focus within its internal controls
virtual bool focused() const = 0; /// Returns true if the control is focused
virtual bool focusing() const = 0; /// Returns true if the control receives focus
virtual void update_theme(std::shared_ptr<i_theme> theme_ = nullptr) = 0;
virtual void show() = 0;
virtual void hide() = 0;
virtual bool showed() const = 0;
virtual void enable() = 0;
virtual void disable() = 0;
virtual bool enabled() const = 0;
protected:
~i_control() {}
};The draw() method implements the drawing of each specific Control. This method is called by the window containing the control. The containing window passes its graphical context for drawing as a parameter.
The receive_event() method, like the Draw() method, is called by the containing control window. Through this method the window transmits events received from user, system or internal.
The set_position() method sets the position and size of the control on the parent window, or, if the control is an free window, the position of the window on the screen.
The method returns the current position and size of Control.
The method is required to save shared_ptr to the containing control window. This method should not be called directly by the user, because it is called via add_control() of the window containing control.
The clear_parent() method is called when the Control is removed from the window. This method should not be called directly by the user, because it is called via remove_control() of the window containing control.