1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 21:42:13 +00:00
OpenMW/apps/openmw/mwgui/formatting.hpp
2012-05-09 02:11:44 +02:00

54 lines
1.3 KiB
C++

#ifndef MWGUI_FORMATTING_H
#define MWGUI_FORMATTING_H
#include <MyGUI.h>
#include <boost/property_tree/ptree.hpp>
namespace MWGui
{
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 parse(std::string text, MyGUI::Widget* parent, const int width);
protected:
void parseSubText(std::string text);
void parseImage(std::string tag);
void parseDiv(std::string tag);
void parseFont(std::string tag);
private:
MyGUI::Widget* mParent;
int mWidth; // maximum width
int mHeight; // current height
TextStyle mTextStyle;
};
}
#endif