ES-DE/es-core/src/components/DateTimeComponent.h

56 lines
1.4 KiB
C
Raw Normal View History

//
// DateTimeComponent.h
//
// Provides the date and time, in absolute (actual date) or relative
// (delta from current date and time) form.
// Used by the gamelist views.
//
#pragma once
#ifndef ES_CORE_COMPONENTS_DATE_TIME_COMPONENT_H
#define ES_CORE_COMPONENTS_DATE_TIME_COMPONENT_H
#include "utils/TimeUtil.h"
2018-10-13 01:08:15 +00:00
#include "TextComponent.h"
2017-11-01 22:21:10 +00:00
2018-10-13 01:08:15 +00:00
class ThemeData;
// Used to display date and time.
2018-10-13 01:08:15 +00:00
class DateTimeComponent : public TextComponent
{
public:
2018-10-13 01:08:15 +00:00
DateTimeComponent(Window* window);
DateTimeComponent(
Window* window,
const std::string& text,
const std::shared_ptr<Font>& font,
unsigned int color = 0x000000FF,
Alignment align = ALIGN_LEFT,
Vector3f pos = Vector3f::Zero(),
Vector2f size = Vector2f::Zero(),
unsigned int bgcolor = 0x00000000);
2018-10-13 01:08:15 +00:00
void render(const Transform4x4f& parentTrans) override;
void setValue(const std::string& val) override;
std::string getValue() const override;
2018-10-13 01:08:15 +00:00
void setFormat(const std::string& format);
void setDisplayRelative(bool displayRelative);
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view,
const std::string& element, unsigned int properties) override;
2018-10-13 01:08:15 +00:00
protected:
void onTextChanged() override;
2018-10-13 01:08:15 +00:00
private:
std::string getDisplayString() const;
Utils::Time::DateTime mTime;
2018-10-13 01:08:15 +00:00
std::string mFormat;
bool mDisplayRelative;
};
#endif // ES_CORE_COMPONENTS_DATE_TIME_COMPONENT_H