#pragma once #include "../GuiComponent.h" #include #include "../resources/Font.h" class DateTimeComponent : public GuiComponent { public: DateTimeComponent(Window* window); void setValue(const std::string& val) override; std::string getValue() const override; bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; void render(const Eigen::Affine3f& parentTrans) override; enum DisplayMode { DISP_DATE, DISP_DATE_TIME, DISP_RELATIVE_TO_NOW }; void setDisplayMode(DisplayMode mode); void setColor(unsigned int color); void setFont(std::shared_ptr font); virtual void applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) override; private: std::shared_ptr getFont() const; std::string getDisplayString(DisplayMode mode) const; DisplayMode getCurrentDisplayMode() const; void updateTextCache(); boost::posix_time::ptime mTime; boost::posix_time::ptime mTimeBeforeEdit; bool mEditing; int mEditIndex; DisplayMode mDisplayMode; int mRelativeUpdateAccumulator; std::unique_ptr mTextCache; std::vector mCursorBoxes; unsigned int mColor; std::shared_ptr mFont; };