metaforce/specter/include/Specter/MultiLineTextView.hpp

56 lines
1.8 KiB
C++
Raw Normal View History

2015-11-29 02:55:30 +00:00
#ifndef SPECTER_MULTILINETEXTVIEW_HPP
#define SPECTER_MULTILINETEXTVIEW_HPP
#include "View.hpp"
#include "TextView.hpp"
#include "FontCache.hpp"
namespace Specter
{
class MultiLineTextView : public View
{
ViewResources& m_viewSystem;
2015-11-30 00:21:42 +00:00
std::vector<std::unique_ptr<TextView>> m_lines;
2015-11-29 02:55:30 +00:00
const FontAtlas& m_fontAtlas;
2015-12-13 21:00:30 +00:00
TextView::Alignment m_align;
2015-11-29 02:55:30 +00:00
size_t m_lineCapacity;
float m_lineHeight;
2015-12-07 00:52:07 +00:00
int m_width;
std::string LineWrap(const std::string& str, int wrap);
std::wstring LineWrap(const std::wstring& str, int wrap);
2015-12-13 21:00:30 +00:00
2015-11-29 02:55:30 +00:00
public:
2015-12-13 21:00:30 +00:00
MultiLineTextView(ViewResources& res, View& parentView, const FontAtlas& font,
TextView::Alignment align=TextView::Alignment::Left,
size_t lineCapacity=256, float lineHeight=1.0);
MultiLineTextView(ViewResources& res, View& parentView, FontTag font,
TextView::Alignment align=TextView::Alignment::Left,
size_t lineCapacity=256, float lineHeight=1.0);
2015-11-29 02:55:30 +00:00
void typesetGlyphs(const std::string& str,
2015-12-07 00:52:07 +00:00
const Zeus::CColor& defaultColor=Zeus::CColor::skWhite,
unsigned wrap=0);
2015-11-29 02:55:30 +00:00
void typesetGlyphs(const std::wstring& str,
2015-12-07 00:52:07 +00:00
const Zeus::CColor& defaultColor=Zeus::CColor::skWhite,
unsigned wrap=0);
2015-11-29 02:55:30 +00:00
2015-12-13 21:00:30 +00:00
void colorGlyphs(const Zeus::CColor& newColor);
2016-01-02 23:07:40 +00:00
void setMultiplyColor(const Zeus::CColor& color)
{
for (std::unique_ptr<TextView>& l : m_lines)
l->setMultiplyColor(color);
}
2015-12-07 00:52:07 +00:00
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
2015-11-29 02:55:30 +00:00
void draw(boo::IGraphicsCommandQueue* gfxQ);
2015-12-07 00:52:07 +00:00
int nominalWidth() const {return m_width;}
int nominalHeight() const {return (int(m_lineHeight * m_fontAtlas.FT_LineHeight()) >> 6) * m_lines.size();}
2015-11-29 02:55:30 +00:00
};
}
#endif // SPECTER_MULTILINETEXTVIEW_HPP