2012-05-07 22:39:52 +00:00
|
|
|
#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;
|
|
|
|
};
|
|
|
|
|
2012-05-07 22:39:52 +00:00
|
|
|
/// \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
|
|
|
|
*/
|
2013-05-02 03:35:25 +00:00
|
|
|
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-07 22:39:52 +00:00
|
|
|
|
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);
|
|
|
|
|
2012-05-07 22:39:52 +00:00
|
|
|
protected:
|
2013-02-12 07:22:19 +00:00
|
|
|
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);
|
2012-05-07 22:39:52 +00:00
|
|
|
private:
|
|
|
|
MyGUI::Widget* mParent;
|
2012-05-08 23:34:32 +00:00
|
|
|
int mWidth; // maximum width
|
|
|
|
int mHeight; // current height
|
|
|
|
TextStyle mTextStyle;
|
2012-05-07 22:39:52 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|