1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-08 09:37:53 +00:00
OpenMW/apps/openmw/mwgui/formatting.hpp

68 lines
2.0 KiB
C++
Raw Normal View History

#ifndef MWGUI_FORMATTING_H
#define MWGUI_FORMATTING_H
#include <MyGUI.h>
namespace MWGui
{
2012-05-08 23:34:32 +00:00
struct TextStyle
{
TextStyle() :
mColour(0,0,0)
, mFont("Default")
, mTextSize(16)
, mTextAlign(MyGUI::Align::Left | MyGUI::Align::Top)
{
}
MyGUI::Colour mColour;
std::string mFont;
int mTextSize;
MyGUI::Align mTextAlign;
};
/// \brief utilities for parsing book/scroll text as mygui widgets
class BookTextParser
{
public:
/**
* Parse markup as MyGUI widgets
* @param markup to parse
* @param parent for the created widgets
* @param maximum width
* @return size of the created widgets
*/
MyGUI::IntSize parsePage(std::string text, MyGUI::Widget* parent, const int width);
/**
* Parse markup as MyGUI widgets
* @param markup to parse
* @param parent for the created widgets
* @param maximum width
* @return size of the created widgets
*/
MyGUI::IntSize parseScroll(std::string text, MyGUI::Widget* parent, const int width);
2012-05-10 09:03:27 +00:00
/**
* Split the specified text into pieces that fit in the area specified by width and height parameters
*/
std::vector<std::string> split(std::string text, const int width, const int height);
protected:
float widthForCharGlyph(unsigned unicodeChar) const;
float currentFontHeight() const;
2012-05-08 23:34:32 +00:00
void parseSubText(std::string text);
2012-05-10 09:03:27 +00:00
void parseImage(std::string tag, bool createWidget=true);
2012-05-09 00:11:44 +00:00
void parseDiv(std::string tag);
void parseFont(std::string tag);
private:
MyGUI::Widget* mParent;
2012-05-08 23:34:32 +00:00
int mWidth; // maximum width
int mHeight; // current height
TextStyle mTextStyle;
};
}
#endif